Partially restore pump render (doesn't move yet)

This commit is contained in:
Vincent Lee committed 2019-11-19 11:40:00 -06:00
1 parent 5c9246ca8d
commit 53ea3b9bf3
9 files changed
+133 -61

No files matched your search

@@ -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
@@ -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());
@@ -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<TilePump> {
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();
}
}
@@ -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
@@ -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<IAnimationStateMachine> 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 <T> LazyOptional<T> getCapability(@Nonnull Capability<T> 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) {