diff --git a/.gitignore b/.gitignore index 2f83d69..3bf601d 100644 --- a/.gitignore +++ b/.gitignore @@ -21,4 +21,5 @@ build/ # other eclipse run -*.blend1 \ No newline at end of file +*.blend1 +logs/* \ No newline at end of file diff --git a/build.gradle b/build.gradle index 05c9723..99b021d 100644 --- a/build.gradle +++ b/build.gradle @@ -131,11 +131,15 @@ def gitVersion(value) { def desc = (raw == null ? 'unknown-offset-hash' : grgit.describe(longDescr: true)).split('-') as List def vers = desc.get(1) def splis = vers.split(/[.]/) + def majver = splis[0].toInteger() def subver = splis[1].toInteger() def offset = splis[2].toInteger() def ver = offset + 1 if (subver < version_minor.toInteger()){ ver = 0 } + if (majver < version_major.toInteger()){ + ver = 0 + } return "${value}.${ver}" } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 087235b..65d34cc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,15 +3,16 @@ org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false -version_forge=31.1.0 -version_minecraft=1.15.2 -version_mcsupport=[1.15.2] -version_mappings=20200203-1.15.1 -version_thutcore=7.2.1 -version_cct=1.88.1 +version_forge=34.1.0 +version_minecraft=1.16.3 +version_mcsupport=[1.16.3] +version_mappings=20200916-1.16.2 -version_major=8 -version_minor=2 +version_thutcore=8.0.0 +version_cct=1.93.0 + +version_major=9 +version_minor=0 compile_name=thuttech author_name=Thutmose diff --git a/libs/thutcore-1.15.2-7.2.1-sources.jar b/libs/thutcore-1.16.3-8.0.0-sources.jar similarity index 54% rename from libs/thutcore-1.15.2-7.2.1-sources.jar rename to libs/thutcore-1.16.3-8.0.0-sources.jar index 1dd4898..c765bf8 100644 Binary files a/libs/thutcore-1.15.2-7.2.1-sources.jar and b/libs/thutcore-1.16.3-8.0.0-sources.jar differ diff --git a/libs/thutcore-1.15.2-7.2.1.jar b/libs/thutcore-1.16.3-8.0.0.jar similarity index 50% rename from libs/thutcore-1.15.2-7.2.1.jar rename to libs/thutcore-1.16.3-8.0.0.jar index f09e800..1f85d61 100644 Binary files a/libs/thutcore-1.15.2-7.2.1.jar and b/libs/thutcore-1.16.3-8.0.0.jar differ diff --git a/src/main/java/thut/tech/client/ClientProxy.java b/src/main/java/thut/tech/client/ClientProxy.java index dda4cb5..4da089f 100644 --- a/src/main/java/thut/tech/client/ClientProxy.java +++ b/src/main/java/thut/tech/client/ClientProxy.java @@ -10,17 +10,17 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.Matrix4f; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderTypeLookup; -import net.minecraft.client.renderer.Vector3f; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.RayTraceResult.Type; -import net.minecraft.util.math.Vec3d; +import net.minecraft.util.math.vector.Matrix4f; +import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.util.math.vector.Vector3f; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.client.event.RenderWorldLastEvent; @@ -51,13 +51,15 @@ public void RenderBounds(final RenderWorldLastEvent event) if (held.getTag() != null && held.getTag().contains("min")) { final Minecraft mc = Minecraft.getInstance(); - final Vec3d projectedView = mc.gameRenderer.getActiveRenderInfo().getProjectedView(); - Vec3d pointed = new Vec3d(projectedView.x, projectedView.y, projectedView.z).add(mc.player.getLook(event + final Vector3d projectedView = mc.gameRenderer.getActiveRenderInfo().getProjectedView(); + Vector3d pointed = new Vector3d(projectedView.x, projectedView.y, projectedView.z).add(mc.player + .getLook( + event .getPartialTicks())); if (mc.objectMouseOver != null && mc.objectMouseOver.getType() == Type.BLOCK) { final BlockRayTraceResult result = (BlockRayTraceResult) mc.objectMouseOver; - pointed = new Vec3d(result.getPos()); + pointed = new Vector3d(result.getPos().getX(), result.getPos().getY(), result.getPos().getZ()); // } final Vector3 v = Vector3.readFromNBT(held.getTag().getCompound("min"), ""); @@ -106,7 +108,7 @@ public void RenderBounds(final RenderWorldLastEvent event) mat.push(); - final Matrix4f positionMatrix = mat.getLast().getPositionMatrix(); + final Matrix4f positionMatrix = mat.getLast().getMatrix(); final IRenderTypeBuffer.Impl buffer = Minecraft.getInstance().getRenderTypeBuffers().getBufferSource(); final IVertexBuilder builder = buffer.getBuffer(RenderType.LINES); @@ -125,7 +127,7 @@ public void setupClient(final FMLClientSetupEvent event) RenderingRegistry.registerEntityRenderingHandler(EntityLift.TYPE, RenderLift::new); ClientRegistry.bindTileEntityRenderer(ControllerTile.TYPE, ControllerRenderer::new); - RenderTypeLookup.setRenderLayer(TechCore.LIFTCONTROLLER, t -> (t == RenderType.translucent() || t == RenderType - .cutoutMipped())); + RenderTypeLookup.setRenderLayer(TechCore.LIFTCONTROLLER, t -> (t == RenderType.getTranslucent() + || t == RenderType.getCutoutMipped())); } } diff --git a/src/main/java/thut/tech/client/render/ControllerRenderer.java b/src/main/java/thut/tech/client/render/ControllerRenderer.java index d018d92..922a6c5 100644 --- a/src/main/java/thut/tech/client/render/ControllerRenderer.java +++ b/src/main/java/thut/tech/client/render/ControllerRenderer.java @@ -14,7 +14,6 @@ import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.renderer.BlockRendererDispatcher; import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.Matrix4f; import net.minecraft.client.renderer.RenderState; import net.minecraft.client.renderer.RenderState.AlphaState; import net.minecraft.client.renderer.RenderState.TextureState; @@ -22,7 +21,6 @@ import net.minecraft.client.renderer.RenderState.WriteMaskState; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderTypeLookup; -import net.minecraft.client.renderer.Vector3f; import net.minecraft.client.renderer.model.IBakedModel; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; @@ -31,6 +29,8 @@ import net.minecraft.util.Direction; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.vector.Matrix4f; +import net.minecraft.util.math.vector.Vector3f; import net.minecraft.world.World; import net.minecraftforge.client.model.data.EmptyModelData; import net.minecraftforge.client.model.data.IModelData; @@ -64,7 +64,7 @@ private static void render(final RenderType type, final MatrixStack mat, final I final float a, final float u1, final float u2, final float v1, final float v2) { final IVertexBuilder buffer = buff.getBuffer(type); - final Matrix4f o = mat.getLast().getPositionMatrix(); + final Matrix4f o = mat.getLast().getMatrix(); buffer.pos(o, x2, y2, 0).color(r, g, b, a).tex(u1, v1).endVertex(); buffer.pos(o, x2, y1, 0).color(r, g, b, a).tex(u1, v2).endVertex(); buffer.pos(o, x1, y1, 0).color(r, g, b, a).tex(u2, v2).endVertex(); @@ -85,15 +85,15 @@ private static void render(final RenderType type, final MatrixStack mat, final I private static RenderType.State getState(final ResourceLocation texture) { - return RenderType.State.builder().texture(new TextureState(texture, false, true)).transparency( - ControllerRenderer.TRANSP).writeMask(ControllerRenderer.MASK).alpha(ControllerRenderer.ALPHA).build( - false); + return RenderType.State.getBuilder().texture(new TextureState(texture, false, true)) + .transparency(ControllerRenderer.TRANSP).writeMask(ControllerRenderer.MASK).alpha( + ControllerRenderer.ALPHA).build(false); } public static RenderType makeType(final ResourceLocation tex) { - return RenderType.get(tex.toString(), DefaultVertexFormats.POSITION_COLOR_TEX, GL11.GL_QUADS, 256, false, true, - ControllerRenderer.getState(tex)); + return RenderType.makeType(tex.toString(), DefaultVertexFormats.POSITION_COLOR_TEX, GL11.GL_QUADS, 256, false, + true, ControllerRenderer.getState(tex)); } private static RenderType NUMBERS = ControllerRenderer.makeType(ControllerRenderer.font); diff --git a/src/main/java/thut/tech/common/CommonProxy.java b/src/main/java/thut/tech/common/CommonProxy.java index 7b8f615..0b78fb7 100644 --- a/src/main/java/thut/tech/common/CommonProxy.java +++ b/src/main/java/thut/tech/common/CommonProxy.java @@ -4,9 +4,10 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.Hand; +import net.minecraft.util.Util; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; +import net.minecraft.util.math.vector.Vector3d; import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; @@ -31,7 +32,7 @@ public void interactRightClickBlock(final PlayerInteractEvent.RightClickBlock ev final ItemStack itemstack = evt.getItemStack(); final PlayerEntity playerIn = evt.getPlayer(); final World worldIn = evt.getWorld(); - if (!evt.getPlayer().isShiftKeyDown()) + if (!evt.getPlayer().isSneaking()) { if (itemstack.hasTag()) { @@ -39,14 +40,14 @@ public void interactRightClickBlock(final PlayerInteractEvent.RightClickBlock ev itemstack.getTag().remove("time"); if (itemstack.getTag().isEmpty()) itemstack.setTag(null); final String message = "msg.lift.reset"; - if (!worldIn.isRemote) playerIn.sendMessage(new TranslationTextComponent(message)); + if (!worldIn.isRemote) playerIn.sendMessage(new TranslationTextComponent(message), Util.DUMMY_UUID); evt.setCanceled(true); } return; } final BlockPos pos = evt.getPos(); - if (itemstack.hasTag() && playerIn.isShiftKeyDown() && itemstack.getTag().contains("min")) + if (itemstack.hasTag() && playerIn.isSneaking() && itemstack.getTag().contains("min")) { final CompoundNBT minTag = itemstack.getTag().getCompound("min"); itemstack.getTag().putLong("time", worldIn.getGameTime()); @@ -62,7 +63,7 @@ public void interactRightClickBlock(final PlayerInteractEvent.RightClickBlock ev if (max.getY() - min.getY() > TechCore.config.maxHeight || dw > 2 * TechCore.config.maxRadius + 1) { final String message = "msg.lift.toobig"; - if (!worldIn.isRemote) playerIn.sendMessage(new TranslationTextComponent(message)); + if (!worldIn.isRemote) playerIn.sendMessage(new TranslationTextComponent(message), Util.DUMMY_UUID); return; } final int num = (dw + 1) * (max.getY() - min.getY() + 1); @@ -72,18 +73,19 @@ public void interactRightClickBlock(final PlayerInteractEvent.RightClickBlock ev if (!playerIn.abilities.isCreativeMode && count < num) { final String message = "msg.lift.noblock"; - if (!worldIn.isRemote) playerIn.sendMessage(new TranslationTextComponent(message, num)); + if (!worldIn.isRemote) playerIn.sendMessage(new TranslationTextComponent(message, num), + Util.DUMMY_UUID); return; } - else if (!playerIn.abilities.isCreativeMode) playerIn.inventory.clearMatchingItems(b -> b - .getItem() == TechCore.LIFT, num); + else if (!playerIn.abilities.isCreativeMode) playerIn.inventory.func_234564_a_(b -> b + .getItem() == TechCore.LIFT, num, playerIn.container.func_234641_j_()); if (!worldIn.isRemote) { final EntityLift lift = IBlockEntity.BlockEntityFormer.makeBlockEntity(worldIn, min, max, mid, EntityLift.TYPE); if (lift != null) lift.owner = playerIn.getUniqueID(); final String message = lift != null ? "msg.lift.create" : "msg.lift.fail"; - playerIn.sendMessage(new TranslationTextComponent(message)); + playerIn.sendMessage(new TranslationTextComponent(message), Util.DUMMY_UUID); } itemstack.getTag().remove("min"); evt.setCanceled(true); @@ -95,7 +97,7 @@ else if (!playerIn.abilities.isCreativeMode) playerIn.inventory.clearMatchingIte Vector3.getNewVector().set(pos).writeToNBT(min, ""); itemstack.getTag().put("min", min); final String message = "msg.lift.setcorner"; - if (!worldIn.isRemote) playerIn.sendMessage(new TranslationTextComponent(message, pos)); + if (!worldIn.isRemote) playerIn.sendMessage(new TranslationTextComponent(message, pos), Util.DUMMY_UUID); evt.setCanceled(true); itemstack.getTag().putLong("time", worldIn.getGameTime()); } @@ -110,7 +112,7 @@ public void interactRightClickBlock(final PlayerInteractEvent.RightClickItem evt final PlayerEntity playerIn = evt.getPlayer(); final World worldIn = evt.getWorld(); - if (!evt.getPlayer().isShiftKeyDown()) + if (!evt.getPlayer().isSneaking()) { if (itemstack.hasTag()) { @@ -119,7 +121,7 @@ public void interactRightClickBlock(final PlayerInteractEvent.RightClickItem evt if (itemstack.getTag().isEmpty()) itemstack.setTag(null); } final String message = "msg.lift.reset"; - if (!worldIn.isRemote) playerIn.sendMessage(new TranslationTextComponent(message)); + if (!worldIn.isRemote) playerIn.sendMessage(new TranslationTextComponent(message), Util.DUMMY_UUID); return; } @@ -128,7 +130,8 @@ public void interactRightClickBlock(final PlayerInteractEvent.RightClickItem evt if (validTag && !alreadyUsed) { final CompoundNBT minTag = itemstack.getTag().getCompound("min"); - final Vec3d loc = playerIn.getPositionVector().add(0, playerIn.getEyeHeight(), 0).add(playerIn.getLookVec() + final Vector3d loc = playerIn.getPositionVec().add(0, playerIn.getEyeHeight(), 0).add(playerIn + .getLookVec() .scale(2)); final BlockPos pos = new BlockPos(loc); BlockPos min = pos; @@ -143,7 +146,7 @@ public void interactRightClickBlock(final PlayerInteractEvent.RightClickItem evt if (max.getY() - min.getY() > TechCore.config.maxHeight || dw > 2 * TechCore.config.maxRadius + 1) { final String message = "msg.lift.toobig"; - if (!worldIn.isRemote) playerIn.sendMessage(new TranslationTextComponent(message)); + if (!worldIn.isRemote) playerIn.sendMessage(new TranslationTextComponent(message), Util.DUMMY_UUID); return; } final int num = (dw + 1) * (max.getY() - min.getY() + 1); @@ -153,18 +156,19 @@ public void interactRightClickBlock(final PlayerInteractEvent.RightClickItem evt if (!playerIn.abilities.isCreativeMode && count < num) { final String message = "msg.lift.noblock"; - if (!worldIn.isRemote) playerIn.sendMessage(new TranslationTextComponent(message, num)); + if (!worldIn.isRemote) playerIn.sendMessage(new TranslationTextComponent(message, num), + Util.DUMMY_UUID); return; } - else if (!playerIn.abilities.isCreativeMode) playerIn.inventory.clearMatchingItems(i -> i - .getItem() == TechCore.LIFT, num); + else if (!playerIn.abilities.isCreativeMode) playerIn.inventory.func_234564_a_(i -> i + .getItem() == TechCore.LIFT, num, playerIn.container.func_234641_j_()); if (!worldIn.isRemote) { final EntityLift lift = IBlockEntity.BlockEntityFormer.makeBlockEntity(worldIn, min, max, mid, EntityLift.TYPE); if (lift != null) lift.owner = playerIn.getUniqueID(); final String message = lift != null ? "msg.lift.create" : "msg.lift.fail"; - playerIn.sendMessage(new TranslationTextComponent(message)); + playerIn.sendMessage(new TranslationTextComponent(message), Util.DUMMY_UUID); } itemstack.getTag().remove("min"); } diff --git a/src/main/java/thut/tech/common/TechCore.java b/src/main/java/thut/tech/common/TechCore.java index e0ec48e..ed11fc6 100644 --- a/src/main/java/thut/tech/common/TechCore.java +++ b/src/main/java/thut/tech/common/TechCore.java @@ -81,7 +81,8 @@ public static void registerTiles(final RegistryEvent.Register> public final static PacketHandler packets = new PacketHandler(new ResourceLocation(Reference.MOD_ID, "comms"), Reference.NETVERSION); - public static final CommonProxy proxy = DistExecutor.runForDist(() -> () -> new ClientProxy(), + public static final CommonProxy proxy = DistExecutor.safeRunForDist( + () -> () -> new ClientProxy(), () -> () -> new CommonProxy()); public static Block LIFTCONTROLLER; diff --git a/src/main/java/thut/tech/common/blocks/lift/ControllerBlock.java b/src/main/java/thut/tech/common/blocks/lift/ControllerBlock.java index 1520e52..85b476e 100644 --- a/src/main/java/thut/tech/common/blocks/lift/ControllerBlock.java +++ b/src/main/java/thut/tech/common/blocks/lift/ControllerBlock.java @@ -15,6 +15,7 @@ import net.minecraft.util.ActionResultType; import net.minecraft.util.Direction; import net.minecraft.util.Hand; +import net.minecraft.util.Util; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.text.TranslationTextComponent; @@ -124,7 +125,7 @@ public ActionResultType onBlockActivated(final BlockState state, final World wor final ItemStack heldItem = playerIn.getHeldItem(handIn); final Direction side = hit.getFace(); final boolean linkerOrStick = heldItem.getItem() == Items.STICK || heldItem.getItem() == TechCore.LINKER; - if (linkerOrStick && playerIn.isShiftKeyDown()) + if (linkerOrStick && playerIn.isSneaking()) { final ControllerTile te = (ControllerTile) worldIn.getTileEntity(pos); if (te == null) return ActionResultType.PASS; @@ -173,7 +174,7 @@ else if (te.isSideOn(side)) if (heldItem.getItem() == TechCore.LINKER) } return ActionResultType.SUCCESS; } - else if (!playerIn.isShiftKeyDown()) + else if (!playerIn.isSneaking()) { final float hitX = (float) hit.getHitVec().x; final float hitY = (float) hit.getHitVec().y; @@ -182,22 +183,25 @@ else if (!playerIn.isShiftKeyDown()) : ActionResultType.PASS; } - if (playerIn.isShiftKeyDown() && handIn == Hand.MAIN_HAND && playerIn instanceof ServerPlayerEntity) + if (playerIn.isSneaking() && handIn == Hand.MAIN_HAND && playerIn instanceof ServerPlayerEntity) { final boolean sideOn = !te.isSideOn(side); - playerIn.sendMessage(new TranslationTextComponent("msg.lift.side." + (sideOn ? "on" : "off"))); + playerIn.sendMessage(new TranslationTextComponent("msg.lift.side." + (sideOn ? "on" : "off")), + Util.DUMMY_UUID); if (sideOn) { final boolean call = te.isCallPanel(side); final boolean edit = te.isEditMode(side); final boolean display = te.isFloorDisplay(side); - if (edit) playerIn.sendMessage(new TranslationTextComponent("msg.lift.side.edit")); - else if (call) playerIn.sendMessage(new TranslationTextComponent("msg.lift.side.call")); - else if (display) playerIn.sendMessage(new TranslationTextComponent("msg.lift.side.display")); + if (edit) playerIn.sendMessage(new TranslationTextComponent("msg.lift.side.edit"), Util.DUMMY_UUID); + else if (call) playerIn.sendMessage(new TranslationTextComponent("msg.lift.side.call"), + Util.DUMMY_UUID); + else if (display) playerIn.sendMessage(new TranslationTextComponent("msg.lift.side.display"), + Util.DUMMY_UUID); else { final int page = te.getSidePage(side); - playerIn.sendMessage(new TranslationTextComponent("msg.lift.side.page", page)); + playerIn.sendMessage(new TranslationTextComponent("msg.lift.side.page", page), Util.DUMMY_UUID); } } } diff --git a/src/main/java/thut/tech/common/blocks/lift/ControllerTile.java b/src/main/java/thut/tech/common/blocks/lift/ControllerTile.java index b413844..077dc97 100644 --- a/src/main/java/thut/tech/common/blocks/lift/ControllerTile.java +++ b/src/main/java/thut/tech/common/blocks/lift/ControllerTile.java @@ -15,6 +15,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.Direction; +import net.minecraft.util.Util; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.World; @@ -120,13 +121,14 @@ public boolean doButtonClick(final LivingEntity clicker, final Direction side, f case 1: this.callFaces[side.ordinal()] = !this.isCallPanel(side); this.floorDisplay[side.ordinal()] = false; - clicker.sendMessage(new TranslationTextComponent(message, this.isCallPanel(side))); + clicker.sendMessage(new TranslationTextComponent(message, this.isCallPanel(side)), Util.DUMMY_UUID); break; case 2: this.floorDisplay[side.ordinal()] = !this.isFloorDisplay(side); this.callFaces[side.ordinal()] = false; message = "msg.floorDisplay"; - clicker.sendMessage(new TranslationTextComponent(message, this.isFloorDisplay(side))); + clicker.sendMessage(new TranslationTextComponent(message, this.isFloorDisplay(side)), + Util.DUMMY_UUID); break; case 13: if (this.getLift() != null) this.setLift(null); @@ -134,7 +136,7 @@ public boolean doButtonClick(final LivingEntity clicker, final Direction side, f case 16: this.editFace[side.ordinal()] = false; message = "msg.editMode"; - clicker.sendMessage(new TranslationTextComponent(message, false)); + clicker.sendMessage(new TranslationTextComponent(message, false), Util.DUMMY_UUID); break; } if (clicker instanceof ServerPlayerEntity) this.sendUpdate((ServerPlayerEntity) clicker); @@ -227,9 +229,9 @@ public CompoundNBT getUpdateTag() } @Override - public void handleUpdateTag(final CompoundNBT tag) + public void handleUpdateTag(final BlockState stateIn, final CompoundNBT tag) { - this.read(tag); + this.read(stateIn, tag); } public boolean isSideOn(final Direction side) @@ -255,9 +257,9 @@ public boolean isEditMode(final Direction side) } @Override - public void read(final CompoundNBT par1) + public void read(final BlockState stateIn, final CompoundNBT par1) { - super.read(par1); + super.read(stateIn, par1); this.floor = par1.getInt("floor"); // Reset this so that it will re-find after loading. this.lift = null; @@ -385,7 +387,7 @@ public void tick() // Set lifts current floor to this if it is in the area of the // floor. - if ((int) Math.round(this.getLift().posY) == yWhenLiftHere) lift.setCurrentFloor(this.floor); + if ((int) Math.round(this.getLift().getPosY()) == yWhenLiftHere) lift.setCurrentFloor(this.floor); else if (this.getLift().getCurrentFloor() == this.floor) lift.setCurrentFloor(-1); // Below here is server side only for these checks diff --git a/src/main/java/thut/tech/common/entity/EntityLift.java b/src/main/java/thut/tech/common/entity/EntityLift.java index fb2c077..694f755 100644 --- a/src/main/java/thut/tech/common/entity/EntityLift.java +++ b/src/main/java/thut/tech/common/entity/EntityLift.java @@ -17,7 +17,7 @@ import net.minecraft.network.datasync.DataSerializers; import net.minecraft.network.datasync.EntityDataManager; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.Vec3d; +import net.minecraft.util.math.vector.Vector3d; import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; import net.minecraftforge.common.MinecraftForge; @@ -92,7 +92,7 @@ public static EntityLift getLiftFromUUID(final UUID liftID, final World world) private final Vector3f velocity = new Vector3f(); - private Vec3d motion = new Vec3d(0, 0, 0); + private Vector3d motion = new Vector3d(0, 0, 0); EntitySize size; @@ -113,15 +113,15 @@ public void accelerate() if (this.isServerWorld() && !this.consumePower()) { this.toMoveY = this.toMoveX = this.toMoveZ = false; - this.setDestX((float) this.posX); + this.setDestX((float) this.getPosX()); this.setCalled(false); } else { // Otherwise set it to move if it has a destination. - this.toMoveX = this.getDestX() != this.posX; - this.toMoveY = this.getDestY() != this.posY; - this.toMoveZ = this.getDestZ() != this.posZ; + this.toMoveX = this.getDestX() != this.getPosX(); + this.toMoveY = this.getDestY() != this.getPosY(); + this.toMoveZ = this.getDestZ() != this.getPosZ(); } if (!(this.toMoveX || this.toMoveY || this.toMoveZ)) this.setCalled(false); @@ -141,46 +141,46 @@ public void accelerate() final float destY = this.getDestY(); // If Sufficiently close (0,01 blocks) just snap the elevator to // the destination. - if (Math.abs(destY - this.posY) < 0.01) + if (Math.abs(destY - this.getPosY()) < 0.01) { - this.setPosition(this.posX, destY, this.posZ); + this.setPosition(this.getPosX(), destY, this.getPosZ()); this.toMoveY = false; this.velocity.y = 0; } else { // Otherwise accelerate accordingly. - final double dy = this.getSpeed(this.posY, destY, this.velocity.y, speedUp, speedDown); + final double dy = this.getSpeed(this.getPosY(), destY, this.velocity.y, speedUp, speedDown); this.velocity.y = (float) dy; } } if (this.toMoveX) { final float destX = this.getDestX(); - if (Math.abs(destX - this.posX) < 0.01) + if (Math.abs(destX - this.getPosX()) < 0.01) { - this.setPosition(destX, this.posY, this.posZ); + this.setPosition(destX, this.getPosY(), this.getPosZ()); this.toMoveX = false; this.velocity.x = 0; } else { - final double dx = this.getSpeed(this.posX, destX, this.velocity.x, speedHoriz, speedHoriz); + final double dx = this.getSpeed(this.getPosX(), destX, this.velocity.x, speedHoriz, speedHoriz); this.velocity.x = (float) dx; } } if (this.toMoveZ) { final float destZ = this.getDestZ(); - if (Math.abs(destZ - this.posZ) < 0.01) + if (Math.abs(destZ - this.getPosZ()) < 0.01) { - this.setPosition(this.posX, this.posY, destZ); + this.setPosition(this.getPosX(), this.getPosY(), destZ); this.toMoveZ = false; this.velocity.z = 0; } else { - final double dz = this.getSpeed(this.posZ, destZ, this.velocity.z, speedHoriz, speedHoriz); + final double dz = this.getSpeed(this.getPosZ(), destZ, this.velocity.z, speedHoriz, speedHoriz); this.velocity.z = (float) dz; } } @@ -189,23 +189,13 @@ public void accelerate() } @Override - public void setRawPosition(final double x, final double y, final double z) - { - this.posX = x; - this.posY = y; - this.posZ = z; - if (this.isAddedToWorld() && !this.world.isRemote && this.isAlive()) this.world.getChunk((int) Math.floor( - this.posX) >> 4, (int) Math.floor(this.posZ) >> 4); - } - - @Override - public Vec3d getMotion() + public Vector3d getMotion() { return this.motion; } @Override - public void setMotion(final Vec3d vec) + public void setMotion(final Vector3d vec) { this.motion = vec; } @@ -245,7 +235,7 @@ private boolean consumePower() boolean power = false; final Vector3 bounds = Vector3.getNewVector().set(this.boundMax.subtract(this.boundMin)); final double volume = bounds.x * bounds.y * bounds.z; - int energyCost = (int) (Math.abs(this.getDestY() - this.posY) * EntityLift.ENERGYCOST * volume * 0.01); + int energyCost = (int) (Math.abs(this.getDestY() - this.getPosY()) * EntityLift.ENERGYCOST * volume * 0.01); energyCost = Math.max(energyCost, 1); final int canExtract = this.energy.extractEnergy(energyCost, true); if (canExtract == energyCost) @@ -257,7 +247,7 @@ private boolean consumePower() if (!power) { this.setDestinationFloor(-1); - this.setDestY((float) this.posY); + this.setDestY((float) this.getPosY()); this.setCalled(false); this.toMoveY = false; } @@ -435,8 +425,8 @@ public void setDestinationFloor(final int destinationFloor) public void setDestX(final float dest) { this.dataManager.set(EntityLift.DESTINATIONXDW, Float.valueOf(dest)); - this.dataManager.set(EntityLift.DESTINATIONYDW, Float.valueOf((float) this.posY)); - this.dataManager.set(EntityLift.DESTINATIONZDW, Float.valueOf((float) this.posZ)); + this.dataManager.set(EntityLift.DESTINATIONYDW, Float.valueOf((float) this.getPosY())); + this.dataManager.set(EntityLift.DESTINATIONZDW, Float.valueOf((float) this.getPosZ())); this.setCalled(true); } @@ -447,8 +437,8 @@ public void setDestX(final float dest) public void setDestY(final float dest) { this.dataManager.set(EntityLift.DESTINATIONYDW, Float.valueOf(dest)); - this.dataManager.set(EntityLift.DESTINATIONXDW, Float.valueOf((float) this.posX)); - this.dataManager.set(EntityLift.DESTINATIONZDW, Float.valueOf((float) this.posZ)); + this.dataManager.set(EntityLift.DESTINATIONXDW, Float.valueOf((float) this.getPosX())); + this.dataManager.set(EntityLift.DESTINATIONZDW, Float.valueOf((float) this.getPosZ())); this.setCalled(true); } @@ -459,8 +449,8 @@ public void setDestY(final float dest) public void setDestZ(final float dest) { this.dataManager.set(EntityLift.DESTINATIONZDW, Float.valueOf(dest)); - this.dataManager.set(EntityLift.DESTINATIONYDW, Float.valueOf((float) this.posY)); - this.dataManager.set(EntityLift.DESTINATIONXDW, Float.valueOf((float) this.posX)); + this.dataManager.set(EntityLift.DESTINATIONYDW, Float.valueOf((float) this.getPosY())); + this.dataManager.set(EntityLift.DESTINATIONXDW, Float.valueOf((float) this.getPosX())); this.setCalled(true); } diff --git a/src/main/java/thut/tech/common/entity/LiftInteractHandler.java b/src/main/java/thut/tech/common/entity/LiftInteractHandler.java index e7b8f3a..c6740eb 100644 --- a/src/main/java/thut/tech/common/entity/LiftInteractHandler.java +++ b/src/main/java/thut/tech/common/entity/LiftInteractHandler.java @@ -9,6 +9,7 @@ import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; +import net.minecraft.util.Util; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.TranslationTextComponent; import thut.api.entity.blockentity.BlockEntityInteractHandler; @@ -35,7 +36,8 @@ public ActionResultType interactInternal(final PlayerEntity player, final BlockP } @Override - public boolean processInitialInteract(final PlayerEntity player, @Nullable ItemStack stack, final Hand hand) + public ActionResultType processInitialInteract(final PlayerEntity player, @Nullable ItemStack stack, + final Hand hand) { final boolean isElevatorItemOrStick = stack.getItem() == Items.STICK || stack.getItem() == TechCore.LIFT; @@ -44,10 +46,10 @@ public boolean processInitialInteract(final PlayerEntity player, @Nullable ItemS final boolean canEdit = this.lift.owner != null && player.getUniqueID().equals(this.lift.owner) || player.abilities.isCreativeMode; - final boolean shouldLinkLift = player.isShiftKeyDown() && isLinker && canEdit; + final boolean shouldLinkLift = player.isSneaking() && isLinker && canEdit; final boolean shouldKillLiftUnowned = this.lift.owner == null; final boolean shouldDisplayOwner = isLinker && canEdit; - final boolean shouldKillLiftOwned = player.isShiftKeyDown() && isElevatorItemOrStick && canEdit; + final boolean shouldKillLiftOwned = player.isSneaking() && isElevatorItemOrStick && canEdit; if (shouldKillLiftUnowned) { @@ -55,7 +57,7 @@ public boolean processInitialInteract(final PlayerEntity player, @Nullable ItemS if (!this.lift.getEntityWorld().isRemote) { final String message = "msg.lift.killed"; - player.sendMessage(new TranslationTextComponent(message)); + player.sendMessage(new TranslationTextComponent(message), Util.DUMMY_UUID); if (LiftInteractHandler.DROPSPARTS) { final BlockPos max = this.lift.boundMax; @@ -68,7 +70,7 @@ public boolean processInitialInteract(final PlayerEntity player, @Nullable ItemS } this.lift.remove(); } - return true; + return ActionResultType.SUCCESS; } else if (shouldLinkLift) { @@ -77,8 +79,9 @@ else if (shouldLinkLift) final String message = "msg.liftSet"; - if (!this.lift.getEntityWorld().isRemote) player.sendMessage(new TranslationTextComponent(message)); - return true; + if (!this.lift.getEntityWorld().isRemote) player.sendMessage(new TranslationTextComponent(message), + Util.DUMMY_UUID); + return ActionResultType.SUCCESS; } else if (shouldDisplayOwner) { @@ -87,16 +90,16 @@ else if (shouldDisplayOwner) final Entity ownerentity = this.lift.getEntityWorld().getPlayerByUuid(this.lift.owner); final String message = "msg.lift.owner"; - player.sendMessage(new TranslationTextComponent(message, ownerentity.getName())); + player.sendMessage(new TranslationTextComponent(message, ownerentity.getName()), Util.DUMMY_UUID); } - return true; + return ActionResultType.SUCCESS; } else if (shouldKillLiftOwned) { if (!this.lift.getEntityWorld().isRemote) { final String message = "msg.lift.killed"; - player.sendMessage(new TranslationTextComponent(message)); + player.sendMessage(new TranslationTextComponent(message), Util.DUMMY_UUID); if (LiftInteractHandler.DROPSPARTS) { final BlockPos max = this.lift.boundMax; @@ -109,8 +112,8 @@ else if (shouldKillLiftOwned) } this.lift.remove(); } - return true; + return ActionResultType.SUCCESS; } - return false; + return ActionResultType.PASS; } } diff --git a/src/main/java/thut/tech/common/items/ItemLinker.java b/src/main/java/thut/tech/common/items/ItemLinker.java index f3ad3e0..d5571f3 100644 --- a/src/main/java/thut/tech/common/items/ItemLinker.java +++ b/src/main/java/thut/tech/common/items/ItemLinker.java @@ -10,6 +10,7 @@ import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.ActionResultType; import net.minecraft.util.Direction; +import net.minecraft.util.Util; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TranslationTextComponent; @@ -46,7 +47,7 @@ public ActionResultType onItemUse(final ItemUseContext context) if (!stack.hasTag()) return ActionResultType.PASS; else { - if (state.getBlock() == TechCore.LIFTCONTROLLER && !playerIn.isShiftKeyDown()) + if (state.getBlock() == TechCore.LIFTCONTROLLER && !playerIn.isSneaking()) { final ControllerTile te = (ControllerTile) worldIn.getTileEntity(pos); te.setSide(face, true); @@ -63,7 +64,7 @@ public ActionResultType onItemUse(final ItemUseContext context) liftID = new UUID(0000, 0000); } final EntityLift lift = EntityLift.getLiftFromUUID(liftID, worldIn); - if (playerIn.isShiftKeyDown() && lift != null && state.getBlock() == TechCore.LIFTCONTROLLER) + if (playerIn.isSneaking() && lift != null && state.getBlock() == TechCore.LIFTCONTROLLER) { if (face != Direction.UP && face != Direction.DOWN) { @@ -74,11 +75,12 @@ public ActionResultType onItemUse(final ItemUseContext context) te.setFloor(floor); if (floor >= 64) floor = 64 - floor; final String message = "msg.floorSet"; - if (!worldIn.isRemote) playerIn.sendMessage(new TranslationTextComponent(message, floor)); + if (!worldIn.isRemote) playerIn.sendMessage(new TranslationTextComponent(message, floor), + Util.DUMMY_UUID); return ActionResultType.SUCCESS; } } - else if (playerIn.isShiftKeyDown() && state.getBlock() == TechCore.LIFTCONTROLLER) + else if (playerIn.isSneaking() && state.getBlock() == TechCore.LIFTCONTROLLER) { if (face != Direction.UP && face != Direction.DOWN) { @@ -87,15 +89,15 @@ else if (playerIn.isShiftKeyDown() && state.getBlock() == TechCore.LIFTCONTROLLE te.setSidePage(face, 0); final String message = "msg.editMode"; if (!worldIn.isRemote) playerIn.sendMessage(new TranslationTextComponent(message, te.editFace[face - .ordinal()])); + .ordinal()]), Util.DUMMY_UUID); return ActionResultType.SUCCESS; } } - else if (playerIn.isShiftKeyDown()) + else if (playerIn.isSneaking()) { stack.setTag(new CompoundNBT()); final String message = "msg.linker.reset"; - if (!worldIn.isRemote) playerIn.sendMessage(new TranslationTextComponent(message)); + if (!worldIn.isRemote) playerIn.sendMessage(new TranslationTextComponent(message), Util.DUMMY_UUID); } } return ActionResultType.PASS; diff --git a/src/main/java/thut/tech/compat/cct/Peripherals.java b/src/main/java/thut/tech/compat/cct/Peripherals.java index 6e9de6c..ab0f20b 100644 --- a/src/main/java/thut/tech/compat/cct/Peripherals.java +++ b/src/main/java/thut/tech/compat/cct/Peripherals.java @@ -40,11 +40,11 @@ public Provider(final ControllerTile tile) public boolean moveBy(final String axis, final float amount) throws LuaException { if (this.tile.getLift() == null) throw new LuaException("No Elevator Linked!"); - if (axis.equalsIgnoreCase("x")) this.tile.getLift().setDestX((float) (this.tile.getLift().posX + if (axis.equalsIgnoreCase("x")) this.tile.getLift().setDestX((float) (this.tile.getLift().getPosX() + amount)); - if (axis.equalsIgnoreCase("y")) this.tile.getLift().setDestY((float) (this.tile.getLift().posY + if (axis.equalsIgnoreCase("y")) this.tile.getLift().setDestY((float) (this.tile.getLift().getPosY() + amount)); - if (axis.equalsIgnoreCase("z")) this.tile.getLift().setDestZ((float) (this.tile.getLift().posZ + if (axis.equalsIgnoreCase("z")) this.tile.getLift().setDestZ((float) (this.tile.getLift().getPosZ() + amount)); return true; } @@ -62,7 +62,8 @@ public boolean goTo(int floor) throws LuaException public double[] find() throws LuaException { if (this.tile.getLift() == null) throw new LuaException("No Elevator Linked!"); - return new double[] { this.tile.getLift().posX, this.tile.getLift().posY, this.tile.getLift().posZ }; + return new double[] { this.tile.getLift().getPosX(), this.tile.getLift().getPosY(), this.tile.getLift() + .getPosZ() }; } diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index f4cb079..f45d3ff 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -1,5 +1,6 @@ modLoader="javafml" loaderVersion="[31,)" +license="All rights reserved" issueTrackerURL="https://github.com/Thutmose/Thut/issues" diff --git a/src/main/resources/pack.mcmeta b/src/main/resources/pack.mcmeta index cad683d..db26742 100644 --- a/src/main/resources/pack.mcmeta +++ b/src/main/resources/pack.mcmeta @@ -1,7 +1,7 @@ { "pack": { "description": "thuttech resources", - "pack_format": 4, + "pack_format": 6, "_comment": "A pack_format of 4 requires json lang files. Note: we require v4 pack meta for all mods." } }