diff --git a/src/main/java/com/simibubi/create/compat/jei/category/MechanicalCraftingCategory.java b/src/main/java/com/simibubi/create/compat/jei/category/MechanicalCraftingCategory.java index ad55adc1c..5b3406708 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/MechanicalCraftingCategory.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/MechanicalCraftingCategory.java @@ -43,9 +43,8 @@ public class MechanicalCraftingCategory extends CreateRecipeCategory 31) startAnimation(Animation.CREEPER); } else { - float value = animationProgress.value; - animationProgress.set(value + 1); + float value = animationProgress.getValue(); + animationProgress.setValue(value + 1); if (value > 100) animationType = Animation.NONE; - if (animationType == Animation.SURPRISE && animationProgress.value == 50) { + if (animationType == Animation.SURPRISE && Mth.equal(animationProgress.getValue(), 50)) { Vec3 center = VecHelper.getCenterOf(worldPosition); level.destroyBlock(worldPosition, false); level.explode(null, CUCKOO_SURPRISE, null, center.x, center.y, center.z, 3, false, @@ -127,8 +123,8 @@ public class CuckooClockTileEntity extends KineticTileEntity { } else { boolean isSurprise = animationType == Animation.SURPRISE; - float value = animationProgress.value; - animationProgress.set(value + 1); + float value = animationProgress.getValue(); + animationProgress.setValue(value + 1); if (value > 100) animationType = null; @@ -171,8 +167,7 @@ public class CuckooClockTileEntity extends KineticTileEntity { animationType = animation; if (animation != null && CuckooClockBlock.containsSurprise(getBlockState())) animationType = Animation.SURPRISE; - animationProgress.lastValue = 0; - animationProgress.value = 0; + animationProgress.startWithValue(0); sendAnimationUpdate = true; if (animation == Animation.CREEPER) @@ -185,11 +180,11 @@ public class CuckooClockTileEntity extends KineticTileEntity { float hourTarget = (float) (360 / 12 * (hours % 12)); float minuteTarget = (float) (360 / 60 * minutes); - hourHand.target(hourHand.value + rad(getShortestAngleDiff(deg(hourHand.value), hourTarget))); - minuteHand.target(minuteHand.value + rad(getShortestAngleDiff(deg(minuteHand.value), minuteTarget))); + hourHand.chase(hourTarget, .2f, Chaser.EXP); + minuteHand.chase(minuteTarget, .2f, Chaser.EXP); - hourHand.tick(); - minuteHand.tick(); + hourHand.tickChaser(); + minuteHand.tickChaser(); } private void playSound(SoundEvent sound, float volume, float pitch) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlyWheelInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlyWheelInstance.java index f394f24d1..d7b8dd9b7 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlyWheelInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlyWheelInstance.java @@ -5,7 +5,6 @@ import com.jozufozu.flywheel.api.instance.DynamicInstance; import com.jozufozu.flywheel.core.materials.model.ModelData; import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; -import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileInstance; import com.simibubi.create.content.contraptions.base.flwdata.RotatingData; import com.simibubi.create.foundation.utility.AngleHelper; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/Contraption.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/Contraption.java index 227bb0312..80ed5d827 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/Contraption.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/Contraption.java @@ -67,6 +67,7 @@ import com.simibubi.create.content.logistics.trains.IBogeyBlock; import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.tileEntity.IMultiTileContainer; import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour; +import com.simibubi.create.foundation.utility.BBHelper; import com.simibubi.create.foundation.utility.BlockFace; import com.simibubi.create.foundation.utility.BlockHelper; import com.simibubi.create.foundation.utility.ICoordinate; @@ -309,8 +310,7 @@ public abstract class Contraption { if (AllBlocks.BELT.has(state)) moveBelt(pos, frontier, visited, state); - if (AllBlocks.WINDMILL_BEARING.has(state) - && world.getBlockEntity(pos) instanceof WindmillBearingTileEntity wbte) + if (AllBlocks.WINDMILL_BEARING.has(state) && world.getBlockEntity(pos)instanceof WindmillBearingTileEntity wbte) wbte.disassembleForMovement(); if (AllBlocks.GANTRY_CARRIAGE.has(state)) @@ -337,7 +337,7 @@ public abstract class Contraption { } // Bogeys tend to have sticky sides - if (state.getBlock() instanceof IBogeyBlock bogey) + if (state.getBlock()instanceof IBogeyBlock bogey) for (Direction d : bogey.getStickySurfaces(world, pos, state)) if (!visited.contains(pos.relative(d))) frontier.add(pos.relative(d)); @@ -926,8 +926,7 @@ public abstract class Contraption { if (minimisedGlue.get(i) == null) minimisedGlue.set(i, new BoundingBox(block.pos)); else - minimisedGlue.get(i) - .encapsulate(block.pos); + minimisedGlue.set(i, BBHelper.encapsulate(minimisedGlue.get(i), block.pos)); } BlockPos add = block.pos.offset(anchor) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/AbstractChassisBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/AbstractChassisBlock.java index 108307d05..3c1ae6875 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/AbstractChassisBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/AbstractChassisBlock.java @@ -82,6 +82,7 @@ public abstract class AbstractChassisBlock extends RotatedPillarBlock implements } @Override + @SuppressWarnings("deprecation") public BlockState rotate(BlockState state, Rotation rotation) { if (rotation == Rotation.NONE) return state; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/CartAssemblerBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/CartAssemblerBlock.java index 98e977334..eac0d072b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/CartAssemblerBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/CartAssemblerBlock.java @@ -334,6 +334,7 @@ public class CartAssemblerBlock extends BaseRailBlock } @Override + @SuppressWarnings("deprecation") public BlockState rotate(BlockState state, Rotation rotation) { if (rotation == Rotation.NONE) return state; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/tracks/ControllerRailBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/tracks/ControllerRailBlock.java index da2497e99..2c5914c76 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/tracks/ControllerRailBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/tracks/ControllerRailBlock.java @@ -268,6 +268,7 @@ public class ControllerRailBlock extends BaseRailBlock implements IWrenchable { } @Override + @SuppressWarnings("deprecation") public BlockState rotate(BlockState state, Rotation rotation) { if (rotation == Rotation.NONE) return state; diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/FluidNetwork.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/FluidNetwork.java index 89986b321..ee559d9ae 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/FluidNetwork.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/FluidNetwork.java @@ -293,7 +293,7 @@ public class FluidNetwork { } private boolean isPresent(BlockFace location) { - return world.isAreaLoaded(location.getPos(), 0); + return world.isLoaded(location.getPos()); } @Nullable diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/FluidPropagator.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/FluidPropagator.java index 43d6f5939..5451e001b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/FluidPropagator.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/FluidPropagator.java @@ -65,7 +65,7 @@ public class FluidPropagator { for (Direction direction : getPipeConnections(currentState, pipe)) { BlockPos target = currentPos.relative(direction); - if (!world.isAreaLoaded(target, 0)) + if (world instanceof Level l && !l.isLoaded(target)) continue; BlockEntity tileEntity = world.getBlockEntity(target); diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/FluidReactions.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/FluidReactions.java index 4c4d58e4e..60f93a592 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/FluidReactions.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/FluidReactions.java @@ -21,7 +21,7 @@ public class FluidReactions { public static void handlePipeFlowCollision(Level world, BlockPos pos, FluidStack fluid, FluidStack fluid2) { Fluid f1 = fluid.getFluid(); Fluid f2 = fluid2.getFluid(); - + AdvancementBehaviour.tryAward(world, pos, AllAdvancements.CROSS_STREAMS); BlockHelper.destroyBlock(world, pos, 1); @@ -43,7 +43,7 @@ public class FluidReactions { public static void handlePipeSpillCollision(Level world, BlockPos pos, Fluid pipeFluid, FluidState worldFluid) { Fluid pf = FluidHelper.convertToStill(pipeFluid); Fluid wf = worldFluid.getType(); - if (pf.is(FluidTags.WATER) && wf == Fluids.LAVA) + if (FluidHelper.isTag(pf, FluidTags.WATER) && wf == Fluids.LAVA) world.setBlockAndUpdate(pos, Blocks.OBSIDIAN.defaultBlockState()); else if (pf == Fluids.WATER && wf == Fluids.FLOWING_LAVA) world.setBlockAndUpdate(pos, Blocks.COBBLESTONE.defaultBlockState()); diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/OpenEndedPipe.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/OpenEndedPipe.java index 8ad5e459b..bc4059b73 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/OpenEndedPipe.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/OpenEndedPipe.java @@ -174,7 +174,7 @@ public class OpenEndedPipe extends FlowSource { private boolean provideFluidToSpace(FluidStack fluid, boolean simulate) { if (world == null) return false; - if (!world.isAreaLoaded(outputPos, 0)) + if (!world.isLoaded(outputPos)) return false; BlockState state = world.getBlockState(outputPos); @@ -202,9 +202,7 @@ public class OpenEndedPipe extends FlowSource { return true; if (world.dimensionType() - .ultraWarm() - && fluid.getFluid() - .is(FluidTags.WATER)) { + .ultraWarm() && FluidHelper.isTag(fluid, FluidTags.WATER)) { int i = outputPos.getX(); int j = outputPos.getY(); int k = outputPos.getZ(); @@ -265,7 +263,7 @@ public class OpenEndedPipe extends FlowSource { FluidStack containedFluidStack = getFluid(); boolean hasBlockState = FluidHelper.hasBlockState(containedFluidStack.getFluid()); - + if (!containedFluidStack.isEmpty() && !containedFluidStack.isFluidEqual(resource)) setFluid(FluidStack.EMPTY); if (wasPulling) @@ -379,8 +377,7 @@ public class OpenEndedPipe extends FlowSource { public static class MilkEffectHandler implements IEffectHandler { @Override public boolean canApplyEffects(OpenEndedPipe pipe, FluidStack fluid) { - return fluid.getFluid() - .is(Tags.Fluids.MILK); + return FluidHelper.isTag(fluid, Tags.Fluids.MILK); } @Override @@ -399,8 +396,7 @@ public class OpenEndedPipe extends FlowSource { public static class WaterEffectHandler implements IEffectHandler { @Override public boolean canApplyEffects(OpenEndedPipe pipe, FluidStack fluid) { - return fluid.getFluid() - .is(FluidTags.WATER); + return FluidHelper.isTag(fluid, FluidTags.WATER); } @Override @@ -433,8 +429,7 @@ public class OpenEndedPipe extends FlowSource { public static class LavaEffectHandler implements IEffectHandler { @Override public boolean canApplyEffects(OpenEndedPipe pipe, FluidStack fluid) { - return fluid.getFluid() - .is(FluidTags.LAVA); + return FluidHelper.isTag(fluid, FluidTags.LAVA); } @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/PumpTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/PumpTileEntity.java index ced22d488..94c155f01 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/PumpTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/PumpTileEntity.java @@ -157,7 +157,7 @@ public class PumpTileEntity extends KineticTileEntity { int distance = entry.getFirst(); BlockPos currentPos = entry.getSecond(); - if (!level.isAreaLoaded(currentPos, 0)) + if (!level.isLoaded(currentPos)) continue; if (visited.contains(currentPos)) continue; @@ -171,7 +171,7 @@ public class PumpTileEntity extends KineticTileEntity { BlockFace blockFace = new BlockFace(currentPos, face); BlockPos connectedPos = blockFace.getConnectedPos(); - if (!level.isAreaLoaded(connectedPos, 0)) + if (!level.isLoaded(connectedPos)) continue; if (blockFace.isEquivalent(start)) continue; diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/FluidDrainingBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/FluidDrainingBehaviour.java index c4386c3ac..916eb54af 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/FluidDrainingBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/FluidDrainingBehaviour.java @@ -12,6 +12,7 @@ import com.simibubi.create.foundation.advancement.AllAdvancements; import com.simibubi.create.foundation.fluid.FluidHelper; import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.behaviour.BehaviourType; +import com.simibubi.create.foundation.utility.BBHelper; import com.simibubi.create.foundation.utility.Iterate; import it.unimi.dsi.fastutil.PriorityQueue; @@ -100,7 +101,7 @@ public class FluidDrainingBehaviour extends FluidManipulationBehaviour { if (blockState.getValue(LiquidBlock.LEVEL) == 0) fluid = flowingFluid.getFluid(); else { - affectedArea.encapsulate(BoundingBox.fromCorners(currentPos, currentPos)); + affectedArea = BBHelper.encapsulate(affectedArea, BoundingBox.fromCorners(currentPos, currentPos)); if (!tileEntity.isVirtual()) world.setBlock(currentPos, emptied, 2 | 16); queue.dequeue(); @@ -144,7 +145,7 @@ public class FluidDrainingBehaviour extends FluidManipulationBehaviour { if (!tileEntity.isVirtual()) world.setBlock(currentPos, emptied, 2 | 16); - affectedArea.encapsulate(BoundingBox.fromCorners(currentPos, currentPos)); + affectedArea = BBHelper.encapsulate(affectedArea, currentPos); queue.dequeue(); if (queue.isEmpty()) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/FluidFillingBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/FluidFillingBehaviour.java index 1802e092b..afdb10379 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/FluidFillingBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/FluidFillingBehaviour.java @@ -11,6 +11,7 @@ import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.fluid.FluidHelper; import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.behaviour.BehaviourType; +import com.simibubi.create.foundation.utility.BBHelper; import com.simibubi.create.foundation.utility.Iterate; import it.unimi.dsi.fastutil.PriorityQueue; @@ -127,7 +128,7 @@ public class FluidFillingBehaviour extends FluidManipulationBehaviour { int maxRangeSq = maxRange * maxRange; int maxBlocks = maxBlocks(); boolean evaporate = world.dimensionType() - .ultraWarm() && fluid.is(FluidTags.WATER); + .ultraWarm() && FluidHelper.isTag(fluid, FluidTags.WATER); boolean canPlaceSources = AllConfigs.SERVER.fluids.placeFluidSourceBlocks.get(); if ((!fillInfinite() && infinite) || evaporate || !canPlaceSources) { @@ -200,7 +201,7 @@ public class FluidFillingBehaviour extends FluidManipulationBehaviour { serverTickList.clearArea(new BoundingBox(currentPos)); } - affectedArea.encapsulate(BoundingBox.fromCorners(currentPos, currentPos)); + affectedArea = BBHelper.encapsulate(affectedArea, currentPos); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/FluidManipulationBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/FluidManipulationBehaviour.java index f859a286c..a3f428274 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/FluidManipulationBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/FluidManipulationBehaviour.java @@ -203,9 +203,9 @@ public abstract class FluidManipulationBehaviour extends TileEntityBehaviour { : fluid.getAttributes() .getEmptySound(); if (soundevent == null) - soundevent = - fluid.is(FluidTags.LAVA) ? fillSound ? SoundEvents.BUCKET_FILL_LAVA : SoundEvents.BUCKET_EMPTY_LAVA - : fillSound ? SoundEvents.BUCKET_FILL : SoundEvents.BUCKET_EMPTY; + soundevent = FluidHelper.isTag(fluid, FluidTags.LAVA) + ? fillSound ? SoundEvents.BUCKET_FILL_LAVA : SoundEvents.BUCKET_EMPTY_LAVA + : fillSound ? SoundEvents.BUCKET_FILL : SoundEvents.BUCKET_EMPTY; world.playSound(null, splooshPos, soundevent, SoundSource.BLOCKS, 0.3F, 1.0F); if (world instanceof ServerLevel) @@ -215,7 +215,8 @@ public abstract class FluidManipulationBehaviour extends TileEntityBehaviour { protected boolean canDrainInfinitely(Fluid fluid) { if (fluid == null) return false; - return maxBlocks() != -1 && AllConfigs.SERVER.fluids.bottomlessFluidMode.get().test(fluid); + return maxBlocks() != -1 && AllConfigs.SERVER.fluids.bottomlessFluidMode.get() + .test(fluid); } @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/tank/FluidTankBlock.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/tank/FluidTankBlock.java index 126f7c8c1..901263a43 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/tank/FluidTankBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/tank/FluidTankBlock.java @@ -131,12 +131,12 @@ public class FluidTankBlock extends Block implements IWrenchable, ITE> { @@ -43,7 +44,7 @@ public class SequencedRecipe> { public static SequencedRecipe fromJson(JsonObject json, SequencedAssemblyRecipe parent, int index) { ResourceLocation parentId = parent.getId(); Recipe recipe = RecipeManager.fromJson( - new ResourceLocation(parentId.getNamespace(), parentId.getPath() + "_step_" + index), json); + new ResourceLocation(parentId.getNamespace(), parentId.getPath() + "_step_" + index), json, IContext.EMPTY); if (recipe instanceof ProcessingRecipe && recipe instanceof IAssemblyRecipe) { ProcessingRecipe processingRecipe = (ProcessingRecipe) recipe; IAssemblyRecipe assemblyRecipe = (IAssemblyRecipe) recipe; diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltBlock.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltBlock.java index 1f0146f9a..501ed451f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltBlock.java @@ -412,7 +412,7 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE pred; - private Function trigger; public BracketedTileEntityBehaviour(SmartTileEntity te) { this(te, state -> true); @@ -39,11 +36,6 @@ public class BracketedTileEntityBehaviour extends TileEntityBehaviour { bracket = Optional.empty(); } - public BracketedTileEntityBehaviour withTrigger(Function trigger) { - this.trigger = trigger; - return this; - } - @Override public BehaviourType getType() { return TYPE; diff --git a/src/main/java/com/simibubi/create/content/curiosities/TreeFertilizerItem.java b/src/main/java/com/simibubi/create/content/curiosities/TreeFertilizerItem.java index d2b15211c..47ae26065 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/TreeFertilizerItem.java +++ b/src/main/java/com/simibubi/create/content/curiosities/TreeFertilizerItem.java @@ -9,11 +9,9 @@ import net.minecraft.world.InteractionResult; import net.minecraft.world.item.BoneMealItem; import net.minecraft.world.item.Item; import net.minecraft.world.item.context.UseOnContext; -import net.minecraft.world.level.block.AzaleaBlock; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.BonemealableBlock; -import net.minecraft.world.level.block.SaplingBlock; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.BlockStateProperties; @@ -87,12 +85,10 @@ public class TreeFertilizerItem extends Item { } private static class TreesDreamWorld extends PlacementSimulationServerWorld { - private final BlockPos saplingPos; private final BlockState soil; protected TreesDreamWorld(ServerLevel wrapped, BlockPos saplingPos) { super(wrapped); - this.saplingPos = saplingPos; soil = wrapped.getBlockState(saplingPos.below()); } diff --git a/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/SymmetryMirror.java b/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/SymmetryMirror.java index 7c85700aa..d30e52ddf 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/SymmetryMirror.java +++ b/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/SymmetryMirror.java @@ -168,11 +168,13 @@ public abstract class SymmetryMirror { return in.mirror(Mirror.LEFT_RIGHT); } + @SuppressWarnings("deprecation") protected BlockState flipD1(BlockState in) { return in.rotate(Rotation.COUNTERCLOCKWISE_90) .mirror(Mirror.FRONT_BACK); } + @SuppressWarnings("deprecation") protected BlockState flipD2(BlockState in) { return in.rotate(Rotation.COUNTERCLOCKWISE_90) .mirror(Mirror.LEFT_RIGHT); diff --git a/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxHandler.java b/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxHandler.java index 2c80bc741..c7ec4aacc 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxHandler.java +++ b/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxHandler.java @@ -1,7 +1,6 @@ package com.simibubi.create.content.curiosities.toolbox; import java.util.List; -import java.util.Objects; import java.util.WeakHashMap; import java.util.stream.Collectors; @@ -67,7 +66,7 @@ public class ToolboxHandler { BlockPos pos = NbtUtils.readBlockPos(data.getCompound("Pos")); int slot = data.getInt("Slot"); - if (!world.isAreaLoaded(pos, 0)) + if (!world.isLoaded(pos)) continue; if (!(world.getBlockState(pos) .getBlock() instanceof ToolboxBlock)) { diff --git a/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxHandlerClient.java b/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxHandlerClient.java index 2834b92b7..8bffaa6f8 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxHandlerClient.java +++ b/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxHandlerClient.java @@ -5,7 +5,6 @@ import static com.simibubi.create.foundation.gui.AllGuiTextures.TOOLBELT_HOTBAR_ import static com.simibubi.create.foundation.gui.AllGuiTextures.TOOLBELT_SELECTED_OFF; import static com.simibubi.create.foundation.gui.AllGuiTextures.TOOLBELT_SELECTED_ON; -import java.util.Collections; import java.util.Comparator; import java.util.List; diff --git a/src/main/java/com/simibubi/create/content/curiosities/tools/SandPaperItem.java b/src/main/java/com/simibubi/create/content/curiosities/tools/SandPaperItem.java index f75ec59ee..65ffc7bf4 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/tools/SandPaperItem.java +++ b/src/main/java/com/simibubi/create/content/curiosities/tools/SandPaperItem.java @@ -60,7 +60,8 @@ public class SandPaperItem extends Item implements CustomUseEffectsItem { return new InteractionResultHolder<>(InteractionResult.PASS, itemstack); } - InteractionHand otherHand = handIn == InteractionHand.MAIN_HAND ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND; + InteractionHand otherHand = + handIn == InteractionHand.MAIN_HAND ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND; ItemStack itemInOtherHand = playerIn.getItemInHand(otherHand); if (SandPaperPolishingRecipe.canPolish(worldIn, itemInOtherHand)) { ItemStack item = itemInOtherHand.copy(); @@ -137,7 +138,8 @@ public class SandPaperItem extends Item implements CustomUseEffectsItem { if (player instanceof FakePlayer) { player.drop(polished, false, false); } else { - player.getInventory().placeItemBackInInventory(polished); + player.getInventory() + .placeItemBackInInventory(polished); } } tag.remove("Polishing"); @@ -163,7 +165,8 @@ public class SandPaperItem extends Item implements CustomUseEffectsItem { CompoundTag tag = stack.getOrCreateTag(); if (tag.contains("Polishing")) { ItemStack toPolish = ItemStack.of(tag.getCompound("Polishing")); - player.getInventory().placeItemBackInInventory(toPolish); + player.getInventory() + .placeItemBackInInventory(toPolish); tag.remove("Polishing"); } } @@ -176,14 +179,15 @@ public class SandPaperItem extends Item implements CustomUseEffectsItem { BlockPos pos = context.getClickedPos(); BlockState state = level.getBlockState(pos); - BlockState newState = state.getToolModifiedState(level, pos, player, stack, ToolActions.AXE_SCRAPE); + BlockState newState = state.getToolModifiedState(context, ToolActions.AXE_SCRAPE, false); if (newState != null) { AllSoundEvents.SANDING_LONG.play(level, player, pos, 1, 1 + (level.random.nextFloat() * 0.5f - 1f) / 5f); level.levelEvent(player, 3005, pos, 0); // Spawn particles } else { - newState = state.getToolModifiedState(level, pos, player, stack, ToolActions.AXE_WAX_OFF); + newState = state.getToolModifiedState(context, ToolActions.AXE_WAX_OFF, false); if (newState != null) { - AllSoundEvents.SANDING_LONG.play(level, player, pos, 1, 1 + (level.random.nextFloat() * 0.5f - 1f) / 5f); + AllSoundEvents.SANDING_LONG.play(level, player, pos, 1, + 1 + (level.random.nextFloat() * 0.5f - 1f) / 5f); level.levelEvent(player, 3004, pos, 0); // Spawn particles } } @@ -219,7 +223,8 @@ public class SandPaperItem extends Item implements CustomUseEffectsItem { // After 6 ticks play the sound every 7th if ((entity.getTicksUsingItem() - 6) % 7 == 0) - entity.playSound(entity.getEatingSound(stack), 0.9F + 0.2F * random.nextFloat(), random.nextFloat() * 0.2F + 0.9F); + entity.playSound(entity.getEatingSound(stack), 0.9F + 0.2F * random.nextFloat(), + random.nextFloat() * 0.2F + 0.9F); return true; } diff --git a/src/main/java/com/simibubi/create/content/curiosities/weapons/BuiltinPotatoProjectileTypes.java b/src/main/java/com/simibubi/create/content/curiosities/weapons/BuiltinPotatoProjectileTypes.java index 7ada41f2a..47a16cbac 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/weapons/BuiltinPotatoProjectileTypes.java +++ b/src/main/java/com/simibubi/create/content/curiosities/weapons/BuiltinPotatoProjectileTypes.java @@ -309,7 +309,7 @@ public class BuiltinPotatoProjectileTypes { return true; BlockPos hitPos = ray.getBlockPos(); - if (!world.isAreaLoaded(hitPos, 1)) + if (world instanceof Level l && !l.isLoaded(hitPos)) return true; Direction face = ray.getDirection(); BlockPos placePos = hitPos.relative(face); @@ -335,7 +335,7 @@ public class BuiltinPotatoProjectileTypes { return true; BlockPos hitPos = ray.getBlockPos(); - if (!world.isAreaLoaded(hitPos, 1)) + if (world instanceof Level l && !l.isLoaded(hitPos)) return true; Direction face = ray.getDirection(); BlockPos placePos = hitPos.relative(face); diff --git a/src/main/java/com/simibubi/create/content/curiosities/weapons/PotatoProjectileRenderMode.java b/src/main/java/com/simibubi/create/content/curiosities/weapons/PotatoProjectileRenderMode.java index 46c96baab..449c7d8f8 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/weapons/PotatoProjectileRenderMode.java +++ b/src/main/java/com/simibubi/create/content/curiosities/weapons/PotatoProjectileRenderMode.java @@ -1,7 +1,5 @@ package com.simibubi.create.content.curiosities.weapons; -import static com.simibubi.create.content.curiosities.weapons.PotatoProjectileRenderMode.entityRandom; - import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.utility.AngleHelper; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelInstance.java b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelInstance.java index 9f0402373..67d5d7c00 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelInstance.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelInstance.java @@ -14,7 +14,7 @@ import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.logistics.block.flap.FlapData; import com.simibubi.create.foundation.render.AllMaterialSpecs; import com.simibubi.create.foundation.utility.AnimationTickHolder; -import com.simibubi.create.foundation.utility.animation.InterpolatedValue; +import com.simibubi.create.foundation.utility.animation.LerpedFloat; import net.minecraft.core.Direction; import net.minecraft.world.level.LightLayer; @@ -37,7 +37,7 @@ public class BeltTunnelInstance extends BlockEntityInstance { - float flapness = flapValue.get(AnimationTickHolder.getPartialTicks()); + float flapness = flapValue.getValue(AnimationTickHolder.getPartialTicks()); float horizontalAngle = direction.getOpposite().toYRot(); @@ -76,12 +76,11 @@ public class BeltTunnelInstance extends BlockEntityInstance { - InterpolatedValue flapValue = blockEntity.flaps.get(direction); - if (flapValue == null) { + LerpedFloat lerpedFloat = blockEntity.flaps.get(direction); + if (lerpedFloat == null) return; - } - float flapness = flapValue.get(AnimationTickHolder.getPartialTicks()); + float flapness = lerpedFloat.getValue(AnimationTickHolder.getPartialTicks()); for (FlapData flap : keys) { flap.setFlapness(flapness); } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelItem.java b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelItem.java index 978dbd9a3..5fb2741b5 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelItem.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelItem.java @@ -4,8 +4,6 @@ import com.simibubi.create.AllBlocks; import com.simibubi.create.content.contraptions.relays.belt.BeltHelper; import com.simibubi.create.content.contraptions.relays.belt.BeltTileEntity; import com.simibubi.create.content.contraptions.relays.belt.BeltTileEntity.CasingType; -import com.simibubi.create.foundation.advancement.AllTriggers; - import net.minecraft.core.BlockPos; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.BlockItem; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelRenderer.java b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelRenderer.java index f5f137b2b..fbf919596 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelRenderer.java @@ -31,7 +31,8 @@ public class BeltTunnelRenderer extends SmartTileEntityRenderer flaps; + public Map flaps; public Set sides; protected LazyOptional cap = LazyOptional.empty(); @@ -93,9 +94,7 @@ public class BeltTunnelTileEntity extends SmartTileEntity { if (!newFlaps.contains(d)) flaps.remove(d); else if (!flaps.containsKey(d)) - flaps.put(d, new InterpolatedChasingValue().start(.25f) - .target(0) - .withSpeed(.05f)); + flaps.put(d, createChasingFlap()); // Backwards compat if (!compound.contains("Sides") && compound.contains("Flaps")) @@ -105,6 +104,12 @@ public class BeltTunnelTileEntity extends SmartTileEntity { DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> InstancedRenderDispatcher.enqueueUpdate(this)); } + private LerpedFloat createChasingFlap() { + return LerpedFloat.linear() + .startWithValue(.25f) + .chase(0, .05f, Chaser.EXP); + } + public void updateTunnelConnections() { flaps.clear(); sides.clear(); @@ -133,9 +138,7 @@ public class BeltTunnelTileEntity extends SmartTileEntity { && nextState.getValue(BeltFunnelBlock.HORIZONTAL_FACING) == direction.getOpposite()) continue; - flaps.put(direction, new InterpolatedChasingValue().start(.25f) - .target(0) - .withSpeed(.05f)); + flaps.put(direction, createChasingFlap()); } sendData(); } @@ -144,7 +147,7 @@ public class BeltTunnelTileEntity extends SmartTileEntity { if (level.isClientSide) { if (flaps.containsKey(side)) flaps.get(side) - .set(inward ^ side.getAxis() == Axis.Z ? -1 : 1); + .setValue(inward ^ side.getAxis() == Axis.Z ? -1 : 1); return; } @@ -165,7 +168,7 @@ public class BeltTunnelTileEntity extends SmartTileEntity { sendFlaps(); return; } - flaps.forEach((d, value) -> value.tick()); + flaps.forEach((d, value) -> value.tickChaser()); } private void sendFlaps() { diff --git a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BrassTunnelTileEntity.java b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BrassTunnelTileEntity.java index e6a17ab1a..32f6e6be7 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BrassTunnelTileEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BrassTunnelTileEntity.java @@ -335,7 +335,7 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity implements IHave for (boolean left : Iterate.trueAndFalse) { BrassTunnelTileEntity adjacent = this; while (adjacent != null) { - if (!level.isAreaLoaded(adjacent.getBlockPos(), 1)) + if (!level.isLoaded(adjacent.getBlockPos())) return null; adjacent = adjacent.getAdjacent(left); if (adjacent == null) @@ -477,7 +477,7 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity implements IHave for (boolean left : Iterate.trueAndFalse) { BrassTunnelTileEntity adjacent = this; while (adjacent != null) { - if (!level.isAreaLoaded(adjacent.getBlockPos(), 1)) + if (!level.isLoaded(adjacent.getBlockPos())) return null; adjacent = adjacent.getAdjacent(left); if (adjacent == null) diff --git a/src/main/java/com/simibubi/create/content/logistics/block/chute/ChuteRenderer.java b/src/main/java/com/simibubi/create/content/logistics/block/chute/ChuteRenderer.java index 627fbbe92..169d45a91 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/chute/ChuteRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/chute/ChuteRenderer.java @@ -15,19 +15,18 @@ import net.minecraft.world.level.block.state.BlockState; public class ChuteRenderer extends SafeTileEntityRenderer { - public ChuteRenderer(BlockEntityRendererProvider.Context context) { - } + public ChuteRenderer(BlockEntityRendererProvider.Context context) {} @Override - protected void renderSafe(ChuteTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, - int light, int overlay) { + protected void renderSafe(ChuteTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, + int overlay) { if (te.item.isEmpty()) return; BlockState blockState = te.getBlockState(); if (blockState.getValue(ChuteBlock.FACING) != Direction.DOWN) return; if (blockState.getValue(ChuteBlock.SHAPE) != Shape.WINDOW - && (te.bottomPullDistance == 0 || te.itemPosition.get(partialTicks) > .5f)) + && (te.bottomPullDistance == 0 || te.itemPosition.getValue(partialTicks) > .5f)) return; renderItem(te, partialTicks, ms, buffer, light, overlay); @@ -41,7 +40,7 @@ public class ChuteRenderer extends SafeTileEntityRenderer { ms.pushPose(); msr.centre(); float itemScale = .5f; - float itemPosition = te.itemPosition.get(partialTicks); + float itemPosition = te.itemPosition.getValue(partialTicks); ms.translate(0, -.5 + itemPosition, 0); ms.scale(itemScale, itemScale, itemScale); msr.rotateX(itemPosition * 180); diff --git a/src/main/java/com/simibubi/create/content/logistics/block/chute/ChuteTileEntity.java b/src/main/java/com/simibubi/create/content/logistics/block/chute/ChuteTileEntity.java index e891205f5..448a0c53d 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/chute/ChuteTileEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/chute/ChuteTileEntity.java @@ -28,7 +28,7 @@ import com.simibubi.create.foundation.utility.BlockHelper; import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.VecHelper; -import com.simibubi.create.foundation.utility.animation.InterpolatedValue; +import com.simibubi.create.foundation.utility.animation.LerpedFloat; import net.minecraft.ChatFormatting; import net.minecraft.MethodsReturnNonnullByDefault; @@ -63,13 +63,13 @@ import net.minecraftforge.items.ItemHandlerHelper; */ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInformation { // , IAirCurrentSource { - // public AirCurrent airCurrent; + // public AirCurrent airCurrent; float pull; float push; ItemStack item; - InterpolatedValue itemPosition; + LerpedFloat itemPosition; ChuteItemHandler itemHandler; LazyOptional lazyHandler; boolean canPickUpItems; @@ -87,14 +87,14 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor public ChuteTileEntity(BlockEntityType type, BlockPos pos, BlockState state) { super(type, pos, state); item = ItemStack.EMPTY; - itemPosition = new InterpolatedValue(); + itemPosition = LerpedFloat.linear(); itemHandler = new ChuteItemHandler(this); lazyHandler = LazyOptional.of(() -> itemHandler); canPickUpItems = false; capAbove = LazyOptional.empty(); capBelow = LazyOptional.empty(); bottomPullDistance = 0; - // airCurrent = new AirCurrent(this); + // airCurrent = new AirCurrent(this); updateAirFlow = true; } @@ -153,7 +153,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor return; } - float nextOffset = itemPosition.value + itemMotion; + float nextOffset = itemPosition.getValue() + itemMotion; if (itemMotion < 0) { if (nextOffset < .5f) { @@ -161,7 +161,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor nextOffset = .5f; else if (nextOffset < 0) { handleDownwardOutput(clientSide); - nextOffset = itemPosition.value; + nextOffset = itemPosition.getValue(); } } } else if (itemMotion > 0) { @@ -170,17 +170,17 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor nextOffset = .5f; else if (nextOffset > 1) { handleUpwardOutput(clientSide); - nextOffset = itemPosition.value; + nextOffset = itemPosition.getValue(); } } } - itemPosition.set(nextOffset); + itemPosition.setValue(nextOffset); } private void updateAirFlow(float itemSpeed) { updateAirFlow = false; - // airCurrent.rebuild(); + // airCurrent.rebuild(); if (itemSpeed > 0 && level != null && !level.isClientSide) { float speed = pull - push; beltBelow = null; @@ -216,15 +216,14 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor } private void findEntities(float itemSpeed) { - // if (getSpeed() != 0) - // airCurrent.findEntities(); + // if (getSpeed() != 0) + // airCurrent.findEntities(); if (bottomPullDistance <= 0 && !getItem().isEmpty() || itemSpeed <= 0 || level == null || level.isClientSide) return; if (!canCollectItemsFromBelow()) return; Vec3 center = VecHelper.getCenterOf(worldPosition); - AABB searchArea = - new AABB(center.add(0, -bottomPullDistance - 0.5, 0), center.add(0, -0.5, 0)).inflate(.45f); + AABB searchArea = new AABB(center.add(0, -bottomPullDistance - 0.5, 0), center.add(0, -0.5, 0)).inflate(.45f); for (ItemEntity itemEntity : level.getEntitiesOfClass(ItemEntity.class, searchArea)) { if (!itemEntity.isAlive()) continue; @@ -268,8 +267,8 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor } extractFromBelt(itemSpeed); - // if (getSpeed() != 0) - // airCurrent.tick(); + // if (getSpeed() != 0) + // airCurrent.tick(); } public void blockBelowChanged() { @@ -289,7 +288,8 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor if (push == 0 && pull == 0) return; - if (up && AbstractChuteBlock.isOpenChute(blockState) && BlockHelper.noCollisionInSpace(level, worldPosition.above())) + if (up && AbstractChuteBlock.isOpenChute(blockState) + && BlockHelper.noCollisionInSpace(level, worldPosition.above())) spawnAirFlow(1, 2, absMotion, .5f); if (AbstractChuteBlock.getChuteFacing(blockState) != Direction.DOWN) @@ -362,7 +362,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor ItemStack remainder = ItemHandlerHelper.insertItemStacked(capBelow.orElse(null), item, simulate); ItemStack held = getItem(); if (!simulate) - setItem(remainder, itemPosition.get(0)); + setItem(remainder, itemPosition.getValue(0)); if (remainder.getCount() != held.getCount()) return true; if (direction == Direction.DOWN) @@ -501,7 +501,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor public void setItem(ItemStack stack, float insertionPos) { item = stack; - itemPosition.lastValue = itemPosition.value = insertionPos; + itemPosition.startWithValue(insertionPos); if (!level.isClientSide) { notifyUpdate(); award(AllAdvancements.CHUTE); @@ -518,7 +518,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor @Override public void write(CompoundTag compound, boolean clientPacket) { compound.put("Item", item.serializeNBT()); - compound.putFloat("ItemPosition", itemPosition.value); + compound.putFloat("ItemPosition", itemPosition.getValue()); compound.putFloat("Pull", pull); compound.putFloat("Push", push); compound.putFloat("BottomAirFlowDistance", bottomPullDistance); @@ -529,7 +529,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor protected void read(CompoundTag compound, boolean clientPacket) { ItemStack previousItem = item; item = ItemStack.of(compound.getCompound("Item")); - itemPosition.lastValue = itemPosition.value = compound.getFloat("ItemPosition"); + itemPosition.startWithValue(compound.getFloat("ItemPosition")); pull = compound.getFloat("Pull"); push = compound.getFloat("Push"); bottomPullDistance = compound.getFloat("BottomAirFlowDistance"); @@ -632,7 +632,8 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor if (level == null) return 0; BlockState blockStateBelow = level.getBlockState(worldPosition.below()); - if (AllBlocks.ENCASED_FAN.has(blockStateBelow) && blockStateBelow.getValue(EncasedFanBlock.FACING) == Direction.UP) { + if (AllBlocks.ENCASED_FAN.has(blockStateBelow) + && blockStateBelow.getValue(EncasedFanBlock.FACING) == Direction.UP) { BlockEntity te = level.getBlockEntity(worldPosition.below()); if (te instanceof EncasedFanTileEntity && !te.isRemoved()) { EncasedFanTileEntity fan = (EncasedFanTileEntity) te; @@ -736,47 +737,50 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor return item; } - // @Override - // @Nullable - // public AirCurrent getAirCurrent() { - // return airCurrent; - // } + // @Override + // @Nullable + // public AirCurrent getAirCurrent() { + // return airCurrent; + // } // - // @Nullable - // @Override - // public World getAirCurrentWorld() { - // return world; - // } + // @Nullable + // @Override + // public World getAirCurrentWorld() { + // return world; + // } // - // @Override - // public BlockPos getAirCurrentPos() { - // return pos; - // } + // @Override + // public BlockPos getAirCurrentPos() { + // return pos; + // } // - // @Override - // public float getSpeed() { - // if (getBlockState().get(ChuteBlock.SHAPE) == Shape.NORMAL && getBlockState().get(ChuteBlock.FACING) != Direction.DOWN) - // return 0; - // return pull + push; - // } + // @Override + // public float getSpeed() { + // if (getBlockState().get(ChuteBlock.SHAPE) == Shape.NORMAL && + // getBlockState().get(ChuteBlock.FACING) != Direction.DOWN) + // return 0; + // return pull + push; + // } // - // @Override - // @Nullable - // public Direction getAirFlowDirection() { - // float speed = getSpeed(); - // if (speed == 0) - // return null; - // return speed > 0 ? Direction.UP : Direction.DOWN; - // } + // @Override + // @Nullable + // public Direction getAirFlowDirection() { + // float speed = getSpeed(); + // if (speed == 0) + // return null; + // return speed > 0 ? Direction.UP : Direction.DOWN; + // } // - // @Override - // public boolean isSourceRemoved() { - // return removed; - // } + // @Override + // public boolean isSourceRemoved() { + // return removed; + // } // - // @Override - // public Direction getAirflowOriginSide() { - // return world != null && !(world.getTileEntity(pos.down()) instanceof IAirCurrentSource) - // && getBlockState().get(ChuteBlock.FACING) == Direction.DOWN ? Direction.DOWN : Direction.UP; - // } + // @Override + // public Direction getAirflowOriginSide() { + // return world != null && !(world.getTileEntity(pos.down()) instanceof + // IAirCurrentSource) + // && getBlockState().get(ChuteBlock.FACING) == Direction.DOWN ? Direction.DOWN + // : Direction.UP; + // } } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/chute/SmartChuteRenderer.java b/src/main/java/com/simibubi/create/content/logistics/block/chute/SmartChuteRenderer.java index adf0967ca..f31cee7b8 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/chute/SmartChuteRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/chute/SmartChuteRenderer.java @@ -18,7 +18,7 @@ public class SmartChuteRenderer extends SmartTileEntityRenderer 0) + if (tileEntityIn.itemPosition.getValue(partialTicks) > 0) return; ChuteRenderer.renderItem(tileEntityIn, partialTicks, ms, buffer, light, overlay); } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/display/DisplayLinkScreen.java b/src/main/java/com/simibubi/create/content/logistics/block/display/DisplayLinkScreen.java index e9c21649a..1f26ab22f 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/display/DisplayLinkScreen.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/display/DisplayLinkScreen.java @@ -3,7 +3,6 @@ package com.simibubi.create.content.logistics.block.display; import java.util.Collections; import java.util.List; -import com.google.common.collect.ImmutableList; import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.content.logistics.block.display.source.DisplaySource; @@ -25,8 +24,6 @@ import com.simibubi.create.foundation.gui.widget.ScrollInput; import com.simibubi.create.foundation.gui.widget.SelectionScrollInput; import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.ponder.PonderTag; -import com.simibubi.create.foundation.ponder.ui.NavigatableSimiScreen; -import com.simibubi.create.foundation.ponder.ui.PonderButton; import com.simibubi.create.foundation.ponder.ui.PonderTagScreen; import com.simibubi.create.foundation.utility.Couple; import com.simibubi.create.foundation.utility.Lang; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/display/target/LecternDisplayTarget.java b/src/main/java/com/simibubi/create/content/logistics/block/display/target/LecternDisplayTarget.java index f5e4324c6..1b2af9226 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/display/target/LecternDisplayTarget.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/display/target/LecternDisplayTarget.java @@ -13,7 +13,6 @@ import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.LecternBlockEntity; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/display/target/SignDisplayTarget.java b/src/main/java/com/simibubi/create/content/logistics/block/display/target/SignDisplayTarget.java index 9e068f1e4..031f4fe0f 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/display/target/SignDisplayTarget.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/display/target/SignDisplayTarget.java @@ -5,7 +5,6 @@ import java.util.List; import com.simibubi.create.content.logistics.block.display.DisplayLinkContext; import net.minecraft.network.chat.MutableComponent; -import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.SignBlockEntity; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/funnel/AbstractDirectionalFunnelBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/funnel/AbstractDirectionalFunnelBlock.java index 0e8003634..9fabd9a11 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/funnel/AbstractDirectionalFunnelBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/funnel/AbstractDirectionalFunnelBlock.java @@ -33,6 +33,7 @@ public class AbstractDirectionalFunnelBlock extends AbstractFunnelBlock { } @Override + @SuppressWarnings("deprecation") public BlockState mirror(BlockState state, Mirror mirrorIn) { return state.rotate(mirrorIn.getRotation(state.getValue(FACING))); } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/funnel/AbstractHorizontalFunnelBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/funnel/AbstractHorizontalFunnelBlock.java index 180698d87..7e1b03073 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/funnel/AbstractHorizontalFunnelBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/funnel/AbstractHorizontalFunnelBlock.java @@ -33,6 +33,7 @@ public abstract class AbstractHorizontalFunnelBlock extends AbstractFunnelBlock } @Override + @SuppressWarnings("deprecation") public BlockState mirror(BlockState p_185471_1_, Mirror p_185471_2_) { return p_185471_1_.rotate(p_185471_2_.getRotation(p_185471_1_.getValue(HORIZONTAL_FACING))); } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelInstance.java b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelInstance.java index b5fd82fd1..24e44245e 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelInstance.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelInstance.java @@ -38,7 +38,7 @@ public class FunnelInstance extends BlockEntityInstance implem Direction direction = FunnelBlock.getFunnelFacing(blockState); - float flapness = tile.flap.get(AnimationTickHolder.getPartialTicks()); + float flapness = tile.flap.getValue(AnimationTickHolder.getPartialTicks()); float horizontalAngle = direction.getOpposite().toYRot(); for (int segment = 0; segment <= 3; segment++) { @@ -65,7 +65,7 @@ public class FunnelInstance extends BlockEntityInstance implem public void beginFrame() { if (flaps == null) return; - float flapness = blockEntity.flap.get(AnimationTickHolder.getPartialTicks()); + float flapness = blockEntity.flap.getValue(AnimationTickHolder.getPartialTicks()); for (FlapData flap : flaps) { flap.setFlapness(flapness); diff --git a/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelRenderer.java b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelRenderer.java index 3a1d3cd76..1e62bf553 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelRenderer.java @@ -36,18 +36,18 @@ public class FunnelRenderer extends SmartTileEntityRenderer { BlockState blockState = te.getBlockState(); VertexConsumer vb = buffer.getBuffer(RenderType.solid()); PartialModel partialModel = (blockState.getBlock() instanceof FunnelBlock ? AllBlockPartials.FUNNEL_FLAP - : AllBlockPartials.BELT_FUNNEL_FLAP); + : AllBlockPartials.BELT_FUNNEL_FLAP); SuperByteBuffer flapBuffer = CachedBufferer.partial(partialModel, blockState); Vec3 pivot = VecHelper.voxelSpace(0, 10, 9.5f); TransformStack msr = TransformStack.cast(ms); float horizontalAngle = AngleHelper.horizontalAngle(FunnelBlock.getFunnelFacing(blockState) - .getOpposite()); - float f = te.flap.get(partialTicks); + .getOpposite()); + float f = te.flap.getValue(partialTicks); ms.pushPose(); msr.centre() - .rotateY(horizontalAngle) + .rotateY(horizontalAngle) .unCentre(); ms.translate(0, 0, -te.getFlapOffset()); diff --git a/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelTileEntity.java b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelTileEntity.java index c21554a91..b48342493 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelTileEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelTileEntity.java @@ -22,7 +22,8 @@ import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBe import com.simibubi.create.foundation.tileEntity.behaviour.inventory.InvManipulationBehaviour; import com.simibubi.create.foundation.utility.BlockFace; import com.simibubi.create.foundation.utility.VecHelper; -import com.simibubi.create.foundation.utility.animation.InterpolatedChasingValue; +import com.simibubi.create.foundation.utility.animation.LerpedFloat; +import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; @@ -45,7 +46,7 @@ public class FunnelTileEntity extends SmartTileEntity implements IHaveHoveringIn private WeakReference lastObserved; // In-world Extractors only - InterpolatedChasingValue flap; + LerpedFloat flap; static enum Mode { INVALID, PAUSED, COLLECT, PUSHING_TO_BELT, TAKING_FROM_BELT, EXTRACT @@ -54,9 +55,7 @@ public class FunnelTileEntity extends SmartTileEntity implements IHaveHoveringIn public FunnelTileEntity(BlockEntityType type, BlockPos pos, BlockState state) { super(type, pos, state); extractionCooldown = 0; - flap = new InterpolatedChasingValue().start(.25f) - .target(0) - .withSpeed(.05f); + flap = createChasingFlap(); } public Mode determineCurrentMode() { @@ -88,7 +87,7 @@ public class FunnelTileEntity extends SmartTileEntity implements IHaveHoveringIn @Override public void tick() { super.tick(); - flap.tick(); + flap.tickChaser(); Mode mode = determineCurrentMode(); if (level.isClientSide) return; @@ -287,7 +286,7 @@ public class FunnelTileEntity extends SmartTileEntity implements IHaveHoveringIn if (!level.isClientSide) { AllPackets.channel.send(packetTarget(), new FunnelFlapPacket(this, inward)); } else { - flap.set(inward ? 1 : -1); + flap.setValue(inward ? 1 : -1); AllSoundEvents.FUNNEL_FLAP.playAt(level, worldPosition, 1, 1, true); } } @@ -337,5 +336,11 @@ public class FunnelTileEntity extends SmartTileEntity implements IHaveHoveringIn .onFunnelTransfer(level, worldPosition, stack); award(AllAdvancements.FUNNEL); } + + private LerpedFloat createChasingFlap() { + return LerpedFloat.linear() + .startWithValue(.25f) + .chase(0, .05f, Chaser.EXP); + } } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInstance.java b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInstance.java index 2feb23b98..ab27c8f6a 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInstance.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInstance.java @@ -49,11 +49,16 @@ public class ArmInstance extends SingleRotatingInstance implements DynamicInstan Material mat = getTransformMaterial(); - base = mat.getModel(AllBlockPartials.ARM_BASE, blockState).createInstance(); - lowerBody = mat.getModel(AllBlockPartials.ARM_LOWER_BODY, blockState).createInstance(); - upperBody = mat.getModel(AllBlockPartials.ARM_UPPER_BODY, blockState).createInstance(); - head = mat.getModel(AllBlockPartials.ARM_HEAD, blockState).createInstance(); - claw = mat.getModel(AllBlockPartials.ARM_CLAW_BASE, blockState).createInstance(); + base = mat.getModel(AllBlockPartials.ARM_BASE, blockState) + .createInstance(); + lowerBody = mat.getModel(AllBlockPartials.ARM_LOWER_BODY, blockState) + .createInstance(); + upperBody = mat.getModel(AllBlockPartials.ARM_UPPER_BODY, blockState) + .createInstance(); + head = mat.getModel(AllBlockPartials.ARM_HEAD, blockState) + .createInstance(); + claw = mat.getModel(AllBlockPartials.ARM_CLAW_BASE, blockState) + .createInstance(); Instancer clawHalfModel = mat.getModel(AllBlockPartials.ARM_CLAW_GRIP, blockState); ModelData clawGrip1 = clawHalfModel.createInstance(); @@ -77,15 +82,13 @@ public class ArmInstance extends SingleRotatingInstance implements DynamicInstan float pt = AnimationTickHolder.getPartialTicks(); - float baseAngleNow = this.arm.baseAngle.get(pt); - float lowerArmAngleNow = this.arm.lowerArmAngle.get(pt); - float upperArmAngleNow = this.arm.upperArmAngle.get(pt); - float headAngleNow = this.arm.headAngle.get(pt); + float baseAngleNow = arm.baseAngle.getValue(pt); + float lowerArmAngleNow = arm.lowerArmAngle.getValue(pt); + float upperArmAngleNow = arm.upperArmAngle.getValue(pt); + float headAngleNow = arm.headAngle.getValue(pt); - boolean settled = Mth.equal(baseAngle, baseAngleNow) - && Mth.equal(lowerArmAngle, lowerArmAngleNow) - && Mth.equal(upperArmAngle, upperArmAngleNow) - && Mth.equal(headAngle, headAngleNow); + boolean settled = Mth.equal(baseAngle, baseAngleNow) && Mth.equal(lowerArmAngle, lowerArmAngleNow) + && Mth.equal(upperArmAngle, upperArmAngleNow) && Mth.equal(headAngle, headAngleNow); this.baseAngle = baseAngleNow; this.lowerArmAngle = lowerArmAngleNow; @@ -112,7 +115,8 @@ public class ArmInstance extends SingleRotatingInstance implements DynamicInstan lowerArmAngle = Mth.lerp((Mth.sin(renderTick / 4) + 1) / 2, -45, 15); upperArmAngle = Mth.lerp((Mth.sin(renderTick / 8) + 1) / 4, -45, 95); headAngle = -lowerArmAngle; - color = Color.rainbowColor(AnimationTickHolder.getTicks() * 100).getRGB(); + color = Color.rainbowColor(AnimationTickHolder.getTicks() * 100) + .getRGB(); } else { baseAngle = this.baseAngle; lowerArmAngle = this.lowerArmAngle - 135; @@ -122,7 +126,7 @@ public class ArmInstance extends SingleRotatingInstance implements DynamicInstan } PoseStack msLocal = new PoseStack(); - TransformStack msr = TransformStack.cast(msLocal); + TransformStack msr = TransformStack.cast(msLocal); msr.translate(getInstancePosition()); msr.centre(); @@ -134,11 +138,11 @@ public class ArmInstance extends SingleRotatingInstance implements DynamicInstan ArmRenderer.transformLowerArm(msr, lowerArmAngle); lowerBody.setTransform(msLocal) - .setColor(color); + .setColor(color); ArmRenderer.transformUpperArm(msr, upperArmAngle); upperBody.setTransform(msLocal) - .setColor(color); + .setColor(color); ArmRenderer.transformHead(msr, headAngle); head.setTransform(msLocal); @@ -148,17 +152,18 @@ public class ArmInstance extends SingleRotatingInstance implements DynamicInstan ItemStack item = this.arm.heldItem; ItemRenderer itemRenderer = Minecraft.getInstance() - .getItemRenderer(); + .getItemRenderer(); boolean hasItem = !item.isEmpty(); boolean isBlockItem = hasItem && (item.getItem() instanceof BlockItem) - && itemRenderer.getModel(item, Minecraft.getInstance().level, null, 0) + && itemRenderer.getModel(item, Minecraft.getInstance().level, null, 0) .isGui3d(); for (int index : Iterate.zeroAndOne) { msLocal.pushPose(); int flip = index * 2 - 1; ArmRenderer.transformClawHalf(msr, hasItem, isBlockItem, flip); - clawGrips.get(index).setTransform(msLocal); + clawGrips.get(index) + .setTransform(msLocal); msLocal.popPose(); } } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmRenderer.java b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmRenderer.java index c8212791f..1baec6fdc 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmRenderer.java @@ -41,20 +41,21 @@ public class ArmRenderer extends KineticTileEntityRenderer { boolean hasItem = !item.isEmpty(); boolean usingFlywheel = Backend.canUseInstancing(te.getLevel()); - if (usingFlywheel && !hasItem) return; + if (usingFlywheel && !hasItem) + return; ItemRenderer itemRenderer = Minecraft.getInstance() - .getItemRenderer(); + .getItemRenderer(); - boolean isBlockItem = hasItem && (item.getItem() instanceof BlockItem) - && itemRenderer.getModel(item, te.getLevel(), null, 0) - .isGui3d(); + boolean isBlockItem = + hasItem && (item.getItem() instanceof BlockItem) && itemRenderer.getModel(item, te.getLevel(), null, 0) + .isGui3d(); VertexConsumer builder = buffer.getBuffer(RenderType.solid()); BlockState blockState = te.getBlockState(); PoseStack msLocal = new PoseStack(); - TransformStack msr = TransformStack.cast(msLocal); + TransformStack msr = TransformStack.cast(msLocal); float baseAngle; float lowerArmAngle; @@ -69,12 +70,13 @@ public class ArmRenderer extends KineticTileEntityRenderer { lowerArmAngle = Mth.lerp((Mth.sin(renderTick / 4) + 1) / 2, -45, 15); upperArmAngle = Mth.lerp((Mth.sin(renderTick / 8) + 1) / 4, -45, 95); headAngle = -lowerArmAngle; - color = Color.rainbowColor(AnimationTickHolder.getTicks() * 100).getRGB(); + color = Color.rainbowColor(AnimationTickHolder.getTicks() * 100) + .getRGB(); } else { - baseAngle = arm.baseAngle.get(pt); - lowerArmAngle = arm.lowerArmAngle.get(pt) - 135; - upperArmAngle = arm.upperArmAngle.get(pt) - 90; - headAngle = arm.headAngle.get(pt); + baseAngle = arm.baseAngle.getValue(pt); + lowerArmAngle = arm.lowerArmAngle.getValue(pt) - 135; + upperArmAngle = arm.upperArmAngle.getValue(pt) - 90; + headAngle = arm.headAngle.getValue(pt); color = 0xFFFFFF; } @@ -86,7 +88,8 @@ public class ArmRenderer extends KineticTileEntityRenderer { if (usingFlywheel) doItemTransforms(msr, baseAngle, lowerArmAngle, upperArmAngle, headAngle); else - renderArm(builder, ms, msLocal, msr, blockState, color, baseAngle, lowerArmAngle, upperArmAngle, headAngle, hasItem, isBlockItem, light); + renderArm(builder, ms, msLocal, msr, blockState, color, baseAngle, lowerArmAngle, upperArmAngle, headAngle, + hasItem, isBlockItem, light); if (hasItem) { ms.pushPose(); @@ -95,36 +98,45 @@ public class ArmRenderer extends KineticTileEntityRenderer { msLocal.translate(0, -4 / 16f, 0); msLocal.scale(itemScale, itemScale, itemScale); - ms.last().pose().multiply(msLocal.last().pose()); + ms.last() + .pose() + .multiply(msLocal.last() + .pose()); - itemRenderer - .renderStatic(item, TransformType.FIXED, light, overlay, ms, buffer, 0); + itemRenderer.renderStatic(item, TransformType.FIXED, light, overlay, ms, buffer, 0); ms.popPose(); } } - private void renderArm(VertexConsumer builder, PoseStack ms, PoseStack msLocal, TransformStack msr, BlockState blockState, int color, float baseAngle, float lowerArmAngle, float upperArmAngle, float headAngle, boolean hasItem, boolean isBlockItem, int light) { - SuperByteBuffer base = CachedBufferer.partial(AllBlockPartials.ARM_BASE, blockState).light(light); - SuperByteBuffer lowerBody = CachedBufferer.partial(AllBlockPartials.ARM_LOWER_BODY, blockState).light(light); - SuperByteBuffer upperBody = CachedBufferer.partial(AllBlockPartials.ARM_UPPER_BODY, blockState).light(light); - SuperByteBuffer head = CachedBufferer.partial(AllBlockPartials.ARM_HEAD, blockState).light(light); - SuperByteBuffer claw = CachedBufferer.partial(AllBlockPartials.ARM_CLAW_BASE, blockState).light(light); + private void renderArm(VertexConsumer builder, PoseStack ms, PoseStack msLocal, TransformStack msr, + BlockState blockState, int color, float baseAngle, float lowerArmAngle, float upperArmAngle, float headAngle, + boolean hasItem, boolean isBlockItem, int light) { + SuperByteBuffer base = CachedBufferer.partial(AllBlockPartials.ARM_BASE, blockState) + .light(light); + SuperByteBuffer lowerBody = CachedBufferer.partial(AllBlockPartials.ARM_LOWER_BODY, blockState) + .light(light); + SuperByteBuffer upperBody = CachedBufferer.partial(AllBlockPartials.ARM_UPPER_BODY, blockState) + .light(light); + SuperByteBuffer head = CachedBufferer.partial(AllBlockPartials.ARM_HEAD, blockState) + .light(light); + SuperByteBuffer claw = CachedBufferer.partial(AllBlockPartials.ARM_CLAW_BASE, blockState) + .light(light); SuperByteBuffer clawGrip = CachedBufferer.partial(AllBlockPartials.ARM_CLAW_GRIP, blockState); transformBase(msr, baseAngle); base.transform(msLocal) - .renderInto(ms, builder); + .renderInto(ms, builder); transformLowerArm(msr, lowerArmAngle); lowerBody.color(color) - .transform(msLocal) - .renderInto(ms, builder); + .transform(msLocal) + .renderInto(ms, builder); transformUpperArm(msr, upperArmAngle); upperBody.color(color) - .transform(msLocal) - .renderInto(ms, builder); + .transform(msLocal) + .renderInto(ms, builder); transformHead(msr, headAngle); head.transform(msLocal) @@ -137,12 +149,15 @@ public class ArmRenderer extends KineticTileEntityRenderer { for (int flip : Iterate.positiveAndNegative) { msLocal.pushPose(); transformClawHalf(msr, hasItem, isBlockItem, flip); - clawGrip.light(light).transform(msLocal).renderInto(ms, builder); + clawGrip.light(light) + .transform(msLocal) + .renderInto(ms, builder); msLocal.popPose(); } } - private void doItemTransforms(TransformStack msr, float baseAngle, float lowerArmAngle, float upperArmAngle, float headAngle) { + private void doItemTransforms(TransformStack msr, float baseAngle, float lowerArmAngle, float upperArmAngle, + float headAngle) { transformBase(msr, baseAngle); transformLowerArm(msr, lowerArmAngle); diff --git a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmTileEntity.java b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmTileEntity.java index 45394f290..f1f818632 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmTileEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmTileEntity.java @@ -23,7 +23,7 @@ import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.VecHelper; -import com.simibubi.create.foundation.utility.animation.InterpolatedAngle; +import com.simibubi.create.foundation.utility.animation.LerpedFloat; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; @@ -57,11 +57,11 @@ public class ArmTileEntity extends KineticTileEntity implements ITransformableTE // Client ArmAngleTarget previousTarget; - InterpolatedAngle lowerArmAngle; - InterpolatedAngle upperArmAngle; - InterpolatedAngle baseAngle; - InterpolatedAngle headAngle; - InterpolatedAngle clawAngle; + LerpedFloat lowerArmAngle; + LerpedFloat upperArmAngle; + LerpedFloat baseAngle; + LerpedFloat headAngle; + LerpedFloat clawAngle; float previousBaseAngle; boolean updateInteractionPoints; @@ -83,15 +83,15 @@ public class ArmTileEntity extends KineticTileEntity implements ITransformableTE heldItem = ItemStack.EMPTY; phase = Phase.SEARCH_INPUTS; previousTarget = ArmAngleTarget.NO_TARGET; - baseAngle = new InterpolatedAngle(); - baseAngle.init(previousTarget.baseAngle); - lowerArmAngle = new InterpolatedAngle(); - lowerArmAngle.init(previousTarget.lowerArmAngle); - upperArmAngle = new InterpolatedAngle(); - upperArmAngle.init(previousTarget.upperArmAngle); - headAngle = new InterpolatedAngle(); - headAngle.init(previousTarget.headAngle); - clawAngle = new InterpolatedAngle(); + baseAngle = LerpedFloat.angular(); + baseAngle.startWithValue(previousTarget.baseAngle); + lowerArmAngle = LerpedFloat.angular(); + lowerArmAngle.startWithValue(previousTarget.lowerArmAngle); + upperArmAngle = LerpedFloat.angular(); + upperArmAngle.startWithValue(previousTarget.upperArmAngle); + headAngle = LerpedFloat.angular(); + headAngle.startWithValue(previousTarget.headAngle); + clawAngle = LerpedFloat.angular(); previousBaseAngle = previousTarget.baseAngle; updateInteractionPoints = true; redstoneLocked = false; @@ -191,7 +191,7 @@ public class ArmTileEntity extends KineticTileEntity implements ITransformableTE ArmAngleTarget target = targetedInteractionPoint == null ? ArmAngleTarget.NO_TARGET : targetedInteractionPoint.getTargetAngles(worldPosition, isOnCeiling()); - baseAngle.set(AngleHelper.angleLerp(chasedPointProgress, previousBaseAngle, + baseAngle.setValue(AngleHelper.angleLerp(chasedPointProgress, previousBaseAngle, target == ArmAngleTarget.NO_TARGET ? previousBaseAngle : target.baseAngle)); // Arm's angles first backup to resting position and then continue @@ -201,10 +201,10 @@ public class ArmTileEntity extends KineticTileEntity implements ITransformableTE previousTarget = ArmAngleTarget.NO_TARGET; float progress = chasedPointProgress == 1 ? 1 : (chasedPointProgress % .5f) * 2; - lowerArmAngle.set(Mth.lerp(progress, previousTarget.lowerArmAngle, target.lowerArmAngle)); - upperArmAngle.set(Mth.lerp(progress, previousTarget.upperArmAngle, target.upperArmAngle)); + lowerArmAngle.setValue(Mth.lerp(progress, previousTarget.lowerArmAngle, target.lowerArmAngle)); + upperArmAngle.setValue(Mth.lerp(progress, previousTarget.upperArmAngle, target.upperArmAngle)); + headAngle.setValue(AngleHelper.angleLerp(progress, previousTarget.headAngle % 360, target.headAngle % 360)); - headAngle.set(AngleHelper.angleLerp(progress, previousTarget.headAngle % 360, target.headAngle % 360)); return false; } @@ -342,11 +342,11 @@ public class ArmTileEntity extends KineticTileEntity implements ITransformableTE ItemStack toInsert = heldItem.copy(); ItemStack remainder = armInteractionPoint.insert(toInsert, false); heldItem = remainder; - + if (armInteractionPoint instanceof JukeboxPoint && remainder.isEmpty()) award(AllAdvancements.MUSICAL_ARM); } - + phase = heldItem.isEmpty() ? Phase.SEARCH_INPUTS : Phase.SEARCH_OUTPUTS; chasedPointProgress = 0; chasedPointIndex = -1; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverInstance.java b/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverInstance.java index 4195b9dde..86a77af8b 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverInstance.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverInstance.java @@ -17,64 +17,65 @@ import net.minecraft.world.level.block.state.properties.AttachFace; public class AnalogLeverInstance extends BlockEntityInstance implements DynamicInstance { - protected final ModelData handle; - protected final ModelData indicator; + protected final ModelData handle; + protected final ModelData indicator; - final float rX; - final float rY; + final float rX; + final float rY; - public AnalogLeverInstance(MaterialManager modelManager, AnalogLeverTileEntity tile) { - super(modelManager, tile); + public AnalogLeverInstance(MaterialManager modelManager, AnalogLeverTileEntity tile) { + super(modelManager, tile); - Material mat = getTransformMaterial(); + Material mat = getTransformMaterial(); - handle = mat.getModel(AllBlockPartials.ANALOG_LEVER_HANDLE, blockState).createInstance(); - indicator = mat.getModel(AllBlockPartials.ANALOG_LEVER_INDICATOR, blockState).createInstance(); + handle = mat.getModel(AllBlockPartials.ANALOG_LEVER_HANDLE, blockState) + .createInstance(); + indicator = mat.getModel(AllBlockPartials.ANALOG_LEVER_INDICATOR, blockState) + .createInstance(); transform(indicator); - AttachFace face = blockState.getValue(AnalogLeverBlock.FACE); - rX = face == AttachFace.FLOOR ? 0 : face == AttachFace.WALL ? 90 : 180; - rY = AngleHelper.horizontalAngle(blockState.getValue(AnalogLeverBlock.FACING)); + AttachFace face = blockState.getValue(AnalogLeverBlock.FACE); + rX = face == AttachFace.FLOOR ? 0 : face == AttachFace.WALL ? 90 : 180; + rY = AngleHelper.horizontalAngle(blockState.getValue(AnalogLeverBlock.FACING)); - animateLever(); - } + animateLever(); + } - @Override - public void beginFrame() { - if (!blockEntity.clientState.settled()) - animateLever(); - } + @Override + public void beginFrame() { + if (!blockEntity.clientState.settled()) + animateLever(); + } - protected void animateLever() { - float state = blockEntity.clientState.get(AnimationTickHolder.getPartialTicks()); + protected void animateLever() { + float state = blockEntity.clientState.getValue(AnimationTickHolder.getPartialTicks()); indicator.setColor(Color.mixColors(0x2C0300, 0xCD0000, state / 15f)); - float angle = (float) ((state / 15) * 90 / 180 * Math.PI); + float angle = (float) ((state / 15) * 90 / 180 * Math.PI); - transform(handle.loadIdentity()) - .translate(1 / 2f, 1 / 16f, 1 / 2f) - .rotate(Direction.EAST, angle) - .translate(-1 / 2f, -1 / 16f, -1 / 2f); + transform(handle.loadIdentity()).translate(1 / 2f, 1 / 16f, 1 / 2f) + .rotate(Direction.EAST, angle) + .translate(-1 / 2f, -1 / 16f, -1 / 2f); } - @Override - public void remove() { - handle.delete(); - indicator.delete(); - } + @Override + public void remove() { + handle.delete(); + indicator.delete(); + } - @Override - public void updateLight() { - relight(pos, handle, indicator); - } + @Override + public void updateLight() { + relight(pos, handle, indicator); + } - private & Rotate> T transform(T msr) { - return msr.translate(getInstancePosition()) - .centre() - .rotate(Direction.UP, (float) (rY / 180 * Math.PI)) - .rotate(Direction.EAST, (float) (rX / 180 * Math.PI)) - .unCentre(); - } + private & Rotate> T transform(T msr) { + return msr.translate(getInstancePosition()) + .centre() + .rotate(Direction.UP, (float) (rY / 180 * Math.PI)) + .rotate(Direction.EAST, (float) (rX / 180 * Math.PI)) + .unCentre(); + } } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverRenderer.java b/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverRenderer.java index 2d6026c16..8fb88fd82 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverRenderer.java @@ -29,7 +29,7 @@ public class AnalogLeverRenderer extends SafeTileEntityRenderer type, BlockPos pos, BlockState state) { super(type, pos, state); + clientState = LerpedFloat.linear(); } @Override @@ -36,7 +38,7 @@ public class AnalogLeverTileEntity extends SmartTileEntity implements IHaveGoggl protected void read(CompoundTag compound, boolean clientPacket) { state = compound.getInt("State"); lastChange = compound.getInt("ChangeTimer"); - clientState.target(state); + clientState.chase(state, 0.2f, Chaser.EXP); super.read(compound, clientPacket); } @@ -49,7 +51,7 @@ public class AnalogLeverTileEntity extends SmartTileEntity implements IHaveGoggl updateOutput(); } if (level.isClientSide) - clientState.tick(); + clientState.tickChaser(); } @Override diff --git a/src/main/java/com/simibubi/create/content/logistics/block/redstone/StockpileSwitchBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/redstone/StockpileSwitchBlock.java index dc548ab53..8b28fab10 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/redstone/StockpileSwitchBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/redstone/StockpileSwitchBlock.java @@ -73,10 +73,6 @@ public class StockpileSwitchBlock extends HorizontalDirectionalBlock withTileEntityDo(world, pos, StockpileSwitchTileEntity::updateCurrentLevel); } - private boolean isObserving(BlockState state, BlockPos pos, BlockPos observing) { - return observing.equals(pos.relative(state.getValue(FACING))); - } - @Override public boolean canConnectRedstone(BlockState state, BlockGetter world, BlockPos pos, Direction side) { return side != null && side.getOpposite() != state.getValue(FACING); diff --git a/src/main/java/com/simibubi/create/content/schematics/SchematicPrinter.java b/src/main/java/com/simibubi/create/content/schematics/SchematicPrinter.java index 9df53cf9a..528e67b2b 100644 --- a/src/main/java/com/simibubi/create/content/schematics/SchematicPrinter.java +++ b/src/main/java/com/simibubi/create/content/schematics/SchematicPrinter.java @@ -9,6 +9,7 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Blo import com.simibubi.create.content.contraptions.components.structureMovement.StructureTransform; import com.simibubi.create.content.schematics.item.SchematicItem; import com.simibubi.create.foundation.tileEntity.IMergeableTE; +import com.simibubi.create.foundation.utility.BBHelper; import com.simibubi.create.foundation.utility.BlockHelper; import net.minecraft.core.BlockPos; @@ -96,7 +97,7 @@ public class SchematicPrinter { BlockPos extraBounds = StructureTemplate.calculateRelativePosition(settings, new BlockPos(activeTemplate.getSize()) .offset(-1, -1, -1)); - blockReader.bounds.encapsulate(BoundingBox.fromCorners(extraBounds, extraBounds)); + blockReader.bounds = BBHelper.encapsulate(blockReader.bounds, extraBounds); StructureTransform transform = new StructureTransform(settings.getRotationPivot(), Direction.Axis.Y, settings.getRotation(), settings.getMirror()); @@ -237,7 +238,7 @@ public class SchematicPrinter { BlockState required = blockReader.getBlockState(relPos); BlockEntity requiredTE = blockReader.getBlockEntity(relPos); - if (!world.isAreaLoaded(pos.offset(schematicAnchor), 0)) { + if (!world.isLoaded(pos.offset(schematicAnchor))) { checklist.warnBlockNotLoaded(); continue; } diff --git a/src/main/java/com/simibubi/create/content/schematics/SchematicWorld.java b/src/main/java/com/simibubi/create/content/schematics/SchematicWorld.java index b03fc9b00..e503b539a 100644 --- a/src/main/java/com/simibubi/create/content/schematics/SchematicWorld.java +++ b/src/main/java/com/simibubi/create/content/schematics/SchematicWorld.java @@ -10,6 +10,7 @@ import java.util.function.Predicate; import java.util.stream.Stream; import com.simibubi.create.Create; +import com.simibubi.create.foundation.utility.BBHelper; import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld; import net.minecraft.core.BlockPos; @@ -203,7 +204,7 @@ public class SchematicWorld extends WrappedWorld implements ServerLevelAccessor public boolean setBlock(BlockPos pos, BlockState arg1, int arg2) { pos = pos.immutable() .subtract(anchor); - bounds.encapsulate(BoundingBox.fromCorners(pos, pos)); + bounds = BBHelper.encapsulate(bounds, pos); blocks.put(pos, arg1); if (tileEntities.containsKey(pos)) { BlockEntity tileEntity = tileEntities.get(pos); diff --git a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java index f2da30a84..89a10159f 100644 --- a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java +++ b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java @@ -359,7 +359,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements MenuPro } // Check block - if (!getLevel().isAreaLoaded(printer.getCurrentTarget(), 0)) { + if (!getLevel().isLoaded(printer.getCurrentTarget())) { positionNotLoaded = true; statusMsg = "targetNotLoaded"; state = State.PAUSED; diff --git a/src/main/java/com/simibubi/create/content/schematics/client/SchematicHandler.java b/src/main/java/com/simibubi/create/content/schematics/client/SchematicHandler.java index dfe9c35e3..9269de411 100644 --- a/src/main/java/com/simibubi/create/content/schematics/client/SchematicHandler.java +++ b/src/main/java/com/simibubi/create/content/schematics/client/SchematicHandler.java @@ -189,9 +189,9 @@ public class SchematicHandler { if (!renderers.isEmpty()) { float pt = AnimationTickHolder.getPartialTicks(); boolean lr = transformation.getScaleLR() - .get(pt) < 0; + .getValue(pt) < 0; boolean fb = transformation.getScaleFB() - .get(pt) < 0; + .getValue(pt) < 0; if (lr && !fb) renderers.get(2) .render(ms, buffer); diff --git a/src/main/java/com/simibubi/create/content/schematics/client/SchematicTransformation.java b/src/main/java/com/simibubi/create/content/schematics/client/SchematicTransformation.java index 73b27b5a2..d9d7628aa 100644 --- a/src/main/java/com/simibubi/create/content/schematics/client/SchematicTransformation.java +++ b/src/main/java/com/simibubi/create/content/schematics/client/SchematicTransformation.java @@ -6,8 +6,8 @@ import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.VecHelper; -import com.simibubi.create.foundation.utility.animation.InterpolatedChasingAngle; -import com.simibubi.create.foundation.utility.animation.InterpolatedChasingValue; +import com.simibubi.create.foundation.utility.animation.LerpedFloat; +import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction.Axis; @@ -19,49 +19,55 @@ import net.minecraft.world.phys.Vec3; public class SchematicTransformation { - private InterpolatedChasingValue x, y, z, scaleFrontBack, scaleLeftRight; - private InterpolatedChasingAngle rotation; + private LerpedFloat x, y, z, scaleFrontBack, scaleLeftRight; + private LerpedFloat rotation; private double xOrigin; private double zOrigin; public SchematicTransformation() { - x = new InterpolatedChasingValue(); - y = new InterpolatedChasingValue(); - z = new InterpolatedChasingValue(); - scaleFrontBack = new InterpolatedChasingValue(); - scaleLeftRight = new InterpolatedChasingValue(); - rotation = new InterpolatedChasingAngle(); + x = LerpedFloat.linear(); + y = LerpedFloat.linear(); + z = LerpedFloat.linear(); + scaleFrontBack = LerpedFloat.linear(); + scaleLeftRight = LerpedFloat.linear(); + rotation = LerpedFloat.angular(); } public void init(BlockPos anchor, StructurePlaceSettings settings, AABB bounds) { int leftRight = settings.getMirror() == Mirror.LEFT_RIGHT ? -1 : 1; int frontBack = settings.getMirror() == Mirror.FRONT_BACK ? -1 : 1; - getScaleFB().start(frontBack); - getScaleLR().start(leftRight); + getScaleFB().chase(0, 0.45f, Chaser.EXP) + .startWithValue(frontBack); + getScaleLR().chase(0, 0.45f, Chaser.EXP) + .startWithValue(leftRight); xOrigin = bounds.getXsize() / 2f; zOrigin = bounds.getZsize() / 2f; int r = -(settings.getRotation() .ordinal() * 90); - rotation.start(r); + rotation.chase(0, 0.45f, Chaser.EXP) + .startWithValue(r); Vec3 vec = fromAnchor(anchor); - x.start((float) vec.x); - y.start((float) vec.y); - z.start((float) vec.z); + x.chase(0, 0.45f, Chaser.EXP) + .startWithValue((float) vec.x); + y.chase(0, 0.45f, Chaser.EXP) + .startWithValue((float) vec.y); + z.chase(0, 0.45f, Chaser.EXP) + .startWithValue((float) vec.z); } public void applyGLTransformations(PoseStack ms) { float pt = AnimationTickHolder.getPartialTicks(); // Translation - ms.translate(x.get(pt), y.get(pt), z.get(pt)); + ms.translate(x.getValue(pt), y.getValue(pt), z.getValue(pt)); Vec3 rotationOffset = getRotationOffset(true); // Rotation & Mirror - float fb = getScaleFB().get(pt); - float lr = getScaleLR().get(pt); - float rot = rotation.get(pt) + ((fb < 0 && lr < 0) ? 180 : 0); + float fb = getScaleFB().getValue(pt); + float lr = getScaleLR().getValue(pt); + float rot = rotation.getValue(pt) + ((fb < 0 && lr < 0) ? 180 : 0); ms.translate(xOrigin, 0, zOrigin); TransformStack.cast(ms) .translate(rotationOffset) @@ -95,11 +101,11 @@ public class SchematicTransformation { float pt = AnimationTickHolder.getPartialTicks(); Vec3 rotationOffset = getRotationOffset(true); - vec = vec.subtract(x.get(pt), y.get(pt), z.get(pt)); + vec = vec.subtract(x.getValue(pt), y.getValue(pt), z.getValue(pt)); vec = vec.subtract(xOrigin + rotationOffset.x, 0, zOrigin + rotationOffset.z); - vec = VecHelper.rotate(vec, -rotation.get(pt), Axis.Y); + vec = VecHelper.rotate(vec, -rotation.getValue(pt), Axis.Y); vec = vec.add(rotationOffset.x, 0, rotationOffset.z); - vec = vec.multiply(getScaleFB().get(pt), 1, getScaleLR().get(pt)); + vec = vec.multiply(getScaleFB().getValue(pt), 1, getScaleLR().getValue(pt)); vec = vec.add(xOrigin, 0, zOrigin); return vec; @@ -108,10 +114,10 @@ public class SchematicTransformation { public StructurePlaceSettings toSettings() { StructurePlaceSettings settings = new StructurePlaceSettings(); - int i = (int) rotation.getTarget(); + int i = (int) rotation.getChaseTarget(); - boolean mirrorlr = getScaleLR().getTarget() < 0; - boolean mirrorfb = getScaleFB().getTarget() < 0; + boolean mirrorlr = getScaleLR().getChaseTarget() < 0; + boolean mirrorfb = getScaleFB().getChaseTarget() < 0; if (mirrorlr && mirrorfb) { mirrorlr = mirrorfb = false; i += 180; @@ -148,11 +154,11 @@ public class SchematicTransformation { Vec3 rotationOffset = getRotationOffset(false); vec = vec.subtract(xOrigin, 0, zOrigin); vec = vec.subtract(rotationOffset.x, 0, rotationOffset.z); - vec = vec.multiply(getScaleFB().getTarget(), 1, getScaleLR().getTarget()); - vec = VecHelper.rotate(vec, rotation.getTarget(), Axis.Y); + vec = vec.multiply(getScaleFB().getChaseTarget(), 1, getScaleLR().getChaseTarget()); + vec = VecHelper.rotate(vec, rotation.getChaseTarget(), Axis.Y); vec = vec.add(xOrigin, 0, zOrigin); - vec = vec.add(x.getTarget(), y.getTarget(), z.getTarget()); + vec = vec.add(x.getChaseTarget(), y.getChaseTarget(), z.getChaseTarget()); return new BlockPos(vec.x, vec.y, vec.z); } @@ -161,56 +167,56 @@ public class SchematicTransformation { Vec3 rotationOffset = getRotationOffset(false); vec = vec.subtract(xOrigin, 0, zOrigin); vec = vec.subtract(rotationOffset.x, 0, rotationOffset.z); - vec = vec.multiply(getScaleFB().getTarget(), 1, getScaleLR().getTarget()); - vec = VecHelper.rotate(vec, rotation.getTarget(), Axis.Y); + vec = vec.multiply(getScaleFB().getChaseTarget(), 1, getScaleLR().getChaseTarget()); + vec = VecHelper.rotate(vec, rotation.getChaseTarget(), Axis.Y); vec = vec.add(xOrigin, 0, zOrigin); return Vec3.atLowerCornerOf(pos.subtract(new BlockPos(vec.x, vec.y, vec.z))); } public int getRotationTarget() { - return (int) rotation.getTarget(); + return (int) rotation.getChaseTarget(); } public int getMirrorModifier(Axis axis) { if (axis == Axis.Z) - return (int) getScaleLR().getTarget(); - return (int) getScaleFB().getTarget(); + return (int) getScaleLR().getChaseTarget(); + return (int) getScaleFB().getChaseTarget(); } public float getCurrentRotation() { float pt = AnimationTickHolder.getPartialTicks(); - return rotation.get(pt); + return rotation.getValue(pt); } public void tick() { - x.tick(); - y.tick(); - z.tick(); - getScaleLR().tick(); - getScaleFB().tick(); - rotation.tick(); + x.tickChaser(); + y.tickChaser(); + z.tickChaser(); + getScaleLR().tickChaser(); + getScaleFB().tickChaser(); + rotation.tickChaser(); } public void flip(Axis axis) { if (axis == Axis.X) - getScaleLR().target(getScaleLR().getTarget() * -1); + getScaleLR().updateChaseTarget(getScaleLR().getChaseTarget() * -1); if (axis == Axis.Z) - getScaleFB().target(getScaleFB().getTarget() * -1); + getScaleFB().updateChaseTarget(getScaleFB().getChaseTarget() * -1); } public void rotate90(boolean clockwise) { - rotation.target(rotation.getTarget() + (clockwise ? -90 : 90)); + rotation.updateChaseTarget(rotation.getChaseTarget() + (clockwise ? -90 : 90)); } public void move(float xIn, float yIn, float zIn) { - moveTo(x.getTarget() + xIn, y.getTarget() + yIn, z.getTarget() + zIn); + moveTo(x.getChaseTarget() + xIn, y.getChaseTarget() + yIn, z.getChaseTarget() + zIn); } public void startAt(BlockPos pos) { - x.start(pos.getX()); - y.start(0); - z.start(pos.getZ()); + x.startWithValue(pos.getX()); + y.startWithValue(pos.getY() - 10); + z.startWithValue(pos.getZ()); moveTo(pos); } @@ -219,16 +225,16 @@ public class SchematicTransformation { } public void moveTo(float xIn, float yIn, float zIn) { - x.target(xIn); - y.target(yIn); - z.target(zIn); + x.updateChaseTarget(xIn); + y.updateChaseTarget(yIn); + z.updateChaseTarget(zIn); } - public InterpolatedChasingValue getScaleFB() { + public LerpedFloat getScaleFB() { return scaleFrontBack; } - public InterpolatedChasingValue getScaleLR() { + public LerpedFloat getScaleLR() { return scaleLeftRight; } diff --git a/src/main/java/com/simibubi/create/content/schematics/client/tools/DeployTool.java b/src/main/java/com/simibubi/create/content/schematics/client/tools/DeployTool.java index 02181b313..e2abd68c1 100644 --- a/src/main/java/com/simibubi/create/content/schematics/client/tools/DeployTool.java +++ b/src/main/java/com/simibubi/create/content/schematics/client/tools/DeployTool.java @@ -96,6 +96,8 @@ public class DeployTool extends PlacementToolBase { .putBoolean("Deployed", true); item.getTag() .put("Anchor", NbtUtils.writeBlockPos(target)); + schematicHandler.getTransformation() + .startAt(target); } schematicHandler.getTransformation() diff --git a/src/main/java/com/simibubi/create/foundation/block/WrenchableDirectionalBlock.java b/src/main/java/com/simibubi/create/foundation/block/WrenchableDirectionalBlock.java index def8bdcff..2714f87dd 100644 --- a/src/main/java/com/simibubi/create/foundation/block/WrenchableDirectionalBlock.java +++ b/src/main/java/com/simibubi/create/foundation/block/WrenchableDirectionalBlock.java @@ -47,6 +47,7 @@ public class WrenchableDirectionalBlock extends DirectionalBlock implements IWre } @Override + @SuppressWarnings("deprecation") public BlockState mirror(BlockState state, Mirror mirrorIn) { return state.rotate(mirrorIn.getRotation(state.getValue(FACING))); } diff --git a/src/main/java/com/simibubi/create/foundation/config/CClient.java b/src/main/java/com/simibubi/create/foundation/config/CClient.java index 4bd6662c5..01f374a13 100644 --- a/src/main/java/com/simibubi/create/foundation/config/CClient.java +++ b/src/main/java/com/simibubi/create/foundation/config/CClient.java @@ -74,7 +74,7 @@ public class CClient extends ConfigBase { Comments.ambientVolumeCap); //train group - public final ConfigGroup trains = group(1, "trains"); + public final ConfigGroup trains = group(1, "trains", Comments.trains); public final ConfigFloat mountedZoomMultiplier = f(3, 0, "mountedZoomMultiplier", Comments.mountedZoomMultiplier); @Override diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/ConfigHelper.java b/src/main/java/com/simibubi/create/foundation/config/ui/ConfigHelper.java index 6d4cf2713..af0e38450 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/ConfigHelper.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/ConfigHelper.java @@ -35,24 +35,30 @@ public class ConfigHelper { public static final Pattern annotationPattern = Pattern.compile("\\[@cui:([^:]*)(?::(.*))?]"); public static final Map changes = new HashMap<>(); - private static final LoadingCache> configCache = CacheBuilder.newBuilder().expireAfterAccess(5, TimeUnit.MINUTES).build( - new CacheLoader>() { + private static final LoadingCache> configCache = + CacheBuilder.newBuilder() + .expireAfterAccess(5, TimeUnit.MINUTES) + .build(new CacheLoader>() { @Override public EnumMap load(@Nonnull String key) { return findModConfigsUncached(key); } - } - ); + }); private static EnumMap findModConfigsUncached(String modID) { - ModContainer modContainer = ModList.get().getModContainerById(modID).orElseThrow(() -> new IllegalArgumentException("Unable to find ModContainer for id: " + modID)); - EnumMap configs = ObfuscationReflectionHelper.getPrivateValue(ModContainer.class, modContainer, "configs"); + ModContainer modContainer = ModList.get() + .getModContainerById(modID) + .orElseThrow(() -> new IllegalArgumentException("Unable to find ModContainer for id: " + modID)); + EnumMap configs = + ObfuscationReflectionHelper.getPrivateValue(ModContainer.class, modContainer, "configs"); return Objects.requireNonNull(configs); } public static IConfigSpec findConfigSpecFor(ModConfig.Type type, String modID) { if (!modID.equals(Create.ID)) - return configCache.getUnchecked(modID).get(type).getSpec(); + return configCache.getUnchecked(modID) + .get(type) + .getSpec(); return AllConfigs.byType(type).specification; } @@ -67,13 +73,17 @@ public class ConfigHelper { public static boolean hasAnyConfig(String modID) { if (!modID.equals(Create.ID)) - return !configCache.getUnchecked(modID).isEmpty(); + return !configCache.getUnchecked(modID) + .isEmpty(); return true; } public static boolean hasAnyForgeConfig(String modID) { if (!modID.equals(Create.ID)) - return configCache.getUnchecked(modID).values().stream().anyMatch(config -> config.getSpec() instanceof ForgeConfigSpec); + return configCache.getUnchecked(modID) + .values() + .stream() + .anyMatch(config -> config.getSpec() instanceof ForgeConfigSpec); return true; } @@ -85,7 +95,8 @@ public class ConfigHelper { List pathList = Arrays.asList(path.getPath()); ForgeConfigSpec.ValueSpec valueSpec = spec.getRaw(pathList); - ForgeConfigSpec.ConfigValue configValue = spec.getValues().get(pathList); + ForgeConfigSpec.ConfigValue configValue = spec.getValues() + .get(pathList); T v = (T) CConfigureConfigPacket.deserialize(configValue.get(), value); if (!valueSpec.test(v)) throw new InvalidValueException(); @@ -94,7 +105,8 @@ public class ConfigHelper { } // Add a value to the current UI's changes list - public static void setValue(String path, ForgeConfigSpec.ConfigValue configValue, T value, @Nullable Map annotations) { + public static void setValue(String path, ForgeConfigSpec.ConfigValue configValue, T value, + @Nullable Map annotations) { if (value.equals(configValue.get())) { changes.remove(path); } else { @@ -102,11 +114,12 @@ public class ConfigHelper { } } - // Get a value from the current UI's changes list or the config value, if its unchanged + // Get a value from the current UI's changes list or the config value, if its + // unchanged public static T getValue(String path, ForgeConfigSpec.ConfigValue configValue) { ConfigChange configChange = changes.get(path); if (configChange != null) - //noinspection unchecked + // noinspection unchecked return (T) configChange.value; else return configValue.get(); @@ -117,7 +130,8 @@ public class ConfigHelper { Map annotations = new HashMap<>(); commentLines.removeIf(line -> { - if (line.trim().isEmpty()) { + if (line.trim() + .isEmpty()) { return true; } @@ -212,5 +226,7 @@ public class ConfigHelper { } } - public static class InvalidValueException extends Exception {} + public static class InvalidValueException extends Exception { + private static final long serialVersionUID = 1L; + } } diff --git a/src/main/java/com/simibubi/create/foundation/fluid/FluidHelper.java b/src/main/java/com/simibubi/create/foundation/fluid/FluidHelper.java index 2d2c7c977..ce8dec8de 100644 --- a/src/main/java/com/simibubi/create/foundation/fluid/FluidHelper.java +++ b/src/main/java/com/simibubi/create/foundation/fluid/FluidHelper.java @@ -15,6 +15,7 @@ import com.simibubi.create.foundation.utility.Pair; import net.minecraft.nbt.TagParser; import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.TagKey; import net.minecraft.util.GsonHelper; import net.minecraft.world.InteractionHand; import net.minecraft.world.entity.player.Player; @@ -23,6 +24,7 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.level.material.FluidState; import net.minecraft.world.level.material.Fluids; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.fluids.FluidStack; @@ -46,6 +48,18 @@ public class FluidHelper { public static boolean isLava(Fluid fluid) { return convertToStill(fluid) == Fluids.LAVA; } + + public static boolean isTag(Fluid fluid, TagKey pTag) { + return fluid.is(pTag); + } + + public static boolean isTag(FluidState fluid, TagKey pTag) { + return isTag(fluid.getType(), pTag); + } + + public static boolean isTag(FluidStack fluid, TagKey pTag) { + return isTag(fluid.getFluid(), pTag); + } public static boolean hasBlockState(Fluid fluid) { BlockState blockState = fluid.defaultFluidState() diff --git a/src/main/java/com/simibubi/create/foundation/gui/RemovedGuiUtils.java b/src/main/java/com/simibubi/create/foundation/gui/RemovedGuiUtils.java index 371f08cef..a33b5f66b 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/RemovedGuiUtils.java +++ b/src/main/java/com/simibubi/create/foundation/gui/RemovedGuiUtils.java @@ -179,8 +179,6 @@ public class RemovedGuiUtils { .getBuilder()); pStack.translate(0.0D, 0.0D, zLevel); - int tooltipTop = tooltipY; - for (int lineNumber = 0; lineNumber < list.size(); ++lineNumber) { ClientTooltipComponent line = list.get(lineNumber); diff --git a/src/main/java/com/simibubi/create/foundation/ponder/ui/PonderProgressBar.java b/src/main/java/com/simibubi/create/foundation/ponder/ui/PonderProgressBar.java index 1fcf41414..ab3e5b0e9 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/ui/PonderProgressBar.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/ui/PonderProgressBar.java @@ -2,7 +2,6 @@ package com.simibubi.create.foundation.ponder.ui; import javax.annotation.Nonnull; -import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.gui.Theme; import com.simibubi.create.foundation.gui.element.BoxElement; diff --git a/src/main/java/com/simibubi/create/foundation/utility/BBHelper.java b/src/main/java/com/simibubi/create/foundation/utility/BBHelper.java new file mode 100644 index 000000000..f2b9af890 --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/utility/BBHelper.java @@ -0,0 +1,20 @@ +package com.simibubi.create.foundation.utility; + +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.levelgen.structure.BoundingBox; + +public class BBHelper { + + public static BoundingBox encapsulate(BoundingBox bb, BlockPos pos) { + return new BoundingBox(Math.min(bb.minX(), pos.getX()), Math.min(bb.minY(), pos.getY()), + Math.min(bb.minZ(), pos.getZ()), Math.max(bb.maxX(), pos.getX()), Math.max(bb.maxY(), pos.getY()), + Math.max(bb.maxZ(), pos.getZ())); + } + + public static BoundingBox encapsulate(BoundingBox bb, BoundingBox bb2) { + return new BoundingBox(Math.min(bb.minX(), bb2.minX()), Math.min(bb.minY(), bb2.minY()), + Math.min(bb.minZ(), bb2.minZ()), Math.max(bb.maxX(), bb2.maxX()), Math.max(bb.maxY(), bb2.maxY()), + Math.max(bb.maxZ(), bb2.maxZ())); + } + +} diff --git a/src/main/java/com/simibubi/create/foundation/utility/BlockHelper.java b/src/main/java/com/simibubi/create/foundation/utility/BlockHelper.java index a8945b3d3..6cacb3fc9 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/BlockHelper.java +++ b/src/main/java/com/simibubi/create/foundation/utility/BlockHelper.java @@ -6,7 +6,7 @@ import javax.annotation.Nullable; import com.simibubi.create.AllBlocks; import com.simibubi.create.content.contraptions.base.KineticTileEntity; -import com.simibubi.create.content.contraptions.components.actors.SeatBlock; +import com.simibubi.create.foundation.fluid.FluidHelper; import com.simibubi.create.foundation.tileEntity.IMergeableTE; import net.minecraft.core.BlockPos; @@ -234,10 +234,7 @@ public class BlockHelper { state = ((IPlantable) state.getBlock()).getPlant(world, target); if (world.dimensionType() - .ultraWarm() - && state.getFluidState() - .getType() - .is(FluidTags.WATER)) { + .ultraWarm() && FluidHelper.isTag(state.getFluidState(), FluidTags.WATER)) { int i = target.getX(); int j = target.getY(); int k = target.getZ(); diff --git a/src/main/java/com/simibubi/create/foundation/utility/Color.java b/src/main/java/com/simibubi/create/foundation/utility/Color.java index aa4e32f9b..a1f1bb4f5 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/Color.java +++ b/src/main/java/com/simibubi/create/foundation/utility/Color.java @@ -10,7 +10,6 @@ import com.mojang.math.Vector3f; import net.minecraft.util.Mth; import net.minecraft.world.phys.Vec3; -@SuppressWarnings("PointlessBitwiseExpression") public class Color { public final static Color TRANSPARENT_BLACK = new Color(0, 0, 0, 0).setImmutable(); public final static Color BLACK = new Color(0, 0, 0).setImmutable(); diff --git a/src/main/java/com/simibubi/create/foundation/utility/ServerSpeedProvider.java b/src/main/java/com/simibubi/create/foundation/utility/ServerSpeedProvider.java index 117dfa007..3ec6c4619 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/ServerSpeedProvider.java +++ b/src/main/java/com/simibubi/create/foundation/utility/ServerSpeedProvider.java @@ -5,7 +5,8 @@ import java.util.function.Supplier; import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.networking.SimplePacketBase; -import com.simibubi.create.foundation.utility.animation.InterpolatedChasingValue; +import com.simibubi.create.foundation.utility.animation.LerpedFloat; +import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser; import net.minecraft.client.Minecraft; import net.minecraft.network.FriendlyByteBuf; @@ -19,7 +20,7 @@ public class ServerSpeedProvider { static int clientTimer = 0; static int serverTimer = 0; static boolean initialized = false; - static InterpolatedChasingValue modifier = new InterpolatedChasingValue().withSpeed(.25f); + static LerpedFloat modifier = LerpedFloat.linear(); public static void serverTick() { serverTimer++; @@ -36,7 +37,7 @@ public class ServerSpeedProvider { && Minecraft.getInstance() .isPaused()) return; - modifier.tick(); + modifier.tickChaser(); clientTimer++; } @@ -45,7 +46,7 @@ public class ServerSpeedProvider { } public static float get() { - return modifier.value; + return modifier.getValue(); } public static class Packet extends SimplePacketBase { @@ -67,7 +68,7 @@ public class ServerSpeedProvider { return; } float target = ((float) getSyncInterval()) / Math.max(clientTimer, 1); - modifier.target(Math.min(target, 1)); + modifier.chase(Math.min(target, 1), .25, Chaser.EXP); // Set this to -1 because packets are processed before ticks. // ServerSpeedProvider#clientTick will increment it to 0 at the end of this tick. // Setting it to 0 causes consistent desync, as the client ends up counting too many ticks. diff --git a/src/main/java/com/simibubi/create/foundation/utility/UniqueLinkedList.java b/src/main/java/com/simibubi/create/foundation/utility/UniqueLinkedList.java index 83a1d82b4..d97f077ba 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/UniqueLinkedList.java +++ b/src/main/java/com/simibubi/create/foundation/utility/UniqueLinkedList.java @@ -7,6 +7,10 @@ import java.util.List; import java.util.stream.Collectors; public class UniqueLinkedList extends LinkedList { + /** + * + */ + private static final long serialVersionUID = 1L; private final HashSet contained = new HashSet<>(); @Override diff --git a/src/main/java/com/simibubi/create/foundation/utility/animation/InterpolatedAngle.java b/src/main/java/com/simibubi/create/foundation/utility/animation/InterpolatedAngle.java deleted file mode 100644 index ccdd17b68..000000000 --- a/src/main/java/com/simibubi/create/foundation/utility/animation/InterpolatedAngle.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.simibubi.create.foundation.utility.animation; - -import com.simibubi.create.foundation.utility.AngleHelper; - -/** - * Use {@link LerpedFloat} instead. - */ -@Deprecated -public class InterpolatedAngle extends InterpolatedValue { - - public float get(float partialTicks) { - return AngleHelper.angleLerp(partialTicks, lastValue, value); - } - -} diff --git a/src/main/java/com/simibubi/create/foundation/utility/animation/InterpolatedChasingAngle.java b/src/main/java/com/simibubi/create/foundation/utility/animation/InterpolatedChasingAngle.java deleted file mode 100644 index ef944296e..000000000 --- a/src/main/java/com/simibubi/create/foundation/utility/animation/InterpolatedChasingAngle.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.simibubi.create.foundation.utility.animation; - -import com.simibubi.create.foundation.utility.AngleHelper; - -/** - * Use {@link LerpedFloat} instead. - */ -@Deprecated -public class InterpolatedChasingAngle extends InterpolatedChasingValue { - - public float get(float partialTicks) { - return AngleHelper.angleLerp(partialTicks, lastValue, value); - } - - @Override - protected float getCurrentDiff() { - return AngleHelper.getShortestAngleDiff(value, getTarget()); - } - -} diff --git a/src/main/java/com/simibubi/create/foundation/utility/animation/InterpolatedChasingValue.java b/src/main/java/com/simibubi/create/foundation/utility/animation/InterpolatedChasingValue.java deleted file mode 100644 index 099623ad6..000000000 --- a/src/main/java/com/simibubi/create/foundation/utility/animation/InterpolatedChasingValue.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.simibubi.create.foundation.utility.animation; - -/** - * Use {@link LerpedFloat} instead. - */ -@Deprecated -public class InterpolatedChasingValue extends InterpolatedValue { - - float speed = 0.5f; - float target = 0; - float eps = 1 / 4096f; - - public void tick() { - float diff = getCurrentDiff(); - if (Math.abs(diff) < eps) - return; - set(value + (diff) * speed); - } - - protected float getCurrentDiff() { - return getTarget() - value; - } - - public InterpolatedChasingValue withSpeed(float speed) { - this.speed = speed; - return this; - } - - public InterpolatedChasingValue target(float target) { - this.target = target; - return this; - } - - public InterpolatedChasingValue start(float value) { - lastValue = this.value = value; - target(value); - return this; - } - - public float getTarget() { - return target; - } - -} diff --git a/src/main/java/com/simibubi/create/foundation/utility/animation/InterpolatedValue.java b/src/main/java/com/simibubi/create/foundation/utility/animation/InterpolatedValue.java deleted file mode 100644 index 0b8e1893f..000000000 --- a/src/main/java/com/simibubi/create/foundation/utility/animation/InterpolatedValue.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.simibubi.create.foundation.utility.animation; - -import net.minecraft.util.Mth; - -/** - * Use {@link LerpedFloat} instead. - */ -@Deprecated -public class InterpolatedValue { - - public float value = 0; - public float lastValue = 0; - - public InterpolatedValue set(float value) { - lastValue = this.value; - this.value = value; - return this; - } - - public InterpolatedValue init(float value) { - this.lastValue = this.value = value; - return this; - } - - public float get(float partialTicks) { - return Mth.lerp(partialTicks, lastValue, value); - } - - public boolean settled() { - return Math.abs(value - lastValue) < 1e-3; - } - -} diff --git a/src/main/java/com/simibubi/create/foundation/utility/animation/LerpedFloat.java b/src/main/java/com/simibubi/create/foundation/utility/animation/LerpedFloat.java index a8c2892de..0ae289f46 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/animation/LerpedFloat.java +++ b/src/main/java/com/simibubi/create/foundation/utility/animation/LerpedFloat.java @@ -5,8 +5,6 @@ import com.simibubi.create.foundation.utility.AngleHelper; import net.minecraft.nbt.CompoundTag; import net.minecraft.util.Mth; -// Can replace all Interpolated value classes -// InterpolatedChasingValue, InterpolatedValue, InterpolatedChasingAngle, InterpolatedAngle public class LerpedFloat { protected Interpolator interpolator; @@ -16,6 +14,7 @@ public class LerpedFloat { protected Chaser chaseFunction; protected float chaseTarget; protected float chaseSpeed; + protected boolean angularChase; protected boolean forcedSync; @@ -30,7 +29,9 @@ public class LerpedFloat { } public static LerpedFloat angular() { - return new LerpedFloat(AngleHelper::angleLerp); + LerpedFloat lerpedFloat = new LerpedFloat(AngleHelper::angleLerp); + lerpedFloat.angularChase = true; + return lerpedFloat; } public LerpedFloat startWithValue(double value) { @@ -42,13 +43,15 @@ public class LerpedFloat { } public LerpedFloat chase(double value, double speed, Chaser chaseFunction) { - this.chaseTarget = (float) value; + updateChaseTarget((float) value); this.chaseSpeed = (float) speed; this.chaseFunction = chaseFunction; return this; } public void updateChaseTarget(float target) { + if (angularChase) + target = value + AngleHelper.getShortestAngleDiff(value, target); this.chaseTarget = target; } @@ -72,7 +75,7 @@ public class LerpedFloat { public void setValueNoUpdate(double value) { this.value = (float) value; } - + public void setValue(double value) { this.previousValue = this.value; this.value = (float) value; diff --git a/src/main/java/com/simibubi/create/foundation/utility/placement/PlacementHelpers.java b/src/main/java/com/simibubi/create/foundation/utility/placement/PlacementHelpers.java index 0e626e4de..e3427f52c 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/placement/PlacementHelpers.java +++ b/src/main/java/com/simibubi/create/foundation/utility/placement/PlacementHelpers.java @@ -18,8 +18,8 @@ import com.simibubi.create.foundation.config.CClient; import com.simibubi.create.foundation.gui.AllGuiTextures; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.VecHelper; -import com.simibubi.create.foundation.utility.animation.InterpolatedChasingAngle; -import com.simibubi.create.foundation.utility.animation.InterpolatedChasingValue; +import com.simibubi.create.foundation.utility.animation.LerpedFloat; +import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ClientLevel; @@ -43,7 +43,8 @@ public class PlacementHelpers { private static final List helpers = new ArrayList<>(); private static int animationTick = 0; - private static final InterpolatedChasingValue angle = new InterpolatedChasingAngle().withSpeed(0.25f); + private static final LerpedFloat angle = LerpedFloat.angular() + .chase(0, 0.25f, Chaser.EXP); private static BlockPos target = null; private static BlockPos lastTarget = null; @@ -92,20 +93,25 @@ public class PlacementHelpers { if (mc.player == null) return; - if (mc.player.isShiftKeyDown())//for now, disable all helpers when sneaking TODO add helpers that respect sneaking but still show position + if (mc.player.isShiftKeyDown())// for now, disable all helpers when sneaking TODO add helpers that respect + // sneaking but still show position return; for (InteractionHand hand : InteractionHand.values()) { ItemStack heldItem = mc.player.getItemInHand(hand); - List filteredForHeldItem = helpers.stream().filter(helper -> helper.matchesItem(heldItem)).collect(Collectors.toList()); + List filteredForHeldItem = helpers.stream() + .filter(helper -> helper.matchesItem(heldItem)) + .collect(Collectors.toList()); if (filteredForHeldItem.isEmpty()) continue; BlockPos pos = ray.getBlockPos(); BlockState state = world.getBlockState(pos); - List filteredForState = filteredForHeldItem.stream().filter(helper -> helper.matchesState(state)).collect(Collectors.toList()); + List filteredForState = filteredForHeldItem.stream() + .filter(helper -> helper.matchesState(state)) + .collect(Collectors.toList()); if (filteredForState.isEmpty()) continue; @@ -122,7 +128,8 @@ public class PlacementHelpers { } - //at least one helper activated, no need to check the offhand if we are still in the mainhand + // at least one helper activated, no need to check the offhand if we are still + // in the mainhand if (atLeastOneMatch) return; @@ -165,11 +172,12 @@ public class PlacementHelpers { } public static float getCurrentAlpha() { - return Math.min(animationTick / 10f/* + event.getPartialTicks()*/, 1f); + return Math.min(animationTick / 10f/* + event.getPartialTicks() */, 1f); } @OnlyIn(Dist.CLIENT) - private static void drawDirectionIndicator(PoseStack ms, float partialTicks, float centerX, float centerY, float progress) { + private static void drawDirectionIndicator(PoseStack ms, float partialTicks, float centerX, float centerY, + float progress) { float r = .8f; float g = .8f; float b = .8f; @@ -178,28 +186,24 @@ public class PlacementHelpers { Vec3 projTarget = VecHelper.projectToPlayerView(VecHelper.getCenterOf(lastTarget), partialTicks); Vec3 target = new Vec3(projTarget.x, projTarget.y, 0); - if (projTarget.z > 0) { + if (projTarget.z > 0) target = target.reverse(); - } Vec3 norm = target.normalize(); Vec3 ref = new Vec3(0, 1, 0); float targetAngle = AngleHelper.deg(Math.acos(norm.dot(ref))); - angle.withSpeed(0.25f); - - if (norm.x < 0) { + if (norm.x < 0) targetAngle = 360 - targetAngle; - } if (animationTick < 10) - angle.set(targetAngle); + angle.setValue(targetAngle); - angle.target(targetAngle); - angle.tick(); + angle.chase(targetAngle, .25f, Chaser.EXP); + angle.tickChaser(); float snapSize = 22.5f; - float snappedAngle = (snapSize * Math.round(angle.get(0f) / snapSize)) % 360f; + float snappedAngle = (snapSize * Math.round(angle.getValue(0f) / snapSize)) % 360f; float length = 10; @@ -210,7 +214,8 @@ public class PlacementHelpers { textured(ms, centerX, centerY, a, snappedAngle); } - private static void fadedArrow(PoseStack ms, float centerX, float centerY, float r, float g, float b, float a, float length, float snappedAngle) { + private static void fadedArrow(PoseStack ms, float centerX, float centerY, float r, float g, float b, float a, + float length, float snappedAngle) { RenderSystem.disableTexture(); RenderSystem.enableBlend(); RenderSystem.defaultBlendFunc(); @@ -218,8 +223,8 @@ public class PlacementHelpers { ms.pushPose(); ms.translate(centerX, centerY, 5); - ms.mulPose(Vector3f.ZP.rotationDegrees(angle.get(0))); - //RenderSystem.rotatef(snappedAngle, 0, 0, 1); + ms.mulPose(Vector3f.ZP.rotationDegrees(angle.getValue(0))); + // RenderSystem.rotatef(snappedAngle, 0, 0, 1); double scale = AllConfigs.CLIENT.indicatorScale.get(); ms.scale((float) scale, (float) scale, 1); @@ -227,17 +232,34 @@ public class PlacementHelpers { BufferBuilder bufferbuilder = tessellator.getBuilder(); bufferbuilder.begin(VertexFormat.Mode.TRIANGLE_FAN, DefaultVertexFormat.POSITION_COLOR); - Matrix4f mat = ms.last().pose(); + Matrix4f mat = ms.last() + .pose(); - bufferbuilder.vertex(mat, 0, -(10 + length), 0).color(r, g, b, a).endVertex(); + bufferbuilder.vertex(mat, 0, -(10 + length), 0) + .color(r, g, b, a) + .endVertex(); - bufferbuilder.vertex(mat, -9, -3, 0).color(r, g, b, 0f).endVertex(); - bufferbuilder.vertex(mat, -6, -6, 0).color(r, g, b, 0f).endVertex(); - bufferbuilder.vertex(mat, -3, -8, 0).color(r, g, b, 0f).endVertex(); - bufferbuilder.vertex(mat, 0, -8.5f, 0).color(r, g, b, 0f).endVertex(); - bufferbuilder.vertex(mat, 3, -8, 0).color(r, g, b, 0f).endVertex(); - bufferbuilder.vertex(mat, 6, -6, 0).color(r, g, b, 0f).endVertex(); - bufferbuilder.vertex(mat, 9, -3, 0).color(r, g, b, 0f).endVertex(); + bufferbuilder.vertex(mat, -9, -3, 0) + .color(r, g, b, 0f) + .endVertex(); + bufferbuilder.vertex(mat, -6, -6, 0) + .color(r, g, b, 0f) + .endVertex(); + bufferbuilder.vertex(mat, -3, -8, 0) + .color(r, g, b, 0f) + .endVertex(); + bufferbuilder.vertex(mat, 0, -8.5f, 0) + .color(r, g, b, 0f) + .endVertex(); + bufferbuilder.vertex(mat, 3, -8, 0) + .color(r, g, b, 0f) + .endVertex(); + bufferbuilder.vertex(mat, 6, -6, 0) + .color(r, g, b, 0f) + .endVertex(); + bufferbuilder.vertex(mat, 9, -3, 0) + .color(r, g, b, 0f) + .endVertex(); tessellator.end(); RenderSystem.disableBlend(); @@ -256,12 +278,13 @@ public class PlacementHelpers { ms.pushPose(); ms.translate(centerX, centerY, 50); - float scale = AllConfigs.CLIENT.indicatorScale.get().floatValue() * .75f; + float scale = AllConfigs.CLIENT.indicatorScale.get() + .floatValue() * .75f; ms.scale(scale, scale, 1); ms.scale(12, 12, 1); float index = snappedAngle / 22.5f; - float tex_size = 16f/256f; + float tex_size = 16f / 256f; float tx = 0; float ty = index * tex_size; @@ -272,11 +295,24 @@ public class PlacementHelpers { BufferBuilder buffer = tessellator.getBuilder(); buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR_TEX); - Matrix4f mat = ms.last().pose(); - buffer.vertex(mat, -1, -1, 0).color(1f, 1f, 1f, alpha).uv(tx, ty).endVertex(); - buffer.vertex(mat, -1, 1, 0).color(1f, 1f, 1f, alpha).uv(tx, ty + th).endVertex(); - buffer.vertex(mat, 1, 1, 0).color(1f, 1f, 1f, alpha).uv(tx + tw, ty + th).endVertex(); - buffer.vertex(mat, 1, -1, 0).color(1f, 1f, 1f, alpha).uv(tx + tw, ty).endVertex(); + Matrix4f mat = ms.last() + .pose(); + buffer.vertex(mat, -1, -1, 0) + .color(1f, 1f, 1f, alpha) + .uv(tx, ty) + .endVertex(); + buffer.vertex(mat, -1, 1, 0) + .color(1f, 1f, 1f, alpha) + .uv(tx, ty + th) + .endVertex(); + buffer.vertex(mat, 1, 1, 0) + .color(1f, 1f, 1f, alpha) + .uv(tx + tw, ty + th) + .endVertex(); + buffer.vertex(mat, 1, -1, 0) + .color(1f, 1f, 1f, alpha) + .uv(tx + tw, ty) + .endVertex(); tessellator.end(); diff --git a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedWorld.java b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedWorld.java index 871f848da..fe0e82d5d 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedWorld.java +++ b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedWorld.java @@ -171,11 +171,6 @@ public class WrappedWorld extends Level { return world.getShade(p_230487_1_, p_230487_2_); } - @Override - public boolean hasChunkAt(BlockPos p_175667_1_) { - return world.hasChunkAt(p_175667_1_); - } - @Override public void updateNeighbourForOutputSignal(BlockPos p_175666_1_, Block p_175666_2_) {}