From ad58fb185595b9ef5c3d22b12d4e6d6e6ce866f1 Mon Sep 17 00:00:00 2001 From: Vincent Lee Date: Mon, 4 Jan 2016 12:18:19 -0600 Subject: [PATCH] Partial tiny potato --- .../botania/api/state/BotaniaStateProps.java | 3 ++ .../api/state/enums/PotatoVariant.java | 24 ++++++++++ .../client/core/handler/ModelHandler.java | 1 + .../render/tile/RenderTileTinyPotato.java | 42 ++++++++++++------ .../common/block/decor/BlockTinyPotato.java | 29 ++++++++++-- .../botania/blockstates/tinyPotato.json | 34 ++++++++++++++ .../botania/models/block/tiny_potato.json | 20 +++++++++ .../botania/textures/model/tinyPotatoCopy.png | Bin 0 -> 487 bytes .../textures/model/tinyPotatoGrayCopy.png | Bin 0 -> 446 bytes .../model/tinyPotato_halloweenCopy.png | Bin 0 -> 864 bytes 10 files changed, 136 insertions(+), 17 deletions(-) create mode 100644 src/main/java/vazkii/botania/api/state/enums/PotatoVariant.java create mode 100644 src/main/resources/assets/botania/blockstates/tinyPotato.json create mode 100644 src/main/resources/assets/botania/models/block/tiny_potato.json create mode 100644 src/main/resources/assets/botania/textures/model/tinyPotatoCopy.png create mode 100644 src/main/resources/assets/botania/textures/model/tinyPotatoGrayCopy.png create mode 100644 src/main/resources/assets/botania/textures/model/tinyPotato_halloweenCopy.png diff --git a/src/main/java/vazkii/botania/api/state/BotaniaStateProps.java b/src/main/java/vazkii/botania/api/state/BotaniaStateProps.java index b6d60778f..c4b9c604f 100644 --- a/src/main/java/vazkii/botania/api/state/BotaniaStateProps.java +++ b/src/main/java/vazkii/botania/api/state/BotaniaStateProps.java @@ -167,6 +167,9 @@ public class BotaniaStateProps { // BlockStorage public static final PropertyEnum STORAGE_VARIANT = PropertyEnum.create("variant", StorageVariant.class); + // BlockTinyPotato + public static final PropertyEnum POTATO_VARIANT = PropertyEnum.create("variant", PotatoVariant.class); + private BotaniaStateProps() {} } diff --git a/src/main/java/vazkii/botania/api/state/enums/PotatoVariant.java b/src/main/java/vazkii/botania/api/state/enums/PotatoVariant.java new file mode 100644 index 000000000..ed7ca2536 --- /dev/null +++ b/src/main/java/vazkii/botania/api/state/enums/PotatoVariant.java @@ -0,0 +1,24 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php + */ +package vazkii.botania.api.state.enums; + +import net.minecraft.util.IStringSerializable; + +import java.util.Locale; + +public enum PotatoVariant implements IStringSerializable { + DEFAULT, + HALLOWEEN, + GRAYSCALE; + + @Override + public String getName() { + return name().toLowerCase(Locale.ROOT); + } +} diff --git a/src/main/java/vazkii/botania/client/core/handler/ModelHandler.java b/src/main/java/vazkii/botania/client/core/handler/ModelHandler.java index 3a599dff9..c43be5c62 100644 --- a/src/main/java/vazkii/botania/client/core/handler/ModelHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/ModelHandler.java @@ -407,6 +407,7 @@ public final class ModelHandler { registerItemModel(ModBlocks.alfPortal); registerItemModel(ModBlocks.root); registerItemModel(ModBlocks.cacophonium); + registerItemModel(ModBlocks.tinyPotato); registerItemModelAllMeta(Item.getItemFromBlock(ModBlocks.floatingFlower), EnumDyeColor.values().length); diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileTinyPotato.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileTinyPotato.java index dbbecc693..30230ae41 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileTinyPotato.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileTinyPotato.java @@ -10,6 +10,7 @@ */ package vazkii.botania.client.render.tile; +import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.ItemRenderer; @@ -21,10 +22,12 @@ import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.client.resources.model.IBakedModel; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumFacing; import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.MinecraftForge; @@ -33,6 +36,7 @@ import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; import vazkii.botania.api.item.TinyPotatoRenderEvent; +import vazkii.botania.api.state.BotaniaStateProps; import vazkii.botania.client.core.handler.ContributorFancinessHandler; import vazkii.botania.client.core.handler.RenderEventHandler; import vazkii.botania.client.core.helper.IconHelper; @@ -62,7 +66,7 @@ public class RenderTileTinyPotato extends TileEntitySpecialRenderer { GlStateManager.translate(d0, d1, d2); Minecraft mc = Minecraft.getMinecraft(); - mc.renderEngine.bindTexture(ClientProxy.dootDoot ? textureHalloween : texture); + mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture); String name = potato.name.toLowerCase(); boolean usedShader = false; @@ -88,17 +92,23 @@ public class RenderTileTinyPotato extends TileEntitySpecialRenderer { usedShader = true; } - GlStateManager.translate(0.5F, 1.5F, 0.5F); - GlStateManager.scale(1F, -1F, -1F); - int meta = potato.getWorld() == null ? 3 : potato.getBlockMetadata(); - float rotY = meta * 90F - 180F; + GlStateManager.translate(0.5F, 0F, 0.5F); + //GlStateManager.scale(1F, -1F, -1F); + EnumFacing facing = potato.getWorld() == null ? EnumFacing.NORTH : potato.getWorld().getBlockState(potato.getPos()).getValue(BotaniaStateProps.CARDINALS); + float rotY = 0; + switch (facing) { + case NORTH: break; + case SOUTH: rotY = 180; break; + case WEST: rotY = 90; break; + case EAST: rotY = 270; break; + } GlStateManager.rotate(rotY, 0F, 1F, 0F); float jump = potato.jumpTicks; if(jump > 0) jump -= var8; - float up = (float) -Math.abs(Math.sin(jump / 10 * Math.PI)) * 0.2F; + float up = (float) Math.abs(Math.sin(jump / 10 * Math.PI)) * 0.2F; float rotZ = (float) Math.sin(jump / 10 * Math.PI) * 2; GlStateManager.translate(0F, up, 0F); @@ -108,21 +118,27 @@ public class RenderTileTinyPotato extends TileEntitySpecialRenderer { if(name.equals("pahimar")) { GlStateManager.scale(1F, 0.3F, 1F); GlStateManager.translate(0F, 3.5F, 0F); - } else if(name.equals("kyle hyde")) - mc.renderEngine.bindTexture(textureGrayscale); - else if(name.equals("dinnerbone") || name.equals("grumm")) { + } else if(name.equals("kyle hyde")) { + // 1.8: handled using getActualState - mc.renderEngine.bindTexture(textureGrayscale); + } else if(name.equals("dinnerbone") || name.equals("grumm")) { GlStateManager.rotate(180F, 0F, 0F, 1F); GlStateManager.translate(0F, -2.625F, 0F); } else if(name.equals("aureylian")) GlStateManager.color(1F, 0.5F, 1F); + IBlockState state = potato.getWorld().getBlockState(potato.getPos()); + state = state.getBlock().getActualState(state, potato.getWorld(), potato.getPos()); + IBakedModel bakedModel = mc.getBlockRendererDispatcher().getBlockModelShapes().getModelForState(state); boolean render = !(name.equals("mami") || name.equals("soaryn") || name.equals("eloraam") && jump != 0); - if(render) - model.render(); + if(render) { + mc.getBlockRendererDispatcher().getBlockModelRenderer().renderModelBrightness(bakedModel, potato.getWorld().getBlockState(potato.getPos()), 1.0F, false); + //model.render(); + } if(name.equals("kingdaddydmac")) { GlStateManager.translate(0.5F, 0F, 0F); - model.render(); + mc.getBlockRendererDispatcher().getBlockModelRenderer().renderModelBrightness(bakedModel, potato.getWorld().getBlockState(potato.getPos()), 1.0F, false); + //model.render(); } if(usedShader) @@ -338,7 +354,7 @@ public class RenderTileTinyPotato extends TileEntitySpecialRenderer { GlStateManager.rotate(-rotZ, 0F, 0F, 1F); GlStateManager.rotate(-rotY, 0F, 1F, 0F); GlStateManager.color(1F, 1F, 1F); - GlStateManager.scale(1F, -1F, -1F); + //GlStateManager.scale(1F, -1F, -1F); MovingObjectPosition pos = mc.objectMouseOver; if(!name.isEmpty() && pos != null && pos.getBlockPos().equals(potato.getPos())) { diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockTinyPotato.java b/src/main/java/vazkii/botania/common/block/decor/BlockTinyPotato.java index 3f7f9ee5e..61537ab19 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockTinyPotato.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockTinyPotato.java @@ -28,9 +28,14 @@ import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.MathHelper; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; import vazkii.botania.api.lexicon.ILexiconable; import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.state.BotaniaStateProps; +import vazkii.botania.api.state.enums.PotatoVariant; +import vazkii.botania.client.core.handler.ClientTickHandler; +import vazkii.botania.client.core.proxy.ClientProxy; import vazkii.botania.client.lib.LibRenderIDs; import vazkii.botania.common.achievement.ModAchievements; import vazkii.botania.common.block.BlockModContainer; @@ -48,17 +53,20 @@ public class BlockTinyPotato extends BlockModContainer implements ILexiconable { setUnlocalizedName(LibBlockNames.TINY_POTATO); float f = 1F / 16F * 6F; setBlockBounds(f, 0, f, 1F - f, f, 1F - f); - setDefaultState(blockState.getBaseState().withProperty(BotaniaStateProps.CARDINALS, EnumFacing.SOUTH)); + setDefaultState(blockState.getBaseState() + .withProperty(BotaniaStateProps.CARDINALS, EnumFacing.SOUTH) + .withProperty(BotaniaStateProps.POTATO_VARIANT, PotatoVariant.DEFAULT) + ); } @Override public BlockState createBlockState() { - return new BlockState(this, BotaniaStateProps.CARDINALS); + return new BlockState(this, BotaniaStateProps.CARDINALS, BotaniaStateProps.POTATO_VARIANT); } @Override public int getMetaFromState(IBlockState state) { - switch (((EnumFacing) state.getValue(BotaniaStateProps.CARDINALS))) { + switch (state.getValue(BotaniaStateProps.CARDINALS)) { case NORTH: return 0; case WEST: return 3; case EAST: return 1; @@ -82,6 +90,19 @@ public class BlockTinyPotato extends BlockModContainer implements ILexiconable { return getDefaultState().withProperty(BotaniaStateProps.CARDINALS, side); } + @Override + @SideOnly(Side.CLIENT) + public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) { + if (ClientProxy.dootDoot) { + return state.withProperty(BotaniaStateProps.POTATO_VARIANT, PotatoVariant.HALLOWEEN); + } else if (world.getTileEntity(pos) instanceof TileTinyPotato) { + if (((TileTinyPotato) world.getTileEntity(pos)).name.toLowerCase().equals("kyle hyde")) { + return state.withProperty(BotaniaStateProps.POTATO_VARIANT, PotatoVariant.GRAYSCALE); + } + } + return state.withProperty(BotaniaStateProps.POTATO_VARIANT, PotatoVariant.DEFAULT); + } + @Override public Block setUnlocalizedName(String par1Str) { GameRegistry.registerBlock(this, ItemBlockTinyPotato.class, par1Str); @@ -145,7 +166,7 @@ public class BlockTinyPotato extends BlockModContainer implements ILexiconable { @Override public int getRenderType() { - return LibRenderIDs.idTinyPotato; + return 2; } @Override diff --git a/src/main/resources/assets/botania/blockstates/tinyPotato.json b/src/main/resources/assets/botania/blockstates/tinyPotato.json new file mode 100644 index 000000000..66e158d6d --- /dev/null +++ b/src/main/resources/assets/botania/blockstates/tinyPotato.json @@ -0,0 +1,34 @@ +{ + "forge_marker": 1, + "defaults": { + "model": "botania:tiny_potato", + "textures": { + "all": "botania:model/tinyPotatoCopy" + }, + "transform": "forge:default-block" + }, + "variants": { + "variant": { + "default": {}, + "halloween": { + "textures": { "all": "botania:model/tinyPotato_halloweenCopy" } + }, + "grayscale": { + "textures": { "all": "botania:model/tinyPotatoGrayCopy" } + } + }, + "facing": { + "north": {}, + "south": {}, + "west": {}, + "east": {} + }, + "inventory": [{ + "transform": { + "firstperson": { + "translation": [ 0, 0.25, 0 ] + } + } + }] + } +} \ No newline at end of file diff --git a/src/main/resources/assets/botania/models/block/tiny_potato.json b/src/main/resources/assets/botania/models/block/tiny_potato.json new file mode 100644 index 000000000..38c56cb6c --- /dev/null +++ b/src/main/resources/assets/botania/models/block/tiny_potato.json @@ -0,0 +1,20 @@ +{ + "textures": { + "particle": "minecraft:blocks/hardened_clay" + }, + "elements": [ + { + "name": "Po Ta To", + "from": [ 6.0, 0.0, 6.0 ], + "to": [ 10.0, 6.0, 10.0 ], + "faces": { + "west": { "texture": "#all", "uv": [ 0.0, 4.0, 4.0, 10.0 ] }, + "north": { "texture": "#all", "uv": [ 4.0, 4.0, 8.0, 10.0 ] }, + "east": { "texture": "#all", "uv": [ 8.0, 4.0, 12.0, 10.0 ] }, + "south": { "texture": "#all", "uv": [ 12.0, 4.0, 16.0, 10.0 ] }, + "up": { "texture": "#all", "uv": [ 4.0, 0.0, 8.0, 4.0 ] }, + "down": { "texture": "#all", "uv": [ 8.0, 0.0, 12.0, 4.0 ], "cullface": "down" } + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/botania/textures/model/tinyPotatoCopy.png b/src/main/resources/assets/botania/textures/model/tinyPotatoCopy.png new file mode 100644 index 0000000000000000000000000000000000000000..d0d0dd3c2f883c1e492edd694bbc18d4b77491e6 GIT binary patch literal 487 zcmVc&25JmqCDRPVTU2>x!Ra`iL6Qs%kTp39Kr-+**urHL- z_wW`L$(c#9mUb7GEG-tSqSuL!Lw)FjB24i2`pTyEyvCc)U+6XO=N?2vh#|sx2PuL! zwJ@{U{^S5LM6A!&2q7S)1Uv#y?bB>O2G0%Pyh8{9>-F{}&by=h$pNGYQcBotHb^N! ziX7#~m|a1eTHp}}9UtRQ4q#^6PDjq2@?*@dpcd5Kb7ltfE|020Rr}{!-V+g=bMVfC z9fOEqW>8TSDG-sWo}F`Ong$^T#2B$!tq@~GhyhL0p!1*p-1q+S*WC+0H9zL*;pVG_ z7!bnq!gIo$Gg3-OZ9+}&*>Rt;ODwXz!y#B;|i*vla{tg51`{M`XoDcle{FwJD3K2oh830g9={ph;?EBk` za}W`7&Vznxe#rYG1(a#m2{Tl8L$$r{K8vZ1-s76yn;A+eP*t!D|H*24KQu5zZNIRv du(0s|@(*+9XeXh@YYYGY002ovPDHLkV1f*j<97f6 literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/botania/textures/model/tinyPotatoGrayCopy.png b/src/main/resources/assets/botania/textures/model/tinyPotatoGrayCopy.png new file mode 100644 index 0000000000000000000000000000000000000000..5da02df33be9cb0bb877db36bdd038b299dde93f GIT binary patch literal 446 zcmV;v0YUzWP)&xB>8Ivjd0$Ea5j}PGI8@vF{7k#4Z-g`nt(rDq9a1YapbTkU1#E-C z#)P!7Z?q#4-+%)bcBqr4;b2~9(uR@RRTcI9q{?;TzhC?O>}OlRlAE^&iESS?+<*E^ z*yyFJA5v93*BuIB1|+Bj008AF06;v70RTGG0DvT!9XPi7vTy{r?vO^Veyfu84W#I^L-673c8o7GijO6X@ZRS1nV)SL<2yopYt=2SWY2>I*?-!*n z3rB$K4k=I5YF(7a7o{%?M}X@NX@{2P>5>Cxt1rvSM*uru**{>}i2Qk8N|`D1jK||l znWt*{m5%_A&fiLzeCsKb7^E`3q4%^pk7MJxQ9J?w#Bp3{z4HhdTwG&taXt0Ce|F{C zloLGiobUUYlAhCCqB%nz7g6>qj&uOfY-se)uF%_QK}v}i@6G@iCp>@j@Sl2H`(^b` zBjE7-E1C_nbD@%GHZ+=Avon!WNk}E3l!8(UzVBx~K@cDaf~n`!ep27tX{8-^w)Rr} z$*b;^;aPfH`}63XABNf+ote)&TYCWhhTw4M=2FuZDTII!0#ZsyDM9tTN2y-aUP_7H z@n--)w||nhfAaDWzV9Q7BJA$Jfe-@S{>eaqS|gT)M|)%PP(DwNMrO~P&!f~nuisv8r)}CB9S9+? z+v*}o5*%F&5JeHT*V_og5OEw&>22+o)r)VZM+pGb0<(em-;D%aQ-|7=Rn>cRD$4Jz z$wNhZY3iuzdcF_Hua>m8E_)uYs-7c&JVUExnjhnGcXCzLa|Glc+;!`E7gf`*d;~BI q!!QiPFbu;m48t%C!!Qi9I{XIn4e*Dow_zIq0000 literal 0 HcmV?d00001