diff --git a/dependencies.gradle b/dependencies.gradle index 54ccbc7..7951731 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -30,11 +30,11 @@ */ dependencies { api('com.github.GTNewHorizons:Galaxy-Space-GTNH:1.1.121-GTNH:dev') - api('com.github.GTNewHorizons:GT5-Unofficial:5.09.51.449:dev') + api('com.github.GTNewHorizons:GT5-Unofficial:5.09.51.459:dev') api('com.github.GTNewHorizons:CodeChickenCore:1.4.7:dev') - implementation('com.github.GTNewHorizons:NewHorizonsCoreMod:2.7.247:dev') + implementation('com.github.GTNewHorizons:NewHorizonsCoreMod:2.7.256:dev') implementation('com.github.GTNewHorizons:Avaritia:1.75:dev') - runtimeOnlyNonPublishable('com.github.GTNewHorizons:ServerUtilities:2.1.59:dev') + runtimeOnlyNonPublishable('com.github.GTNewHorizons:ServerUtilities:2.1.61:dev') runtimeOnlyNonPublishable('com.github.GTNewHorizons:BlockRenderer6343:1.3.16:dev') implementation('com.google.auto.value:auto-value-annotations:1.10.1') diff --git a/src/main/java/com/silvermoon/boxplusplus/common/block/BlockBoxRing.java b/src/main/java/com/silvermoon/boxplusplus/common/block/BlockBoxRing.java index f8989ef..670277d 100644 --- a/src/main/java/com/silvermoon/boxplusplus/common/block/BlockBoxRing.java +++ b/src/main/java/com/silvermoon/boxplusplus/common/block/BlockBoxRing.java @@ -5,6 +5,7 @@ import net.minecraft.block.Block; import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.material.Material; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; @@ -54,4 +55,39 @@ public Block setBlockName(String name) { public boolean isOpaqueCube() { return false; } + + @Override + public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player) { + if (!world.isRemote) { + TileEntity te = world.getTileEntity(x, y, z); + if (te instanceof TEBoxRing ring) { + ring.scale -= 0.05f; + if (ring.scale < 0.05f) ring.scale = 0.05f; + + ring.markDirty(); + world.markBlockForUpdate(x, y, z); + } + } + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, + float hitY, float hitZ) { + + if (!world.isRemote) { + TileEntity te = world.getTileEntity(x, y, z); + if (te instanceof TEBoxRing ring) { + if (player.isSneaking()) { + ring.scale += 0.05f; + if (ring.scale > 3.0f) ring.scale = 3.0f; + } else { + ring.renderStatus = !ring.renderStatus; + } + + ring.markDirty(); + world.markBlockForUpdate(x, y, z); + } + } + return true; + } } diff --git a/src/main/java/com/silvermoon/boxplusplus/common/render/RenderBoxRing.java b/src/main/java/com/silvermoon/boxplusplus/common/render/RenderBoxRing.java index 077018c..afacbe2 100644 --- a/src/main/java/com/silvermoon/boxplusplus/common/render/RenderBoxRing.java +++ b/src/main/java/com/silvermoon/boxplusplus/common/render/RenderBoxRing.java @@ -22,33 +22,44 @@ public class RenderBoxRing extends TileEntitySpecialRenderer { private static final IModelCustom Ring = AdvancedModelLoader .loadModel(new ResourceLocation(Tags.MODID, "models/Ring.obj")); - public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float timeSinceLastTick) { + @Override + public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partialTicks) { if (!(tile instanceof TEBoxRing ring)) return; + GL11.glPushMatrix(); GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5); - // Render the outside ring. Keep internal ring visible! + + double rotation = ring.getInterpolatedRotation(partialTicks); + if (ring.teRingSwitch && ring.renderStatus) { - GL11.glRotated(ring.getCurrentRotation(), 1, 1, 1); - renderRing(tile, 1.1f); - GL11.glRotated(ring.getCurrentRotation(), 0, 0, 1); - renderRing(tile, 1.4f); + GL11.glRotated(rotation, 1, 1, 1); + renderRing((float) (1.1f * ring.scale)); + GL11.glRotated(rotation, 0, 0, 1); + renderRing((float) (1.4f * ring.scale)); } - GL11.glRotated(ring.getCurrentRotation(), 0, -1, 1); - renderRing(tile, 0.0118f); + + GL11.glRotated(rotation, 0, -1, 1); + renderRing(0.0118f); + GL11.glPopMatrix(); } - private void renderRing(TileEntity tile, float scale) { + private void renderRing(float scale) { + GL11.glPushMatrix(); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + this.bindTexture(BoxRingTexture); GL11.glScaled(scale, scale, scale); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240f, 240f); Ring.renderAll(); + GL11.glDisable(GL11.GL_BLEND); GL11.glDepthMask(true); GL11.glEnable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); } } diff --git a/src/main/java/com/silvermoon/boxplusplus/common/tileentities/TEBoxRing.java b/src/main/java/com/silvermoon/boxplusplus/common/tileentities/TEBoxRing.java index 92cf631..1582539 100644 --- a/src/main/java/com/silvermoon/boxplusplus/common/tileentities/TEBoxRing.java +++ b/src/main/java/com/silvermoon/boxplusplus/common/tileentities/TEBoxRing.java @@ -10,12 +10,22 @@ public class TEBoxRing extends TileEntityAdvanced { @Annotations.NetworkedField(targetSide = Side.CLIENT) - public double Rotation = 0; + public double scale = 1; + + @Annotations.NetworkedField(targetSide = Side.CLIENT) + public double rotation = 0; + + @Annotations.NetworkedField(targetSide = Side.CLIENT) + public double prevRotation = 0; + @Annotations.NetworkedField(targetSide = Side.CLIENT) public boolean renderStatus = false; + @Annotations.NetworkedField(targetSide = Side.CLIENT) public boolean teRingSwitch = true; + private static final double ROTATION_SPEED = 1.2; + @Override public AxisAlignedBB getRenderBoundingBox() { return INFINITE_EXTENT_AABB; @@ -26,15 +36,12 @@ public double getMaxRenderDistanceSquared() { return 65536; } - public double getCurrentRotation() { - return Rotation; - } - @Override public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); nbt.setBoolean("renderStatus", renderStatus); - nbt.setDouble("Rotation", Rotation); + nbt.setDouble("scale", scale); + nbt.setDouble("rotation", rotation); nbt.setBoolean("switch", teRingSwitch); } @@ -42,7 +49,8 @@ public void writeToNBT(NBTTagCompound nbt) { public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); renderStatus = nbt.getBoolean("renderStatus"); - Rotation = nbt.getDouble("Rotation"); + rotation = nbt.getDouble("rotation"); + scale = nbt.getDouble("scale"); teRingSwitch = nbt.getBoolean("switch"); } @@ -64,6 +72,16 @@ public boolean isNetworkedTile() { @Override public void updateEntity() { super.updateEntity(); - Rotation = (Rotation + 1.2) % 360d; + prevRotation = rotation; + rotation = (rotation + ROTATION_SPEED) % 360d; + } + + public double getInterpolatedRotation(float partialTicks) { + double delta = rotation - prevRotation; + + if (delta < -180.0) delta += 360.0; + if (delta > 180.0) delta -= 360.0; + + return (prevRotation + delta * partialTicks) % 360.0; } }