diff --git a/resources/resources/assets/minecraft/models/item/shield.json b/resources/resources/assets/minecraft/models/item/shield.json new file mode 100755 index 0000000..4152c0e --- /dev/null +++ b/resources/resources/assets/minecraft/models/item/shield.json @@ -0,0 +1,30 @@ +{ + "parent": "builtin/entity", + "display": { + "thirdperson": { + "rotation": [ 0, 90, 0 ], + "translation": [ 10.51, 6, -4 ], + "scale": [ 1, 1, 1 ] + }, + "firstperson": { + "rotation": [ 0, 180, 5 ], + "translation": [ -10, 2, -10 ], + "scale": [ 1.25, 1.25, 1.25 ] + }, + "gui": { + "rotation": [ 15, -25, -5 ], + "translation": [ 2, 3, 0 ], + "scale": [ 0.65, 0.65, 0.65 ] + }, + "fixed": { + "rotation": [ 0, 180, 0 ], + "translation": [ -2, 4, -5], + "scale":[ 0.5, 0.5, 0.5] + }, + "ground": { + "rotation": [ 0, 0, 0 ], + "translation": [ 4, 4, 2], + "scale":[ 0.25, 0.25, 0.25] + } + } +} diff --git a/resources/resources/assets/minecraft/textures/entity/shield_base.png b/resources/resources/assets/minecraft/textures/entity/shield_base.png new file mode 100755 index 0000000..9c51041 Binary files /dev/null and b/resources/resources/assets/minecraft/textures/entity/shield_base.png differ diff --git a/resources/resources/assets/minecraft/textures/entity/shield_base_nopattern.png b/resources/resources/assets/minecraft/textures/entity/shield_base_nopattern.png new file mode 100755 index 0000000..cb540dc Binary files /dev/null and b/resources/resources/assets/minecraft/textures/entity/shield_base_nopattern.png differ diff --git a/src/game/java/net/minecraft/client/model/ModelShield.java b/src/game/java/net/minecraft/client/model/ModelShield.java new file mode 100644 index 0000000..4ff75e6 --- /dev/null +++ b/src/game/java/net/minecraft/client/model/ModelShield.java @@ -0,0 +1,23 @@ +package net.minecraft.client.model; + +public class ModelShield extends ModelBase +{ + public ModelRenderer plate; + public ModelRenderer handle; + + public ModelShield() + { + this.textureWidth = 64; + this.textureHeight = 64; + this.plate = new ModelRenderer(this, 0, 0); + this.plate.addBox(-6.0F, -11.0F, -2.0F, 12, 22, 1, 0.0F); + this.handle = new ModelRenderer(this, 26, 0); + this.handle.addBox(-1.0F, -3.0F, -1.0F, 2, 6, 6, 0.0F); + } + + public void render() + { + this.plate.render(0.0625F); + this.handle.render(0.0625F); + } +} diff --git a/src/game/java/net/minecraft/client/renderer/block/model/ItemTransformVec3f.java b/src/game/java/net/minecraft/client/renderer/block/model/ItemTransformVec3f.java index b1da3a3..ff6e773 100644 --- a/src/game/java/net/minecraft/client/renderer/block/model/ItemTransformVec3f.java +++ b/src/game/java/net/minecraft/client/renderer/block/model/ItemTransformVec3f.java @@ -79,9 +79,9 @@ public class ItemTransformVec3f { Vector3f vector3f = this.parseVector3f(jsonobject, "rotation", ROTATION_DEFAULT); Vector3f vector3f1 = this.parseVector3f(jsonobject, "translation", TRANSLATION_DEFAULT); vector3f1.scale(0.0625F); - vector3f1.x = MathHelper.clamp_float(vector3f1.x, -1.5F, 1.5F); - vector3f1.y = MathHelper.clamp_float(vector3f1.y, -1.5F, 1.5F); - vector3f1.z = MathHelper.clamp_float(vector3f1.z, -1.5F, 1.5F); + vector3f1.x = MathHelper.clamp_float(vector3f1.x, -5.0F, 5.0F); + vector3f1.y = MathHelper.clamp_float(vector3f1.y, -5.0F, 5.0F); + vector3f1.z = MathHelper.clamp_float(vector3f1.z, -5.0F, 5.0F); Vector3f vector3f2 = this.parseVector3f(jsonobject, "scale", SCALE_DEFAULT); vector3f2.x = MathHelper.clamp_float(vector3f2.x, -4.0F, 4.0F); vector3f2.y = MathHelper.clamp_float(vector3f2.y, -4.0F, 4.0F); diff --git a/src/game/java/net/minecraft/client/renderer/entity/RenderItem.java b/src/game/java/net/minecraft/client/renderer/entity/RenderItem.java index 2fa30e1..657d55d 100644 --- a/src/game/java/net/minecraft/client/renderer/entity/RenderItem.java +++ b/src/game/java/net/minecraft/client/renderer/entity/RenderItem.java @@ -1164,6 +1164,15 @@ public class RenderItem implements IResourceManagerReloadListener { this.registerBlock(EaglerItems.getEaglerBlock("purpur_slab"), BlockPurpurSlab.EnumType.DEFAULT.getMetadata(), "purpur_slab"); + + // this.itemModelMesher.register(EaglerItems.getEaglerItem("shield"), new ItemMeshDefinition() + // { + // public ModelResourceLocation getModelLocation(ItemStack stack) + // { + // return new ModelResourceLocation("shield", "inventory"); + // } + // }); + // TODO: Make custom slabs not have to be registered manually for (Map.Entry entry : EaglerItems.getEaglerCustomBlockEntries()) { if (entry.getValue().isSlab() || !entry.getValue().hasItem()) { @@ -1173,6 +1182,9 @@ public class RenderItem implements IResourceManagerReloadListener { } for (Map.Entry entry : EaglerItems.getEaglerItemEntries()) { + if (!EaglerItems.shouldRegisterModel(entry.getKey())) { + continue; + } this.registerItem(entry.getValue(), entry.getKey()); } } diff --git a/src/game/java/net/minecraft/client/renderer/tileentity/TileEntityItemStackRenderer.java b/src/game/java/net/minecraft/client/renderer/tileentity/TileEntityItemStackRenderer.java index 60f51c8..d7b4d14 100644 --- a/src/game/java/net/minecraft/client/renderer/tileentity/TileEntityItemStackRenderer.java +++ b/src/game/java/net/minecraft/client/renderer/tileentity/TileEntityItemStackRenderer.java @@ -1,10 +1,13 @@ package net.minecraft.client.renderer.tileentity; +import net.hoosiertransfer.EaglerItems; import net.lax1dude.eaglercraft.v1_8.EaglercraftUUID; import net.lax1dude.eaglercraft.v1_8.mojang.authlib.GameProfile; import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager; import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.model.ModelShield; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; @@ -15,6 +18,7 @@ import net.minecraft.tileentity.TileEntityChest; import net.minecraft.tileentity.TileEntityEnderChest; import net.minecraft.tileentity.TileEntitySkull; import net.minecraft.util.EnumFacing; +import net.minecraft.util.ResourceLocation; /** * + @@ -52,11 +56,23 @@ public class TileEntityItemStackRenderer { private TileEntityEnderChest enderChest = new TileEntityEnderChest(); private TileEntityBanner banner = new TileEntityBanner(); private TileEntitySkull skull = new TileEntitySkull(); + private ModelShield modelShield = new ModelShield(); + + public static final ResourceLocation SHIELD_BASE_TEXTURE = new ResourceLocation("textures/entity/shield_base_nopattern.png"); public void renderByItem(ItemStack itemStackIn) { if (itemStackIn.getItem() == Items.banner) { this.banner.setItemValues(itemStackIn); TileEntityRendererDispatcher.instance.renderTileEntityAt(this.banner, 0.0D, 0.0D, 0.0D, 0.0F); + } else if (itemStackIn.getItem() == EaglerItems.getEaglerItem("shield")) { + { + Minecraft.getMinecraft().getTextureManager().bindTexture(SHIELD_BASE_TEXTURE); + + GlStateManager.pushMatrix(); + GlStateManager.scale(1.0F, -1.0F, -1.0F); + this.modelShield.render(); + GlStateManager.popMatrix(); + } } else if (itemStackIn.getItem() == Items.skull) { GameProfile gameprofile = null; if (itemStackIn.hasTagCompound()) { diff --git a/src/game/java/net/minecraft/item/Item.java b/src/game/java/net/minecraft/item/Item.java index 2bbe746..8fedb1b 100644 --- a/src/game/java/net/minecraft/item/Item.java +++ b/src/game/java/net/minecraft/item/Item.java @@ -1161,6 +1161,9 @@ public class Item { .setUnlocalizedName("beetroot_seeds")); registerEaglerItem(436, "beetroot_soup", (new ItemSoup(6)).setUnlocalizedName("beetroot_soup")); registerEaglerItem(443, "elytra", (new ItemElytra()).setUnlocalizedName("elytra")); + + // registerEaglerItem(442, "shield", (new ItemShield()).setUnlocalizedName("shield"), false); + } /** @@ -1194,6 +1197,11 @@ public class Item { registerItem(id, textualID, itemIn); } + protected static void registerEaglerItem(int id, String textualID, Item itemIn, boolean registerModel) { + EaglerItems.registerEaglerItem(textualID, itemIn, registerModel); + registerItem(id, textualID, itemIn); + } + public static enum ToolMaterial { WOOD(0, 59, 2.0F, 0.0F, 15), STONE(1, 131, 4.0F, 1.0F, 5), diff --git a/src/game/java/net/minecraft/item/ItemShield.java b/src/game/java/net/minecraft/item/ItemShield.java new file mode 100644 index 0000000..bbddf6a --- /dev/null +++ b/src/game/java/net/minecraft/item/ItemShield.java @@ -0,0 +1,91 @@ +package net.minecraft.item; + +import java.util.List; +import javax.annotation.Nullable; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; + +public class ItemShield extends Item +{ + public ItemShield() + { + this.maxStackSize = 1; + this.setCreativeTab(CreativeTabs.tabCombat); + this.setMaxDamage(336); + // this.addPropertyOverride(new ResourceLocation("blocking"), new IItemPropertyGetter() + // { + // public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) + // { + // return entityIn != null && entityIn.isHandActive() && entityIn.getActiveItemStack() == stack ? 1.0F : 0.0F; + // } + // }); + } + + // /** + // * Called when a Block is right-clicked with this Item + // */ + // public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) + // { + // return super.onItemUse(stack, playerIn, worldIn, pos, hand, facing, hitX, hitY, hitZ); + // } + + /** + * allows items to add custom lines of information to the mouseover description + */ + public void addInformation(ItemStack stack, EntityPlayer playerIn, List tooltip, boolean advanced) + { + // ItemBanner.appendHoverTextFromTileEntityTag(stack, tooltip); + } + + /** + * returns a list of items with the same ID, but different meta (eg: dye returns 16 items) + */ + public void getSubItems(Item itemIn, CreativeTabs tab, List subItems) + { + ItemStack itemstack = new ItemStack(itemIn, 1, 0); + subItems.add(itemstack); + } + + /** + * gets the CreativeTab this item is displayed on + */ + public CreativeTabs getCreativeTab() + { + return CreativeTabs.tabCombat; + } + + /** + * returns the action that specifies what animation to play when the items is being used + */ + public EnumAction getItemUseAction(ItemStack stack) + { + return EnumAction.BLOCK; + } + + /** + * How long it takes to use or consume an item + */ + public int getMaxItemUseDuration(ItemStack stack) + { + return 72000; + } + + // public ActionResult onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) + // { + // playerIn.setActiveHand(hand); + // return new ActionResult(EnumActionResult.SUCCESS, itemStackIn); + // } + + // /** + // * Return whether this item is repairable in an anvil. + // */ + // public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) + // { + // return repair.getItem() == Item.getItemFromBlock(Blocks.PLANKS) ? true : super.getIsRepairable(toRepair, repair); + // } +} diff --git a/src/main/java/net/hoosiertransfer/EaglerItems.java b/src/main/java/net/hoosiertransfer/EaglerItems.java index ed6f540..83c6c53 100644 --- a/src/main/java/net/hoosiertransfer/EaglerItems.java +++ b/src/main/java/net/hoosiertransfer/EaglerItems.java @@ -12,6 +12,7 @@ import net.minecraft.item.Item; public class EaglerItems { protected static Map blockMap = new HashMap<>(); protected static Map itemMap = new HashMap<>(); + protected static Map itemModelRegisterMap = new HashMap<>(); public static void registerEaglerBlock(String id, Block block) { blockMap.put(id, new EaglerCustomBlock(block)); @@ -27,6 +28,12 @@ public class EaglerItems { public static void registerEaglerItem(String id, Item item) { itemMap.put(id, item); + itemModelRegisterMap.put(id, true); + } + + public static void registerEaglerItem(String id, Item item, boolean registerModel) { + itemMap.put(id, item); + itemModelRegisterMap.put(id, registerModel); } public static EaglerCustomBlock getEaglerCustomBlock(String id) { @@ -76,4 +83,8 @@ public class EaglerItems { public static List> getEaglerItemEntries() { return new ArrayList<>(itemMap.entrySet()); } + + public static boolean shouldRegisterModel(String id) { + return itemModelRegisterMap.get(id); + } }