mirror of
https://github.com/GTNewHorizons/Chisel.git
synced 2026-11-11 15:57:31 +00:00
#69 Allow autochisel to function properly when upgrades are disabled
Conflicts: src/main/java/team/chisel/block/tileentity/TileEntityAutoChisel.java
This commit is contained in:
1 parent
40a54a7e6c
commit
f181ff19f5
9 files changed
+43
-120
No files matched your search
@@ -2,15 +2,6 @@ package team.chisel.block.tileentity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cricketcraft.chisel.api.IChiselItem;
|
||||
|
||||
import team.chisel.carving.Carving;
|
||||
import team.chisel.client.GeneralChiselClient;
|
||||
import team.chisel.init.ChiselItems;
|
||||
import team.chisel.network.PacketHandler;
|
||||
import team.chisel.network.message.MessageAutoChisel;
|
||||
import team.chisel.network.message.MessageSlotUpdate;
|
||||
import team.chisel.utils.General;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
@@ -21,7 +12,19 @@ import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import team.chisel.Features;
|
||||
import team.chisel.carving.Carving;
|
||||
import team.chisel.client.GeneralChiselClient;
|
||||
import team.chisel.init.ChiselItems;
|
||||
import team.chisel.network.PacketHandler;
|
||||
import team.chisel.network.message.MessageAutoChisel;
|
||||
import team.chisel.network.message.MessageSlotUpdate;
|
||||
import team.chisel.utils.General;
|
||||
|
||||
import com.cricketcraft.chisel.api.IChiselItem;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@@ -34,11 +37,18 @@ public class TileEntityAutoChisel extends TileEntity implements ISidedInventory
|
||||
REVERSION;
|
||||
|
||||
public String getUnlocalizedName() {
|
||||
return ChiselItems.upgrade.getUnlocalizedName() + "_" + this.name().toLowerCase();
|
||||
if (Features.AUTO_CHISEL_UPGRADES.enabled()) {
|
||||
return ChiselItems.upgrade.getUnlocalizedName() + "_" + this.name().toLowerCase() + ".name";
|
||||
}
|
||||
return "chisel.autochisel.upgrade.disabled";
|
||||
}
|
||||
|
||||
public String getLocalizedName() {
|
||||
return StatCollector.translateToLocal(getUnlocalizedName() + ".name");
|
||||
String ret = StatCollector.translateToLocal(getUnlocalizedName());
|
||||
if (!Features.AUTO_CHISEL_UPGRADES.enabled()) {
|
||||
ret = EnumChatFormatting.RED.toString().concat(ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,8 +95,9 @@ public class TileEntityAutoChisel extends TileEntity implements ISidedInventory
|
||||
inventory[slot] = null;
|
||||
return is;
|
||||
}
|
||||
} else
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -351,7 +362,7 @@ public class TileEntityAutoChisel extends TileEntity implements ISidedInventory
|
||||
case CHISEL:
|
||||
return itemStack.getItem() instanceof IChiselItem;
|
||||
default:
|
||||
return itemStack.getItem() == ChiselItems.upgrade && Upgrade.values()[slot - MIN_UPGRADE].ordinal() == itemStack.getItemDamage();
|
||||
return Features.AUTO_CHISEL_UPGRADES.enabled() && itemStack.getItem() == ChiselItems.upgrade && Upgrade.values()[slot - MIN_UPGRADE].ordinal() == itemStack.getItemDamage();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -413,11 +424,15 @@ public class TileEntityAutoChisel extends TileEntity implements ISidedInventory
|
||||
}
|
||||
|
||||
public boolean hasUpgrade(Upgrade upgrade) {
|
||||
ItemStack stack = inventory[MIN_UPGRADE + upgrade.ordinal()];
|
||||
if (stack != null) {
|
||||
return stack.getItem() == ChiselItems.upgrade && stack.getItemDamage() == upgrade.ordinal();
|
||||
if (Features.AUTO_CHISEL_UPGRADES.enabled()) {
|
||||
ItemStack stack = inventory[MIN_UPGRADE + upgrade.ordinal()];
|
||||
if (stack != null) {
|
||||
return stack.getItem() == ChiselItems.upgrade && stack.getItemDamage() == upgrade.ordinal();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
|
||||
return upgrade == Upgrade.REVERSION ? false : true;
|
||||
}
|
||||
|
||||
public String getSlotTooltipUnloc(int slotNumber) {
|
||||
@@ -429,9 +444,10 @@ public class TileEntityAutoChisel extends TileEntity implements ISidedInventory
|
||||
} else if (slotNumber == CHISEL) {
|
||||
name = "chisel";
|
||||
}
|
||||
return name == null ? null : String.format(base, name);
|
||||
String unloc = name == null ? null : String.format(base, name);
|
||||
return StatCollector.translateToLocal(unloc);
|
||||
} else {
|
||||
return Upgrade.values()[slotNumber - MIN_UPGRADE].getUnlocalizedName() + ".name";
|
||||
return Upgrade.values()[slotNumber - MIN_UPGRADE].getLocalizedName();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@@ -28,10 +27,15 @@ public class GuiAutoChisel extends GuiContainer {
|
||||
autochisel = tileEntityAutoChisel;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTick) {
|
||||
super.drawScreen(mouseX, mouseY, partialTick);
|
||||
|
||||
int x = (this.width - this.xSize) / 2;
|
||||
int y = (this.height - this.ySize) / 2;
|
||||
@@ -41,7 +45,7 @@ public class GuiAutoChisel extends GuiContainer {
|
||||
if (slot.slotNumber < autochisel.getSizeInventory()) {
|
||||
String tt = autochisel.getSlotTooltipUnloc(slot.slotNumber);
|
||||
if (!Strings.isNullOrEmpty(tt)) {
|
||||
this.func_146283_a(Lists.newArrayList(StatCollector.translateToLocal(tt)), mouseX - x, mouseY - y);
|
||||
this.func_146283_a(Lists.newArrayList(tt), mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user