From d508fad79b2f0bc9bb0553d5fb7f8f11b57472c0 Mon Sep 17 00:00:00 2001 From: Aether Date: Wed, 16 Oct 2024 14:58:19 -0400 Subject: [PATCH] broken shield just the item not even going to fix yet tho --- .../assets/minecraft/models/item/shield.json | 30 ++++++ .../minecraft/textures/entity/shield_base.png | Bin 0 -> 2025 bytes .../textures/entity/shield_base_nopattern.png | Bin 0 -> 2056 bytes .../minecraft/client/model/ModelShield.java | 23 +++++ .../block/model/ItemTransformVec3f.java | 6 +- .../client/renderer/entity/RenderItem.java | 12 +++ .../TileEntityItemStackRenderer.java | 16 +++ src/game/java/net/minecraft/item/Item.java | 8 ++ .../java/net/minecraft/item/ItemShield.java | 91 ++++++++++++++++++ .../java/net/hoosiertransfer/EaglerItems.java | 11 +++ 10 files changed, 194 insertions(+), 3 deletions(-) create mode 100755 resources/resources/assets/minecraft/models/item/shield.json create mode 100755 resources/resources/assets/minecraft/textures/entity/shield_base.png create mode 100755 resources/resources/assets/minecraft/textures/entity/shield_base_nopattern.png create mode 100644 src/game/java/net/minecraft/client/model/ModelShield.java create mode 100644 src/game/java/net/minecraft/item/ItemShield.java 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 0000000000000000000000000000000000000000..9c51041b84f98b0ce3c9cdb8ba7e768d7dbadd90 GIT binary patch literal 2025 zcmY+Fc{r4N8^?doGc#r|HI@mb%v8iMQs)&a%kXk!iHMYtR$HfxC9<5JMqW`}$@XI>>S|QUpZqE%0e04wZjtMUR&tFrQ!9btG zU(i-e%~w-2^s!NJHr~~eJ~Zy0t)2XN=%C+BX2*wtGEQTI*l&7rB3qP54&yzojS8#{ zimmD`a6fR|{l)s+)Yrte*Vu+9lru5ncCU~h-H z5O;SEQS+R#3X(tPIroLEulxuf`TaVXil^-|tD%p)|IV)ps^NqRKYbT{sY{*eD-jxn zvzjPiU?}Qrii}HJceH`fbJ_j#a%;NY-;3zXb%ArX z>5KHf#W*Y>M7<_PJV!)O182PRF5j|hKMayN!;^5a30DC-yZG~U#d?gt-@|^cS2LZeCk`D~bcdOulD=av{s{)t%XU8tgk3~$en-47KL=FfQLF-;3x9Ifi=j&he zX%Ff1W9<}B9HtJ4_9c&%MEcWwX6}#q8{Ti37FhPRtDx}nQE<#lr4x(Pfr@Qg76g4u zH7MU+mnA{*(JD+1Fx`$gX7QnB{gZMNZ4rF1lCnYt`_`}#4KA;-DBo)rCt36eOmU0i zcA8;0fuYFV6G0=i!iRw~l*a1~I|12o;aO?7XJU z+~Z$eHOQdSL4_SO`g3!FW;0Zp$g0Bc#dD=$ISd_hivY#J9-tfzv8VU4JNoUJUSycN zOC=EUl;s2K_zTrJic0JdPG+cS6BoHrM$ef|{K!C0<35NvcRn8puf$Uj>7=WLqmQw~d%z*3yFwZF1Zw2Eh^!Ck5|#zubH78exM!qwuqQW}_PF+k;2MUfE-&J6UzJ zu$EQssc;~Y)Gj^ZnPtb%X**|Av)9CQj|s<8G}oIZ#{>&<3|3;8nk$|mQqhtyZE{8` zbvF=}J^zdEw+2nH)1^en?5tc<2t($-LL)OMKT zG3)!n#03_Z&wwaxt2ehVzPtdrwi;V^nZ2>-AOje&RPOStK@4KMFg*!|CZ32y$P5dfXgRA-CdvGSr?I;$5yY z?uf)rDMt2Bt3k8U!fWH9XAv&Xazu8)ww#1++{n~9sQx@xQq;5ONx3<;Gul8Q&VeYJ zl0-&j@N+p@0nx>xrseUv9{SdI!VTe%c;KJ17j-XbRWOh}u%Iz>I^<^jy5Y5j4}^mM zuD$9>#1Il2NeW^@w$s`A>5WQTp?SymfB2P=7MBQJp*eRgJZkDKB0BNLTS)$Pk#skc z&4X(%ckmuscRXN}c}Iy(zW?oE+1-oO^IO~gJr=H`&Q0DVD1$OZ=^qAmHcr;XR=$k? E1Kot6qyPW_ literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..cb540dc63b45e63017ac23f2980dd9141bae8579 GIT binary patch literal 2056 zcmY*adoi~pe`z>x}^?B zV>rkAeY_QB9Fg)!F>1UJ?|8QK1OQMtWackV59F{~dniXW--caI>(P_?MqUq#bwyKLt)7aoF^LUpHcGvDB)pYC$>yJvt zYLr0R?ur-3m3KP)rorCT#D7pHQNHe=EW%`{h~7M^C@af|v}~^&-@jN>GuoPx6cgVv z<$Jn=yXS1j$@*HM$bTj{onlhIcDcN8E^?iuFfz4hcf6%GT$)}|QiA_Fxb8{1I4w%0 zng1%BxVNy-P7ag3DE-tQ*K>05ywtAquI1BoX{Dw5pMg;g*F9JB3#Nav`8|j9exBX|M#YrtKEeaU?&d99GXm!L8 zOR?8P9&QO2*hE|Iw{PWFXU5n&rrWDlyN4>Rp2$KEmM6uF*H)LS!EMAC440NWym2Md znM8Y4TdxBZwb#Zy9cnFgO+gWhc&=3xUGwcQ(gyKCS0)iP8$e)qcsR*~cS}ZtjzsiG z9q)M;rVvi`W`NGSwTRW*mb;!p;QDN#`roBr*ceW_ACR%I{{n?vcJm-m+q2R)LZp2+%8?%?eJ;(6ss6FzwiVdU}6kg2}vth&&dIz7qwqC!b-rJ!L{dG|La>=jS^c8m!U-w}EpPhHptE z8~2Yey|+PvYt+vH9{Uh@=mcu&>itX?Fn>!BU^r$7XH=R?N!&(WwKt{;-dpfx_|JF@ zc|NZo-5LSP(ntHr3L%D(F|ErU`aOcMKnwkofIdQRm!xP8^<$<5^XV13SJ9)_k}HE`lPOirQ*TX@!6{iREMS}ed2J`n612#cm&G}NKxAFRdpdxiNJ5Kt3eS-u!Okh z3{sq+sShDBM|SgrqaGntr5m&pn+!)r(24a{x%@m{(ZSG9H)y@nMNLo;Vo6yfneEN&uT~OXyhkt@*Rcsw^<@M`(;h(aay#|taII0(i5Do;C*53HX(Yt-* z>v10@=ljF7Cy>-@-b7OH>8nKe&eQ${h)YErWUA2j=7#)DV0P?joHhm2iKlPUB`EH`ER>?!eQvB<%y zl=H}+cLaNsV+{8E+n3902(NiS*S56^!tnHG+3YaV;7u*tIbHNq+zibR-}JZ{Lulr# zdmOVr)V`#$;gX|Z;u@H`-aP#3-2(TkUY_?r>C8~5WAACjLq&)0R${5iA2qXGoN=k$ zY*F|ZW(Vp%_x9b_)E}&Wy4w5SM$8j8!4}2OTP(N@zj&k$>u#2I?pPYlv`+ndiuR6_ z*m*6f*S|jF%z*+4)lzV~py9H3$)Z;+f5%iTK~&MhcFA>0%yrH%bjh*(|FUp}n2?BF UCVy#e+j!G(%=$-qp%p9oe=x$IJpcdz literal 0 HcmV?d00001 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); + } }