Skip to content

Commit

Permalink
Added tool display mode. Closes #2
Browse files Browse the repository at this point in the history
  • Loading branch information
olee committed Oct 22, 2015
1 parent 539ab74 commit daa06d9
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
public class CommandCustomServerItem extends CommandBase
{

public static final String[] subCommands = new String[] { "texture", "name", "tooltip", "damage", "durability", "meta", "texturelist" };
public static final String[] subCommands = new String[] { "texture", "name", "tooltip", "tool", "damage", "durability", "meta", "texturelist" };

@Override
public String getCommandName()
Expand Down Expand Up @@ -46,7 +46,7 @@ public void processCommand(ICommandSender sender, String[] argArray)
}

ItemStack stack = player.getCurrentEquippedItem();
if (stack == null || stack.getItem() != CustomServerItems.ITEM)
if (stack == null || !(stack.getItem() instanceof ItemCustom))
throw new WrongUsageException("commands.customservercommand.itemNeeded");

String subArg = args.remove().toLowerCase();
Expand All @@ -64,6 +64,9 @@ public void processCommand(ICommandSender sender, String[] argArray)
case "tooltip":
parseTooltip(player, args, stack);
break;
case "tool":
parseTool(player, args, stack);
break;
case "damage":
parseDamage(player, args, stack);
break;
Expand Down Expand Up @@ -128,6 +131,15 @@ public void parseTooltip(EntityPlayer player, LinkedList<String> args, ItemStack
func_152373_a(player, this, "commands.customservercommand.tooltipSet", name);
}

public void parseTool(EntityPlayer player, LinkedList<String> args, ItemStack stack)
{
if (args.isEmpty())
throw new WrongUsageException("commands.notEnoughArguments");
boolean isTool = parseBoolean(player, args.remove());
stack.func_150996_a(isTool ? CustomServerItems.ITEM_TOOL : CustomServerItems.ITEM);
func_152373_a(player, this, "commands.customservercommand.toolSet", isTool ? "tool" : "item");
}

public void parseDamage(EntityPlayer player, LinkedList<String> args, ItemStack stack)
{
if (args.isEmpty())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack stack, ItemR
case ENTITY_BOBBING:
return true;
case BLOCK_3D:
case INVENTORY_BLOCK:
case EQUIPPED_BLOCK:
case INVENTORY_BLOCK:
default:
return false;
}
Expand Down Expand Up @@ -76,8 +76,10 @@ public void renderItem(ItemRenderType type, ItemStack stack, Object... data)
tessellator.addVertexWithUV(16, 0, zLevel, 1, 0);
tessellator.addVertexWithUV(0, 0, zLevel, 0, 0);
tessellator.draw();
GL11.glDisable(GL11.GL_BLEND);
break;
}
GL11.glPopMatrix();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public class CustomServerItems implements IMessageHandler<PacketRequestTexture,

public static final ItemCustom ITEM = new ItemCustom();

public static final ItemCustom ITEM_TOOL = new ItemCustomTool();

public static final SimpleNetworkWrapper CHANNEL = NetworkRegistry.INSTANCE.newSimpleChannel(MODID);

public static final File TEXTURE_DIRECTORY = new File("config/CustomServerItems");
Expand All @@ -67,6 +69,7 @@ public boolean accept(File dir, String name)
public void init(FMLInitializationEvent event)
{
GameRegistry.registerItem(ITEM, "custom_item");
GameRegistry.registerItem(ITEM_TOOL, "custom_item_tool");

CHANNEL.registerMessage(this, PacketRequestTexture.class, 0, Side.SERVER);
CHANNEL.registerMessage(PacketTexture.class, PacketTexture.class, 1, Side.CLIENT);
Expand All @@ -77,6 +80,7 @@ public void init(FMLInitializationEvent event)
{
TEXTURE_REGISTRY = new TextureRegistry();
MinecraftForgeClient.registerItemRenderer(ITEM, new CustomItemRenderer());
MinecraftForgeClient.registerItemRenderer(ITEM_TOOL, new CustomItemRenderer());
}

FMLCommonHandler.instance().bus().register(this);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.forgeessentials.customserveritems;

public class ItemCustomTool extends ItemCustom
{

public ItemCustomTool()
{
setFull3D();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ commands.customservercommand.itemNeeded=You need to equip a custom item first
commands.customservercommand.textures=Available textures: %s
commands.customservercommand.iconSet=Set custom item texture to %s
commands.customservercommand.nameSet=Set custom item name to "%s"
commands.customservercommand.toolSet=Set custom item display to %s-mode
commands.customservercommand.damageSet=Set custom item damage to +%s
commands.customservercommand.tooltipSet=Set custom item tooltip to "%s"
commands.customservercommand.durabilitySet=Set custom item durability to %s
Expand Down

0 comments on commit daa06d9

Please sign in to comment.