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 db3523b60..cd1cec77f 100644 --- a/src/main/java/vazkii/botania/client/core/handler/ModelHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/ModelHandler.java @@ -33,6 +33,7 @@ import net.minecraftforge.client.model.obj.OBJLoader; import net.minecraftforge.fml.common.registry.GameData; import vazkii.botania.api.BotaniaAPIClient; import vazkii.botania.api.state.enums.PlatformVariant; +import vazkii.botania.api.state.enums.SpreaderVariant; import vazkii.botania.client.model.SpecialFlowerModel; import vazkii.botania.api.state.BotaniaStateProps; import vazkii.botania.api.state.enums.AltGrassVariant; @@ -463,6 +464,7 @@ public final class ModelHandler { registerVariantsDefaulted(ModBlocks.openCrate, CrateVariant.class, "pattern=none,variant"); registerVariantsDefaulted(ModBlocks.platform, PlatformVariant.class, "variant"); registerVariantsDefaulted(ModBlocks.prismarine, PrismarineVariant.class, "variant"); + registerVariantsDefaulted(ModBlocks.spreader, SpreaderVariant.class, "variant"); registerVariantsDefaulted(ModFluffBlocks.stone, FutureStoneVariant.class, "variant"); registerVariantsDefaulted(ModBlocks.storage, StorageVariant.class, "variant"); } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileSpreader.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileSpreader.java index d65f8294c..f188dc490 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileSpreader.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileSpreader.java @@ -14,12 +14,15 @@ import java.awt.Color; import java.util.Random; import net.minecraft.block.Block; +import net.minecraft.block.BlockCarpet; +import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.block.model.ItemCameraTransforms; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.init.Blocks; +import net.minecraft.item.EnumDyeColor; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; @@ -90,35 +93,37 @@ public class RenderTileSpreader extends TileEntitySpecialRenderer GlStateManager.pushMatrix(); GlStateManager.translate(-0.0F, -1F, -0.4375F); GlStateManager.scale(0.8F, 0.8F, 0.8F); - Minecraft.getMinecraft().getRenderItem().renderItem(stack, ItemCameraTransforms.TransformType.FIXED); + Minecraft.getMinecraft().getRenderItem().renderItem(stack, ItemCameraTransforms.TransformType.NONE); GlStateManager.popMatrix(); } if(spreader.paddingColor != -1) { Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); - Block block = Blocks.carpet; - int color = spreader.paddingColor; - //RenderBlocks render = RenderBlocks.getInstance(); - float f = 1F / 16F; - GlStateManager.translate(0F, -f, 0F); - //render.renderBlockAsItem(block, color, 1F); - GlStateManager.translate(0F, -f * 15, 0F); - //render.renderBlockAsItem(block, color, 1F); - GlStateManager.rotate(90F, 1F, 0F, 0F); - GlStateManager.rotate(90F, 0F, 1F, 0F); + IBlockState carpet = Blocks.carpet.getDefaultState().withProperty(BlockCarpet.COLOR, EnumDyeColor.byMetadata(spreader.paddingColor)); - GlStateManager.pushMatrix(); - GlStateManager.scale(f * 14F, 1F, 1F); - //render.renderBlockAsItem(block, color, 1F); - GlStateManager.popMatrix(); + GlStateManager.translate(-0.5F, -0.5F, 0.5F); + float f = 1 / 16F; - GlStateManager.rotate(90F, 1F, 0F, 0F); - GlStateManager.translate(0F, 0F, -f / 2); - GlStateManager.scale(f * 14F, 1F, f * 15F); - //render.renderBlockAsItem(block, color, 1F); - GlStateManager.translate(0F, f * 15F, 0F); - //render.renderBlockAsItem(block, color, 1F); todo 1.8 + Minecraft.getMinecraft().getBlockRendererDispatcher().renderBlockBrightness(carpet, 1.0F); + GlStateManager.rotate(-90, 0, 1, 0); + + GlStateManager.rotate(270, 0, 0, 1); + Minecraft.getMinecraft().getBlockRendererDispatcher().renderBlockBrightness(carpet, 1.0F); + GlStateManager.rotate(-90, 0, 1, 0); + + GlStateManager.translate(0, 15 * f, 0); + Minecraft.getMinecraft().getBlockRendererDispatcher().renderBlockBrightness(carpet, 1.0F); + GlStateManager.rotate(-90, 0, 1, 0); + + GlStateManager.translate(15 * f, f, 0); + GlStateManager.rotate(270, 0, 0, 1); + Minecraft.getMinecraft().getBlockRendererDispatcher().renderBlockBrightness(carpet, 1.0F); + GlStateManager.rotate(-90, 0, 1, 0); + + GlStateManager.translate(0, -1, 0); + GlStateManager.rotate(90, 1, 0, 0); + Minecraft.getMinecraft().getBlockRendererDispatcher().renderBlockBrightness(carpet, 1.0F); } GlStateManager.enableRescaleNormal(); diff --git a/src/main/resources/assets/botania/models/block/spreader.json b/src/main/resources/assets/botania/models/block/spreader.json new file mode 100644 index 000000000..e057858f9 --- /dev/null +++ b/src/main/resources/assets/botania/models/block/spreader.json @@ -0,0 +1,137 @@ +{ + "textures": { + "particle": "#all" + }, + "elements": [ + { + "__comment": "cubeSide4", + "from": [14, 1, 2], + "to": [15, 14, 15], + "faces": { + "down": {"uv": [0.5, 0, 0.75, 3.25], "texture": "#all"}, + "up": {"uv": [0.25, 0, 0.5, 3.25], "texture": "#all"}, + "north": {"uv": [3.75, 3.25, 7, 6.5], "texture": "#all"}, + "south": {"uv": [0.25, 3.25, 3.5, 6.5], "texture": "#all"}, + "west": {"uv": [0, 3.25, 0.25, 6.5], "texture": "#all"}, + "east": {"uv": [3.5, 3.25, 3.75, 6.5], "texture": "#all"} + } + }, + { + "__comment": "cubeInside", + "from": [5, 4, 5], + "to": [11, 10, 11], + "faces": { + "down": {"uv": [10.5, 4.25, 12, 5.75], "texture": "#all"}, + "up": {"uv": [9, 4.25, 10.5, 5.75], "texture": "#all"}, + "north": {"uv": [12, 5.75, 13.5, 7.25], "texture": "#all"}, + "south": {"uv": [9, 5.75, 10.5, 7.25], "texture": "#all"}, + "west": {"uv": [7.5, 5.75, 9, 7.25], "texture": "#all"}, + "east": {"uv": [10.5, 5.75, 12, 7.25], "texture": "#all"} + } + }, + { + "__comment": "cubeHole2", + "from": [2, 1, 14], + "to": [6, 13, 15], + "faces": { + "down": {"uv": [2, 0, 3, 0.25], "texture": "#all"}, + "up": {"uv": [1, 0, 2, 0.25], "texture": "#all"}, + "north": {"uv": [2.25, 0.25, 2.5, 3.25], "texture": "#all"}, + "south": {"uv": [1, 0.25, 1.25, 3.25], "texture": "#all"}, + "west": {"uv": [0, 0.25, 1, 3.25], "texture": "#all"}, + "east": {"uv": [1.25, 0.25, 2.25, 3.25], "texture": "#all"} + } + }, + { + "__comment": "cubeSide5", + "from": [2, 13, 2], + "to": [14, 14, 15], + "faces": { + "down": {"uv": [6, 0, 9, 3.25], "texture": "#all"}, + "up": {"uv": [3, 0, 6, 3.25], "texture": "#all"}, + "north": {"uv": [9.25, 3.25, 12.5, 3.5], "texture": "#all"}, + "south": {"uv": [3, 3.25, 6.25, 3.5], "texture": "#all"}, + "west": {"uv": [0, 3.25, 3, 3.5], "texture": "#all"}, + "east": {"uv": [6.25, 3.25, 9.25, 3.5], "texture": "#all"} + } + }, + { + "__comment": "cubeHole4", + "from": [6, 9, 14], + "to": [10, 13, 15], + "faces": { + "down": {"uv": [2, 0, 3, 0.25], "texture": "#all"}, + "up": {"uv": [1, 0, 2, 0.25], "texture": "#all"}, + "north": {"uv": [2.25, 0.25, 2.5, 1.25], "texture": "#all"}, + "south": {"uv": [1, 0.25, 1.25, 1.25], "texture": "#all"}, + "west": {"uv": [0, 0.25, 1, 1.25], "texture": "#all"}, + "east": {"uv": [1.25, 0.25, 2.25, 1.25], "texture": "#all"} + } + }, + { + "__comment": "cubeHole3", + "from": [6, 1, 14], + "to": [10, 5, 15], + "faces": { + "down": {"uv": [2, 0, 3, 0.25], "texture": "#all"}, + "up": {"uv": [1, 0, 2, 0.25], "texture": "#all"}, + "north": {"uv": [2.25, 0.25, 2.5, 1.25], "texture": "#all"}, + "south": {"uv": [1, 0.25, 1.25, 1.25], "texture": "#all"}, + "west": {"uv": [0, 0.25, 1, 1.25], "texture": "#all"}, + "east": {"uv": [1.25, 0.25, 2.25, 1.25], "texture": "#all"} + } + }, + { + "__comment": "cubeSide1", + "from": [1, 0, 1], + "to": [15, 1, 15], + "faces": { + "down": {"uv": [7, 0, 10.5, 3.5], "texture": "#all"}, + "up": {"uv": [3.5, 0, 7, 3.5], "texture": "#all"}, + "north": {"uv": [10.5, 3.5, 14, 3.75], "texture": "#all"}, + "south": {"uv": [3.5, 3.5, 7, 3.75], "texture": "#all"}, + "west": {"uv": [0, 3.5, 3.5, 3.75], "texture": "#all"}, + "east": {"uv": [7, 3.5, 10.5, 3.75], "texture": "#all"} + } + }, + { + "__comment": "cubeSide3", + "from": [1, 1, 2], + "to": [2, 14, 15], + "faces": { + "down": {"uv": [0.5, 0, 0.75, 3.25], "texture": "#all"}, + "up": {"uv": [0.25, 0, 0.5, 3.25], "texture": "#all"}, + "north": {"uv": [3.75, 3.25, 7, 6.5], "texture": "#all"}, + "south": {"uv": [0.25, 3.25, 3.5, 6.5], "texture": "#all"}, + "west": {"uv": [0, 3.25, 0.25, 6.5], "texture": "#all"}, + "east": {"uv": [3.5, 3.25, 3.75, 6.5], "texture": "#all"} + } + }, + { + "__comment": "cubeHole1", + "from": [10, 1, 14], + "to": [14, 13, 15], + "faces": { + "down": {"uv": [2, 0, 3, 0.25], "texture": "#all"}, + "up": {"uv": [1, 0, 2, 0.25], "texture": "#all"}, + "north": {"uv": [2.25, 0.25, 2.5, 3.25], "texture": "#all"}, + "south": {"uv": [1, 0.25, 1.25, 3.25], "texture": "#all"}, + "west": {"uv": [0, 0.25, 1, 3.25], "texture": "#all"}, + "east": {"uv": [1.25, 0.25, 2.25, 3.25], "texture": "#all"} + } + }, + { + "__comment": "cubeSide2", + "from": [1, 1, 1], + "to": [15, 14, 2], + "faces": { + "down": {"uv": [7, 0, 10.5, 0.25], "texture": "#all"}, + "up": {"uv": [3.5, 0, 7, 0.25], "texture": "#all"}, + "north": {"uv": [7.25, 0.25, 7.5, 3.5], "texture": "#all"}, + "south": {"uv": [3.5, 0.25, 3.75, 3.5], "texture": "#all"}, + "west": {"uv": [0, 0.25, 3.5, 3.5], "texture": "#all"}, + "east": {"uv": [3.75, 0.25, 7.25, 3.5], "texture": "#all"} + } + } + ] +}