From 53ea3b9bf30dccdf61700dc23dd2182c932a43b9 Mon Sep 17 00:00:00 2001 From: Vincent Lee Date: Tue, 19 Nov 2019 11:40:00 -0600 Subject: [PATCH] Partially restore pump render (doesn't move yet) --- .../core/handler/MiscellaneousIcons.java | 4 +- .../client/core/handler/ModelHandler.java | 5 +- .../client/render/tile/RenderTilePump.java | 39 ++++++++++ .../botania/common/block/mana/BlockPump.java | 2 +- .../common/block/tile/mana/TilePump.java | 26 ------- .../assets/botania/blockstates/pump.json | 33 +------- .../botania/models/block/mana_pump.json | 4 +- .../botania/models/block/mana_pump_head.json | 4 +- .../assets/botania/models/item/pump.json | 77 +++++++++++++++++++ 9 files changed, 133 insertions(+), 61 deletions(-) create mode 100644 src/main/java/vazkii/botania/client/render/tile/RenderTilePump.java create mode 100644 src/main/resources/assets/botania/models/item/pump.json diff --git a/src/main/java/vazkii/botania/client/core/handler/MiscellaneousIcons.java b/src/main/java/vazkii/botania/client/core/handler/MiscellaneousIcons.java index 6a5b9ca76..5d7e9c90f 100644 --- a/src/main/java/vazkii/botania/client/core/handler/MiscellaneousIcons.java +++ b/src/main/java/vazkii/botania/client/core/handler/MiscellaneousIcons.java @@ -22,6 +22,7 @@ import vazkii.botania.client.model.GunModel; import vazkii.botania.client.model.LexiconModel; import vazkii.botania.client.model.PlatformModel; import vazkii.botania.client.render.tile.RenderTileCorporeaCrystalCube; +import vazkii.botania.client.render.tile.RenderTilePump; import vazkii.botania.common.item.equipment.bauble.ItemFlightTiara; import vazkii.botania.common.item.relic.ItemKingKey; import vazkii.botania.common.lib.LibMisc; @@ -118,7 +119,8 @@ public class MiscellaneousIcons { IBakedModel originalModelClip = evt.getModelRegistry().get(clipKey); evt.getModelRegistry().put(key, new GunModel(evt.getModelLoader(), originalModel, originalModelClip)); - RenderTileCorporeaCrystalCube.cubeModel = evt.getModelRegistry().get(new ResourceLocation(LibMisc.MOD_ID, "block/corporea_crystal_cube_glass")); + RenderTileCorporeaCrystalCube.cubeModel = evt.getModelRegistry().get(prefix("block/corporea_crystal_cube_glass")); + RenderTilePump.headModel = evt.getModelRegistry().get(prefix("block/mana_pump_head")); } @SubscribeEvent 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 b67302c87..b17f5a3d7 100644 --- a/src/main/java/vazkii/botania/client/core/handler/ModelHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/ModelHandler.java @@ -84,7 +84,8 @@ public final class ModelHandler { ModelLoader.addSpecialModel(new ModelResourceLocation(LibMisc.MOD_ID + ":mana_gun_clip", "inventory")); ModelLoader.addSpecialModel(new ModelResourceLocation(LibMisc.MOD_ID + ":desu_gun", "inventory")); ModelLoader.addSpecialModel(new ModelResourceLocation(LibMisc.MOD_ID + ":desu_gun_clip", "inventory")); - ModelLoader.addSpecialModel(new ResourceLocation(LibMisc.MOD_ID, "block/corporea_crystal_cube_glass")); + ModelLoader.addSpecialModel(prefix("block/corporea_crystal_cube_glass")); + ModelLoader.addSpecialModel(prefix("block/mana_pump_head")); registerSubtiles(); RenderTileFloatingFlower renderTileFloatingFlower = new RenderTileFloatingFlower(); @@ -106,7 +107,7 @@ public final class ModelHandler { ClientRegistry.bindTileEntitySpecialRenderer(TileRedString.class, new RenderTileRedString()); ClientRegistry.bindTileEntitySpecialRenderer(TilePrism.class, new RenderTilePrism()); ClientRegistry.bindTileEntitySpecialRenderer(TileCorporeaIndex.class, new RenderTileCorporeaIndex()); - ClientRegistry.bindTileEntitySpecialRenderer(TilePump.class, new TileEntityRendererAnimation<>()); + ClientRegistry.bindTileEntitySpecialRenderer(TilePump.class, new RenderTilePump()); ClientRegistry.bindTileEntitySpecialRenderer(TileCorporeaCrystalCube.class, new RenderTileCorporeaCrystalCube()); ClientRegistry.bindTileEntitySpecialRenderer(TileIncensePlate.class, new RenderTileIncensePlate()); ClientRegistry.bindTileEntitySpecialRenderer(TileHourglass.class, new RenderTileHourglass()); diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTilePump.java b/src/main/java/vazkii/botania/client/render/tile/RenderTilePump.java new file mode 100644 index 000000000..9f7867e03 --- /dev/null +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTilePump.java @@ -0,0 +1,39 @@ +package vazkii.botania.client.render.tile; + +import com.mojang.blaze3d.platform.GlStateManager; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.model.IBakedModel; +import net.minecraft.client.renderer.texture.AtlasTexture; +import net.minecraft.client.renderer.tileentity.TileEntityRenderer; +import net.minecraft.util.Direction; +import vazkii.botania.api.state.BotaniaStateProps; +import vazkii.botania.common.block.tile.mana.TilePump; + +public class RenderTilePump extends TileEntityRenderer { + public static IBakedModel headModel = null; + + @Override + public void render(TilePump pump, double x, double y, double z, float partialTicks, int destroyStage) { + GlStateManager.pushMatrix(); + GlStateManager.translated(x, y, z); + GlStateManager.translated(0.5, 0, 0.5); + switch (pump.getBlockState().get(BotaniaStateProps.CARDINALS)) { + default: + case NORTH: break; + case SOUTH: + GlStateManager.rotatef(180, 0, 1, 0); + break; + case EAST: + GlStateManager.rotatef(-90, 0, 1, 0); + break; + case WEST: + GlStateManager.rotatef(90, 0, 1, 0); + break; + } + GlStateManager.translated(-0.5, 0, -0.5); + GlStateManager.color4f(1, 1, 1, 1); + Minecraft.getInstance().textureManager.bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE); + Minecraft.getInstance().getBlockRendererDispatcher().getBlockModelRenderer().renderModelBrightnessColor(headModel, 1, 1, 1, 1); + GlStateManager.popMatrix(); + } +} diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockPump.java b/src/main/java/vazkii/botania/common/block/mana/BlockPump.java index 461c9d108..3d50b6701 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockPump.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockPump.java @@ -46,7 +46,7 @@ public class BlockPump extends BlockMod { @Nullable @Override public BlockState getStateForPlacement(BlockItemUseContext context) { - return getDefaultState().with(BotaniaStateProps.CARDINALS, context.getNearestLookingDirection().getOpposite()); + return getDefaultState().with(BotaniaStateProps.CARDINALS, context.getPlacementHorizontalFacing().getOpposite()); } @Nonnull diff --git a/src/main/java/vazkii/botania/common/block/tile/mana/TilePump.java b/src/main/java/vazkii/botania/common/block/tile/mana/TilePump.java index d4cca1663..808ccf73c 100644 --- a/src/main/java/vazkii/botania/common/block/tile/mana/TilePump.java +++ b/src/main/java/vazkii/botania/common/block/tile/mana/TilePump.java @@ -48,27 +48,8 @@ public class TilePump extends TileMod implements ITickableTileEntity { public boolean hasRedstone = false; private int lastComparator = 0; - private final TimeValues.VariableValue move; - private final IAnimationStateMachine asm; - private final LazyOptional asmCap; - public TilePump() { super(TYPE); - if (FMLEnvironment.dist == Dist.CLIENT) { - move = new TimeValues.VariableValue(0); - asm = ModelLoaderRegistry.loadASM(new ResourceLocation("botania", "asms/block/pump.json"), ImmutableMap.of("move", move)); - asmCap = LazyOptional.of(() -> asm); - } else { - move = null; - asm = null; - asmCap = LazyOptional.empty(); - } - } - - @Nonnull - @Override - public LazyOptional getCapability(@Nonnull Capability cap, Direction side) { - return CapabilityAnimation.ANIMATION_CAPABILITY.orEmpty(cap, asmCap); } @Override @@ -105,9 +86,6 @@ public class TilePump extends TileMod implements ITickableTileEntity { } } - if(world.isRemote) - move.setValue(innerRingPos / 8 * 0.5F); // rescale to 0 - 0.5 for json animation - if(!hasCartOnTop) comparator = 0; if(!hasCart && active) @@ -130,11 +108,7 @@ public class TilePump extends TileMod implements ITickableTileEntity { @Override public void readPacketNBT(CompoundNBT cmp) { - boolean prevActive = active; active = cmp.getBoolean(TAG_ACTIVE); - if(world != null && world.isRemote) - if(prevActive != active) - asm.transition(active ? "moving" : "default"); } public void setActive(boolean active) { diff --git a/src/main/resources/assets/botania/blockstates/pump.json b/src/main/resources/assets/botania/blockstates/pump.json index b4963f30d..c773fa9eb 100644 --- a/src/main/resources/assets/botania/blockstates/pump.json +++ b/src/main/resources/assets/botania/blockstates/pump.json @@ -1,33 +1,8 @@ { - "forge_marker": 1, - "defaults": { - "textures": { - "particle": "botania:blocks/livingrock0" - }, - "transform": "forge:default-block" - }, "variants": { - "facing": { - "north": {}, - "south": { "y": 180 }, - "west": { "y": 270 }, - "east": { "y": 90 } - }, - "static": { - "true": { - "model": "botania:block/mana_pump" - }, - "false": { - "model": "botania:block/mana_pump_head" - } - }, - "inventory": [{ - "model": "botania:block/mana_pump", - "submodel": { - "head": { - "model": "botania:block/mana_pump_head" - } - } - }] + "facing=north": { "model": "botania:block/mana_pump" }, + "facing=south": { "model": "botania:block/mana_pump","y": 180 }, + "facing=west": { "model": "botania:block/mana_pump","y": 270 }, + "facing=east": { "model": "botania:block/mana_pump","y": 90 } } } \ No newline at end of file diff --git a/src/main/resources/assets/botania/models/block/mana_pump.json b/src/main/resources/assets/botania/models/block/mana_pump.json index 5713da3c8..59d04425f 100644 --- a/src/main/resources/assets/botania/models/block/mana_pump.json +++ b/src/main/resources/assets/botania/models/block/mana_pump.json @@ -1,8 +1,10 @@ { "Comment": "Designed by Wiiv with Cubik Studio - https://cubik.studio", + "parent": "minecraft:block/block", "textures": { "structure": "botania:blocks/pump_structure", - "head_sheat": "botania:blocks/pump_head_sheat" + "head_sheat": "botania:blocks/pump_head_sheat", + "particle": "botania:blocks/livingrock0" }, "elements": [ { diff --git a/src/main/resources/assets/botania/models/block/mana_pump_head.json b/src/main/resources/assets/botania/models/block/mana_pump_head.json index b11697450..c7b7e077a 100644 --- a/src/main/resources/assets/botania/models/block/mana_pump_head.json +++ b/src/main/resources/assets/botania/models/block/mana_pump_head.json @@ -1,7 +1,9 @@ { "Comment": "Designed by Wiiv with Cubik Studio - https://cubik.studio", + "parent": "minecraft:block/block", "textures": { - "head_sheat": "botania:blocks/pump_head_sheat" + "head_sheat": "botania:blocks/pump_head_sheat", + "particle": "botania:blocks/livingrock0" }, "elements": [ { diff --git a/src/main/resources/assets/botania/models/item/pump.json b/src/main/resources/assets/botania/models/item/pump.json new file mode 100644 index 000000000..fd632fdc9 --- /dev/null +++ b/src/main/resources/assets/botania/models/item/pump.json @@ -0,0 +1,77 @@ +{ + "Comment0": "Combination of block/mana_pump and block/mana_pump_head", + "Comment": "Designed by Wiiv with Cubik Studio - https://cubik.studio", + "parent": "minecraft:block/block", + "textures": { + "structure": "botania:blocks/pump_structure", + "head_sheat": "botania:blocks/pump_head_sheat", + "particle": "botania:blocks/livingrock0" + }, + "elements": [ + { + "Comment": "end_east", + "from": [ 4, 0, 14 ], + "to": [ 12, 8, 16 ], + "faces": { + "down": { "uv": [ 8, 2, 16, 4 ], "texture": "#structure" }, + "up": { "uv": [ 8, 2, 16, 4 ], "texture": "#structure" }, + "north": { "uv": [ 0, 8, 8, 16 ], "texture": "#structure" }, + "south": { "uv": [ 0, 0, 8, 8 ], "texture": "#structure" }, + "west": { "uv": [ 8, 2, 16, 0 ], "texture": "#structure", "rotation": 90 }, + "east": { "uv": [ 8, 0, 16, 2 ], "texture": "#structure", "rotation": 90 } + } + }, + { + "Comment": "end_west", + "from": [ 4, 0, 0 ], + "to": [ 12, 8, 2 ], + "faces": { + "down": { "uv": [ 8, 2, 16, 4 ], "texture": "#structure" }, + "up": { "uv": [ 8, 2, 16, 4 ], "texture": "#structure" }, + "north": { "uv": [ 0, 0, 8, 8 ], "texture": "#structure" }, + "south": { "uv": [ 0, 8, 8, 16 ], "texture": "#structure" }, + "west": { "uv": [ 8, 4, 16, 2 ], "texture": "#structure", "rotation": 90 }, + "east": { "uv": [ 8, 2, 16, 4 ], "texture": "#structure", "rotation": 90 } + } + }, + { + "Comment": "tube", + "from": [ 6, 2, 2 ], + "to": [ 10, 6, 10 ], + "faces": { + "down": { "uv": [ 12, 8, 16, 16 ], "texture": "#structure" }, + "up": { "uv": [ 12, 8, 16, 16 ], "texture": "#structure" }, + "north": { "uv": [ 8, 12, 12, 16 ], "texture": "#structure" }, + "south": { "uv": [ 8, 8, 12, 12 ], "texture": "#structure" }, + "west": { "uv": [ 8, 4, 16, 8 ], "texture": "#structure" }, + "east": { "uv": [ 8, 4, 16, 8 ], "texture": "#structure" } + } + }, + { + "Comment": "sheat", + "from": [ 4, 0, 10 ], + "to": [ 12, 8, 14 ], + "faces": { + "down": { "uv": [ 8, 4, 16, 8 ], "texture": "#head_sheat" }, + "up": { "uv": [ 8, 0, 16, 4 ], "texture": "#head_sheat" }, + "north": { "uv": [ 0, 0, 8, 8 ], "texture": "#head_sheat" }, + "south": { "uv": [ 0, 0, 8, 8 ], "texture": "#head_sheat" }, + "west": { "uv": [ 8, 8, 16, 4 ], "texture": "#head_sheat", "rotation": 90 }, + "east": { "uv": [ 8, 4, 16, 8 ], "texture": "#head_sheat", "rotation": 90 } + } + }, + { + "Comment": "head", + "from": [ 5, 1, 2 ], + "to": [ 11, 7, 6 ], + "faces": { + "down": { "uv": [ 6, 8, 12, 12 ], "texture": "#head_sheat" }, + "up": { "uv": [ 6, 8, 12, 12 ], "texture": "#head_sheat" }, + "north": { "uv": [ 0, 8, 6, 14 ], "texture": "#head_sheat" }, + "south": { "uv": [ 0, 8, 6, 14 ], "texture": "#head_sheat" }, + "west": { "uv": [ 6, 12, 12, 8 ], "texture": "#head_sheat", "rotation": 90 }, + "east": { "uv": [ 6, 8, 12, 12 ], "texture": "#head_sheat", "rotation": 90 } + } + } + ] +} \ No newline at end of file