From e6b9edc4987d9567fa59bead50bee45332336368 Mon Sep 17 00:00:00 2001 From: yor42 Date: Tue, 26 Nov 2024 07:59:21 +0900 Subject: [PATCH] make waypoint is visible when player is holding waypoint or wrench --- .../lulan/shincolle/block/BlockLightLiquid.java | 8 ++++++++ .../shincolle/client/model/ModelWayPoint.java | 2 +- .../client/render/block/RenderWaypoint.java | 15 ++++++++------- .../shincolle/tileentity/TileEntityWaypoint.java | 11 +---------- .../com/lulan/shincolle/utility/MathHelper.java | 11 +++++++++++ .../textures/blocks/blockwaypointrender.png | Bin 0 -> 869 bytes 6 files changed, 29 insertions(+), 18 deletions(-) create mode 100644 src/main/java/com/lulan/shincolle/utility/MathHelper.java create mode 100644 src/main/resources/assets/shincolle/textures/blocks/blockwaypointrender.png diff --git a/src/main/java/com/lulan/shincolle/block/BlockLightLiquid.java b/src/main/java/com/lulan/shincolle/block/BlockLightLiquid.java index e803cded..d45b8798 100644 --- a/src/main/java/com/lulan/shincolle/block/BlockLightLiquid.java +++ b/src/main/java/com/lulan/shincolle/block/BlockLightLiquid.java @@ -11,6 +11,7 @@ import net.minecraft.client.renderer.block.statemap.StateMap; import net.minecraft.item.Item; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; @@ -64,6 +65,13 @@ public String getTranslationKey() { return String.format("tile.%s%s", Tags.MOD_ID + ":", getUnwrappedUnlocalizedName(super.getTranslationKey())); } + @Override + public boolean doesSideBlockRendering(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing face) { + Material mat = world.getBlockState(pos.offset(face)).getMaterial(); + + return !mat.isLiquid(); + } + @Override public TileEntity createNewTileEntity(World world, int meta) { return new TileEntityLightBlock(); diff --git a/src/main/java/com/lulan/shincolle/client/model/ModelWayPoint.java b/src/main/java/com/lulan/shincolle/client/model/ModelWayPoint.java index 59b74694..8456ce25 100644 --- a/src/main/java/com/lulan/shincolle/client/model/ModelWayPoint.java +++ b/src/main/java/com/lulan/shincolle/client/model/ModelWayPoint.java @@ -11,7 +11,7 @@ public class ModelWayPoint extends ModelBase { public final ModelRenderer waypoint; public ModelWayPoint(){ - this.textureWidth = 16; + this.textureWidth = 32; this.textureHeight = 16; this.waypoint = new ModelRenderer(this, 0, 0); this.waypoint.setRotationPoint(0.0F, 0.0F, 0.0F); diff --git a/src/main/java/com/lulan/shincolle/client/render/block/RenderWaypoint.java b/src/main/java/com/lulan/shincolle/client/render/block/RenderWaypoint.java index ee4fc040..1a8a5350 100644 --- a/src/main/java/com/lulan/shincolle/client/render/block/RenderWaypoint.java +++ b/src/main/java/com/lulan/shincolle/client/render/block/RenderWaypoint.java @@ -17,11 +17,13 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; +import static com.lulan.shincolle.utility.MathHelper.RadianToDegrees; + public class RenderWaypoint extends TileEntitySpecialRenderer { private final ModelWayPoint model_waypoint; - private static final ResourceLocation TEXTURE = new ResourceLocation(Tags.TEXTURES_BLOCKS + "blockwaypoint.png"); + private static final ResourceLocation TEXTURE = new ResourceLocation(Tags.TEXTURES_BLOCKS + "blockwaypointrender.png"); public RenderWaypoint(){ this.model_waypoint = new ModelWayPoint(); @@ -37,10 +39,9 @@ public void render(TileEntityWaypoint te, double x, double y, double z, float pa return; } - BlockPos pos = te.getPos(); double distX = pos.getX() + 0.5D - player.posX; - double distY = pos.getY() - 0.75D - player.posY; + double distY = pos.getY() - 0.5D - player.posY; double distZ = pos.getZ() + 0.5D - player.posZ; float f1 = MathHelper.sqrt(distX * distX + distZ * distZ); float pitch = (float) (Math.atan2(f1, distY)); @@ -48,11 +49,11 @@ public void render(TileEntityWaypoint te, double x, double y, double z, float pa Minecraft.getMinecraft().renderEngine.bindTexture(TEXTURE); GlStateManager.pushMatrix(); - GlStateManager.depthMask(ConfigHandler.vortexDepth); + GlStateManager.depthMask(true); GlStateManager.translate((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.5F); - GlStateManager.rotate(yaw * 57.2957F, 0F, 1F, 0F); - GlStateManager.rotate(pitch * 57.2957F, 1F, 0F, 0F); - this.model_waypoint.render(0.03125F); + GlStateManager.rotate(RadianToDegrees(yaw), 0F, 1F, 0F); + GlStateManager.rotate(RadianToDegrees(pitch)+90, 1F, 0F, 0F); + this.model_waypoint.render(0.05F); GlStateManager.depthMask(true); GlStateManager.popMatrix(); } diff --git a/src/main/java/com/lulan/shincolle/tileentity/TileEntityWaypoint.java b/src/main/java/com/lulan/shincolle/tileentity/TileEntityWaypoint.java index bc1eb83e..690bf729 100644 --- a/src/main/java/com/lulan/shincolle/tileentity/TileEntityWaypoint.java +++ b/src/main/java/com/lulan/shincolle/tileentity/TileEntityWaypoint.java @@ -97,16 +97,7 @@ public void update() { this.tick++; //client side - if (this.world.isRemote) { - //valid tile - this.world.getBlockState(this.pos).getBlock(); - this.invalidate(); - return; - - //show client particle: player hold waypoint or target wrench - }//end client side - //server side - else { + if (!this.world.isRemote) { //get owner entity if ((this.tick & 15) == 0 && this.owner == null && this.playerUID > 0) { this.owner = EntityHelper.getEntityPlayerByUID(this.playerUID); diff --git a/src/main/java/com/lulan/shincolle/utility/MathHelper.java b/src/main/java/com/lulan/shincolle/utility/MathHelper.java new file mode 100644 index 00000000..c6ecc059 --- /dev/null +++ b/src/main/java/com/lulan/shincolle/utility/MathHelper.java @@ -0,0 +1,11 @@ +package com.lulan.shincolle.utility; + +public class MathHelper { + public static float DegreesToRadian(float degrees){ + return degrees * (float)Math.PI / 180; + } + + public static float RadianToDegrees(float radian){ + return radian * 180 / (float)Math.PI; + } +} diff --git a/src/main/resources/assets/shincolle/textures/blocks/blockwaypointrender.png b/src/main/resources/assets/shincolle/textures/blocks/blockwaypointrender.png new file mode 100644 index 0000000000000000000000000000000000000000..a0ae2fdc615947bca982258c22d3436e4bcf8ce6 GIT binary patch literal 869 zcmV-r1DgDaP)YB|47uLXSUOpVEn*1%0SjH|Rz$6e z>*7WiS=CP_@PIet}R4G&LCrNEVr-xifR;-}|_jn=zRrHMsGC z!#($$^E~Hy-}9bhlK4Mi09Sx7vW%6%fZUAKj3+~276ecNJMIi59!b2MruJ!3=%!=< zADii>WWUbNYKjlQd{Nj*1_D4IxYg;f2Xx%ITb8=j?M`wtkU*m2&fa*f`Ugb%z}GQq zpN}-=Fpl7}81+>M$EG>}T+1>x-B~izpYCeJNM?osqe?8Au?sAj*`_}1N5p0&5UP4AOZ3ixjr+a*OP?jVkFELh2_9`Gj=2zAplS_ z!-1j10BA`p#ArX1rJ6uKmC7b?HA(bFzi+LIGnDX33!o7KI}+#3$bqN!_ACILiP1)8 z)PcGgxf!`cArZ`I1BFE0jJ7+)m~+TL0kqx6eTg;@%qS#siQJ5Owa3Ve#ZJd2H30Bd znp$E;Ed=U7vY!E9%bn-VtQG<;aksiX2l2CHUKQT^y`F7VN9mPT9jJvsV#ejNobbaz zkt^-C-RO30Ax*9C&W1ZJi5~D`ug8sUR}ZSS^F=Z3fd|0nF^cN^TM`@Y^xb)(EbZx{ zu<0v#$iN0Lbmw+i^2caoYwm0T?_IcH-zJHM?ra>{_9*|mG}Yx^&$fUycRm~rPkaXe z*v>MxvvD0SA2WZiUgxiK=U4{$rAw1>Nk`f;=(zEdTA1D}0JrTQ!(RehySx0-Y$^bn zn|o|90r=^JN9Q;s(*sQ)NPGg!0j~isB?ZyLWzwhnxA%3}y09Qb(~ vcokR$RwZW7p2ZdyS(R8ljar3${%P