mirror of
https://github.com/GTNewHorizons/Chisel.git
synced 2026-11-12 16:27:45 +00:00
Further simplify IChiselItem and improve chisel tooltips
This commit is contained in:
1 parent
25dc76a739
commit
047df88793
6 files changed
+43
-29
No files matched your search
@@ -18,12 +18,4 @@ public interface IChiselItem extends IChiselMode {
|
||||
*/
|
||||
void onChisel(World world, IInventory inv, int slot, ItemStack chisel, ItemStack target);
|
||||
|
||||
/**
|
||||
* Gets the current target of this chisel.
|
||||
*
|
||||
* @param chisel
|
||||
* @return The ItemStack this chisel is targeting. {@code null} if nothing is targeted.
|
||||
*/
|
||||
ItemStack getTarget(ItemStack chisel);
|
||||
|
||||
}
|
||||
@@ -143,14 +143,8 @@ public class ContainerChisel extends Container {
|
||||
if (finished)
|
||||
return;
|
||||
|
||||
if (chisel.stackTagCompound == null)
|
||||
chisel.stackTagCompound = new NBTTagCompound();
|
||||
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
if (inventory.getStackInSpecialSlot() != null)
|
||||
inventory.getStackInSpecialSlot().writeToNBT(tag);
|
||||
|
||||
chisel.stackTagCompound.setTag("chiselTarget", tag);
|
||||
General.setChiselTarget(chisel, inventory.getStackInSpecialSlot());
|
||||
|
||||
playerInventory.mainInventory[currentIndex] = chisel;
|
||||
}
|
||||
}
|
||||
@@ -14,11 +14,11 @@ import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import com.cricketcraft.chisel.Chisel;
|
||||
import com.cricketcraft.chisel.PacketHandler;
|
||||
import com.cricketcraft.chisel.api.ChiselMode;
|
||||
import com.cricketcraft.chisel.api.IChiselItem;
|
||||
import com.cricketcraft.chisel.carving.Carving;
|
||||
import com.cricketcraft.chisel.carving.CarvingVariation;
|
||||
import com.cricketcraft.chisel.client.GeneralChiselClient;
|
||||
import com.cricketcraft.chisel.utils.General;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
@@ -56,7 +56,7 @@ public final class ChiselController {
|
||||
CarvingVariation[] variations = Carving.chisel.getVariations(block, metadata);
|
||||
|
||||
if (variations != null) {
|
||||
ItemStack target = ((IChiselItem) held.getItem()).getTarget(held);
|
||||
ItemStack target = General.getChiselTarget(held);
|
||||
|
||||
if (target != null) {
|
||||
for (CarvingVariation v : variations) {
|
||||
|
||||
@@ -59,7 +59,15 @@ public class ItemChisel extends Item implements IChiselItem {
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean held) {
|
||||
list.add(StatCollector.translateToLocal(getUnlocalizedName(stack) + ".desc"));
|
||||
String unloc = "item.chisel.chisel.desc.";
|
||||
for (int i = 0; i < 3; i ++) {
|
||||
list.add(StatCollector.translateToLocal(unloc + i));
|
||||
}
|
||||
|
||||
if (type == ChiselType.DIAMOND) {
|
||||
list.add("");
|
||||
list.add(StatCollector.translateToLocal(getUnlocalizedName(stack) + ".desc"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -88,10 +96,4 @@ public class ItemChisel extends Item implements IChiselItem {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getTarget(ItemStack chisel) {
|
||||
return chisel.hasTagCompound() ? ItemStack.loadItemStackFromNBT(chisel.stackTagCompound.getCompoundTag("chiselTarget")) : null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
@@ -89,6 +90,26 @@ public class General {
|
||||
Vec3 var23 = var13.addVector(var18 * var21, var17 * var21, var20 * var21);
|
||||
return par1World.rayTraceBlocks(var13, var23, par3);
|
||||
}
|
||||
|
||||
public static final String[] sGNames = new String[] { "White", "Orange", "Magenta", "Light Blue", "Yellow", "Lime", "Pink", "Gray", "Light Gray", "Cyan", "Purple", "Blue", "Brown", "Green", "Red", "Black" };
|
||||
|
||||
public static ItemStack getChiselTarget(ItemStack chisel) {
|
||||
return chisel.hasTagCompound() ? ItemStack.loadItemStackFromNBT(chisel.stackTagCompound.getCompoundTag("chiselTarget")) : null;
|
||||
}
|
||||
|
||||
public static final String[] sGNames = new String[] { "White", "Orange", "Magenta", "Light Blue", "Yellow", "Lime", "Pink", "Gray", "Light Gray", "Cyan", "Purple", "Blue", "Brown", "Green",
|
||||
"Red", "Black" };
|
||||
|
||||
public static void setChiselTarget(ItemStack chisel, ItemStack target) {
|
||||
initTag(chisel);
|
||||
NBTTagCompound targetTag = new NBTTagCompound();
|
||||
if (target != null) {
|
||||
target.writeToNBT(targetTag);
|
||||
}
|
||||
chisel.getTagCompound().setTag("chiselTarget", targetTag);
|
||||
}
|
||||
|
||||
private static void initTag(ItemStack stack) {
|
||||
if (!stack.hasTagCompound()) {
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user