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:
malte0811 2017-05-20 17:14:43 +02:00
parent 6a2ce4685b
commit 695679caa2
12 changed files with 49 additions and 10 deletions

View file

@ -130,12 +130,18 @@ public class IndustrialWires {
@EventHandler
public void remap(FMLMissingMappingsEvent ev) {
for (FMLMissingMappingsEvent.MissingMapping miss : ev.get()) {
if (miss.resourceLocation.getResourcePath().equals("ic2connector")) {
if (miss.type== GameRegistry.Type.ITEM) {
String name = miss.resourceLocation.getResourcePath();
switch (name) {
case "ic2connector":
if (miss.type == GameRegistry.Type.ITEM) {
miss.remap(Item.getItemFromBlock(IndustrialWires.ic2conn));
} else {
miss.remap(IndustrialWires.ic2conn);
}
break;
case "ic2wirecoil":
miss.remap(IndustrialWires.coil);
break;
}
}
}

View file

@ -42,6 +42,7 @@ import malte0811.industrialWires.client.panelmodel.PanelModelLoader;
import malte0811.industrialWires.client.render.TileRenderJacobsLadder;
import malte0811.industrialWires.controlpanel.PanelComponent;
import malte0811.industrialWires.items.ItemIC2Coil;
import malte0811.industrialWires.items.ItemKey;
import malte0811.industrialWires.items.ItemPanelComponent;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
@ -118,6 +119,11 @@ public class ClientProxy extends CommonProxy {
ModelBakery.registerItemVariants(IndustrialWires.panelComponent, loc);
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};
for (Block b : blocks) {

View file

@ -96,11 +96,9 @@ public class GuiRenameKey extends GuiContainer {
@Override
public void onGuiClosed() {
super.onGuiClosed();
if (!field.getText().isEmpty()) {
NBTTagCompound nbt = new NBTTagCompound();
nbt.setString("name", field.getText());
IndustrialWires.packetHandler.sendToServer(new MessageItemSync(hand, nbt));
}
}
}

View file

@ -41,7 +41,7 @@ public class RecipeKeyLock implements IRecipe {
@Nonnull
@Override
public ItemStack getCraftingResult(@Nonnull InventoryCrafting inv) {
ItemStack ret = getKey(inv).copy();
ItemStack ret = new ItemStack(IndustrialWires.key, 1, 1);
ItemKey.setId(ret, getLockId(inv));
return ret;
}
@ -54,7 +54,7 @@ public class RecipeKeyLock implements IRecipe {
@Nonnull
@Override
public ItemStack getRecipeOutput() {
return new ItemStack(IndustrialWires.key);
return new ItemStack(IndustrialWires.key, 1, 1);
}
@Nonnull

View file

@ -61,7 +61,7 @@ public class ItemIC2Coil extends Item implements IWireCoil {
setHasSubtypes(true);
this.setCreativeTab(IndustrialWires.creativeTab);
setMaxStackSize(64);
setRegistryName(new ResourceLocation(IndustrialWires.MODID, "ic2WireCoil"));
setRegistryName(new ResourceLocation(IndustrialWires.MODID, "ic2_wire_coil"));
GameRegistry.register(this);
}

View file

@ -25,6 +25,7 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagInt;
import net.minecraft.nbt.NBTTagString;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
@ -36,6 +37,7 @@ import javax.annotation.Nonnull;
public class ItemKey extends Item implements INetGUIItem {
private static final String lockId = "lockId";
public static final String[] types = {"blank_key", "key"};
public ItemKey() {
setUnlocalizedName(IndustrialWires.MODID + ".key");
@ -71,7 +73,7 @@ public class ItemKey extends Item implements INetGUIItem {
}
public static int idForKey(@Nonnull ItemStack held) {
if (held.getItem()!=IndustrialWires.key) {
if (held.getItem()!=IndustrialWires.key||held.getMetadata()==0) {
return 0;
}
NBTTagCompound nbt = held.getTagCompound();
@ -89,7 +91,8 @@ public class ItemKey extends Item implements INetGUIItem {
@Override
@Nonnull
public ActionResult<ItemStack> onItemRightClick(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);
}
return new ActionResult<>(EnumActionResult.SUCCESS, playerIn.getHeldItem(hand));
@ -98,6 +101,14 @@ public class ItemKey extends Item implements INetGUIItem {
@Override
public void onChange(NBTTagCompound nbt, EntityPlayer p, EnumHand 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");
}
}
}
}

View file

@ -0,0 +1,6 @@
{
"parent":"item/generated",
"textures": {
"layer0":"industrialwires:items/blank_key"
}
}

View file

@ -0,0 +1,6 @@
{
"parent":"item/generated",
"textures": {
"layer0":"industrialwires:items/key"
}
}

View file

@ -0,0 +1,6 @@
{
"parent":"item/generated",
"textures": {
"layer0":"industrialwires:items/lock_switch"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 321 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 334 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 497 B