mirror of
https://github.com/GTNewHorizons/Chisel.git
synced 2026-11-11 15:57:31 +00:00
Allow only the diamond chisel to have modes. Fix breaking sounds up more
This commit is contained in:
1 parent
5188e39b57
commit
5b4af2ee49
10 files changed
+81
-43
No files matched your search
@@ -80,4 +80,13 @@ public interface IChiselItem {
|
||||
* @return True if the chiseling should take place. False otherwise.
|
||||
*/
|
||||
boolean canChiselBlock(World world, int x, int y, int z, Block block, int metadata);
|
||||
|
||||
/**
|
||||
* Allows you to control if your item has chiseling modes.
|
||||
*
|
||||
* @param chisel
|
||||
* The {@link ItemStack} representing the chisel.
|
||||
* @return True if the chisel supports modes. False otherwise.
|
||||
*/
|
||||
boolean hasModes(ItemStack chisel);
|
||||
}
|
||||
@@ -60,7 +60,7 @@ public class TileEntityAutoChisel extends TileEntity implements ISidedInventory
|
||||
public static final int maxRot = 60;
|
||||
public static final int rotAmnt = 15;
|
||||
public float chiselRot;
|
||||
public boolean chiseling = false;
|
||||
public boolean chiseling = false, breakChisel = false;;
|
||||
public int toChisel = 1;
|
||||
|
||||
private ItemStack lastBase;
|
||||
@@ -166,6 +166,7 @@ public class TileEntityAutoChisel extends TileEntity implements ISidedInventory
|
||||
}
|
||||
}
|
||||
} else if (worldObj.isRemote) {
|
||||
System.out.println(chiseling + " " + chiselRot);
|
||||
if (chiseling) {
|
||||
chiselRot += rotAmnt;
|
||||
if (chiselRot >= maxRot) {
|
||||
@@ -209,14 +210,19 @@ public class TileEntityAutoChisel extends TileEntity implements ISidedInventory
|
||||
/** Calls IChiselItem#onChisel() and sends the chisel packet for sound/animation */
|
||||
private void chiselItem(int chiseled) {
|
||||
if (!worldObj.isRemote) {
|
||||
boolean breakChisel = false;
|
||||
if (((IChiselItem) inventory[CHISEL].getItem()).onChisel(worldObj, this, CHISEL, inventory[CHISEL], General.getVariation(inventory[TARGET]))) {
|
||||
inventory[CHISEL].setItemDamage(inventory[CHISEL].getItemDamage() - 1);
|
||||
inventory[CHISEL].setItemDamage(inventory[CHISEL].getItemDamage() + 1);
|
||||
if (inventory[CHISEL].getItemDamage() >= inventory[CHISEL].getMaxDamage()) {
|
||||
inventory[CHISEL] = null;
|
||||
setInventorySlotContents(CHISEL, null);
|
||||
breakChisel = true;
|
||||
}
|
||||
}
|
||||
PacketHandler.INSTANCE.sendToDimension(new MessageAutoChisel(this, chiseled, true), worldObj.provider.dimensionId);
|
||||
PacketHandler.INSTANCE.sendToDimension(new MessageAutoChisel(this, chiseled, true, breakChisel), worldObj.provider.dimensionId);
|
||||
} else {
|
||||
if (breakChisel) {
|
||||
worldObj.playSound(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, "random.break", 0.8F, 0.8F + worldObj.rand.nextFloat() * 0.4F, false);
|
||||
}
|
||||
GeneralChiselClient.spawnAutoChiselFX(this, lastBase != null ? lastBase : inventory[BASE]);
|
||||
chiseling = false;
|
||||
if (lastBase != null) {
|
||||
@@ -276,7 +282,7 @@ public class TileEntityAutoChisel extends TileEntity implements ISidedInventory
|
||||
if (stack != null && stack.stackSize > getInventoryStackLimit()) {
|
||||
stack.stackSize = getInventoryStackLimit();
|
||||
}
|
||||
|
||||
|
||||
if (worldObj.isRemote && slot == BASE && stack != null) {
|
||||
lastBase = stack.copy();
|
||||
}
|
||||
@@ -368,7 +374,7 @@ public class TileEntityAutoChisel extends TileEntity implements ISidedInventory
|
||||
} else if (inventory[slot] == null) {
|
||||
return null;
|
||||
} else {
|
||||
ghostItem.setEntityItemStack(new ItemStack(inventory[slot].getItem(), 1, inventory[slot].getItemDamage()));
|
||||
ghostItem.setEntityItemStack(inventory[slot].copy());
|
||||
return ghostItem;
|
||||
}
|
||||
}
|
||||
@@ -408,14 +414,15 @@ public class TileEntityAutoChisel extends TileEntity implements ISidedInventory
|
||||
}
|
||||
}
|
||||
|
||||
public void doChiselAnim(ItemStack lastChiseled, int chiseled, boolean playSound) {
|
||||
public void doChiselAnim(ItemStack lastChiseled, int chiseled, boolean playSound, boolean breakChisel) {
|
||||
this.lastBase = lastChiseled == null ? null : lastChiseled.copy();
|
||||
this.toChisel = chiseled;
|
||||
if (playSound) {
|
||||
this.chiseling = true;
|
||||
}
|
||||
this.breakChisel = breakChisel;
|
||||
}
|
||||
|
||||
|
||||
public ItemStack getLastBase() {
|
||||
return lastBase == null ? null : lastBase.copy();
|
||||
}
|
||||
|
||||
@@ -2,12 +2,10 @@ package com.cricketcraft.chisel.client.gui;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import net.minecraft.inventory.Slot;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.cricketcraft.chisel.api.IChiselItem;
|
||||
import com.cricketcraft.chisel.inventory.ContainerChisel;
|
||||
import com.cricketcraft.chisel.inventory.InventoryChiselSelection;
|
||||
import com.cricketcraft.chisel.inventory.SlotChiselInput;
|
||||
@@ -45,24 +46,36 @@ public class GuiChisel extends GuiContainer {
|
||||
super.initGui();
|
||||
currentMode = General.getChiselMode(container.chisel);
|
||||
|
||||
int x = this.width / 2 - 120;
|
||||
int y = this.height / 2 - 6;
|
||||
buttonList.add(new GuiButton(0, x, y, 53, 20, ""));
|
||||
setButtonText();
|
||||
if (showMode()) {
|
||||
int x = this.width / 2 - 120;
|
||||
int y = this.height / 2 - 6;
|
||||
buttonList.add(new GuiButton(0, x, y, 53, 20, ""));
|
||||
setButtonText();
|
||||
}
|
||||
}
|
||||
|
||||
private void setButtonText() {
|
||||
((GuiButton) buttonList.get(0)).displayString = I18n.format(container.inventory.getInventoryName() + ".mode." + currentMode.name().toLowerCase());
|
||||
}
|
||||
|
||||
private boolean showMode() {
|
||||
if (container.chisel != null && container.chisel.getItem() instanceof IChiselItem) {
|
||||
return ((IChiselItem) container.chisel.getItem()).hasModes(container.chisel);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int j, int i) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
String line = I18n.format(this.container.inventory.getInventoryName() + ".title");
|
||||
fontRendererObj.drawSplitString(line, 50 - fontRendererObj.getStringWidth(line) / 2, 60, 40, 0x404040);
|
||||
line = I18n.format(this.container.inventory.getInventoryName() + ".mode");
|
||||
fontRendererObj.drawString(line, fontRendererObj.getStringWidth(line) / 2 + 6, 85, 0x404040);
|
||||
|
||||
if (showMode()) {
|
||||
line = I18n.format(this.container.inventory.getInventoryName() + ".mode");
|
||||
fontRendererObj.drawString(line, fontRendererObj.getStringWidth(line) / 2 + 6, 85, 0x404040);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -186,9 +186,6 @@ public class RenderAutoChisel extends TileEntitySpecialRenderer implements ISimp
|
||||
renderItem.doRender(item, 0, 0, 0, 0, 0);
|
||||
settings.fancyGraphics = was;
|
||||
glPopMatrix();
|
||||
} else {
|
||||
autoChisel.chiselRot = 0;
|
||||
autoChisel.chiseling = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,11 +39,12 @@ public class Configurations {
|
||||
public static int ironChiselMaxDamage;
|
||||
public static int diamondChiselMaxDamage;
|
||||
public static boolean ironChiselCanLeftClick;
|
||||
|
||||
public static boolean ironChiselHasModes;
|
||||
|
||||
public static boolean useRoadLineTool;
|
||||
public static String getRoadLineTool;
|
||||
public static int roadLineToolLevel;
|
||||
|
||||
|
||||
public static boolean refreshConfig() {
|
||||
|
||||
String category;
|
||||
@@ -78,19 +79,21 @@ public class Configurations {
|
||||
.getBoolean(true);
|
||||
|
||||
/* chisel */
|
||||
|
||||
category = "chisel";
|
||||
allowChiselDamage = config.get(category, "allowChiselDamage", true, "Should the chisel be damageable and take damage when it chisels something.").getBoolean();
|
||||
ironChiselMaxDamage = config.get(category, "ironChiselMaxDamage", 500, "The max damage of the standard iron chisel. Default: 500.").getInt();
|
||||
diamondChiselMaxDamage = config.get(category, "diamondChiselMaxDamage", 5000, "The max damage of the diamond chisel. Default: 5000").getInt();
|
||||
ironChiselCanLeftClick = config.get(category, "ironChiselCanLeftClick", true, "If this is true, the iron chisel can left click chisel blocks. If false, it cannot.").getBoolean();
|
||||
|
||||
ironChiselHasModes = config.get(category, "ironChiselHasModes", false, "If this is true, the iron chisel can change its chisel mode just as the diamond chisel can.").getBoolean();
|
||||
|
||||
/* block */
|
||||
category = "block";
|
||||
useRoadLineTool = config.get(category, "useRoadLineTool", false, "Should the road line require a tool to break (If false, road lines can be broken in Adventure)").getBoolean();
|
||||
getRoadLineTool = config.get(category, "getRoadLineTool","pickaxe","The tool that is able to break roadLines (requires useRoadLineTool to be true to take effect)").getString();
|
||||
roadLineToolLevel = config.get(category, "roadLineToolLevel",0,"The lowest harvest level of the tool able to break the road lines (requires useRoadLineTool to be true to take effect) (0 = Wood/Gold, 1 = Stone, 2 = Iron, 3 = Diamond) Default: 0").getInt();
|
||||
|
||||
getRoadLineTool = config.get(category, "getRoadLineTool", "pickaxe", "The tool that is able to break roadLines (requires useRoadLineTool to be true to take effect)").getString();
|
||||
roadLineToolLevel = config.get(category, "roadLineToolLevel", 0,
|
||||
"The lowest harvest level of the tool able to break the road lines (requires useRoadLineTool to be true to take effect) (0 = Wood/Gold, 1 = Stone, 2 = Iron, 3 = Diamond) Default: 0")
|
||||
.getInt();
|
||||
|
||||
if (config.hasChanged()) {
|
||||
config.save();
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ public class ContainerAutoChisel extends Container {
|
||||
|
||||
if (!player.worldObj.isRemote && slot.slotNumber == TileEntityAutoChisel.BASE && !ItemStack.areItemStacksEqual(stack, slot.getStack())) {
|
||||
int chiseled = stack == null ? 0 : slot.getStack() == null ? stack.stackSize : stack.stackSize - slot.getStack().stackSize;
|
||||
PacketHandler.INSTANCE.sendToDimension(new MessageAutoChisel(autoChisel, chiseled, false), player.worldObj.provider.dimensionId);
|
||||
PacketHandler.INSTANCE.sendToDimension(new MessageAutoChisel(autoChisel, chiseled, false, false), player.worldObj.provider.dimensionId);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
@@ -3,11 +3,11 @@ package com.cricketcraft.chisel.item.chisel;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
@@ -57,16 +57,19 @@ public class ItemChisel extends Item implements IChiselItem {
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean held) {
|
||||
String unloc = "item.chisel.chisel.desc."; // TODO this is hacky
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (i == 0 || type == ChiselType.DIAMOND || Configurations.ironChiselCanLeftClick) {
|
||||
list.add(StatCollector.translateToLocal(unloc + i));
|
||||
}
|
||||
String base = "item.chisel.chisel.desc.";
|
||||
String gui = I18n.format(base + "gui");
|
||||
String lc1 = I18n.format(base + "lc1");
|
||||
String lc2 = I18n.format(base + "lc2");
|
||||
String modes = I18n.format(base + "modes");
|
||||
list.add(gui);
|
||||
if (type == ChiselType.DIAMOND || Configurations.ironChiselCanLeftClick) {
|
||||
list.add(lc1);
|
||||
list.add(lc2);
|
||||
}
|
||||
|
||||
if (type == ChiselType.DIAMOND) {
|
||||
if (type == ChiselType.DIAMOND || Configurations.ironChiselHasModes) {
|
||||
list.add("");
|
||||
list.add(StatCollector.translateToLocal(getUnlocalizedName(stack) + ".desc"));
|
||||
list.add(modes);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,4 +97,9 @@ public class ItemChisel extends Item implements IChiselItem {
|
||||
public boolean canChiselBlock(World world, int x, int y, int z, Block block, int metadata) {
|
||||
return type == ChiselType.DIAMOND || Configurations.ironChiselCanLeftClick;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasModes(ItemStack chisel) {
|
||||
return type == ChiselType.DIAMOND || Configurations.ironChiselHasModes;
|
||||
}
|
||||
}
|
||||
@@ -18,16 +18,17 @@ public class MessageAutoChisel extends MessageCoords {
|
||||
}
|
||||
|
||||
ItemStack base;
|
||||
boolean playSound;
|
||||
boolean playSound, breakChisel;
|
||||
int chiseled;
|
||||
|
||||
public MessageAutoChisel(TileEntityAutoChisel tile, int chiseled, boolean playSound) {
|
||||
public MessageAutoChisel(TileEntityAutoChisel tile, int chiseled, boolean playSound, boolean breakChisel) {
|
||||
super(tile);
|
||||
this.base = tile.getStackInSlot(TileEntityAutoChisel.BASE);
|
||||
if (base != null) {
|
||||
base = base.copy();
|
||||
}
|
||||
this.playSound = playSound;
|
||||
this.breakChisel = breakChisel;
|
||||
this.chiseled = chiseled;
|
||||
}
|
||||
|
||||
@@ -35,6 +36,7 @@ public class MessageAutoChisel extends MessageCoords {
|
||||
public void toBytes(ByteBuf buf) {
|
||||
super.toBytes(buf);
|
||||
buf.writeBoolean(playSound);
|
||||
buf.writeBoolean(breakChisel);
|
||||
buf.writeInt(chiseled);
|
||||
ByteBufUtils.writeItemStack(buf, base);
|
||||
}
|
||||
@@ -43,6 +45,7 @@ public class MessageAutoChisel extends MessageCoords {
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
super.fromBytes(buf);
|
||||
this.playSound = buf.readBoolean();
|
||||
this.breakChisel = buf.readBoolean();
|
||||
this.chiseled = buf.readInt();
|
||||
this.base = ByteBufUtils.readItemStack(buf);
|
||||
}
|
||||
@@ -53,7 +56,7 @@ public class MessageAutoChisel extends MessageCoords {
|
||||
|
||||
TileEntity te = message.getTileEntity(ctx);
|
||||
if (te instanceof TileEntityAutoChisel) {
|
||||
((TileEntityAutoChisel) te).doChiselAnim(message.base, message.chiseled, message.playSound);
|
||||
((TileEntityAutoChisel) te).doChiselAnim(message.base, message.chiseled, message.playSound, message.breakChisel);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user