diff --git a/src/main/java/tconstruct/smeltery/logic/CastingBlockLogic.java b/src/main/java/tconstruct/smeltery/logic/CastingBlockLogic.java index 521e843e..123b2097 100644 --- a/src/main/java/tconstruct/smeltery/logic/CastingBlockLogic.java +++ b/src/main/java/tconstruct/smeltery/logic/CastingBlockLogic.java @@ -1,5 +1,6 @@ package tconstruct.smeltery.logic; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; @@ -9,6 +10,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.util.MathHelper; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.ForgeDirection; @@ -21,6 +23,7 @@ import net.minecraftforge.fluids.IFluidTank; import cpw.mods.fml.common.eventhandler.Event; import mantle.blocks.abstracts.InventoryLogic; +import mantle.blocks.iface.IFacingLogic; import tconstruct.TConstruct; import tconstruct.library.crafting.CastingRecipe; import tconstruct.library.crafting.LiquidCasting; @@ -30,9 +33,11 @@ import tconstruct.library.event.SmelteryEvent; import tconstruct.library.tools.AbilityHelper; import tconstruct.library.util.IPattern; -public abstract class CastingBlockLogic extends InventoryLogic implements IFluidTank, IFluidHandler, ISidedInventory { +public abstract class CastingBlockLogic extends InventoryLogic + implements IFluidTank, IFluidHandler, ISidedInventory, IFacingLogic { public FluidStack liquid; + protected byte direction; protected int maxCastingDelay = 0; protected int castingDelay = 0; protected int renderOffset = 0; @@ -289,7 +294,7 @@ public abstract class CastingBlockLogic extends InventoryLogic implements IFluid player); MinecraftForge.EVENT_BUS.post(event); - // try to transfer thes tack to the player inventory + // try to transfer the stack to the player inventory ItemStack output = event.item; AbilityHelper.spawnItemAtPlayer(player, output); @@ -431,6 +436,7 @@ public abstract class CastingBlockLogic extends InventoryLogic implements IFluid this.castingDelay = tags.getInteger("castingDelay"); this.maxCastingDelay = tags.getInteger("maxCastingDelay"); this.renderOffset = tags.getInteger("RenderOffset"); + this.direction = tags.getByte("direction"); } @Override @@ -451,6 +457,7 @@ public abstract class CastingBlockLogic extends InventoryLogic implements IFluid tags.setInteger("castingDelay", castingDelay); tags.setInteger("maxCastingDelay", maxCastingDelay); tags.setInteger("RenderOffset", renderOffset); + tags.setByte("direction", direction); } /* Packets */ @@ -474,4 +481,28 @@ public abstract class CastingBlockLogic extends InventoryLogic implements IFluid return (int) (((maxCastingDelay - castingDelay) / (double) maxCastingDelay) * 100); } + + @Override + public byte getRenderDirection() { + return direction; + } + + @Override + public ForgeDirection getForgeDirection() { + return ForgeDirection.VALID_DIRECTIONS[direction]; + } + + @Override + public void setDirection(int side) {} + + @Override + public void setDirection(float yaw, float pitch, EntityLivingBase player) { + int facing = MathHelper.floor_double((double) (yaw / 360) + 0.5D) & 3; + switch (facing) { + case 1 -> direction = 5; + case 2 -> direction = 3; + case 3 -> direction = 4; + default -> direction = 2; + } + } } diff --git a/src/main/java/tconstruct/smeltery/logic/FaucetLogic.java b/src/main/java/tconstruct/smeltery/logic/FaucetLogic.java index f8610af4..a272ac71 100644 --- a/src/main/java/tconstruct/smeltery/logic/FaucetLogic.java +++ b/src/main/java/tconstruct/smeltery/logic/FaucetLogic.java @@ -6,6 +6,7 @@ import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.MathHelper; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; @@ -18,7 +19,7 @@ import tconstruct.TConstruct; public class FaucetLogic extends TileEntity implements IFacingLogic, IActiveLogic, IFluidHandler { - byte direction; + byte direction = 0; boolean active; public FluidStack liquid; public boolean hasRedstonePower = false; @@ -91,17 +92,20 @@ public class FaucetLogic extends TileEntity implements IFacingLogic, IActiveLogi public void setDirection(int side) { if (side != 0 && side != 1) { direction = (byte) side; - } else { - direction = 2; } } @Override public void setDirection(float yaw, float pitch, EntityLivingBase player) { - /* - * int facing = MathHelper.floor_double((double) (yaw / 360) + 0.5D) & 3; switch (facing) { case 0: direction = - * 2; break; case 1: direction = 5; break; case 2: direction = 3; break; case 3: direction = 4; break; } - */ + if (direction > 1) return; + + int facing = MathHelper.floor_double((double) (yaw / 360) + 0.5D) & 3; + switch (facing) { + case 1 -> direction = 5; + case 2 -> direction = 3; + case 3 -> direction = 4; + default -> direction = 2; + } } @Override diff --git a/src/main/java/tconstruct/smeltery/model/CastingBasinSpecialRender.java b/src/main/java/tconstruct/smeltery/model/CastingBasinSpecialRender.java index 14c68c9b..a8df2114 100644 --- a/src/main/java/tconstruct/smeltery/model/CastingBasinSpecialRender.java +++ b/src/main/java/tconstruct/smeltery/model/CastingBasinSpecialRender.java @@ -47,11 +47,20 @@ public class CastingBasinSpecialRender extends TileEntitySpecialRenderer { entityitem.hoverStart = 0.0F; GL11.glPushMatrix(); GL11.glTranslatef(1F, 0.675F, 1.0F); - // GL11.glRotatef(90F, 1, 0F, 0F); + + float rotationY = switch (logic.getRenderDirection()) { + case 2 -> 90F; + case 3 -> 270F; + case 4 -> 180F; + default -> 0F; + }; + + GL11.glRotatef(rotationY, 0F, 1F, 0F); GL11.glScalef(1.75F, 1.75F, 1.75F); + if (stack.getItem() instanceof ItemBlock) { GL11.glScalef(1.6F, 1.6F, 1.6F); - GL11.glTranslatef(0F, 0.045F, 0.0f); + GL11.glTranslatef(0F, 0.045F, 0F); } else if (!(stack.getItem() instanceof ItemBlocklike)) { GL11.glRotatef(90F, 1F, 0F, 0F); GL11.glRotatef(90F, 0F, 0F, 1F); diff --git a/src/main/java/tconstruct/smeltery/model/CastingTableSpecialRenderer.java b/src/main/java/tconstruct/smeltery/model/CastingTableSpecialRenderer.java index ac9d44c2..40376c4f 100644 --- a/src/main/java/tconstruct/smeltery/model/CastingTableSpecialRenderer.java +++ b/src/main/java/tconstruct/smeltery/model/CastingTableSpecialRenderer.java @@ -53,11 +53,30 @@ public class CastingTableSpecialRenderer extends TileEntitySpecialRenderer { entityitem.hoverStart = 0.0F; GL11.glPushMatrix(); GL11.glTranslatef(1F, 1.48F, 0.55F); - GL11.glRotatef(90F, 1, 0F, 0F); + + float rotationY = switch (logic.getRenderDirection()) { + case 3 -> 180F; + case 4 -> 90F; + case 5 -> 270F; + default -> 0F; + }; + GL11.glRotatef(rotationY, 0F, 1F, 0F); + + if (logic.getRenderDirection() == 3) { + GL11.glTranslatef(0F, 0F, -0.9F); + } else if (logic.getRenderDirection() == 4) { + GL11.glTranslatef(-0.45F, 0F, -0.45F); + } else if (logic.getRenderDirection() == 5) { + GL11.glTranslatef(0.45F, 0F, -0.45F); + } + + GL11.glRotatef(90F, 1F, 0F, 0F); GL11.glScalef(2F, 2F, 2F); + if (stack.getItem() instanceof ItemBlock || stack.getItem() instanceof ItemBlocklike) { - GL11.glRotatef(90F, -1, 0F, 0F); - GL11.glTranslatef(0F, -0.1F, 0.2275F); + GL11.glRotatef(-90F, 0F, 0F, 1F); + GL11.glRotatef(90F, -1F, 0F, 0F); + GL11.glTranslatef(-0.2275F, -0.1F, 0F); } if (stack.isItemEqual(new ItemStack(TinkerSmeltery.glassPane))) {