Added textures for the key+lock switch
Renaming a key to an empty name returns it to its unnamed state
This commit is contained in:
parent
65ba8acbec
commit
9ba2dcb0b6
|
@ -129,5 +129,4 @@ public class IndustrialWires {
|
||||||
public void postInit(FMLPostInitializationEvent e) {
|
public void postInit(FMLPostInitializationEvent e) {
|
||||||
proxy.postInit();
|
proxy.postInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@ import malte0811.industrialWires.client.panelmodel.PanelModelLoader;
|
||||||
import malte0811.industrialWires.client.render.TileRenderJacobsLadder;
|
import malte0811.industrialWires.client.render.TileRenderJacobsLadder;
|
||||||
import malte0811.industrialWires.controlpanel.PanelComponent;
|
import malte0811.industrialWires.controlpanel.PanelComponent;
|
||||||
import malte0811.industrialWires.items.ItemIC2Coil;
|
import malte0811.industrialWires.items.ItemIC2Coil;
|
||||||
|
import malte0811.industrialWires.items.ItemKey;
|
||||||
import malte0811.industrialWires.items.ItemPanelComponent;
|
import malte0811.industrialWires.items.ItemPanelComponent;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
@ -118,6 +119,11 @@ public class ClientProxy extends CommonProxy {
|
||||||
ModelBakery.registerItemVariants(IndustrialWires.panelComponent, loc);
|
ModelBakery.registerItemVariants(IndustrialWires.panelComponent, loc);
|
||||||
ModelLoader.setCustomModelResourceLocation(IndustrialWires.panelComponent, meta, new ModelResourceLocation(loc, "inventory"));
|
ModelLoader.setCustomModelResourceLocation(IndustrialWires.panelComponent, meta, new ModelResourceLocation(loc, "inventory"));
|
||||||
}
|
}
|
||||||
|
for (int meta = 0; meta < ItemKey.types.length; meta++) {
|
||||||
|
ResourceLocation loc = new ResourceLocation(IndustrialWires.MODID, "key/" + ItemKey.types[meta]);
|
||||||
|
ModelBakery.registerItemVariants(IndustrialWires.key, loc);
|
||||||
|
ModelLoader.setCustomModelResourceLocation(IndustrialWires.key, meta, new ModelResourceLocation(loc, "inventory"));
|
||||||
|
}
|
||||||
|
|
||||||
Block[] blocks = {IndustrialWires.ic2conn, IndustrialWires.mechConv, IndustrialWires.jacobsLadder, IndustrialWires.panel};
|
Block[] blocks = {IndustrialWires.ic2conn, IndustrialWires.mechConv, IndustrialWires.jacobsLadder, IndustrialWires.panel};
|
||||||
for (Block b : blocks) {
|
for (Block b : blocks) {
|
||||||
|
|
|
@ -98,11 +98,9 @@ public class GuiRenameKey extends GuiContainer {
|
||||||
@Override
|
@Override
|
||||||
public void onGuiClosed() {
|
public void onGuiClosed() {
|
||||||
super.onGuiClosed();
|
super.onGuiClosed();
|
||||||
if (!field.getText().isEmpty()) {
|
|
||||||
NBTTagCompound nbt = new NBTTagCompound();
|
NBTTagCompound nbt = new NBTTagCompound();
|
||||||
nbt.setString("name", field.getText());
|
nbt.setString("name", field.getText());
|
||||||
IndustrialWires.packetHandler.sendToServer(new MessageItemSync(hand, nbt));
|
IndustrialWires.packetHandler.sendToServer(new MessageItemSync(hand, nbt));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,14 +39,13 @@ public class RecipeKeyLock implements IRecipe {
|
||||||
return getLockId(inv) != 0;
|
return getLockId(inv) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getCraftingResult(@Nonnull InventoryCrafting inv) {
|
public ItemStack getCraftingResult(@Nonnull InventoryCrafting inv) {
|
||||||
ItemStack key = getKey(inv);
|
ItemStack key = getKey(inv);
|
||||||
if (key==null) {
|
if (key==null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
ItemStack ret = key.copy();
|
ItemStack ret = new ItemStack(IndustrialWires.key, 1, 1);
|
||||||
ItemKey.setId(ret, getLockId(inv));
|
ItemKey.setId(ret, getLockId(inv));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -59,7 +58,7 @@ public class RecipeKeyLock implements IRecipe {
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getRecipeOutput() {
|
public ItemStack getRecipeOutput() {
|
||||||
return new ItemStack(IndustrialWires.key);
|
return new ItemStack(IndustrialWires.key, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
|
|
@ -64,7 +64,7 @@ public class ItemIC2Coil extends Item implements IWireCoil {
|
||||||
setHasSubtypes(true);
|
setHasSubtypes(true);
|
||||||
this.setCreativeTab(IndustrialWires.creativeTab);
|
this.setCreativeTab(IndustrialWires.creativeTab);
|
||||||
setMaxStackSize(64);
|
setMaxStackSize(64);
|
||||||
setRegistryName(new ResourceLocation(IndustrialWires.MODID, "ic2WireCoil"));
|
setRegistryName(new ResourceLocation(IndustrialWires.MODID, "ic2_wire_coil"));
|
||||||
GameRegistry.register(this);
|
GameRegistry.register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.nbt.NBTTagInt;
|
import net.minecraft.nbt.NBTTagInt;
|
||||||
|
import net.minecraft.nbt.NBTTagString;
|
||||||
import net.minecraft.util.ActionResult;
|
import net.minecraft.util.ActionResult;
|
||||||
import net.minecraft.util.EnumActionResult;
|
import net.minecraft.util.EnumActionResult;
|
||||||
import net.minecraft.util.EnumHand;
|
import net.minecraft.util.EnumHand;
|
||||||
|
@ -37,6 +38,7 @@ import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class ItemKey extends Item implements INetGUIItem {
|
public class ItemKey extends Item implements INetGUIItem {
|
||||||
private static final String lockId = "lockId";
|
private static final String lockId = "lockId";
|
||||||
|
public static final String[] types = {"blank_key", "key"};
|
||||||
|
|
||||||
public ItemKey() {
|
public ItemKey() {
|
||||||
setUnlocalizedName(IndustrialWires.MODID + ".key");
|
setUnlocalizedName(IndustrialWires.MODID + ".key");
|
||||||
|
@ -72,7 +74,7 @@ public class ItemKey extends Item implements INetGUIItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int idForKey(@Nullable ItemStack held) {
|
public static int idForKey(@Nullable ItemStack held) {
|
||||||
if (held==null||held.getItem()!=IndustrialWires.key) {
|
if (held==null||held.getItem()!=IndustrialWires.key||held.getMetadata()==0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
NBTTagCompound nbt = held.getTagCompound();
|
NBTTagCompound nbt = held.getTagCompound();
|
||||||
|
@ -90,7 +92,8 @@ public class ItemKey extends Item implements INetGUIItem {
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack stack, World worldIn, EntityPlayer playerIn, @Nonnull EnumHand hand) {
|
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack stack, World worldIn, EntityPlayer playerIn, @Nonnull EnumHand hand) {
|
||||||
if (!worldIn.isRemote&&idForKey(playerIn.getHeldItem(hand))!=0) {
|
ItemStack held = playerIn.getHeldItem(hand);
|
||||||
|
if (!worldIn.isRemote&&idForKey(held)!=0) {
|
||||||
playerIn.openGui(IndustrialWires.MODID, 1, worldIn, 0, 0, hand == EnumHand.MAIN_HAND ? 1 : 0);
|
playerIn.openGui(IndustrialWires.MODID, 1, worldIn, 0, 0, hand == EnumHand.MAIN_HAND ? 1 : 0);
|
||||||
}
|
}
|
||||||
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
|
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
|
||||||
|
@ -99,6 +102,14 @@ public class ItemKey extends Item implements INetGUIItem {
|
||||||
@Override
|
@Override
|
||||||
public void onChange(NBTTagCompound nbt, EntityPlayer p, EnumHand hand) {
|
public void onChange(NBTTagCompound nbt, EntityPlayer p, EnumHand hand) {
|
||||||
ItemStack held = p.getHeldItem(hand);
|
ItemStack held = p.getHeldItem(hand);
|
||||||
held.setTagInfo("name", nbt.getTag("name"));
|
String name = nbt.getString("name");
|
||||||
|
if (!name.trim().isEmpty()) {
|
||||||
|
held.setTagInfo("name", new NBTTagString(name));
|
||||||
|
} else {
|
||||||
|
NBTTagCompound heldNBT = held.getTagCompound();
|
||||||
|
if (heldNBT!=null) {
|
||||||
|
heldNBT.removeTag("name");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent":"item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0":"industrialwires:items/blank_key"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent":"item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0":"industrialwires:items/key"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent":"item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0":"industrialwires:items/lock_switch"
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 321 B |
BIN
src/main/resources/assets/industrialwires/textures/items/key.png
Normal file
BIN
src/main/resources/assets/industrialwires/textures/items/key.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 334 B |
Binary file not shown.
After Width: | Height: | Size: 497 B |
Loading…
Reference in a new issue