Skip to content

Commit

Permalink
now 1.12 branch is up to date, closes #44
Browse files Browse the repository at this point in the history
  • Loading branch information
realmayus committed Mar 26, 2020
1 parent 433feaf commit 74bec5d
Show file tree
Hide file tree
Showing 13 changed files with 247 additions and 118 deletions.
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ apply plugin: 'net.minecraftforge.gradle.forge'
//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.


version = "1.12.2-2.0"
version = "1.12.2-2.1.0"
group = "realmayus.youmatter" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "youmatter"

Expand Down Expand Up @@ -59,7 +59,6 @@ dependencies {
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
// http://www.gradle.org/docs/current/userguide/dependency_management.html
deobfCompile "curse.maven:mekanism:2745458"

}

processResources {
Expand Down
14 changes: 12 additions & 2 deletions src/main/java/realmayus/youmatter/YMConfig.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package realmayus.youmatter;

import com.google.common.collect.ImmutableMap;
import net.minecraftforge.common.config.Config;

import java.util.HashMap;
import java.util.Map;

@Config(modid = YouMatter.MODID)
public class YMConfig {
Expand All @@ -24,4 +22,16 @@ public class YMConfig {

@Config.Comment(value = "How much U-Matter (in mB) should you need for one item to be duplicated (that is not overridden)")
public static int uMatterPerItem = 1000;

@Config.Comment(value = "The energy consumption of the replicator per tick. Default: 2048")
public static int energyReplicator = 2048;

@Config.Comment(value = "The energy consumption of the encoder per tick. Default: 512")
public static int energyEncoder = 512;

@Config.Comment(value = "The energy consumption of the scanner per tick. Default: 512")
public static int energyScanner = 512;

@Config.Comment(value = "Determines how much U-Matter [in mB] the creator produces every work cycle. Energy is withdrawn like this: if energy more than 30% of max energy, consume 30% and add [whatever value below] of U-Matter to the tank. Default is 1mB/work cycle. Don't increase this too much due to balancing issues.")
public static int productionPerWorkcycle = 1;
}
39 changes: 30 additions & 9 deletions src/main/java/realmayus/youmatter/creator/ContainerCreator.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fluids.UniversalBucket;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.fluids.capability.IFluidTankProperties;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.SlotItemHandler;
Expand Down Expand Up @@ -88,24 +90,43 @@ public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) {
ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();

if (index >= 37 && index <= 39) { //originating slot is custom slot
if (index >= 36 && index <= 39) { //originating slot is custom slot
if (!this.mergeItemStack(itemstack1, 0, 36, true)) {
return ItemStack.EMPTY; // Inventory is full, can't transfer item!
}
} else {
if(itemstack1.getItem() instanceof UniversalBucket) {
if (itemstack1.getItem() instanceof UniversalBucket) {
UniversalBucket bucket = (UniversalBucket) itemstack1.getItem();
if(bucket.getFluid(itemstack1) != null) {
if (bucket.getFluid(itemstack1).getFluid().equals(ModFluids.STABILIZER)) {
if(!this.mergeItemStack(itemstack1, 36, 37, false)) {
return ItemStack.EMPTY; // custom slot is full, can't transfer item!
}
if (bucket.getFluid(itemstack1).getFluid().equals(ModFluids.STABILIZER)) {
if (!this.mergeItemStack(itemstack1, 36, 37, false)) {
return ItemStack.EMPTY; // custom slot is full, can't transfer item!
}
} else if (bucket == Items.BUCKET) {
if (!this.mergeItemStack(itemstack1, 38, 39, false)) {
return ItemStack.EMPTY; // custom slot is full, can't transfer item!
}
}
} else if(itemstack1.getItem().equals(Items.BUCKET)) {
if(!this.mergeItemStack(itemstack1, 38, 39, false)) {
} else if (itemstack1.getItem().equals(Items.BUCKET)) {
if (!this.mergeItemStack(itemstack1, 38, 39, false)) {
return ItemStack.EMPTY; // custom slot is full, can't transfer item!
}

} else if (itemstack1.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null)) {
IFluidTankProperties tankProperties = itemstack1.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null).getTankProperties()[0];
if (tankProperties.getContents() == null || tankProperties.getContents().getFluid().equals(ModFluids.UMATTER)) {
if (!this.mergeItemStack(itemstack1, 38, 39, false)) {
return ItemStack.EMPTY; // custom slot is full, can't transfer item!
}
} else if (tankProperties.getContents().getFluid().equals(ModFluids.STABILIZER)) {
if (!this.mergeItemStack(itemstack1, 36, 37, false)) {
return ItemStack.EMPTY; // custom slot is full, can't transfer item!
}
} else {
return ItemStack.EMPTY;
}
return ItemStack.EMPTY;


}
return ItemStack.EMPTY;
}
Expand Down
20 changes: 12 additions & 8 deletions src/main/java/realmayus/youmatter/creator/GuiCreator.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,18 @@ protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, i
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
drawFluidTank(89, 23, te.getUTank());
drawFluidTank(31, 23, te.getSTank());
drawActiveIcon(te.isActivatedClient());
drawEnergyBolt(te.getClientEnergy());
}

private void drawActiveIcon(boolean isActive) {
mc.getTextureManager().bindTexture(GUI);

if(isActive) {
drawTexturedModalRect(154, 13, 176, 24, 8, 9);
drawTexturedModalRect(guiLeft +154, guiTop + 13, 176, 24, 8, 9);

} else {
drawTexturedModalRect(154, 13, 176, 15, 8, 9);
drawTexturedModalRect(guiLeft +154, guiTop + 13, 176, 15, 8, 9);
}
}

Expand All @@ -69,16 +71,18 @@ protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {

mc.getTextureManager().bindTexture(GUI);

if(te.getClientEnergy() == 0) {
drawTexturedModalRect(150, 59, 176, 114, 15, 20);
this.fontRenderer.drawString(I18n.format("youmatter.guiname.creator"), 8, 6, 4210752);
}

private void drawEnergyBolt(int clientEnergy) {
if(clientEnergy == 0) {
drawTexturedModalRect(guiLeft + 150, guiTop + 59, 176, 114, 15, 20);
} else {
double percentage = te.getClientEnergy() * 100 / 1000000; // i know this is dumb
double percentage = clientEnergy * 100 / 1000000F; // i know this is dumb
float percentagef = (float)percentage / 100; // but it works.
drawTexturedModalRect(150, 59, 176, 93, 15, Math.round(20 * percentagef)); // it's not really intended that the bolt fills from the top but it looks cool tbh.
drawTexturedModalRect(guiLeft + 150, guiTop + 59, 176, 93, 15, Math.round(20 * percentagef)); // it's not really intended that the bolt fills from the top but it looks cool tbh.

}
drawActiveIcon(te.isActivatedClient());
this.fontRenderer.drawString(I18n.format("youmatter.guiname.creator"), 8, 6, 4210752);
}

@Override
Expand Down
69 changes: 52 additions & 17 deletions src/main/java/realmayus/youmatter/creator/TileCreator.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package realmayus.youmatter.creator;

import net.minecraft.block.state.IBlockState;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.inventory.Container;
import net.minecraft.item.ItemBucket;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
Expand All @@ -24,14 +23,16 @@
import net.minecraftforge.items.ItemStackHandler;
import net.minecraftforge.items.wrapper.CombinedInvWrapper;
import realmayus.youmatter.ModFluids;
import realmayus.youmatter.encoder.BlockEncoder;
import realmayus.youmatter.encoder.TileEncoder;
import realmayus.youmatter.YMConfig;
import realmayus.youmatter.replicator.TileReplicator;
import realmayus.youmatter.util.GeneralUtils;
import realmayus.youmatter.util.MyEnergyStorage;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.*;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

public class TileCreator extends TileEntity implements ITickable{

Expand Down Expand Up @@ -329,10 +330,12 @@ public void update() {
if (currentPartTick == 40) { // every 2 sec
if (!world.isRemote) {
if(isActivated()) {
if (getEnergy() >= 0.3f * 1000000 && sTank.getFluidAmount() >= 125) { // if energy more than 10 % of max energy
sTank.drain(125, true);
uTank.fill(new FluidStack(ModFluids.UMATTER, Math.round((float) 0.000005 * (getEnergy()/3f))), true);
myEnergyStorage.consumePower(Math.round(getEnergy()/3f));
if (getEnergy() >= 0.3f * 1000000 && sTank.getFluidAmount() >= 125) { // if energy more than 30 % of max energy
if (uTank.getFluidAmount() + YMConfig.productionPerWorkcycle <= MAX_UMATTER) {
sTank.drain(125, true);
uTank.fill(new FluidStack(ModFluids.UMATTER, YMConfig.productionPerWorkcycle), true);
myEnergyStorage.consumePower(Math.round(getEnergy()/3f));
}
}
}

Expand All @@ -349,27 +352,59 @@ public void update() {
currentPartTick = 0;
} else if ((currentPartTick % 5) == 0) { // every five ticks
if (!world.isRemote) {
if (!this.inputHandler.getStackInSlot(3).isEmpty()) {
if (this.inputHandler.getStackInSlot(3).getItem() == Items.BUCKET) {
if (!(this.inputHandler.getStackInSlot(3).isEmpty()) && GeneralUtils.canAddItemToSlot(this.inputHandler.getStackInSlot(4), this.inputHandler.getStackInSlot(3), false)) {
ItemStack item = this.inputHandler.getStackInSlot(3);
if (item.getItem() instanceof ItemBucket) {
if (getUTank().getFluidAmount() >= 1000) {
getUTank().drain(1000, true);
this.inputHandler.setStackInSlot(3, ItemStack.EMPTY);
this.combinedHandler.insertItem(4, UniversalBucket.getFilledBucket(new UniversalBucket(), ModFluids.UMATTER), false);
}
} else {
if (item.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null)) {
IFluidTankProperties tankProperties = item.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null).getTankProperties()[0];
if (tankProperties.getContents() != null) {
if (tankProperties.getContents().getFluid().equals(ModFluids.UMATTER) || tankProperties.getContents().getFluid() == null) {
if (tankProperties.getCapacity() - tankProperties.getContents().amount < getUTank().getFluidAmount()) { //fluid in S-Tank is more than what fits in the item's tank
getUTank().drain(item.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null).fill(new FluidStack(ModFluids.UMATTER, tankProperties.getCapacity() - tankProperties.getContents().amount), true), true);
} else { //S-Tank's fluid fits perfectly in item's tank
getUTank().drain(item.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null).fill(getUTank().getFluid(), true), true);
}
}
}
}
this.inputHandler.setStackInSlot(3, ItemStack.EMPTY);
this.inputHandler.insertItem(4, item, false);
}
}
if (!this.inputHandler.getStackInSlot(1).isEmpty()) {
if (this.inputHandler.getStackInSlot(1).getItem() instanceof UniversalBucket) {
UniversalBucket bucket = (UniversalBucket) this.inputHandler.getStackInSlot(1).getItem();
if (bucket.getFluid(this.inputHandler.getStackInSlot(1)) != null) {
if (bucket.getFluid(this.inputHandler.getStackInSlot(1)).getFluid().equals(ModFluids.STABILIZER)) {
if (getSTank().getFluidAmount() < getUTank().getCapacity()) {
ItemStack item = this.inputHandler.getStackInSlot(1);
if (item.getItem() instanceof UniversalBucket && GeneralUtils.canAddItemToSlot(this.inputHandler.getStackInSlot(2), new ItemStack(Items.BUCKET, 1), false)) {
if (item.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null)) {
IFluidTankProperties tankProperties = item.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null).getTankProperties()[0];
if (tankProperties.getContents() != null && tankProperties.getContents().getFluid().equals(ModFluids.STABILIZER)) {
if (MAX_STABILIZER - getSTank().getFluidAmount() >= 1000) {
getSTank().fill(new FluidStack(ModFluids.STABILIZER, 1000), true);
this.inputHandler.setStackInSlot(1, ItemStack.EMPTY);
this.combinedHandler.insertItem(2, new ItemStack(Items.BUCKET, 1), false);
this.inputHandler.insertItem(2, new ItemStack(Items.BUCKET, 1), false);
}
}
}
} else if(GeneralUtils.canAddItemToSlot(this.inputHandler.getStackInSlot(2), this.inputHandler.getStackInSlot(1), false)) {
if (item.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null)) {
IFluidTankProperties tankProperties = item.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null).getTankProperties()[0];
if (tankProperties.getContents() != null) {
if (tankProperties.getContents().getFluid().equals(ModFluids.STABILIZER)) {
if (tankProperties.getContents().amount > MAX_STABILIZER - getSTank().getFluidAmount()) { //given fluid is more than what fits in the S-Tank
getSTank().fill(item.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null).drain(MAX_STABILIZER - getSTank().getFluidAmount(), true), true);
} else { //given fluid fits perfectly in S-Tank
getSTank().fill(item.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null).drain(tankProperties.getContents().amount, true), true);
}
}
}
}
this.inputHandler.setStackInSlot(1, ItemStack.EMPTY);
this.inputHandler.insertItem(2, item, false);
}
}

Expand Down
30 changes: 17 additions & 13 deletions src/main/java/realmayus/youmatter/encoder/GuiEncoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,30 @@ protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, i
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
mc.getTextureManager().bindTexture(GUI);
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
}

@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
super.drawGuiContainerForegroundLayer(mouseX, mouseY);

drawEnergyBolt(te.getClientEnergy());
drawProgressDisplayChain(te.getClientProgress());


//draw warning
if (!(te.inputHandler.getStackInSlot(1).getItem() instanceof ThumbdriveItem)) {
drawTexturedModalRect(16, 59, 176, 66, 16, 16);
drawTexturedModalRect(guiLeft + 16, guiTop + 59, 176, 66, 16, 16);
} else {
NBTTagCompound nbt = te.inputHandler.getStackInSlot(1).getTagCompound();
if (nbt != null) {
NBTTagList list = nbt.getTagList("stored_items", Constants.NBT.TAG_STRING);
if (list.tagCount() >= 8) {
drawTexturedModalRect(16, 59, 176, 66, 16, 16);
drawTexturedModalRect(guiLeft + 16, guiTop + 59, 176, 66, 16, 16);
}
}
}
}

@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
super.drawGuiContainerForegroundLayer(mouseX, mouseY);


this.fontRenderer.drawString(I18n.format("youmatter.guiname.encoder"), 8, 6, 4210752);
}

Expand Down Expand Up @@ -84,21 +88,21 @@ private void drawProgressDisplayChain(int progress) {
}

mc.getTextureManager().bindTexture(GUI);
drawTexturedModalRect(22, 42, 176, 41, Math.round((arrow1 / 100.0f) * 18), 12);
drawTexturedModalRect(47, 41, 176, 53, 7, Math.round((lock / 100.0f) * 13));
drawTexturedModalRect(61, 42, 176, 41, Math.round((arrow2 / 100.0f) * 18), 12);
drawTexturedModalRect(guiLeft + 22, guiTop + 42, 176, 41, Math.round((arrow1 / 100.0f) * 18), 12);
drawTexturedModalRect(guiLeft + 47, guiTop + 41, 176, 53, 7, Math.round((lock / 100.0f) * 13));
drawTexturedModalRect(guiLeft + 61, guiTop + 42, 176, 41, Math.round((arrow2 / 100.0f) * 18), 12);

}

private void drawEnergyBolt(int energy) {
mc.getTextureManager().bindTexture(GUI);

if(energy == 0) {
drawTexturedModalRect(141, 37, 176, 21, 15, 20);
drawTexturedModalRect(guiLeft + 141, guiTop + 37, 176, 21, 15, 20);
} else {
double percentage = energy * 100 / 1000000; // i know this is dumb
double percentage = energy * 100 / 1000000F; // i know this is dumb
float percentagef = (float) percentage / 100; // but it works.
drawTexturedModalRect(141, 37, 176, 0, 15, Math.round(20 * percentagef)); // it's not really intended that the bolt fills from the top but it looks cool tbh.
drawTexturedModalRect(guiLeft + 141, guiTop + 37, 176, 0, 15, Math.round(20 * percentagef)); // it's not really intended that the bolt fills from the top but it looks cool tbh.

}
}
Expand Down
Loading

0 comments on commit 74bec5d

Please sign in to comment.