Danger Refactors

- Replaced remaining uses of InterpolatedChasingValue with LerpedFloat
- Addressed & silenced a bunch of warnings
This commit is contained in:
simibubi 2022-07-05 13:14:03 +02:00
parent da7ed8ecda
commit 4e9fc7dba7
78 changed files with 573 additions and 581 deletions

View file

@ -43,9 +43,8 @@ public class MechanicalCraftingCategory extends CreateRecipeCategory<CraftingRec
@Override @Override
public void setRecipe(IRecipeLayoutBuilder builder, CraftingRecipe recipe, IFocusGroup focuses) { public void setRecipe(IRecipeLayoutBuilder builder, CraftingRecipe recipe, IFocusGroup focuses) {
builder builder.addSlot(RecipeIngredientRole.OUTPUT, 134, 81)
.addSlot(RecipeIngredientRole.OUTPUT, 134, 81) .addItemStack(recipe.getResultItem());
.addItemStack(recipe.getResultItem());
int x = getXPadding(recipe); int x = getXPadding(recipe);
int y = getYPadding(recipe); int y = getYPadding(recipe);
@ -56,19 +55,16 @@ public class MechanicalCraftingCategory extends CreateRecipeCategory<CraftingRec
for (Ingredient ingredient : recipe.getIngredients()) { for (Ingredient ingredient : recipe.getIngredients()) {
float f = 19 * scale; float f = 19 * scale;
int slotSize = (int) (16 * scale);
int xPosition = (int) (x + 1 + (i % getWidth(recipe)) * f); int xPosition = (int) (x + 1 + (i % getWidth(recipe)) * f);
int yPosition = (int) (y + 1 + (i / getWidth(recipe)) * f); int yPosition = (int) (y + 1 + (i / getWidth(recipe)) * f);
builder builder.addSlot(RecipeIngredientRole.INPUT, xPosition, yPosition)
.addSlot(RecipeIngredientRole.INPUT, xPosition, yPosition) .setCustomRenderer(VanillaTypes.ITEM, renderer)
.setCustomRenderer(VanillaTypes.ITEM, renderer) .addIngredients(ingredient);
.addIngredients(ingredient);
i++; i++;
} }
} }
static int maxSize = 100; static int maxSize = 100;
@ -96,7 +92,8 @@ public class MechanicalCraftingCategory extends CreateRecipeCategory<CraftingRec
} }
@Override @Override
public void draw(CraftingRecipe recipe, IRecipeSlotsView iRecipeSlotsView, PoseStack matrixStack, double mouseX, double mouseY) { public void draw(CraftingRecipe recipe, IRecipeSlotsView iRecipeSlotsView, PoseStack matrixStack, double mouseX,
double mouseY) {
matrixStack.pushPose(); matrixStack.pushPose();
float scale = getScale(recipe); float scale = getScale(recipe);
matrixStack.translate(getXPadding(recipe), getYPadding(recipe), 0); matrixStack.translate(getXPadding(recipe), getYPadding(recipe), 0);

View file

@ -64,6 +64,7 @@ public abstract class DirectionalKineticBlock extends KineticBlock {
} }
@Override @Override
@SuppressWarnings("deprecation")
public BlockState mirror(BlockState state, Mirror mirrorIn) { public BlockState mirror(BlockState state, Mirror mirrorIn) {
return state.rotate(mirrorIn.getRotation(state.getValue(FACING))); return state.rotate(mirrorIn.getRotation(state.getValue(FACING)));
} }

View file

@ -59,6 +59,7 @@ public abstract class HorizontalKineticBlock extends KineticBlock {
} }
@Override @Override
@SuppressWarnings("deprecation")
public BlockState mirror(BlockState state, Mirror mirrorIn) { public BlockState mirror(BlockState state, Mirror mirrorIn) {
return state.rotate(mirrorIn.getRotation(state.getValue(HORIZONTAL_FACING))); return state.rotate(mirrorIn.getRotation(state.getValue(HORIZONTAL_FACING)));
} }

View file

@ -40,8 +40,8 @@ public class CuckooClockRenderer extends KineticTileEntityRenderer {
// Render Hands // Render Hands
SuperByteBuffer hourHand = CachedBufferer.partial(AllBlockPartials.CUCKOO_HOUR_HAND, blockState); SuperByteBuffer hourHand = CachedBufferer.partial(AllBlockPartials.CUCKOO_HOUR_HAND, blockState);
SuperByteBuffer minuteHand = CachedBufferer.partial(AllBlockPartials.CUCKOO_MINUTE_HAND, blockState); SuperByteBuffer minuteHand = CachedBufferer.partial(AllBlockPartials.CUCKOO_MINUTE_HAND, blockState);
float hourAngle = clock.hourHand.get(partialTicks); float hourAngle = clock.hourHand.getValue(partialTicks);
float minuteAngle = clock.minuteHand.get(partialTicks); float minuteAngle = clock.minuteHand.getValue(partialTicks);
rotateHand(hourHand, hourAngle, direction).light(light) rotateHand(hourHand, hourAngle, direction).light(light)
.renderInto(ms, vb); .renderInto(ms, vb);
rotateHand(minuteHand, minuteAngle, direction).light(light) rotateHand(minuteHand, minuteAngle, direction).light(light)
@ -54,7 +54,7 @@ public class CuckooClockRenderer extends KineticTileEntityRenderer {
float offset = 0; float offset = 0;
if (clock.animationType != null) { if (clock.animationType != null) {
float value = clock.animationProgress.get(partialTicks); float value = clock.animationProgress.getValue(partialTicks);
int step = clock.animationType == Animation.SURPRISE ? 3 : 15; int step = clock.animationType == Animation.SURPRISE ? 3 : 15;
for (int phase = 30; phase <= 60; phase += step) { for (int phase = 30; phase <= 60; phase += step) {
float local = value - phase; float local = value - phase;
@ -102,7 +102,7 @@ public class CuckooClockRenderer extends KineticTileEntityRenderer {
float pivotZ = 8 / 16f; float pivotZ = 8 / 16f;
buffer.rotateCentered(Direction.UP, AngleHelper.rad(AngleHelper.horizontalAngle(facing.getCounterClockWise()))); buffer.rotateCentered(Direction.UP, AngleHelper.rad(AngleHelper.horizontalAngle(facing.getCounterClockWise())));
buffer.translate(pivotX, pivotY, pivotZ); buffer.translate(pivotX, pivotY, pivotZ);
buffer.rotate(Direction.EAST, angle); buffer.rotate(Direction.EAST, AngleHelper.rad(angle));
buffer.translate(-pivotX, -pivotY, -pivotZ); buffer.translate(-pivotX, -pivotY, -pivotZ);
return buffer; return buffer;
} }

View file

@ -1,9 +1,5 @@
package com.simibubi.create.content.contraptions.components.clock; package com.simibubi.create.content.contraptions.components.clock;
import static com.simibubi.create.foundation.utility.AngleHelper.deg;
import static com.simibubi.create.foundation.utility.AngleHelper.getShortestAngleDiff;
import static com.simibubi.create.foundation.utility.AngleHelper.rad;
import java.util.List; import java.util.List;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
@ -12,8 +8,8 @@ import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.NBTHelper;
import com.simibubi.create.foundation.utility.VecHelper; 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.InterpolatedValue; import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.particles.ParticleTypes; import net.minecraft.core.particles.ParticleTypes;
@ -21,6 +17,7 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource; import net.minecraft.sounds.SoundSource;
import net.minecraft.util.Mth;
import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.level.Explosion; import net.minecraft.world.level.Explosion;
import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.entity.BlockEntityType;
@ -31,9 +28,9 @@ public class CuckooClockTileEntity extends KineticTileEntity {
public static DamageSource CUCKOO_SURPRISE = new DamageSource("create.cuckoo_clock_explosion").setExplosion(); public static DamageSource CUCKOO_SURPRISE = new DamageSource("create.cuckoo_clock_explosion").setExplosion();
public InterpolatedChasingValue hourHand = new InterpolatedChasingValue().withSpeed(.2f); public LerpedFloat hourHand = LerpedFloat.angular();
public InterpolatedChasingValue minuteHand = new InterpolatedChasingValue().withSpeed(.2f); public LerpedFloat minuteHand = LerpedFloat.angular();
public InterpolatedValue animationProgress = new InterpolatedValue(); public LerpedFloat animationProgress = LerpedFloat.linear();
public Animation animationType; public Animation animationType;
private boolean sendAnimationUpdate; private boolean sendAnimationUpdate;
@ -57,8 +54,7 @@ public class CuckooClockTileEntity extends KineticTileEntity {
super.read(compound, clientPacket); super.read(compound, clientPacket);
if (clientPacket && compound.contains("Animation")) { if (clientPacket && compound.contains("Animation")) {
animationType = NBTHelper.readEnum(compound, "Animation", Animation.class); animationType = NBTHelper.readEnum(compound, "Animation", Animation.class);
animationProgress.lastValue = 0; animationProgress.startWithValue(0);
animationProgress.value = 0;
} }
} }
@ -101,12 +97,12 @@ public class CuckooClockTileEntity extends KineticTileEntity {
if (hours == 18 && minutes < 36 && minutes > 31) if (hours == 18 && minutes < 36 && minutes > 31)
startAnimation(Animation.CREEPER); startAnimation(Animation.CREEPER);
} else { } else {
float value = animationProgress.value; float value = animationProgress.getValue();
animationProgress.set(value + 1); animationProgress.setValue(value + 1);
if (value > 100) if (value > 100)
animationType = Animation.NONE; animationType = Animation.NONE;
if (animationType == Animation.SURPRISE && animationProgress.value == 50) { if (animationType == Animation.SURPRISE && Mth.equal(animationProgress.getValue(), 50)) {
Vec3 center = VecHelper.getCenterOf(worldPosition); Vec3 center = VecHelper.getCenterOf(worldPosition);
level.destroyBlock(worldPosition, false); level.destroyBlock(worldPosition, false);
level.explode(null, CUCKOO_SURPRISE, null, center.x, center.y, center.z, 3, 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 { } else {
boolean isSurprise = animationType == Animation.SURPRISE; boolean isSurprise = animationType == Animation.SURPRISE;
float value = animationProgress.value; float value = animationProgress.getValue();
animationProgress.set(value + 1); animationProgress.setValue(value + 1);
if (value > 100) if (value > 100)
animationType = null; animationType = null;
@ -171,8 +167,7 @@ public class CuckooClockTileEntity extends KineticTileEntity {
animationType = animation; animationType = animation;
if (animation != null && CuckooClockBlock.containsSurprise(getBlockState())) if (animation != null && CuckooClockBlock.containsSurprise(getBlockState()))
animationType = Animation.SURPRISE; animationType = Animation.SURPRISE;
animationProgress.lastValue = 0; animationProgress.startWithValue(0);
animationProgress.value = 0;
sendAnimationUpdate = true; sendAnimationUpdate = true;
if (animation == Animation.CREEPER) if (animation == Animation.CREEPER)
@ -185,11 +180,11 @@ public class CuckooClockTileEntity extends KineticTileEntity {
float hourTarget = (float) (360 / 12 * (hours % 12)); float hourTarget = (float) (360 / 12 * (hours % 12));
float minuteTarget = (float) (360 / 60 * minutes); float minuteTarget = (float) (360 / 60 * minutes);
hourHand.target(hourHand.value + rad(getShortestAngleDiff(deg(hourHand.value), hourTarget))); hourHand.chase(hourTarget, .2f, Chaser.EXP);
minuteHand.target(minuteHand.value + rad(getShortestAngleDiff(deg(minuteHand.value), minuteTarget))); minuteHand.chase(minuteTarget, .2f, Chaser.EXP);
hourHand.tick(); hourHand.tickChaser();
minuteHand.tick(); minuteHand.tickChaser();
} }
private void playSound(SoundEvent sound, float volume, float pitch) { private void playSound(SoundEvent sound, float volume, float pitch) {

View file

@ -5,7 +5,6 @@ import com.jozufozu.flywheel.api.instance.DynamicInstance;
import com.jozufozu.flywheel.core.materials.model.ModelData; import com.jozufozu.flywheel.core.materials.model.ModelData;
import com.jozufozu.flywheel.util.transform.TransformStack; import com.jozufozu.flywheel.util.transform.TransformStack;
import com.mojang.blaze3d.vertex.PoseStack; 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.KineticTileInstance;
import com.simibubi.create.content.contraptions.base.flwdata.RotatingData; import com.simibubi.create.content.contraptions.base.flwdata.RotatingData;
import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AngleHelper;

View file

@ -67,6 +67,7 @@ import com.simibubi.create.content.logistics.trains.IBogeyBlock;
import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.tileEntity.IMultiTileContainer; import com.simibubi.create.foundation.tileEntity.IMultiTileContainer;
import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour; 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.BlockFace;
import com.simibubi.create.foundation.utility.BlockHelper; import com.simibubi.create.foundation.utility.BlockHelper;
import com.simibubi.create.foundation.utility.ICoordinate; import com.simibubi.create.foundation.utility.ICoordinate;
@ -309,8 +310,7 @@ public abstract class Contraption {
if (AllBlocks.BELT.has(state)) if (AllBlocks.BELT.has(state))
moveBelt(pos, frontier, visited, state); moveBelt(pos, frontier, visited, state);
if (AllBlocks.WINDMILL_BEARING.has(state) if (AllBlocks.WINDMILL_BEARING.has(state) && world.getBlockEntity(pos)instanceof WindmillBearingTileEntity wbte)
&& world.getBlockEntity(pos) instanceof WindmillBearingTileEntity wbte)
wbte.disassembleForMovement(); wbte.disassembleForMovement();
if (AllBlocks.GANTRY_CARRIAGE.has(state)) if (AllBlocks.GANTRY_CARRIAGE.has(state))
@ -337,7 +337,7 @@ public abstract class Contraption {
} }
// Bogeys tend to have sticky sides // 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)) for (Direction d : bogey.getStickySurfaces(world, pos, state))
if (!visited.contains(pos.relative(d))) if (!visited.contains(pos.relative(d)))
frontier.add(pos.relative(d)); frontier.add(pos.relative(d));
@ -926,8 +926,7 @@ public abstract class Contraption {
if (minimisedGlue.get(i) == null) if (minimisedGlue.get(i) == null)
minimisedGlue.set(i, new BoundingBox(block.pos)); minimisedGlue.set(i, new BoundingBox(block.pos));
else else
minimisedGlue.get(i) minimisedGlue.set(i, BBHelper.encapsulate(minimisedGlue.get(i), block.pos));
.encapsulate(block.pos);
} }
BlockPos add = block.pos.offset(anchor) BlockPos add = block.pos.offset(anchor)

View file

@ -82,6 +82,7 @@ public abstract class AbstractChassisBlock extends RotatedPillarBlock implements
} }
@Override @Override
@SuppressWarnings("deprecation")
public BlockState rotate(BlockState state, Rotation rotation) { public BlockState rotate(BlockState state, Rotation rotation) {
if (rotation == Rotation.NONE) if (rotation == Rotation.NONE)
return state; return state;

View file

@ -334,6 +334,7 @@ public class CartAssemblerBlock extends BaseRailBlock
} }
@Override @Override
@SuppressWarnings("deprecation")
public BlockState rotate(BlockState state, Rotation rotation) { public BlockState rotate(BlockState state, Rotation rotation) {
if (rotation == Rotation.NONE) if (rotation == Rotation.NONE)
return state; return state;

View file

@ -268,6 +268,7 @@ public class ControllerRailBlock extends BaseRailBlock implements IWrenchable {
} }
@Override @Override
@SuppressWarnings("deprecation")
public BlockState rotate(BlockState state, Rotation rotation) { public BlockState rotate(BlockState state, Rotation rotation) {
if (rotation == Rotation.NONE) if (rotation == Rotation.NONE)
return state; return state;

View file

@ -293,7 +293,7 @@ public class FluidNetwork {
} }
private boolean isPresent(BlockFace location) { private boolean isPresent(BlockFace location) {
return world.isAreaLoaded(location.getPos(), 0); return world.isLoaded(location.getPos());
} }
@Nullable @Nullable

View file

@ -65,7 +65,7 @@ public class FluidPropagator {
for (Direction direction : getPipeConnections(currentState, pipe)) { for (Direction direction : getPipeConnections(currentState, pipe)) {
BlockPos target = currentPos.relative(direction); BlockPos target = currentPos.relative(direction);
if (!world.isAreaLoaded(target, 0)) if (world instanceof Level l && !l.isLoaded(target))
continue; continue;
BlockEntity tileEntity = world.getBlockEntity(target); BlockEntity tileEntity = world.getBlockEntity(target);

View file

@ -43,7 +43,7 @@ public class FluidReactions {
public static void handlePipeSpillCollision(Level world, BlockPos pos, Fluid pipeFluid, FluidState worldFluid) { public static void handlePipeSpillCollision(Level world, BlockPos pos, Fluid pipeFluid, FluidState worldFluid) {
Fluid pf = FluidHelper.convertToStill(pipeFluid); Fluid pf = FluidHelper.convertToStill(pipeFluid);
Fluid wf = worldFluid.getType(); 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()); world.setBlockAndUpdate(pos, Blocks.OBSIDIAN.defaultBlockState());
else if (pf == Fluids.WATER && wf == Fluids.FLOWING_LAVA) else if (pf == Fluids.WATER && wf == Fluids.FLOWING_LAVA)
world.setBlockAndUpdate(pos, Blocks.COBBLESTONE.defaultBlockState()); world.setBlockAndUpdate(pos, Blocks.COBBLESTONE.defaultBlockState());

View file

@ -174,7 +174,7 @@ public class OpenEndedPipe extends FlowSource {
private boolean provideFluidToSpace(FluidStack fluid, boolean simulate) { private boolean provideFluidToSpace(FluidStack fluid, boolean simulate) {
if (world == null) if (world == null)
return false; return false;
if (!world.isAreaLoaded(outputPos, 0)) if (!world.isLoaded(outputPos))
return false; return false;
BlockState state = world.getBlockState(outputPos); BlockState state = world.getBlockState(outputPos);
@ -202,9 +202,7 @@ public class OpenEndedPipe extends FlowSource {
return true; return true;
if (world.dimensionType() if (world.dimensionType()
.ultraWarm() .ultraWarm() && FluidHelper.isTag(fluid, FluidTags.WATER)) {
&& fluid.getFluid()
.is(FluidTags.WATER)) {
int i = outputPos.getX(); int i = outputPos.getX();
int j = outputPos.getY(); int j = outputPos.getY();
int k = outputPos.getZ(); int k = outputPos.getZ();
@ -379,8 +377,7 @@ public class OpenEndedPipe extends FlowSource {
public static class MilkEffectHandler implements IEffectHandler { public static class MilkEffectHandler implements IEffectHandler {
@Override @Override
public boolean canApplyEffects(OpenEndedPipe pipe, FluidStack fluid) { public boolean canApplyEffects(OpenEndedPipe pipe, FluidStack fluid) {
return fluid.getFluid() return FluidHelper.isTag(fluid, Tags.Fluids.MILK);
.is(Tags.Fluids.MILK);
} }
@Override @Override
@ -399,8 +396,7 @@ public class OpenEndedPipe extends FlowSource {
public static class WaterEffectHandler implements IEffectHandler { public static class WaterEffectHandler implements IEffectHandler {
@Override @Override
public boolean canApplyEffects(OpenEndedPipe pipe, FluidStack fluid) { public boolean canApplyEffects(OpenEndedPipe pipe, FluidStack fluid) {
return fluid.getFluid() return FluidHelper.isTag(fluid, FluidTags.WATER);
.is(FluidTags.WATER);
} }
@Override @Override
@ -433,8 +429,7 @@ public class OpenEndedPipe extends FlowSource {
public static class LavaEffectHandler implements IEffectHandler { public static class LavaEffectHandler implements IEffectHandler {
@Override @Override
public boolean canApplyEffects(OpenEndedPipe pipe, FluidStack fluid) { public boolean canApplyEffects(OpenEndedPipe pipe, FluidStack fluid) {
return fluid.getFluid() return FluidHelper.isTag(fluid, FluidTags.LAVA);
.is(FluidTags.LAVA);
} }
@Override @Override

View file

@ -157,7 +157,7 @@ public class PumpTileEntity extends KineticTileEntity {
int distance = entry.getFirst(); int distance = entry.getFirst();
BlockPos currentPos = entry.getSecond(); BlockPos currentPos = entry.getSecond();
if (!level.isAreaLoaded(currentPos, 0)) if (!level.isLoaded(currentPos))
continue; continue;
if (visited.contains(currentPos)) if (visited.contains(currentPos))
continue; continue;
@ -171,7 +171,7 @@ public class PumpTileEntity extends KineticTileEntity {
BlockFace blockFace = new BlockFace(currentPos, face); BlockFace blockFace = new BlockFace(currentPos, face);
BlockPos connectedPos = blockFace.getConnectedPos(); BlockPos connectedPos = blockFace.getConnectedPos();
if (!level.isAreaLoaded(connectedPos, 0)) if (!level.isLoaded(connectedPos))
continue; continue;
if (blockFace.isEquivalent(start)) if (blockFace.isEquivalent(start))
continue; continue;

View file

@ -12,6 +12,7 @@ import com.simibubi.create.foundation.advancement.AllAdvancements;
import com.simibubi.create.foundation.fluid.FluidHelper; import com.simibubi.create.foundation.fluid.FluidHelper;
import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
import com.simibubi.create.foundation.tileEntity.behaviour.BehaviourType; import com.simibubi.create.foundation.tileEntity.behaviour.BehaviourType;
import com.simibubi.create.foundation.utility.BBHelper;
import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Iterate;
import it.unimi.dsi.fastutil.PriorityQueue; import it.unimi.dsi.fastutil.PriorityQueue;
@ -100,7 +101,7 @@ public class FluidDrainingBehaviour extends FluidManipulationBehaviour {
if (blockState.getValue(LiquidBlock.LEVEL) == 0) if (blockState.getValue(LiquidBlock.LEVEL) == 0)
fluid = flowingFluid.getFluid(); fluid = flowingFluid.getFluid();
else { else {
affectedArea.encapsulate(BoundingBox.fromCorners(currentPos, currentPos)); affectedArea = BBHelper.encapsulate(affectedArea, BoundingBox.fromCorners(currentPos, currentPos));
if (!tileEntity.isVirtual()) if (!tileEntity.isVirtual())
world.setBlock(currentPos, emptied, 2 | 16); world.setBlock(currentPos, emptied, 2 | 16);
queue.dequeue(); queue.dequeue();
@ -144,7 +145,7 @@ public class FluidDrainingBehaviour extends FluidManipulationBehaviour {
if (!tileEntity.isVirtual()) if (!tileEntity.isVirtual())
world.setBlock(currentPos, emptied, 2 | 16); world.setBlock(currentPos, emptied, 2 | 16);
affectedArea.encapsulate(BoundingBox.fromCorners(currentPos, currentPos)); affectedArea = BBHelper.encapsulate(affectedArea, currentPos);
queue.dequeue(); queue.dequeue();
if (queue.isEmpty()) { if (queue.isEmpty()) {

View file

@ -11,6 +11,7 @@ import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.fluid.FluidHelper; import com.simibubi.create.foundation.fluid.FluidHelper;
import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
import com.simibubi.create.foundation.tileEntity.behaviour.BehaviourType; import com.simibubi.create.foundation.tileEntity.behaviour.BehaviourType;
import com.simibubi.create.foundation.utility.BBHelper;
import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Iterate;
import it.unimi.dsi.fastutil.PriorityQueue; import it.unimi.dsi.fastutil.PriorityQueue;
@ -127,7 +128,7 @@ public class FluidFillingBehaviour extends FluidManipulationBehaviour {
int maxRangeSq = maxRange * maxRange; int maxRangeSq = maxRange * maxRange;
int maxBlocks = maxBlocks(); int maxBlocks = maxBlocks();
boolean evaporate = world.dimensionType() boolean evaporate = world.dimensionType()
.ultraWarm() && fluid.is(FluidTags.WATER); .ultraWarm() && FluidHelper.isTag(fluid, FluidTags.WATER);
boolean canPlaceSources = AllConfigs.SERVER.fluids.placeFluidSourceBlocks.get(); boolean canPlaceSources = AllConfigs.SERVER.fluids.placeFluidSourceBlocks.get();
if ((!fillInfinite() && infinite) || evaporate || !canPlaceSources) { if ((!fillInfinite() && infinite) || evaporate || !canPlaceSources) {
@ -200,7 +201,7 @@ public class FluidFillingBehaviour extends FluidManipulationBehaviour {
serverTickList.clearArea(new BoundingBox(currentPos)); serverTickList.clearArea(new BoundingBox(currentPos));
} }
affectedArea.encapsulate(BoundingBox.fromCorners(currentPos, currentPos)); affectedArea = BBHelper.encapsulate(affectedArea, currentPos);
} }
} }

View file

@ -203,9 +203,9 @@ public abstract class FluidManipulationBehaviour extends TileEntityBehaviour {
: fluid.getAttributes() : fluid.getAttributes()
.getEmptySound(); .getEmptySound();
if (soundevent == null) if (soundevent == null)
soundevent = soundevent = FluidHelper.isTag(fluid, FluidTags.LAVA)
fluid.is(FluidTags.LAVA) ? fillSound ? SoundEvents.BUCKET_FILL_LAVA : SoundEvents.BUCKET_EMPTY_LAVA ? fillSound ? SoundEvents.BUCKET_FILL_LAVA : SoundEvents.BUCKET_EMPTY_LAVA
: fillSound ? SoundEvents.BUCKET_FILL : SoundEvents.BUCKET_EMPTY; : fillSound ? SoundEvents.BUCKET_FILL : SoundEvents.BUCKET_EMPTY;
world.playSound(null, splooshPos, soundevent, SoundSource.BLOCKS, 0.3F, 1.0F); world.playSound(null, splooshPos, soundevent, SoundSource.BLOCKS, 0.3F, 1.0F);
if (world instanceof ServerLevel) if (world instanceof ServerLevel)
@ -215,7 +215,8 @@ public abstract class FluidManipulationBehaviour extends TileEntityBehaviour {
protected boolean canDrainInfinitely(Fluid fluid) { protected boolean canDrainInfinitely(Fluid fluid) {
if (fluid == null) if (fluid == null)
return false; return false;
return maxBlocks() != -1 && AllConfigs.SERVER.fluids.bottomlessFluidMode.get().test(fluid); return maxBlocks() != -1 && AllConfigs.SERVER.fluids.bottomlessFluidMode.get()
.test(fluid);
} }
@Override @Override

View file

@ -199,7 +199,8 @@ public class FluidTankBlock extends Block implements IWrenchable, ITE<FluidTankT
FluidAttributes attributes = fluid.getAttributes(); FluidAttributes attributes = fluid.getAttributes();
soundevent = attributes.getEmptySound(); soundevent = attributes.getEmptySound();
if (soundevent == null) if (soundevent == null)
soundevent = fluid.is(FluidTags.LAVA) ? SoundEvents.BUCKET_EMPTY_LAVA : SoundEvents.BUCKET_EMPTY; soundevent =
FluidHelper.isTag(fluid, FluidTags.LAVA) ? SoundEvents.BUCKET_EMPTY_LAVA : SoundEvents.BUCKET_EMPTY;
} }
if (exchange == FluidExchange.TANK_TO_ITEM) { if (exchange == FluidExchange.TANK_TO_ITEM) {
@ -213,7 +214,8 @@ public class FluidTankBlock extends Block implements IWrenchable, ITE<FluidTankT
soundevent = fluid.getAttributes() soundevent = fluid.getAttributes()
.getFillSound(); .getFillSound();
if (soundevent == null) if (soundevent == null)
soundevent = fluid.is(FluidTags.LAVA) ? SoundEvents.BUCKET_FILL_LAVA : SoundEvents.BUCKET_FILL; soundevent =
FluidHelper.isTag(fluid, FluidTags.LAVA) ? SoundEvents.BUCKET_FILL_LAVA : SoundEvents.BUCKET_FILL;
} }
if (soundevent != null && !onClient) { if (soundevent != null && !onClient) {
@ -360,7 +362,7 @@ public class FluidTankBlock extends Block implements IWrenchable, ITE<FluidTankT
public static void updateBoilerState(BlockState pState, Level pLevel, BlockPos tankPos) { public static void updateBoilerState(BlockState pState, Level pLevel, BlockPos tankPos) {
BlockState tankState = pLevel.getBlockState(tankPos); BlockState tankState = pLevel.getBlockState(tankPos);
if (!(tankState.getBlock() instanceof FluidTankBlock tank)) if (!(tankState.getBlock()instanceof FluidTankBlock tank))
return; return;
FluidTankTileEntity tankTE = tank.getTileEntity(pLevel, tankPos); FluidTankTileEntity tankTE = tank.getTileEntity(pLevel, tankPos);
if (tankTE == null) if (tankTE == null)

View file

@ -12,6 +12,7 @@ import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.item.crafting.Recipe; import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.item.crafting.RecipeManager; import net.minecraft.world.item.crafting.RecipeManager;
import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.item.crafting.RecipeSerializer;
import net.minecraftforge.common.crafting.conditions.ICondition.IContext;
import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.ForgeRegistries;
public class SequencedRecipe<T extends ProcessingRecipe<?>> { public class SequencedRecipe<T extends ProcessingRecipe<?>> {
@ -43,7 +44,7 @@ public class SequencedRecipe<T extends ProcessingRecipe<?>> {
public static SequencedRecipe<?> fromJson(JsonObject json, SequencedAssemblyRecipe parent, int index) { public static SequencedRecipe<?> fromJson(JsonObject json, SequencedAssemblyRecipe parent, int index) {
ResourceLocation parentId = parent.getId(); ResourceLocation parentId = parent.getId();
Recipe<?> recipe = RecipeManager.fromJson( 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) { if (recipe instanceof ProcessingRecipe<?> && recipe instanceof IAssemblyRecipe) {
ProcessingRecipe<?> processingRecipe = (ProcessingRecipe<?>) recipe; ProcessingRecipe<?> processingRecipe = (ProcessingRecipe<?>) recipe;
IAssemblyRecipe assemblyRecipe = (IAssemblyRecipe) recipe; IAssemblyRecipe assemblyRecipe = (IAssemblyRecipe) recipe;

View file

@ -412,7 +412,7 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE<BeltTileEnt
BlockPos nextSegmentPosition = nextSegmentPosition(currentState, currentPos, false); BlockPos nextSegmentPosition = nextSegmentPosition(currentState, currentPos, false);
if (nextSegmentPosition == null) if (nextSegmentPosition == null)
break; break;
if (!world.isAreaLoaded(nextSegmentPosition, 0)) if (!world.isLoaded(nextSegmentPosition))
return; return;
currentPos = nextSegmentPosition; currentPos = nextSegmentPosition;
} }

View file

@ -7,6 +7,7 @@ import net.minecraft.core.BlockPos;
import net.minecraft.core.Vec3i; import net.minecraft.core.Vec3i;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
@ -21,7 +22,7 @@ public class BeltHelper {
} }
public static BeltTileEntity getSegmentTE(LevelAccessor world, BlockPos pos) { public static BeltTileEntity getSegmentTE(LevelAccessor world, BlockPos pos) {
if (!world.isAreaLoaded(pos, 0)) if (world instanceof Level l && !l.isLoaded(pos))
return null; return null;
BlockEntity tileEntity = world.getBlockEntity(pos); BlockEntity tileEntity = world.getBlockEntity(pos);
if (!(tileEntity instanceof BeltTileEntity)) if (!(tileEntity instanceof BeltTileEntity))

View file

@ -218,9 +218,7 @@ public class BeltConnectorItem extends BlockItem {
} }
public static boolean canConnect(Level world, BlockPos first, BlockPos second) { public static boolean canConnect(Level world, BlockPos first, BlockPos second) {
if (!world.isAreaLoaded(first, 1)) if (!world.isLoaded(first) || !world.isLoaded(second))
return false;
if (!world.isAreaLoaded(second, 1))
return false; return false;
if (!second.closerThan(first, maxLength())) if (!second.closerThan(first, maxLength()))
return false; return false;
@ -279,7 +277,7 @@ public class BeltConnectorItem extends BlockItem {
} }
public static boolean validateAxis(Level world, BlockPos pos) { public static boolean validateAxis(Level world, BlockPos pos) {
if (!world.isAreaLoaded(pos, 1)) if (!world.isLoaded(pos))
return false; return false;
if (!ShaftBlock.isShaft(world.getBlockState(pos))) if (!ShaftBlock.isShaft(world.getBlockState(pos)))
return false; return false;

View file

@ -1,12 +1,10 @@
package com.simibubi.create.content.contraptions.relays.elementary; package com.simibubi.create.content.contraptions.relays.elementary;
import java.util.Optional; import java.util.Optional;
import java.util.function.Function;
import java.util.function.Predicate; import java.util.function.Predicate;
import com.simibubi.create.content.contraptions.components.structureMovement.StructureTransform; import com.simibubi.create.content.contraptions.components.structureMovement.StructureTransform;
import com.simibubi.create.content.schematics.ItemRequirement; import com.simibubi.create.content.schematics.ItemRequirement;
import com.simibubi.create.foundation.advancement.ITriggerable;
import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.tileEntity.behaviour.BehaviourType; import com.simibubi.create.foundation.tileEntity.behaviour.BehaviourType;
@ -27,7 +25,6 @@ public class BracketedTileEntityBehaviour extends TileEntityBehaviour {
private boolean reRender; private boolean reRender;
private Predicate<BlockState> pred; private Predicate<BlockState> pred;
private Function<BlockState, ITriggerable> trigger;
public BracketedTileEntityBehaviour(SmartTileEntity te) { public BracketedTileEntityBehaviour(SmartTileEntity te) {
this(te, state -> true); this(te, state -> true);
@ -39,11 +36,6 @@ public class BracketedTileEntityBehaviour extends TileEntityBehaviour {
bracket = Optional.empty(); bracket = Optional.empty();
} }
public BracketedTileEntityBehaviour withTrigger(Function<BlockState, ITriggerable> trigger) {
this.trigger = trigger;
return this;
}
@Override @Override
public BehaviourType<?> getType() { public BehaviourType<?> getType() {
return TYPE; return TYPE;

View file

@ -9,11 +9,9 @@ import net.minecraft.world.InteractionResult;
import net.minecraft.world.item.BoneMealItem; import net.minecraft.world.item.BoneMealItem;
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;
import net.minecraft.world.item.context.UseOnContext; 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.Block;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.BonemealableBlock; 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.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties; 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 static class TreesDreamWorld extends PlacementSimulationServerWorld {
private final BlockPos saplingPos;
private final BlockState soil; private final BlockState soil;
protected TreesDreamWorld(ServerLevel wrapped, BlockPos saplingPos) { protected TreesDreamWorld(ServerLevel wrapped, BlockPos saplingPos) {
super(wrapped); super(wrapped);
this.saplingPos = saplingPos;
soil = wrapped.getBlockState(saplingPos.below()); soil = wrapped.getBlockState(saplingPos.below());
} }

View file

@ -168,11 +168,13 @@ public abstract class SymmetryMirror {
return in.mirror(Mirror.LEFT_RIGHT); return in.mirror(Mirror.LEFT_RIGHT);
} }
@SuppressWarnings("deprecation")
protected BlockState flipD1(BlockState in) { protected BlockState flipD1(BlockState in) {
return in.rotate(Rotation.COUNTERCLOCKWISE_90) return in.rotate(Rotation.COUNTERCLOCKWISE_90)
.mirror(Mirror.FRONT_BACK); .mirror(Mirror.FRONT_BACK);
} }
@SuppressWarnings("deprecation")
protected BlockState flipD2(BlockState in) { protected BlockState flipD2(BlockState in) {
return in.rotate(Rotation.COUNTERCLOCKWISE_90) return in.rotate(Rotation.COUNTERCLOCKWISE_90)
.mirror(Mirror.LEFT_RIGHT); .mirror(Mirror.LEFT_RIGHT);

View file

@ -1,7 +1,6 @@
package com.simibubi.create.content.curiosities.toolbox; package com.simibubi.create.content.curiosities.toolbox;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.WeakHashMap; import java.util.WeakHashMap;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -67,7 +66,7 @@ public class ToolboxHandler {
BlockPos pos = NbtUtils.readBlockPos(data.getCompound("Pos")); BlockPos pos = NbtUtils.readBlockPos(data.getCompound("Pos"));
int slot = data.getInt("Slot"); int slot = data.getInt("Slot");
if (!world.isAreaLoaded(pos, 0)) if (!world.isLoaded(pos))
continue; continue;
if (!(world.getBlockState(pos) if (!(world.getBlockState(pos)
.getBlock() instanceof ToolboxBlock)) { .getBlock() instanceof ToolboxBlock)) {

View file

@ -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_OFF;
import static com.simibubi.create.foundation.gui.AllGuiTextures.TOOLBELT_SELECTED_ON; import static com.simibubi.create.foundation.gui.AllGuiTextures.TOOLBELT_SELECTED_ON;
import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;

View file

@ -60,7 +60,8 @@ public class SandPaperItem extends Item implements CustomUseEffectsItem {
return new InteractionResultHolder<>(InteractionResult.PASS, itemstack); 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); ItemStack itemInOtherHand = playerIn.getItemInHand(otherHand);
if (SandPaperPolishingRecipe.canPolish(worldIn, itemInOtherHand)) { if (SandPaperPolishingRecipe.canPolish(worldIn, itemInOtherHand)) {
ItemStack item = itemInOtherHand.copy(); ItemStack item = itemInOtherHand.copy();
@ -137,7 +138,8 @@ public class SandPaperItem extends Item implements CustomUseEffectsItem {
if (player instanceof FakePlayer) { if (player instanceof FakePlayer) {
player.drop(polished, false, false); player.drop(polished, false, false);
} else { } else {
player.getInventory().placeItemBackInInventory(polished); player.getInventory()
.placeItemBackInInventory(polished);
} }
} }
tag.remove("Polishing"); tag.remove("Polishing");
@ -163,7 +165,8 @@ public class SandPaperItem extends Item implements CustomUseEffectsItem {
CompoundTag tag = stack.getOrCreateTag(); CompoundTag tag = stack.getOrCreateTag();
if (tag.contains("Polishing")) { if (tag.contains("Polishing")) {
ItemStack toPolish = ItemStack.of(tag.getCompound("Polishing")); ItemStack toPolish = ItemStack.of(tag.getCompound("Polishing"));
player.getInventory().placeItemBackInInventory(toPolish); player.getInventory()
.placeItemBackInInventory(toPolish);
tag.remove("Polishing"); tag.remove("Polishing");
} }
} }
@ -176,14 +179,15 @@ public class SandPaperItem extends Item implements CustomUseEffectsItem {
BlockPos pos = context.getClickedPos(); BlockPos pos = context.getClickedPos();
BlockState state = level.getBlockState(pos); 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) { 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, 3005, pos, 0); // Spawn particles level.levelEvent(player, 3005, pos, 0); // Spawn particles
} else { } else {
newState = state.getToolModifiedState(level, pos, player, stack, ToolActions.AXE_WAX_OFF); newState = state.getToolModifiedState(context, ToolActions.AXE_WAX_OFF, false);
if (newState != null) { 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 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 // After 6 ticks play the sound every 7th
if ((entity.getTicksUsingItem() - 6) % 7 == 0) 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; return true;
} }

View file

@ -309,7 +309,7 @@ public class BuiltinPotatoProjectileTypes {
return true; return true;
BlockPos hitPos = ray.getBlockPos(); BlockPos hitPos = ray.getBlockPos();
if (!world.isAreaLoaded(hitPos, 1)) if (world instanceof Level l && !l.isLoaded(hitPos))
return true; return true;
Direction face = ray.getDirection(); Direction face = ray.getDirection();
BlockPos placePos = hitPos.relative(face); BlockPos placePos = hitPos.relative(face);
@ -335,7 +335,7 @@ public class BuiltinPotatoProjectileTypes {
return true; return true;
BlockPos hitPos = ray.getBlockPos(); BlockPos hitPos = ray.getBlockPos();
if (!world.isAreaLoaded(hitPos, 1)) if (world instanceof Level l && !l.isLoaded(hitPos))
return true; return true;
Direction face = ray.getDirection(); Direction face = ray.getDirection();
BlockPos placePos = hitPos.relative(face); BlockPos placePos = hitPos.relative(face);

View file

@ -1,7 +1,5 @@
package com.simibubi.create.content.curiosities.weapons; 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.jozufozu.flywheel.util.transform.TransformStack;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AngleHelper;

View file

@ -14,7 +14,7 @@ import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.logistics.block.flap.FlapData; import com.simibubi.create.content.logistics.block.flap.FlapData;
import com.simibubi.create.foundation.render.AllMaterialSpecs; import com.simibubi.create.foundation.render.AllMaterialSpecs;
import com.simibubi.create.foundation.utility.AnimationTickHolder; 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.core.Direction;
import net.minecraft.world.level.LightLayer; import net.minecraft.world.level.LightLayer;
@ -37,7 +37,7 @@ public class BeltTunnelInstance extends BlockEntityInstance<BeltTunnelTileEntity
tile.flaps.forEach((direction, flapValue) -> { tile.flaps.forEach((direction, flapValue) -> {
float flapness = flapValue.get(AnimationTickHolder.getPartialTicks()); float flapness = flapValue.getValue(AnimationTickHolder.getPartialTicks());
float horizontalAngle = direction.getOpposite().toYRot(); float horizontalAngle = direction.getOpposite().toYRot();
@ -76,12 +76,11 @@ public class BeltTunnelInstance extends BlockEntityInstance<BeltTunnelTileEntity
@Override @Override
public void beginFrame() { public void beginFrame() {
tunnelFlaps.forEach((direction, keys) -> { tunnelFlaps.forEach((direction, keys) -> {
InterpolatedValue flapValue = blockEntity.flaps.get(direction); LerpedFloat lerpedFloat = blockEntity.flaps.get(direction);
if (flapValue == null) { if (lerpedFloat == null)
return; return;
}
float flapness = flapValue.get(AnimationTickHolder.getPartialTicks()); float flapness = lerpedFloat.getValue(AnimationTickHolder.getPartialTicks());
for (FlapData flap : keys) { for (FlapData flap : keys) {
flap.setFlapness(flapness); flap.setFlapness(flapness);
} }

View file

@ -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.BeltHelper;
import com.simibubi.create.content.contraptions.relays.belt.BeltTileEntity; import com.simibubi.create.content.contraptions.relays.belt.BeltTileEntity;
import com.simibubi.create.content.contraptions.relays.belt.BeltTileEntity.CasingType; 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.core.BlockPos;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.BlockItem;

View file

@ -31,7 +31,8 @@ public class BeltTunnelRenderer extends SmartTileEntityRenderer<BeltTunnelTileEn
int light, int overlay) { int light, int overlay) {
super.renderSafe(te, partialTicks, ms, buffer, light, overlay); super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
if (Backend.canUseInstancing(te.getLevel())) return; if (Backend.canUseInstancing(te.getLevel()))
return;
SuperByteBuffer flapBuffer = CachedBufferer.partial(AllBlockPartials.BELT_TUNNEL_FLAP, te.getBlockState()); SuperByteBuffer flapBuffer = CachedBufferer.partial(AllBlockPartials.BELT_TUNNEL_FLAP, te.getBlockState());
VertexConsumer vb = buffer.getBuffer(RenderType.solid()); VertexConsumer vb = buffer.getBuffer(RenderType.solid());
@ -44,7 +45,7 @@ public class BeltTunnelRenderer extends SmartTileEntityRenderer<BeltTunnelTileEn
float horizontalAngle = AngleHelper.horizontalAngle(direction.getOpposite()); float horizontalAngle = AngleHelper.horizontalAngle(direction.getOpposite());
float f = te.flaps.get(direction) float f = te.flaps.get(direction)
.get(partialTicks); .getValue(partialTicks);
ms.pushPose(); ms.pushPose();
msr.centre() msr.centre()

View file

@ -18,7 +18,8 @@ import com.simibubi.create.foundation.networking.AllPackets;
import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Iterate;
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.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
@ -41,7 +42,7 @@ import net.minecraftforge.items.IItemHandler;
public class BeltTunnelTileEntity extends SmartTileEntity { public class BeltTunnelTileEntity extends SmartTileEntity {
public Map<Direction, InterpolatedChasingValue> flaps; public Map<Direction, LerpedFloat> flaps;
public Set<Direction> sides; public Set<Direction> sides;
protected LazyOptional<IItemHandler> cap = LazyOptional.empty(); protected LazyOptional<IItemHandler> cap = LazyOptional.empty();
@ -93,9 +94,7 @@ public class BeltTunnelTileEntity extends SmartTileEntity {
if (!newFlaps.contains(d)) if (!newFlaps.contains(d))
flaps.remove(d); flaps.remove(d);
else if (!flaps.containsKey(d)) else if (!flaps.containsKey(d))
flaps.put(d, new InterpolatedChasingValue().start(.25f) flaps.put(d, createChasingFlap());
.target(0)
.withSpeed(.05f));
// Backwards compat // Backwards compat
if (!compound.contains("Sides") && compound.contains("Flaps")) if (!compound.contains("Sides") && compound.contains("Flaps"))
@ -105,6 +104,12 @@ public class BeltTunnelTileEntity extends SmartTileEntity {
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> InstancedRenderDispatcher.enqueueUpdate(this)); DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> InstancedRenderDispatcher.enqueueUpdate(this));
} }
private LerpedFloat createChasingFlap() {
return LerpedFloat.linear()
.startWithValue(.25f)
.chase(0, .05f, Chaser.EXP);
}
public void updateTunnelConnections() { public void updateTunnelConnections() {
flaps.clear(); flaps.clear();
sides.clear(); sides.clear();
@ -133,9 +138,7 @@ public class BeltTunnelTileEntity extends SmartTileEntity {
&& nextState.getValue(BeltFunnelBlock.HORIZONTAL_FACING) == direction.getOpposite()) && nextState.getValue(BeltFunnelBlock.HORIZONTAL_FACING) == direction.getOpposite())
continue; continue;
flaps.put(direction, new InterpolatedChasingValue().start(.25f) flaps.put(direction, createChasingFlap());
.target(0)
.withSpeed(.05f));
} }
sendData(); sendData();
} }
@ -144,7 +147,7 @@ public class BeltTunnelTileEntity extends SmartTileEntity {
if (level.isClientSide) { if (level.isClientSide) {
if (flaps.containsKey(side)) if (flaps.containsKey(side))
flaps.get(side) flaps.get(side)
.set(inward ^ side.getAxis() == Axis.Z ? -1 : 1); .setValue(inward ^ side.getAxis() == Axis.Z ? -1 : 1);
return; return;
} }
@ -165,7 +168,7 @@ public class BeltTunnelTileEntity extends SmartTileEntity {
sendFlaps(); sendFlaps();
return; return;
} }
flaps.forEach((d, value) -> value.tick()); flaps.forEach((d, value) -> value.tickChaser());
} }
private void sendFlaps() { private void sendFlaps() {

View file

@ -335,7 +335,7 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity implements IHave
for (boolean left : Iterate.trueAndFalse) { for (boolean left : Iterate.trueAndFalse) {
BrassTunnelTileEntity adjacent = this; BrassTunnelTileEntity adjacent = this;
while (adjacent != null) { while (adjacent != null) {
if (!level.isAreaLoaded(adjacent.getBlockPos(), 1)) if (!level.isLoaded(adjacent.getBlockPos()))
return null; return null;
adjacent = adjacent.getAdjacent(left); adjacent = adjacent.getAdjacent(left);
if (adjacent == null) if (adjacent == null)
@ -477,7 +477,7 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity implements IHave
for (boolean left : Iterate.trueAndFalse) { for (boolean left : Iterate.trueAndFalse) {
BrassTunnelTileEntity adjacent = this; BrassTunnelTileEntity adjacent = this;
while (adjacent != null) { while (adjacent != null) {
if (!level.isAreaLoaded(adjacent.getBlockPos(), 1)) if (!level.isLoaded(adjacent.getBlockPos()))
return null; return null;
adjacent = adjacent.getAdjacent(left); adjacent = adjacent.getAdjacent(left);
if (adjacent == null) if (adjacent == null)

View file

@ -15,19 +15,18 @@ import net.minecraft.world.level.block.state.BlockState;
public class ChuteRenderer extends SafeTileEntityRenderer<ChuteTileEntity> { public class ChuteRenderer extends SafeTileEntityRenderer<ChuteTileEntity> {
public ChuteRenderer(BlockEntityRendererProvider.Context context) { public ChuteRenderer(BlockEntityRendererProvider.Context context) {}
}
@Override @Override
protected void renderSafe(ChuteTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, protected void renderSafe(ChuteTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light,
int light, int overlay) { int overlay) {
if (te.item.isEmpty()) if (te.item.isEmpty())
return; return;
BlockState blockState = te.getBlockState(); BlockState blockState = te.getBlockState();
if (blockState.getValue(ChuteBlock.FACING) != Direction.DOWN) if (blockState.getValue(ChuteBlock.FACING) != Direction.DOWN)
return; return;
if (blockState.getValue(ChuteBlock.SHAPE) != Shape.WINDOW if (blockState.getValue(ChuteBlock.SHAPE) != Shape.WINDOW
&& (te.bottomPullDistance == 0 || te.itemPosition.get(partialTicks) > .5f)) && (te.bottomPullDistance == 0 || te.itemPosition.getValue(partialTicks) > .5f))
return; return;
renderItem(te, partialTicks, ms, buffer, light, overlay); renderItem(te, partialTicks, ms, buffer, light, overlay);
@ -41,7 +40,7 @@ public class ChuteRenderer extends SafeTileEntityRenderer<ChuteTileEntity> {
ms.pushPose(); ms.pushPose();
msr.centre(); msr.centre();
float itemScale = .5f; float itemScale = .5f;
float itemPosition = te.itemPosition.get(partialTicks); float itemPosition = te.itemPosition.getValue(partialTicks);
ms.translate(0, -.5 + itemPosition, 0); ms.translate(0, -.5 + itemPosition, 0);
ms.scale(itemScale, itemScale, itemScale); ms.scale(itemScale, itemScale, itemScale);
msr.rotateX(itemPosition * 180); msr.rotateX(itemPosition * 180);

View file

@ -28,7 +28,7 @@ import com.simibubi.create.foundation.utility.BlockHelper;
import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Iterate;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.VecHelper; 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.ChatFormatting;
import net.minecraft.MethodsReturnNonnullByDefault; import net.minecraft.MethodsReturnNonnullByDefault;
@ -63,13 +63,13 @@ import net.minecraftforge.items.ItemHandlerHelper;
*/ */
public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInformation { // , IAirCurrentSource { public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInformation { // , IAirCurrentSource {
// public AirCurrent airCurrent; // public AirCurrent airCurrent;
float pull; float pull;
float push; float push;
ItemStack item; ItemStack item;
InterpolatedValue itemPosition; LerpedFloat itemPosition;
ChuteItemHandler itemHandler; ChuteItemHandler itemHandler;
LazyOptional<IItemHandler> lazyHandler; LazyOptional<IItemHandler> lazyHandler;
boolean canPickUpItems; boolean canPickUpItems;
@ -87,14 +87,14 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor
public ChuteTileEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) { public ChuteTileEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type, pos, state); super(type, pos, state);
item = ItemStack.EMPTY; item = ItemStack.EMPTY;
itemPosition = new InterpolatedValue(); itemPosition = LerpedFloat.linear();
itemHandler = new ChuteItemHandler(this); itemHandler = new ChuteItemHandler(this);
lazyHandler = LazyOptional.of(() -> itemHandler); lazyHandler = LazyOptional.of(() -> itemHandler);
canPickUpItems = false; canPickUpItems = false;
capAbove = LazyOptional.empty(); capAbove = LazyOptional.empty();
capBelow = LazyOptional.empty(); capBelow = LazyOptional.empty();
bottomPullDistance = 0; bottomPullDistance = 0;
// airCurrent = new AirCurrent(this); // airCurrent = new AirCurrent(this);
updateAirFlow = true; updateAirFlow = true;
} }
@ -153,7 +153,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor
return; return;
} }
float nextOffset = itemPosition.value + itemMotion; float nextOffset = itemPosition.getValue() + itemMotion;
if (itemMotion < 0) { if (itemMotion < 0) {
if (nextOffset < .5f) { if (nextOffset < .5f) {
@ -161,7 +161,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor
nextOffset = .5f; nextOffset = .5f;
else if (nextOffset < 0) { else if (nextOffset < 0) {
handleDownwardOutput(clientSide); handleDownwardOutput(clientSide);
nextOffset = itemPosition.value; nextOffset = itemPosition.getValue();
} }
} }
} else if (itemMotion > 0) { } else if (itemMotion > 0) {
@ -170,17 +170,17 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor
nextOffset = .5f; nextOffset = .5f;
else if (nextOffset > 1) { else if (nextOffset > 1) {
handleUpwardOutput(clientSide); handleUpwardOutput(clientSide);
nextOffset = itemPosition.value; nextOffset = itemPosition.getValue();
} }
} }
} }
itemPosition.set(nextOffset); itemPosition.setValue(nextOffset);
} }
private void updateAirFlow(float itemSpeed) { private void updateAirFlow(float itemSpeed) {
updateAirFlow = false; updateAirFlow = false;
// airCurrent.rebuild(); // airCurrent.rebuild();
if (itemSpeed > 0 && level != null && !level.isClientSide) { if (itemSpeed > 0 && level != null && !level.isClientSide) {
float speed = pull - push; float speed = pull - push;
beltBelow = null; beltBelow = null;
@ -216,15 +216,14 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor
} }
private void findEntities(float itemSpeed) { private void findEntities(float itemSpeed) {
// if (getSpeed() != 0) // if (getSpeed() != 0)
// airCurrent.findEntities(); // airCurrent.findEntities();
if (bottomPullDistance <= 0 && !getItem().isEmpty() || itemSpeed <= 0 || level == null || level.isClientSide) if (bottomPullDistance <= 0 && !getItem().isEmpty() || itemSpeed <= 0 || level == null || level.isClientSide)
return; return;
if (!canCollectItemsFromBelow()) if (!canCollectItemsFromBelow())
return; return;
Vec3 center = VecHelper.getCenterOf(worldPosition); Vec3 center = VecHelper.getCenterOf(worldPosition);
AABB searchArea = AABB searchArea = new AABB(center.add(0, -bottomPullDistance - 0.5, 0), center.add(0, -0.5, 0)).inflate(.45f);
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)) { for (ItemEntity itemEntity : level.getEntitiesOfClass(ItemEntity.class, searchArea)) {
if (!itemEntity.isAlive()) if (!itemEntity.isAlive())
continue; continue;
@ -268,8 +267,8 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor
} }
extractFromBelt(itemSpeed); extractFromBelt(itemSpeed);
// if (getSpeed() != 0) // if (getSpeed() != 0)
// airCurrent.tick(); // airCurrent.tick();
} }
public void blockBelowChanged() { public void blockBelowChanged() {
@ -289,7 +288,8 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor
if (push == 0 && pull == 0) if (push == 0 && pull == 0)
return; 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); spawnAirFlow(1, 2, absMotion, .5f);
if (AbstractChuteBlock.getChuteFacing(blockState) != Direction.DOWN) 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 remainder = ItemHandlerHelper.insertItemStacked(capBelow.orElse(null), item, simulate);
ItemStack held = getItem(); ItemStack held = getItem();
if (!simulate) if (!simulate)
setItem(remainder, itemPosition.get(0)); setItem(remainder, itemPosition.getValue(0));
if (remainder.getCount() != held.getCount()) if (remainder.getCount() != held.getCount())
return true; return true;
if (direction == Direction.DOWN) if (direction == Direction.DOWN)
@ -501,7 +501,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor
public void setItem(ItemStack stack, float insertionPos) { public void setItem(ItemStack stack, float insertionPos) {
item = stack; item = stack;
itemPosition.lastValue = itemPosition.value = insertionPos; itemPosition.startWithValue(insertionPos);
if (!level.isClientSide) { if (!level.isClientSide) {
notifyUpdate(); notifyUpdate();
award(AllAdvancements.CHUTE); award(AllAdvancements.CHUTE);
@ -518,7 +518,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor
@Override @Override
public void write(CompoundTag compound, boolean clientPacket) { public void write(CompoundTag compound, boolean clientPacket) {
compound.put("Item", item.serializeNBT()); compound.put("Item", item.serializeNBT());
compound.putFloat("ItemPosition", itemPosition.value); compound.putFloat("ItemPosition", itemPosition.getValue());
compound.putFloat("Pull", pull); compound.putFloat("Pull", pull);
compound.putFloat("Push", push); compound.putFloat("Push", push);
compound.putFloat("BottomAirFlowDistance", bottomPullDistance); compound.putFloat("BottomAirFlowDistance", bottomPullDistance);
@ -529,7 +529,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor
protected void read(CompoundTag compound, boolean clientPacket) { protected void read(CompoundTag compound, boolean clientPacket) {
ItemStack previousItem = item; ItemStack previousItem = item;
item = ItemStack.of(compound.getCompound("Item")); item = ItemStack.of(compound.getCompound("Item"));
itemPosition.lastValue = itemPosition.value = compound.getFloat("ItemPosition"); itemPosition.startWithValue(compound.getFloat("ItemPosition"));
pull = compound.getFloat("Pull"); pull = compound.getFloat("Pull");
push = compound.getFloat("Push"); push = compound.getFloat("Push");
bottomPullDistance = compound.getFloat("BottomAirFlowDistance"); bottomPullDistance = compound.getFloat("BottomAirFlowDistance");
@ -632,7 +632,8 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor
if (level == null) if (level == null)
return 0; return 0;
BlockState blockStateBelow = level.getBlockState(worldPosition.below()); 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()); BlockEntity te = level.getBlockEntity(worldPosition.below());
if (te instanceof EncasedFanTileEntity && !te.isRemoved()) { if (te instanceof EncasedFanTileEntity && !te.isRemoved()) {
EncasedFanTileEntity fan = (EncasedFanTileEntity) te; EncasedFanTileEntity fan = (EncasedFanTileEntity) te;
@ -736,47 +737,50 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor
return item; return item;
} }
// @Override // @Override
// @Nullable // @Nullable
// public AirCurrent getAirCurrent() { // public AirCurrent getAirCurrent() {
// return airCurrent; // return airCurrent;
// } // }
// //
// @Nullable // @Nullable
// @Override // @Override
// public World getAirCurrentWorld() { // public World getAirCurrentWorld() {
// return world; // return world;
// } // }
// //
// @Override // @Override
// public BlockPos getAirCurrentPos() { // public BlockPos getAirCurrentPos() {
// return pos; // return pos;
// } // }
// //
// @Override // @Override
// public float getSpeed() { // public float getSpeed() {
// if (getBlockState().get(ChuteBlock.SHAPE) == Shape.NORMAL && getBlockState().get(ChuteBlock.FACING) != Direction.DOWN) // if (getBlockState().get(ChuteBlock.SHAPE) == Shape.NORMAL &&
// return 0; // getBlockState().get(ChuteBlock.FACING) != Direction.DOWN)
// return pull + push; // return 0;
// } // return pull + push;
// }
// //
// @Override // @Override
// @Nullable // @Nullable
// public Direction getAirFlowDirection() { // public Direction getAirFlowDirection() {
// float speed = getSpeed(); // float speed = getSpeed();
// if (speed == 0) // if (speed == 0)
// return null; // return null;
// return speed > 0 ? Direction.UP : Direction.DOWN; // return speed > 0 ? Direction.UP : Direction.DOWN;
// } // }
// //
// @Override // @Override
// public boolean isSourceRemoved() { // public boolean isSourceRemoved() {
// return removed; // return removed;
// } // }
// //
// @Override // @Override
// public Direction getAirflowOriginSide() { // public Direction getAirflowOriginSide() {
// return world != null && !(world.getTileEntity(pos.down()) instanceof IAirCurrentSource) // return world != null && !(world.getTileEntity(pos.down()) instanceof
// && getBlockState().get(ChuteBlock.FACING) == Direction.DOWN ? Direction.DOWN : Direction.UP; // IAirCurrentSource)
// } // && getBlockState().get(ChuteBlock.FACING) == Direction.DOWN ? Direction.DOWN
// : Direction.UP;
// }
} }

View file

@ -18,7 +18,7 @@ public class SmartChuteRenderer extends SmartTileEntityRenderer<SmartChuteTileEn
super.renderSafe(tileEntityIn, partialTicks, ms, buffer, light, overlay); super.renderSafe(tileEntityIn, partialTicks, ms, buffer, light, overlay);
if (tileEntityIn.item.isEmpty()) if (tileEntityIn.item.isEmpty())
return; return;
if (tileEntityIn.itemPosition.get(partialTicks) > 0) if (tileEntityIn.itemPosition.getValue(partialTicks) > 0)
return; return;
ChuteRenderer.renderItem(tileEntityIn, partialTicks, ms, buffer, light, overlay); ChuteRenderer.renderItem(tileEntityIn, partialTicks, ms, buffer, light, overlay);
} }

View file

@ -3,7 +3,6 @@ package com.simibubi.create.content.logistics.block.display;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import com.google.common.collect.ImmutableList;
import com.jozufozu.flywheel.util.transform.TransformStack; import com.jozufozu.flywheel.util.transform.TransformStack;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.content.logistics.block.display.source.DisplaySource; 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.gui.widget.SelectionScrollInput;
import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.networking.AllPackets;
import com.simibubi.create.foundation.ponder.PonderTag; 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.ponder.ui.PonderTagScreen;
import com.simibubi.create.foundation.utility.Couple; import com.simibubi.create.foundation.utility.Couple;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;

View file

@ -13,7 +13,6 @@ import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent; import net.minecraft.network.chat.MutableComponent;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items; 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.BlockEntity;
import net.minecraft.world.level.block.entity.LecternBlockEntity; import net.minecraft.world.level.block.entity.LecternBlockEntity;

View file

@ -5,7 +5,6 @@ import java.util.List;
import com.simibubi.create.content.logistics.block.display.DisplayLinkContext; import com.simibubi.create.content.logistics.block.display.DisplayLinkContext;
import net.minecraft.network.chat.MutableComponent; 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.BlockEntity;
import net.minecraft.world.level.block.entity.SignBlockEntity; import net.minecraft.world.level.block.entity.SignBlockEntity;

View file

@ -33,6 +33,7 @@ public class AbstractDirectionalFunnelBlock extends AbstractFunnelBlock {
} }
@Override @Override
@SuppressWarnings("deprecation")
public BlockState mirror(BlockState state, Mirror mirrorIn) { public BlockState mirror(BlockState state, Mirror mirrorIn) {
return state.rotate(mirrorIn.getRotation(state.getValue(FACING))); return state.rotate(mirrorIn.getRotation(state.getValue(FACING)));
} }

View file

@ -33,6 +33,7 @@ public abstract class AbstractHorizontalFunnelBlock extends AbstractFunnelBlock
} }
@Override @Override
@SuppressWarnings("deprecation")
public BlockState mirror(BlockState p_185471_1_, Mirror p_185471_2_) { 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))); return p_185471_1_.rotate(p_185471_2_.getRotation(p_185471_1_.getValue(HORIZONTAL_FACING)));
} }

View file

@ -38,7 +38,7 @@ public class FunnelInstance extends BlockEntityInstance<FunnelTileEntity> implem
Direction direction = FunnelBlock.getFunnelFacing(blockState); Direction direction = FunnelBlock.getFunnelFacing(blockState);
float flapness = tile.flap.get(AnimationTickHolder.getPartialTicks()); float flapness = tile.flap.getValue(AnimationTickHolder.getPartialTicks());
float horizontalAngle = direction.getOpposite().toYRot(); float horizontalAngle = direction.getOpposite().toYRot();
for (int segment = 0; segment <= 3; segment++) { for (int segment = 0; segment <= 3; segment++) {
@ -65,7 +65,7 @@ public class FunnelInstance extends BlockEntityInstance<FunnelTileEntity> implem
public void beginFrame() { public void beginFrame() {
if (flaps == null) return; if (flaps == null) return;
float flapness = blockEntity.flap.get(AnimationTickHolder.getPartialTicks()); float flapness = blockEntity.flap.getValue(AnimationTickHolder.getPartialTicks());
for (FlapData flap : flaps) { for (FlapData flap : flaps) {
flap.setFlapness(flapness); flap.setFlapness(flapness);

View file

@ -36,18 +36,18 @@ public class FunnelRenderer extends SmartTileEntityRenderer<FunnelTileEntity> {
BlockState blockState = te.getBlockState(); BlockState blockState = te.getBlockState();
VertexConsumer vb = buffer.getBuffer(RenderType.solid()); VertexConsumer vb = buffer.getBuffer(RenderType.solid());
PartialModel partialModel = (blockState.getBlock() instanceof FunnelBlock ? AllBlockPartials.FUNNEL_FLAP PartialModel partialModel = (blockState.getBlock() instanceof FunnelBlock ? AllBlockPartials.FUNNEL_FLAP
: AllBlockPartials.BELT_FUNNEL_FLAP); : AllBlockPartials.BELT_FUNNEL_FLAP);
SuperByteBuffer flapBuffer = CachedBufferer.partial(partialModel, blockState); SuperByteBuffer flapBuffer = CachedBufferer.partial(partialModel, blockState);
Vec3 pivot = VecHelper.voxelSpace(0, 10, 9.5f); Vec3 pivot = VecHelper.voxelSpace(0, 10, 9.5f);
TransformStack msr = TransformStack.cast(ms); TransformStack msr = TransformStack.cast(ms);
float horizontalAngle = AngleHelper.horizontalAngle(FunnelBlock.getFunnelFacing(blockState) float horizontalAngle = AngleHelper.horizontalAngle(FunnelBlock.getFunnelFacing(blockState)
.getOpposite()); .getOpposite());
float f = te.flap.get(partialTicks); float f = te.flap.getValue(partialTicks);
ms.pushPose(); ms.pushPose();
msr.centre() msr.centre()
.rotateY(horizontalAngle) .rotateY(horizontalAngle)
.unCentre(); .unCentre();
ms.translate(0, 0, -te.getFlapOffset()); ms.translate(0, 0, -te.getFlapOffset());

View file

@ -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.tileEntity.behaviour.inventory.InvManipulationBehaviour;
import com.simibubi.create.foundation.utility.BlockFace; import com.simibubi.create.foundation.utility.BlockFace;
import com.simibubi.create.foundation.utility.VecHelper; 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.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
@ -45,7 +46,7 @@ public class FunnelTileEntity extends SmartTileEntity implements IHaveHoveringIn
private WeakReference<ItemEntity> lastObserved; // In-world Extractors only private WeakReference<ItemEntity> lastObserved; // In-world Extractors only
InterpolatedChasingValue flap; LerpedFloat flap;
static enum Mode { static enum Mode {
INVALID, PAUSED, COLLECT, PUSHING_TO_BELT, TAKING_FROM_BELT, EXTRACT 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) { public FunnelTileEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type, pos, state); super(type, pos, state);
extractionCooldown = 0; extractionCooldown = 0;
flap = new InterpolatedChasingValue().start(.25f) flap = createChasingFlap();
.target(0)
.withSpeed(.05f);
} }
public Mode determineCurrentMode() { public Mode determineCurrentMode() {
@ -88,7 +87,7 @@ public class FunnelTileEntity extends SmartTileEntity implements IHaveHoveringIn
@Override @Override
public void tick() { public void tick() {
super.tick(); super.tick();
flap.tick(); flap.tickChaser();
Mode mode = determineCurrentMode(); Mode mode = determineCurrentMode();
if (level.isClientSide) if (level.isClientSide)
return; return;
@ -287,7 +286,7 @@ public class FunnelTileEntity extends SmartTileEntity implements IHaveHoveringIn
if (!level.isClientSide) { if (!level.isClientSide) {
AllPackets.channel.send(packetTarget(), new FunnelFlapPacket(this, inward)); AllPackets.channel.send(packetTarget(), new FunnelFlapPacket(this, inward));
} else { } else {
flap.set(inward ? 1 : -1); flap.setValue(inward ? 1 : -1);
AllSoundEvents.FUNNEL_FLAP.playAt(level, worldPosition, 1, 1, true); AllSoundEvents.FUNNEL_FLAP.playAt(level, worldPosition, 1, 1, true);
} }
} }
@ -338,4 +337,10 @@ public class FunnelTileEntity extends SmartTileEntity implements IHaveHoveringIn
award(AllAdvancements.FUNNEL); award(AllAdvancements.FUNNEL);
} }
private LerpedFloat createChasingFlap() {
return LerpedFloat.linear()
.startWithValue(.25f)
.chase(0, .05f, Chaser.EXP);
}
} }

View file

@ -49,11 +49,16 @@ public class ArmInstance extends SingleRotatingInstance implements DynamicInstan
Material<ModelData> mat = getTransformMaterial(); Material<ModelData> mat = getTransformMaterial();
base = mat.getModel(AllBlockPartials.ARM_BASE, blockState).createInstance(); base = mat.getModel(AllBlockPartials.ARM_BASE, blockState)
lowerBody = mat.getModel(AllBlockPartials.ARM_LOWER_BODY, blockState).createInstance(); .createInstance();
upperBody = mat.getModel(AllBlockPartials.ARM_UPPER_BODY, blockState).createInstance(); lowerBody = mat.getModel(AllBlockPartials.ARM_LOWER_BODY, blockState)
head = mat.getModel(AllBlockPartials.ARM_HEAD, blockState).createInstance(); .createInstance();
claw = mat.getModel(AllBlockPartials.ARM_CLAW_BASE, 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<ModelData> clawHalfModel = mat.getModel(AllBlockPartials.ARM_CLAW_GRIP, blockState); Instancer<ModelData> clawHalfModel = mat.getModel(AllBlockPartials.ARM_CLAW_GRIP, blockState);
ModelData clawGrip1 = clawHalfModel.createInstance(); ModelData clawGrip1 = clawHalfModel.createInstance();
@ -77,15 +82,13 @@ public class ArmInstance extends SingleRotatingInstance implements DynamicInstan
float pt = AnimationTickHolder.getPartialTicks(); float pt = AnimationTickHolder.getPartialTicks();
float baseAngleNow = this.arm.baseAngle.get(pt); float baseAngleNow = arm.baseAngle.getValue(pt);
float lowerArmAngleNow = this.arm.lowerArmAngle.get(pt); float lowerArmAngleNow = arm.lowerArmAngle.getValue(pt);
float upperArmAngleNow = this.arm.upperArmAngle.get(pt); float upperArmAngleNow = arm.upperArmAngle.getValue(pt);
float headAngleNow = this.arm.headAngle.get(pt); float headAngleNow = arm.headAngle.getValue(pt);
boolean settled = Mth.equal(baseAngle, baseAngleNow) boolean settled = Mth.equal(baseAngle, baseAngleNow) && Mth.equal(lowerArmAngle, lowerArmAngleNow)
&& Mth.equal(lowerArmAngle, lowerArmAngleNow) && Mth.equal(upperArmAngle, upperArmAngleNow) && Mth.equal(headAngle, headAngleNow);
&& Mth.equal(upperArmAngle, upperArmAngleNow)
&& Mth.equal(headAngle, headAngleNow);
this.baseAngle = baseAngleNow; this.baseAngle = baseAngleNow;
this.lowerArmAngle = lowerArmAngleNow; 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); lowerArmAngle = Mth.lerp((Mth.sin(renderTick / 4) + 1) / 2, -45, 15);
upperArmAngle = Mth.lerp((Mth.sin(renderTick / 8) + 1) / 4, -45, 95); upperArmAngle = Mth.lerp((Mth.sin(renderTick / 8) + 1) / 4, -45, 95);
headAngle = -lowerArmAngle; headAngle = -lowerArmAngle;
color = Color.rainbowColor(AnimationTickHolder.getTicks() * 100).getRGB(); color = Color.rainbowColor(AnimationTickHolder.getTicks() * 100)
.getRGB();
} else { } else {
baseAngle = this.baseAngle; baseAngle = this.baseAngle;
lowerArmAngle = this.lowerArmAngle - 135; lowerArmAngle = this.lowerArmAngle - 135;
@ -122,7 +126,7 @@ public class ArmInstance extends SingleRotatingInstance implements DynamicInstan
} }
PoseStack msLocal = new PoseStack(); PoseStack msLocal = new PoseStack();
TransformStack msr = TransformStack.cast(msLocal); TransformStack msr = TransformStack.cast(msLocal);
msr.translate(getInstancePosition()); msr.translate(getInstancePosition());
msr.centre(); msr.centre();
@ -134,11 +138,11 @@ public class ArmInstance extends SingleRotatingInstance implements DynamicInstan
ArmRenderer.transformLowerArm(msr, lowerArmAngle); ArmRenderer.transformLowerArm(msr, lowerArmAngle);
lowerBody.setTransform(msLocal) lowerBody.setTransform(msLocal)
.setColor(color); .setColor(color);
ArmRenderer.transformUpperArm(msr, upperArmAngle); ArmRenderer.transformUpperArm(msr, upperArmAngle);
upperBody.setTransform(msLocal) upperBody.setTransform(msLocal)
.setColor(color); .setColor(color);
ArmRenderer.transformHead(msr, headAngle); ArmRenderer.transformHead(msr, headAngle);
head.setTransform(msLocal); head.setTransform(msLocal);
@ -148,17 +152,18 @@ public class ArmInstance extends SingleRotatingInstance implements DynamicInstan
ItemStack item = this.arm.heldItem; ItemStack item = this.arm.heldItem;
ItemRenderer itemRenderer = Minecraft.getInstance() ItemRenderer itemRenderer = Minecraft.getInstance()
.getItemRenderer(); .getItemRenderer();
boolean hasItem = !item.isEmpty(); boolean hasItem = !item.isEmpty();
boolean isBlockItem = hasItem && (item.getItem() instanceof BlockItem) boolean isBlockItem = hasItem && (item.getItem() instanceof BlockItem)
&& itemRenderer.getModel(item, Minecraft.getInstance().level, null, 0) && itemRenderer.getModel(item, Minecraft.getInstance().level, null, 0)
.isGui3d(); .isGui3d();
for (int index : Iterate.zeroAndOne) { for (int index : Iterate.zeroAndOne) {
msLocal.pushPose(); msLocal.pushPose();
int flip = index * 2 - 1; int flip = index * 2 - 1;
ArmRenderer.transformClawHalf(msr, hasItem, isBlockItem, flip); ArmRenderer.transformClawHalf(msr, hasItem, isBlockItem, flip);
clawGrips.get(index).setTransform(msLocal); clawGrips.get(index)
.setTransform(msLocal);
msLocal.popPose(); msLocal.popPose();
} }
} }

View file

@ -41,20 +41,21 @@ public class ArmRenderer extends KineticTileEntityRenderer {
boolean hasItem = !item.isEmpty(); boolean hasItem = !item.isEmpty();
boolean usingFlywheel = Backend.canUseInstancing(te.getLevel()); boolean usingFlywheel = Backend.canUseInstancing(te.getLevel());
if (usingFlywheel && !hasItem) return; if (usingFlywheel && !hasItem)
return;
ItemRenderer itemRenderer = Minecraft.getInstance() ItemRenderer itemRenderer = Minecraft.getInstance()
.getItemRenderer(); .getItemRenderer();
boolean isBlockItem = hasItem && (item.getItem() instanceof BlockItem) boolean isBlockItem =
&& itemRenderer.getModel(item, te.getLevel(), null, 0) hasItem && (item.getItem() instanceof BlockItem) && itemRenderer.getModel(item, te.getLevel(), null, 0)
.isGui3d(); .isGui3d();
VertexConsumer builder = buffer.getBuffer(RenderType.solid()); VertexConsumer builder = buffer.getBuffer(RenderType.solid());
BlockState blockState = te.getBlockState(); BlockState blockState = te.getBlockState();
PoseStack msLocal = new PoseStack(); PoseStack msLocal = new PoseStack();
TransformStack msr = TransformStack.cast(msLocal); TransformStack msr = TransformStack.cast(msLocal);
float baseAngle; float baseAngle;
float lowerArmAngle; float lowerArmAngle;
@ -69,12 +70,13 @@ public class ArmRenderer extends KineticTileEntityRenderer {
lowerArmAngle = Mth.lerp((Mth.sin(renderTick / 4) + 1) / 2, -45, 15); lowerArmAngle = Mth.lerp((Mth.sin(renderTick / 4) + 1) / 2, -45, 15);
upperArmAngle = Mth.lerp((Mth.sin(renderTick / 8) + 1) / 4, -45, 95); upperArmAngle = Mth.lerp((Mth.sin(renderTick / 8) + 1) / 4, -45, 95);
headAngle = -lowerArmAngle; headAngle = -lowerArmAngle;
color = Color.rainbowColor(AnimationTickHolder.getTicks() * 100).getRGB(); color = Color.rainbowColor(AnimationTickHolder.getTicks() * 100)
.getRGB();
} else { } else {
baseAngle = arm.baseAngle.get(pt); baseAngle = arm.baseAngle.getValue(pt);
lowerArmAngle = arm.lowerArmAngle.get(pt) - 135; lowerArmAngle = arm.lowerArmAngle.getValue(pt) - 135;
upperArmAngle = arm.upperArmAngle.get(pt) - 90; upperArmAngle = arm.upperArmAngle.getValue(pt) - 90;
headAngle = arm.headAngle.get(pt); headAngle = arm.headAngle.getValue(pt);
color = 0xFFFFFF; color = 0xFFFFFF;
} }
@ -86,7 +88,8 @@ public class ArmRenderer extends KineticTileEntityRenderer {
if (usingFlywheel) if (usingFlywheel)
doItemTransforms(msr, baseAngle, lowerArmAngle, upperArmAngle, headAngle); doItemTransforms(msr, baseAngle, lowerArmAngle, upperArmAngle, headAngle);
else 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) { if (hasItem) {
ms.pushPose(); ms.pushPose();
@ -95,36 +98,45 @@ public class ArmRenderer extends KineticTileEntityRenderer {
msLocal.translate(0, -4 / 16f, 0); msLocal.translate(0, -4 / 16f, 0);
msLocal.scale(itemScale, itemScale, itemScale); msLocal.scale(itemScale, itemScale, itemScale);
ms.last().pose().multiply(msLocal.last().pose()); ms.last()
.pose()
.multiply(msLocal.last()
.pose());
itemRenderer itemRenderer.renderStatic(item, TransformType.FIXED, light, overlay, ms, buffer, 0);
.renderStatic(item, TransformType.FIXED, light, overlay, ms, buffer, 0);
ms.popPose(); 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) { private void renderArm(VertexConsumer builder, PoseStack ms, PoseStack msLocal, TransformStack msr,
SuperByteBuffer base = CachedBufferer.partial(AllBlockPartials.ARM_BASE, blockState).light(light); BlockState blockState, int color, float baseAngle, float lowerArmAngle, float upperArmAngle, float headAngle,
SuperByteBuffer lowerBody = CachedBufferer.partial(AllBlockPartials.ARM_LOWER_BODY, blockState).light(light); boolean hasItem, boolean isBlockItem, int light) {
SuperByteBuffer upperBody = CachedBufferer.partial(AllBlockPartials.ARM_UPPER_BODY, blockState).light(light); SuperByteBuffer base = CachedBufferer.partial(AllBlockPartials.ARM_BASE, blockState)
SuperByteBuffer head = CachedBufferer.partial(AllBlockPartials.ARM_HEAD, blockState).light(light); .light(light);
SuperByteBuffer claw = CachedBufferer.partial(AllBlockPartials.ARM_CLAW_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); SuperByteBuffer clawGrip = CachedBufferer.partial(AllBlockPartials.ARM_CLAW_GRIP, blockState);
transformBase(msr, baseAngle); transformBase(msr, baseAngle);
base.transform(msLocal) base.transform(msLocal)
.renderInto(ms, builder); .renderInto(ms, builder);
transformLowerArm(msr, lowerArmAngle); transformLowerArm(msr, lowerArmAngle);
lowerBody.color(color) lowerBody.color(color)
.transform(msLocal) .transform(msLocal)
.renderInto(ms, builder); .renderInto(ms, builder);
transformUpperArm(msr, upperArmAngle); transformUpperArm(msr, upperArmAngle);
upperBody.color(color) upperBody.color(color)
.transform(msLocal) .transform(msLocal)
.renderInto(ms, builder); .renderInto(ms, builder);
transformHead(msr, headAngle); transformHead(msr, headAngle);
head.transform(msLocal) head.transform(msLocal)
@ -137,12 +149,15 @@ public class ArmRenderer extends KineticTileEntityRenderer {
for (int flip : Iterate.positiveAndNegative) { for (int flip : Iterate.positiveAndNegative) {
msLocal.pushPose(); msLocal.pushPose();
transformClawHalf(msr, hasItem, isBlockItem, flip); transformClawHalf(msr, hasItem, isBlockItem, flip);
clawGrip.light(light).transform(msLocal).renderInto(ms, builder); clawGrip.light(light)
.transform(msLocal)
.renderInto(ms, builder);
msLocal.popPose(); 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); transformBase(msr, baseAngle);
transformLowerArm(msr, lowerArmAngle); transformLowerArm(msr, lowerArmAngle);

View file

@ -23,7 +23,7 @@ import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.NBTHelper;
import com.simibubi.create.foundation.utility.VecHelper; 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.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
@ -57,11 +57,11 @@ public class ArmTileEntity extends KineticTileEntity implements ITransformableTE
// Client // Client
ArmAngleTarget previousTarget; ArmAngleTarget previousTarget;
InterpolatedAngle lowerArmAngle; LerpedFloat lowerArmAngle;
InterpolatedAngle upperArmAngle; LerpedFloat upperArmAngle;
InterpolatedAngle baseAngle; LerpedFloat baseAngle;
InterpolatedAngle headAngle; LerpedFloat headAngle;
InterpolatedAngle clawAngle; LerpedFloat clawAngle;
float previousBaseAngle; float previousBaseAngle;
boolean updateInteractionPoints; boolean updateInteractionPoints;
@ -83,15 +83,15 @@ public class ArmTileEntity extends KineticTileEntity implements ITransformableTE
heldItem = ItemStack.EMPTY; heldItem = ItemStack.EMPTY;
phase = Phase.SEARCH_INPUTS; phase = Phase.SEARCH_INPUTS;
previousTarget = ArmAngleTarget.NO_TARGET; previousTarget = ArmAngleTarget.NO_TARGET;
baseAngle = new InterpolatedAngle(); baseAngle = LerpedFloat.angular();
baseAngle.init(previousTarget.baseAngle); baseAngle.startWithValue(previousTarget.baseAngle);
lowerArmAngle = new InterpolatedAngle(); lowerArmAngle = LerpedFloat.angular();
lowerArmAngle.init(previousTarget.lowerArmAngle); lowerArmAngle.startWithValue(previousTarget.lowerArmAngle);
upperArmAngle = new InterpolatedAngle(); upperArmAngle = LerpedFloat.angular();
upperArmAngle.init(previousTarget.upperArmAngle); upperArmAngle.startWithValue(previousTarget.upperArmAngle);
headAngle = new InterpolatedAngle(); headAngle = LerpedFloat.angular();
headAngle.init(previousTarget.headAngle); headAngle.startWithValue(previousTarget.headAngle);
clawAngle = new InterpolatedAngle(); clawAngle = LerpedFloat.angular();
previousBaseAngle = previousTarget.baseAngle; previousBaseAngle = previousTarget.baseAngle;
updateInteractionPoints = true; updateInteractionPoints = true;
redstoneLocked = false; redstoneLocked = false;
@ -191,7 +191,7 @@ public class ArmTileEntity extends KineticTileEntity implements ITransformableTE
ArmAngleTarget target = targetedInteractionPoint == null ? ArmAngleTarget.NO_TARGET ArmAngleTarget target = targetedInteractionPoint == null ? ArmAngleTarget.NO_TARGET
: targetedInteractionPoint.getTargetAngles(worldPosition, isOnCeiling()); : targetedInteractionPoint.getTargetAngles(worldPosition, isOnCeiling());
baseAngle.set(AngleHelper.angleLerp(chasedPointProgress, previousBaseAngle, baseAngle.setValue(AngleHelper.angleLerp(chasedPointProgress, previousBaseAngle,
target == ArmAngleTarget.NO_TARGET ? previousBaseAngle : target.baseAngle)); target == ArmAngleTarget.NO_TARGET ? previousBaseAngle : target.baseAngle));
// Arm's angles first backup to resting position and then continue // 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; previousTarget = ArmAngleTarget.NO_TARGET;
float progress = chasedPointProgress == 1 ? 1 : (chasedPointProgress % .5f) * 2; float progress = chasedPointProgress == 1 ? 1 : (chasedPointProgress % .5f) * 2;
lowerArmAngle.set(Mth.lerp(progress, previousTarget.lowerArmAngle, target.lowerArmAngle)); lowerArmAngle.setValue(Mth.lerp(progress, previousTarget.lowerArmAngle, target.lowerArmAngle));
upperArmAngle.set(Mth.lerp(progress, previousTarget.upperArmAngle, target.upperArmAngle)); 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; return false;
} }

View file

@ -17,64 +17,65 @@ import net.minecraft.world.level.block.state.properties.AttachFace;
public class AnalogLeverInstance extends BlockEntityInstance<AnalogLeverTileEntity> implements DynamicInstance { public class AnalogLeverInstance extends BlockEntityInstance<AnalogLeverTileEntity> implements DynamicInstance {
protected final ModelData handle; protected final ModelData handle;
protected final ModelData indicator; protected final ModelData indicator;
final float rX; final float rX;
final float rY; final float rY;
public AnalogLeverInstance(MaterialManager modelManager, AnalogLeverTileEntity tile) { public AnalogLeverInstance(MaterialManager modelManager, AnalogLeverTileEntity tile) {
super(modelManager, tile); super(modelManager, tile);
Material<ModelData> mat = getTransformMaterial(); Material<ModelData> mat = getTransformMaterial();
handle = mat.getModel(AllBlockPartials.ANALOG_LEVER_HANDLE, blockState).createInstance(); handle = mat.getModel(AllBlockPartials.ANALOG_LEVER_HANDLE, blockState)
indicator = mat.getModel(AllBlockPartials.ANALOG_LEVER_INDICATOR, blockState).createInstance(); .createInstance();
indicator = mat.getModel(AllBlockPartials.ANALOG_LEVER_INDICATOR, blockState)
.createInstance();
transform(indicator); transform(indicator);
AttachFace face = blockState.getValue(AnalogLeverBlock.FACE); AttachFace face = blockState.getValue(AnalogLeverBlock.FACE);
rX = face == AttachFace.FLOOR ? 0 : face == AttachFace.WALL ? 90 : 180; rX = face == AttachFace.FLOOR ? 0 : face == AttachFace.WALL ? 90 : 180;
rY = AngleHelper.horizontalAngle(blockState.getValue(AnalogLeverBlock.FACING)); rY = AngleHelper.horizontalAngle(blockState.getValue(AnalogLeverBlock.FACING));
animateLever(); animateLever();
} }
@Override @Override
public void beginFrame() { public void beginFrame() {
if (!blockEntity.clientState.settled()) if (!blockEntity.clientState.settled())
animateLever(); animateLever();
} }
protected void animateLever() { protected void animateLever() {
float state = blockEntity.clientState.get(AnimationTickHolder.getPartialTicks()); float state = blockEntity.clientState.getValue(AnimationTickHolder.getPartialTicks());
indicator.setColor(Color.mixColors(0x2C0300, 0xCD0000, state / 15f)); 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()) transform(handle.loadIdentity()).translate(1 / 2f, 1 / 16f, 1 / 2f)
.translate(1 / 2f, 1 / 16f, 1 / 2f) .rotate(Direction.EAST, angle)
.rotate(Direction.EAST, angle) .translate(-1 / 2f, -1 / 16f, -1 / 2f);
.translate(-1 / 2f, -1 / 16f, -1 / 2f);
} }
@Override @Override
public void remove() { public void remove() {
handle.delete(); handle.delete();
indicator.delete(); indicator.delete();
} }
@Override @Override
public void updateLight() { public void updateLight() {
relight(pos, handle, indicator); relight(pos, handle, indicator);
} }
private <T extends Translate<T> & Rotate<T>> T transform(T msr) { private <T extends Translate<T> & Rotate<T>> T transform(T msr) {
return msr.translate(getInstancePosition()) return msr.translate(getInstancePosition())
.centre() .centre()
.rotate(Direction.UP, (float) (rY / 180 * Math.PI)) .rotate(Direction.UP, (float) (rY / 180 * Math.PI))
.rotate(Direction.EAST, (float) (rX / 180 * Math.PI)) .rotate(Direction.EAST, (float) (rX / 180 * Math.PI))
.unCentre(); .unCentre();
} }
} }

View file

@ -29,7 +29,7 @@ public class AnalogLeverRenderer extends SafeTileEntityRenderer<AnalogLeverTileE
if (Backend.canUseInstancing(te.getLevel())) return; if (Backend.canUseInstancing(te.getLevel())) return;
BlockState leverState = te.getBlockState(); BlockState leverState = te.getBlockState();
float state = te.clientState.get(partialTicks); float state = te.clientState.getValue(partialTicks);
VertexConsumer vb = buffer.getBuffer(RenderType.solid()); VertexConsumer vb = buffer.getBuffer(RenderType.solid());

View file

@ -6,7 +6,8 @@ import com.simibubi.create.content.contraptions.goggles.IHaveGoggleInformation;
import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
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.BlockPos;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
@ -19,10 +20,11 @@ public class AnalogLeverTileEntity extends SmartTileEntity implements IHaveGoggl
int state = 0; int state = 0;
int lastChange; int lastChange;
InterpolatedChasingValue clientState = new InterpolatedChasingValue().withSpeed(.2f); LerpedFloat clientState;
public AnalogLeverTileEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) { public AnalogLeverTileEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type, pos, state); super(type, pos, state);
clientState = LerpedFloat.linear();
} }
@Override @Override
@ -36,7 +38,7 @@ public class AnalogLeverTileEntity extends SmartTileEntity implements IHaveGoggl
protected void read(CompoundTag compound, boolean clientPacket) { protected void read(CompoundTag compound, boolean clientPacket) {
state = compound.getInt("State"); state = compound.getInt("State");
lastChange = compound.getInt("ChangeTimer"); lastChange = compound.getInt("ChangeTimer");
clientState.target(state); clientState.chase(state, 0.2f, Chaser.EXP);
super.read(compound, clientPacket); super.read(compound, clientPacket);
} }
@ -49,7 +51,7 @@ public class AnalogLeverTileEntity extends SmartTileEntity implements IHaveGoggl
updateOutput(); updateOutput();
} }
if (level.isClientSide) if (level.isClientSide)
clientState.tick(); clientState.tickChaser();
} }
@Override @Override

View file

@ -73,10 +73,6 @@ public class StockpileSwitchBlock extends HorizontalDirectionalBlock
withTileEntityDo(world, pos, StockpileSwitchTileEntity::updateCurrentLevel); withTileEntityDo(world, pos, StockpileSwitchTileEntity::updateCurrentLevel);
} }
private boolean isObserving(BlockState state, BlockPos pos, BlockPos observing) {
return observing.equals(pos.relative(state.getValue(FACING)));
}
@Override @Override
public boolean canConnectRedstone(BlockState state, BlockGetter world, BlockPos pos, Direction side) { public boolean canConnectRedstone(BlockState state, BlockGetter world, BlockPos pos, Direction side) {
return side != null && side.getOpposite() != state.getValue(FACING); return side != null && side.getOpposite() != state.getValue(FACING);

View file

@ -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.contraptions.components.structureMovement.StructureTransform;
import com.simibubi.create.content.schematics.item.SchematicItem; import com.simibubi.create.content.schematics.item.SchematicItem;
import com.simibubi.create.foundation.tileEntity.IMergeableTE; import com.simibubi.create.foundation.tileEntity.IMergeableTE;
import com.simibubi.create.foundation.utility.BBHelper;
import com.simibubi.create.foundation.utility.BlockHelper; import com.simibubi.create.foundation.utility.BlockHelper;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
@ -96,7 +97,7 @@ public class SchematicPrinter {
BlockPos extraBounds = StructureTemplate.calculateRelativePosition(settings, new BlockPos(activeTemplate.getSize()) BlockPos extraBounds = StructureTemplate.calculateRelativePosition(settings, new BlockPos(activeTemplate.getSize())
.offset(-1, -1, -1)); .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, StructureTransform transform = new StructureTransform(settings.getRotationPivot(), Direction.Axis.Y,
settings.getRotation(), settings.getMirror()); settings.getRotation(), settings.getMirror());
@ -237,7 +238,7 @@ public class SchematicPrinter {
BlockState required = blockReader.getBlockState(relPos); BlockState required = blockReader.getBlockState(relPos);
BlockEntity requiredTE = blockReader.getBlockEntity(relPos); BlockEntity requiredTE = blockReader.getBlockEntity(relPos);
if (!world.isAreaLoaded(pos.offset(schematicAnchor), 0)) { if (!world.isLoaded(pos.offset(schematicAnchor))) {
checklist.warnBlockNotLoaded(); checklist.warnBlockNotLoaded();
continue; continue;
} }

View file

@ -10,6 +10,7 @@ import java.util.function.Predicate;
import java.util.stream.Stream; import java.util.stream.Stream;
import com.simibubi.create.Create; import com.simibubi.create.Create;
import com.simibubi.create.foundation.utility.BBHelper;
import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld; import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld;
import net.minecraft.core.BlockPos; 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) { public boolean setBlock(BlockPos pos, BlockState arg1, int arg2) {
pos = pos.immutable() pos = pos.immutable()
.subtract(anchor); .subtract(anchor);
bounds.encapsulate(BoundingBox.fromCorners(pos, pos)); bounds = BBHelper.encapsulate(bounds, pos);
blocks.put(pos, arg1); blocks.put(pos, arg1);
if (tileEntities.containsKey(pos)) { if (tileEntities.containsKey(pos)) {
BlockEntity tileEntity = tileEntities.get(pos); BlockEntity tileEntity = tileEntities.get(pos);

View file

@ -359,7 +359,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements MenuPro
} }
// Check block // Check block
if (!getLevel().isAreaLoaded(printer.getCurrentTarget(), 0)) { if (!getLevel().isLoaded(printer.getCurrentTarget())) {
positionNotLoaded = true; positionNotLoaded = true;
statusMsg = "targetNotLoaded"; statusMsg = "targetNotLoaded";
state = State.PAUSED; state = State.PAUSED;

View file

@ -189,9 +189,9 @@ public class SchematicHandler {
if (!renderers.isEmpty()) { if (!renderers.isEmpty()) {
float pt = AnimationTickHolder.getPartialTicks(); float pt = AnimationTickHolder.getPartialTicks();
boolean lr = transformation.getScaleLR() boolean lr = transformation.getScaleLR()
.get(pt) < 0; .getValue(pt) < 0;
boolean fb = transformation.getScaleFB() boolean fb = transformation.getScaleFB()
.get(pt) < 0; .getValue(pt) < 0;
if (lr && !fb) if (lr && !fb)
renderers.get(2) renderers.get(2)
.render(ms, buffer); .render(ms, buffer);

View file

@ -6,8 +6,8 @@ import com.jozufozu.flywheel.util.transform.TransformStack;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
import com.simibubi.create.foundation.utility.animation.InterpolatedChasingAngle; import com.simibubi.create.foundation.utility.animation.LerpedFloat;
import com.simibubi.create.foundation.utility.animation.InterpolatedChasingValue; import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction.Axis; import net.minecraft.core.Direction.Axis;
@ -19,49 +19,55 @@ import net.minecraft.world.phys.Vec3;
public class SchematicTransformation { public class SchematicTransformation {
private InterpolatedChasingValue x, y, z, scaleFrontBack, scaleLeftRight; private LerpedFloat x, y, z, scaleFrontBack, scaleLeftRight;
private InterpolatedChasingAngle rotation; private LerpedFloat rotation;
private double xOrigin; private double xOrigin;
private double zOrigin; private double zOrigin;
public SchematicTransformation() { public SchematicTransformation() {
x = new InterpolatedChasingValue(); x = LerpedFloat.linear();
y = new InterpolatedChasingValue(); y = LerpedFloat.linear();
z = new InterpolatedChasingValue(); z = LerpedFloat.linear();
scaleFrontBack = new InterpolatedChasingValue(); scaleFrontBack = LerpedFloat.linear();
scaleLeftRight = new InterpolatedChasingValue(); scaleLeftRight = LerpedFloat.linear();
rotation = new InterpolatedChasingAngle(); rotation = LerpedFloat.angular();
} }
public void init(BlockPos anchor, StructurePlaceSettings settings, AABB bounds) { public void init(BlockPos anchor, StructurePlaceSettings settings, AABB bounds) {
int leftRight = settings.getMirror() == Mirror.LEFT_RIGHT ? -1 : 1; int leftRight = settings.getMirror() == Mirror.LEFT_RIGHT ? -1 : 1;
int frontBack = settings.getMirror() == Mirror.FRONT_BACK ? -1 : 1; int frontBack = settings.getMirror() == Mirror.FRONT_BACK ? -1 : 1;
getScaleFB().start(frontBack); getScaleFB().chase(0, 0.45f, Chaser.EXP)
getScaleLR().start(leftRight); .startWithValue(frontBack);
getScaleLR().chase(0, 0.45f, Chaser.EXP)
.startWithValue(leftRight);
xOrigin = bounds.getXsize() / 2f; xOrigin = bounds.getXsize() / 2f;
zOrigin = bounds.getZsize() / 2f; zOrigin = bounds.getZsize() / 2f;
int r = -(settings.getRotation() int r = -(settings.getRotation()
.ordinal() * 90); .ordinal() * 90);
rotation.start(r); rotation.chase(0, 0.45f, Chaser.EXP)
.startWithValue(r);
Vec3 vec = fromAnchor(anchor); Vec3 vec = fromAnchor(anchor);
x.start((float) vec.x); x.chase(0, 0.45f, Chaser.EXP)
y.start((float) vec.y); .startWithValue((float) vec.x);
z.start((float) vec.z); 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) { public void applyGLTransformations(PoseStack ms) {
float pt = AnimationTickHolder.getPartialTicks(); float pt = AnimationTickHolder.getPartialTicks();
// Translation // 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); Vec3 rotationOffset = getRotationOffset(true);
// Rotation & Mirror // Rotation & Mirror
float fb = getScaleFB().get(pt); float fb = getScaleFB().getValue(pt);
float lr = getScaleLR().get(pt); float lr = getScaleLR().getValue(pt);
float rot = rotation.get(pt) + ((fb < 0 && lr < 0) ? 180 : 0); float rot = rotation.getValue(pt) + ((fb < 0 && lr < 0) ? 180 : 0);
ms.translate(xOrigin, 0, zOrigin); ms.translate(xOrigin, 0, zOrigin);
TransformStack.cast(ms) TransformStack.cast(ms)
.translate(rotationOffset) .translate(rotationOffset)
@ -95,11 +101,11 @@ public class SchematicTransformation {
float pt = AnimationTickHolder.getPartialTicks(); float pt = AnimationTickHolder.getPartialTicks();
Vec3 rotationOffset = getRotationOffset(true); 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 = 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.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); vec = vec.add(xOrigin, 0, zOrigin);
return vec; return vec;
@ -108,10 +114,10 @@ public class SchematicTransformation {
public StructurePlaceSettings toSettings() { public StructurePlaceSettings toSettings() {
StructurePlaceSettings settings = new StructurePlaceSettings(); StructurePlaceSettings settings = new StructurePlaceSettings();
int i = (int) rotation.getTarget(); int i = (int) rotation.getChaseTarget();
boolean mirrorlr = getScaleLR().getTarget() < 0; boolean mirrorlr = getScaleLR().getChaseTarget() < 0;
boolean mirrorfb = getScaleFB().getTarget() < 0; boolean mirrorfb = getScaleFB().getChaseTarget() < 0;
if (mirrorlr && mirrorfb) { if (mirrorlr && mirrorfb) {
mirrorlr = mirrorfb = false; mirrorlr = mirrorfb = false;
i += 180; i += 180;
@ -148,11 +154,11 @@ public class SchematicTransformation {
Vec3 rotationOffset = getRotationOffset(false); Vec3 rotationOffset = getRotationOffset(false);
vec = vec.subtract(xOrigin, 0, zOrigin); vec = vec.subtract(xOrigin, 0, zOrigin);
vec = vec.subtract(rotationOffset.x, 0, rotationOffset.z); vec = vec.subtract(rotationOffset.x, 0, rotationOffset.z);
vec = vec.multiply(getScaleFB().getTarget(), 1, getScaleLR().getTarget()); vec = vec.multiply(getScaleFB().getChaseTarget(), 1, getScaleLR().getChaseTarget());
vec = VecHelper.rotate(vec, rotation.getTarget(), Axis.Y); vec = VecHelper.rotate(vec, rotation.getChaseTarget(), Axis.Y);
vec = vec.add(xOrigin, 0, zOrigin); 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); return new BlockPos(vec.x, vec.y, vec.z);
} }
@ -161,56 +167,56 @@ public class SchematicTransformation {
Vec3 rotationOffset = getRotationOffset(false); Vec3 rotationOffset = getRotationOffset(false);
vec = vec.subtract(xOrigin, 0, zOrigin); vec = vec.subtract(xOrigin, 0, zOrigin);
vec = vec.subtract(rotationOffset.x, 0, rotationOffset.z); vec = vec.subtract(rotationOffset.x, 0, rotationOffset.z);
vec = vec.multiply(getScaleFB().getTarget(), 1, getScaleLR().getTarget()); vec = vec.multiply(getScaleFB().getChaseTarget(), 1, getScaleLR().getChaseTarget());
vec = VecHelper.rotate(vec, rotation.getTarget(), Axis.Y); vec = VecHelper.rotate(vec, rotation.getChaseTarget(), Axis.Y);
vec = vec.add(xOrigin, 0, zOrigin); vec = vec.add(xOrigin, 0, zOrigin);
return Vec3.atLowerCornerOf(pos.subtract(new BlockPos(vec.x, vec.y, vec.z))); return Vec3.atLowerCornerOf(pos.subtract(new BlockPos(vec.x, vec.y, vec.z)));
} }
public int getRotationTarget() { public int getRotationTarget() {
return (int) rotation.getTarget(); return (int) rotation.getChaseTarget();
} }
public int getMirrorModifier(Axis axis) { public int getMirrorModifier(Axis axis) {
if (axis == Axis.Z) if (axis == Axis.Z)
return (int) getScaleLR().getTarget(); return (int) getScaleLR().getChaseTarget();
return (int) getScaleFB().getTarget(); return (int) getScaleFB().getChaseTarget();
} }
public float getCurrentRotation() { public float getCurrentRotation() {
float pt = AnimationTickHolder.getPartialTicks(); float pt = AnimationTickHolder.getPartialTicks();
return rotation.get(pt); return rotation.getValue(pt);
} }
public void tick() { public void tick() {
x.tick(); x.tickChaser();
y.tick(); y.tickChaser();
z.tick(); z.tickChaser();
getScaleLR().tick(); getScaleLR().tickChaser();
getScaleFB().tick(); getScaleFB().tickChaser();
rotation.tick(); rotation.tickChaser();
} }
public void flip(Axis axis) { public void flip(Axis axis) {
if (axis == Axis.X) if (axis == Axis.X)
getScaleLR().target(getScaleLR().getTarget() * -1); getScaleLR().updateChaseTarget(getScaleLR().getChaseTarget() * -1);
if (axis == Axis.Z) if (axis == Axis.Z)
getScaleFB().target(getScaleFB().getTarget() * -1); getScaleFB().updateChaseTarget(getScaleFB().getChaseTarget() * -1);
} }
public void rotate90(boolean clockwise) { 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) { 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) { public void startAt(BlockPos pos) {
x.start(pos.getX()); x.startWithValue(pos.getX());
y.start(0); y.startWithValue(pos.getY() - 10);
z.start(pos.getZ()); z.startWithValue(pos.getZ());
moveTo(pos); moveTo(pos);
} }
@ -219,16 +225,16 @@ public class SchematicTransformation {
} }
public void moveTo(float xIn, float yIn, float zIn) { public void moveTo(float xIn, float yIn, float zIn) {
x.target(xIn); x.updateChaseTarget(xIn);
y.target(yIn); y.updateChaseTarget(yIn);
z.target(zIn); z.updateChaseTarget(zIn);
} }
public InterpolatedChasingValue getScaleFB() { public LerpedFloat getScaleFB() {
return scaleFrontBack; return scaleFrontBack;
} }
public InterpolatedChasingValue getScaleLR() { public LerpedFloat getScaleLR() {
return scaleLeftRight; return scaleLeftRight;
} }

View file

@ -96,6 +96,8 @@ public class DeployTool extends PlacementToolBase {
.putBoolean("Deployed", true); .putBoolean("Deployed", true);
item.getTag() item.getTag()
.put("Anchor", NbtUtils.writeBlockPos(target)); .put("Anchor", NbtUtils.writeBlockPos(target));
schematicHandler.getTransformation()
.startAt(target);
} }
schematicHandler.getTransformation() schematicHandler.getTransformation()

View file

@ -47,6 +47,7 @@ public class WrenchableDirectionalBlock extends DirectionalBlock implements IWre
} }
@Override @Override
@SuppressWarnings("deprecation")
public BlockState mirror(BlockState state, Mirror mirrorIn) { public BlockState mirror(BlockState state, Mirror mirrorIn) {
return state.rotate(mirrorIn.getRotation(state.getValue(FACING))); return state.rotate(mirrorIn.getRotation(state.getValue(FACING)));
} }

View file

@ -74,7 +74,7 @@ public class CClient extends ConfigBase {
Comments.ambientVolumeCap); Comments.ambientVolumeCap);
//train group //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); public final ConfigFloat mountedZoomMultiplier = f(3, 0, "mountedZoomMultiplier", Comments.mountedZoomMultiplier);
@Override @Override

View file

@ -35,24 +35,30 @@ public class ConfigHelper {
public static final Pattern annotationPattern = Pattern.compile("\\[@cui:([^:]*)(?::(.*))?]"); public static final Pattern annotationPattern = Pattern.compile("\\[@cui:([^:]*)(?::(.*))?]");
public static final Map<String, ConfigChange> changes = new HashMap<>(); public static final Map<String, ConfigChange> changes = new HashMap<>();
private static final LoadingCache<String, EnumMap<ModConfig.Type, ModConfig>> configCache = CacheBuilder.newBuilder().expireAfterAccess(5, TimeUnit.MINUTES).build( private static final LoadingCache<String, EnumMap<ModConfig.Type, ModConfig>> configCache =
new CacheLoader<String, EnumMap<ModConfig.Type, ModConfig>>() { CacheBuilder.newBuilder()
.expireAfterAccess(5, TimeUnit.MINUTES)
.build(new CacheLoader<String, EnumMap<ModConfig.Type, ModConfig>>() {
@Override @Override
public EnumMap<ModConfig.Type, ModConfig> load(@Nonnull String key) { public EnumMap<ModConfig.Type, ModConfig> load(@Nonnull String key) {
return findModConfigsUncached(key); return findModConfigsUncached(key);
} }
} });
);
private static EnumMap<ModConfig.Type, ModConfig> findModConfigsUncached(String modID) { private static EnumMap<ModConfig.Type, ModConfig> findModConfigsUncached(String modID) {
ModContainer modContainer = ModList.get().getModContainerById(modID).orElseThrow(() -> new IllegalArgumentException("Unable to find ModContainer for id: " + modID)); ModContainer modContainer = ModList.get()
EnumMap<ModConfig.Type, ModConfig> configs = ObfuscationReflectionHelper.getPrivateValue(ModContainer.class, modContainer, "configs"); .getModContainerById(modID)
.orElseThrow(() -> new IllegalArgumentException("Unable to find ModContainer for id: " + modID));
EnumMap<ModConfig.Type, ModConfig> configs =
ObfuscationReflectionHelper.getPrivateValue(ModContainer.class, modContainer, "configs");
return Objects.requireNonNull(configs); return Objects.requireNonNull(configs);
} }
public static IConfigSpec<?> findConfigSpecFor(ModConfig.Type type, String modID) { public static IConfigSpec<?> findConfigSpecFor(ModConfig.Type type, String modID) {
if (!modID.equals(Create.ID)) if (!modID.equals(Create.ID))
return configCache.getUnchecked(modID).get(type).getSpec(); return configCache.getUnchecked(modID)
.get(type)
.getSpec();
return AllConfigs.byType(type).specification; return AllConfigs.byType(type).specification;
} }
@ -67,13 +73,17 @@ public class ConfigHelper {
public static boolean hasAnyConfig(String modID) { public static boolean hasAnyConfig(String modID) {
if (!modID.equals(Create.ID)) if (!modID.equals(Create.ID))
return !configCache.getUnchecked(modID).isEmpty(); return !configCache.getUnchecked(modID)
.isEmpty();
return true; return true;
} }
public static boolean hasAnyForgeConfig(String modID) { public static boolean hasAnyForgeConfig(String modID) {
if (!modID.equals(Create.ID)) 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; return true;
} }
@ -85,7 +95,8 @@ public class ConfigHelper {
List<String> pathList = Arrays.asList(path.getPath()); List<String> pathList = Arrays.asList(path.getPath());
ForgeConfigSpec.ValueSpec valueSpec = spec.getRaw(pathList); ForgeConfigSpec.ValueSpec valueSpec = spec.getRaw(pathList);
ForgeConfigSpec.ConfigValue<T> configValue = spec.getValues().get(pathList); ForgeConfigSpec.ConfigValue<T> configValue = spec.getValues()
.get(pathList);
T v = (T) CConfigureConfigPacket.deserialize(configValue.get(), value); T v = (T) CConfigureConfigPacket.deserialize(configValue.get(), value);
if (!valueSpec.test(v)) if (!valueSpec.test(v))
throw new InvalidValueException(); throw new InvalidValueException();
@ -94,7 +105,8 @@ public class ConfigHelper {
} }
// Add a value to the current UI's changes list // Add a value to the current UI's changes list
public static <T> void setValue(String path, ForgeConfigSpec.ConfigValue<T> configValue, T value, @Nullable Map<String, String> annotations) { public static <T> void setValue(String path, ForgeConfigSpec.ConfigValue<T> configValue, T value,
@Nullable Map<String, String> annotations) {
if (value.equals(configValue.get())) { if (value.equals(configValue.get())) {
changes.remove(path); changes.remove(path);
} else { } 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> T getValue(String path, ForgeConfigSpec.ConfigValue<T> configValue) { public static <T> T getValue(String path, ForgeConfigSpec.ConfigValue<T> configValue) {
ConfigChange configChange = changes.get(path); ConfigChange configChange = changes.get(path);
if (configChange != null) if (configChange != null)
//noinspection unchecked // noinspection unchecked
return (T) configChange.value; return (T) configChange.value;
else else
return configValue.get(); return configValue.get();
@ -117,7 +130,8 @@ public class ConfigHelper {
Map<String, String> annotations = new HashMap<>(); Map<String, String> annotations = new HashMap<>();
commentLines.removeIf(line -> { commentLines.removeIf(line -> {
if (line.trim().isEmpty()) { if (line.trim()
.isEmpty()) {
return true; 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;
}
} }

View file

@ -15,6 +15,7 @@ import com.simibubi.create.foundation.utility.Pair;
import net.minecraft.nbt.TagParser; import net.minecraft.nbt.TagParser;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraft.util.GsonHelper; import net.minecraft.util.GsonHelper;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.player.Player; 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.Blocks;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Fluids; import net.minecraft.world.level.material.Fluids;
import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
@ -47,6 +49,18 @@ public class FluidHelper {
return convertToStill(fluid) == Fluids.LAVA; return convertToStill(fluid) == Fluids.LAVA;
} }
public static boolean isTag(Fluid fluid, TagKey<Fluid> pTag) {
return fluid.is(pTag);
}
public static boolean isTag(FluidState fluid, TagKey<Fluid> pTag) {
return isTag(fluid.getType(), pTag);
}
public static boolean isTag(FluidStack fluid, TagKey<Fluid> pTag) {
return isTag(fluid.getFluid(), pTag);
}
public static boolean hasBlockState(Fluid fluid) { public static boolean hasBlockState(Fluid fluid) {
BlockState blockState = fluid.defaultFluidState() BlockState blockState = fluid.defaultFluidState()
.createLegacyBlock(); .createLegacyBlock();

View file

@ -179,8 +179,6 @@ public class RemovedGuiUtils {
.getBuilder()); .getBuilder());
pStack.translate(0.0D, 0.0D, zLevel); pStack.translate(0.0D, 0.0D, zLevel);
int tooltipTop = tooltipY;
for (int lineNumber = 0; lineNumber < list.size(); ++lineNumber) { for (int lineNumber = 0; lineNumber < list.size(); ++lineNumber) {
ClientTooltipComponent line = list.get(lineNumber); ClientTooltipComponent line = list.get(lineNumber);

View file

@ -2,7 +2,6 @@ package com.simibubi.create.foundation.ponder.ui;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.foundation.gui.Theme; import com.simibubi.create.foundation.gui.Theme;
import com.simibubi.create.foundation.gui.element.BoxElement; import com.simibubi.create.foundation.gui.element.BoxElement;

View file

@ -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()));
}
}

View file

@ -6,7 +6,7 @@ import javax.annotation.Nullable;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; 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 com.simibubi.create.foundation.tileEntity.IMergeableTE;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
@ -234,10 +234,7 @@ public class BlockHelper {
state = ((IPlantable) state.getBlock()).getPlant(world, target); state = ((IPlantable) state.getBlock()).getPlant(world, target);
if (world.dimensionType() if (world.dimensionType()
.ultraWarm() .ultraWarm() && FluidHelper.isTag(state.getFluidState(), FluidTags.WATER)) {
&& state.getFluidState()
.getType()
.is(FluidTags.WATER)) {
int i = target.getX(); int i = target.getX();
int j = target.getY(); int j = target.getY();
int k = target.getZ(); int k = target.getZ();

View file

@ -10,7 +10,6 @@ import com.mojang.math.Vector3f;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
@SuppressWarnings("PointlessBitwiseExpression")
public class Color { public class Color {
public final static Color TRANSPARENT_BLACK = new Color(0, 0, 0, 0).setImmutable(); public final static Color TRANSPARENT_BLACK = new Color(0, 0, 0, 0).setImmutable();
public final static Color BLACK = new Color(0, 0, 0).setImmutable(); public final static Color BLACK = new Color(0, 0, 0).setImmutable();

View file

@ -5,7 +5,8 @@ import java.util.function.Supplier;
import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.networking.AllPackets;
import com.simibubi.create.foundation.networking.SimplePacketBase; 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.client.Minecraft;
import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.FriendlyByteBuf;
@ -19,7 +20,7 @@ public class ServerSpeedProvider {
static int clientTimer = 0; static int clientTimer = 0;
static int serverTimer = 0; static int serverTimer = 0;
static boolean initialized = false; static boolean initialized = false;
static InterpolatedChasingValue modifier = new InterpolatedChasingValue().withSpeed(.25f); static LerpedFloat modifier = LerpedFloat.linear();
public static void serverTick() { public static void serverTick() {
serverTimer++; serverTimer++;
@ -36,7 +37,7 @@ public class ServerSpeedProvider {
&& Minecraft.getInstance() && Minecraft.getInstance()
.isPaused()) .isPaused())
return; return;
modifier.tick(); modifier.tickChaser();
clientTimer++; clientTimer++;
} }
@ -45,7 +46,7 @@ public class ServerSpeedProvider {
} }
public static float get() { public static float get() {
return modifier.value; return modifier.getValue();
} }
public static class Packet extends SimplePacketBase { public static class Packet extends SimplePacketBase {
@ -67,7 +68,7 @@ public class ServerSpeedProvider {
return; return;
} }
float target = ((float) getSyncInterval()) / Math.max(clientTimer, 1); 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. // Set this to -1 because packets are processed before ticks.
// ServerSpeedProvider#clientTick will increment it to 0 at the end of this tick. // 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. // Setting it to 0 causes consistent desync, as the client ends up counting too many ticks.

View file

@ -7,6 +7,10 @@ import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class UniqueLinkedList<E> extends LinkedList<E> { public class UniqueLinkedList<E> extends LinkedList<E> {
/**
*
*/
private static final long serialVersionUID = 1L;
private final HashSet<E> contained = new HashSet<>(); private final HashSet<E> contained = new HashSet<>();
@Override @Override

View file

@ -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);
}
}

View file

@ -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());
}
}

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -5,8 +5,6 @@ import com.simibubi.create.foundation.utility.AngleHelper;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
// Can replace all Interpolated value classes
// InterpolatedChasingValue, InterpolatedValue, InterpolatedChasingAngle, InterpolatedAngle
public class LerpedFloat { public class LerpedFloat {
protected Interpolator interpolator; protected Interpolator interpolator;
@ -16,6 +14,7 @@ public class LerpedFloat {
protected Chaser chaseFunction; protected Chaser chaseFunction;
protected float chaseTarget; protected float chaseTarget;
protected float chaseSpeed; protected float chaseSpeed;
protected boolean angularChase;
protected boolean forcedSync; protected boolean forcedSync;
@ -30,7 +29,9 @@ public class LerpedFloat {
} }
public static LerpedFloat angular() { 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) { public LerpedFloat startWithValue(double value) {
@ -42,13 +43,15 @@ public class LerpedFloat {
} }
public LerpedFloat chase(double value, double speed, Chaser chaseFunction) { public LerpedFloat chase(double value, double speed, Chaser chaseFunction) {
this.chaseTarget = (float) value; updateChaseTarget((float) value);
this.chaseSpeed = (float) speed; this.chaseSpeed = (float) speed;
this.chaseFunction = chaseFunction; this.chaseFunction = chaseFunction;
return this; return this;
} }
public void updateChaseTarget(float target) { public void updateChaseTarget(float target) {
if (angularChase)
target = value + AngleHelper.getShortestAngleDiff(value, target);
this.chaseTarget = target; this.chaseTarget = target;
} }

View file

@ -18,8 +18,8 @@ import com.simibubi.create.foundation.config.CClient;
import com.simibubi.create.foundation.gui.AllGuiTextures; import com.simibubi.create.foundation.gui.AllGuiTextures;
import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
import com.simibubi.create.foundation.utility.animation.InterpolatedChasingAngle; import com.simibubi.create.foundation.utility.animation.LerpedFloat;
import com.simibubi.create.foundation.utility.animation.InterpolatedChasingValue; import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.multiplayer.ClientLevel;
@ -43,7 +43,8 @@ public class PlacementHelpers {
private static final List<IPlacementHelper> helpers = new ArrayList<>(); private static final List<IPlacementHelper> helpers = new ArrayList<>();
private static int animationTick = 0; 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 target = null;
private static BlockPos lastTarget = null; private static BlockPos lastTarget = null;
@ -92,20 +93,25 @@ public class PlacementHelpers {
if (mc.player == null) if (mc.player == null)
return; 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; return;
for (InteractionHand hand : InteractionHand.values()) { for (InteractionHand hand : InteractionHand.values()) {
ItemStack heldItem = mc.player.getItemInHand(hand); ItemStack heldItem = mc.player.getItemInHand(hand);
List<IPlacementHelper> filteredForHeldItem = helpers.stream().filter(helper -> helper.matchesItem(heldItem)).collect(Collectors.toList()); List<IPlacementHelper> filteredForHeldItem = helpers.stream()
.filter(helper -> helper.matchesItem(heldItem))
.collect(Collectors.toList());
if (filteredForHeldItem.isEmpty()) if (filteredForHeldItem.isEmpty())
continue; continue;
BlockPos pos = ray.getBlockPos(); BlockPos pos = ray.getBlockPos();
BlockState state = world.getBlockState(pos); BlockState state = world.getBlockState(pos);
List<IPlacementHelper> filteredForState = filteredForHeldItem.stream().filter(helper -> helper.matchesState(state)).collect(Collectors.toList()); List<IPlacementHelper> filteredForState = filteredForHeldItem.stream()
.filter(helper -> helper.matchesState(state))
.collect(Collectors.toList());
if (filteredForState.isEmpty()) if (filteredForState.isEmpty())
continue; 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) if (atLeastOneMatch)
return; return;
@ -165,11 +172,12 @@ public class PlacementHelpers {
} }
public static float getCurrentAlpha() { public static float getCurrentAlpha() {
return Math.min(animationTick / 10f/* + event.getPartialTicks()*/, 1f); return Math.min(animationTick / 10f/* + event.getPartialTicks() */, 1f);
} }
@OnlyIn(Dist.CLIENT) @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 r = .8f;
float g = .8f; float g = .8f;
float b = .8f; float b = .8f;
@ -178,28 +186,24 @@ public class PlacementHelpers {
Vec3 projTarget = VecHelper.projectToPlayerView(VecHelper.getCenterOf(lastTarget), partialTicks); Vec3 projTarget = VecHelper.projectToPlayerView(VecHelper.getCenterOf(lastTarget), partialTicks);
Vec3 target = new Vec3(projTarget.x, projTarget.y, 0); Vec3 target = new Vec3(projTarget.x, projTarget.y, 0);
if (projTarget.z > 0) { if (projTarget.z > 0)
target = target.reverse(); target = target.reverse();
}
Vec3 norm = target.normalize(); Vec3 norm = target.normalize();
Vec3 ref = new Vec3(0, 1, 0); Vec3 ref = new Vec3(0, 1, 0);
float targetAngle = AngleHelper.deg(Math.acos(norm.dot(ref))); float targetAngle = AngleHelper.deg(Math.acos(norm.dot(ref)));
angle.withSpeed(0.25f); if (norm.x < 0)
if (norm.x < 0) {
targetAngle = 360 - targetAngle; targetAngle = 360 - targetAngle;
}
if (animationTick < 10) if (animationTick < 10)
angle.set(targetAngle); angle.setValue(targetAngle);
angle.target(targetAngle); angle.chase(targetAngle, .25f, Chaser.EXP);
angle.tick(); angle.tickChaser();
float snapSize = 22.5f; 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; float length = 10;
@ -210,7 +214,8 @@ public class PlacementHelpers {
textured(ms, centerX, centerY, a, snappedAngle); 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.disableTexture();
RenderSystem.enableBlend(); RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc(); RenderSystem.defaultBlendFunc();
@ -218,8 +223,8 @@ public class PlacementHelpers {
ms.pushPose(); ms.pushPose();
ms.translate(centerX, centerY, 5); ms.translate(centerX, centerY, 5);
ms.mulPose(Vector3f.ZP.rotationDegrees(angle.get(0))); ms.mulPose(Vector3f.ZP.rotationDegrees(angle.getValue(0)));
//RenderSystem.rotatef(snappedAngle, 0, 0, 1); // RenderSystem.rotatef(snappedAngle, 0, 0, 1);
double scale = AllConfigs.CLIENT.indicatorScale.get(); double scale = AllConfigs.CLIENT.indicatorScale.get();
ms.scale((float) scale, (float) scale, 1); ms.scale((float) scale, (float) scale, 1);
@ -227,17 +232,34 @@ public class PlacementHelpers {
BufferBuilder bufferbuilder = tessellator.getBuilder(); BufferBuilder bufferbuilder = tessellator.getBuilder();
bufferbuilder.begin(VertexFormat.Mode.TRIANGLE_FAN, DefaultVertexFormat.POSITION_COLOR); 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, -9, -3, 0)
bufferbuilder.vertex(mat, -6, -6, 0).color(r, g, b, 0f).endVertex(); .color(r, g, b, 0f)
bufferbuilder.vertex(mat, -3, -8, 0).color(r, g, b, 0f).endVertex(); .endVertex();
bufferbuilder.vertex(mat, 0, -8.5f, 0).color(r, g, b, 0f).endVertex(); bufferbuilder.vertex(mat, -6, -6, 0)
bufferbuilder.vertex(mat, 3, -8, 0).color(r, g, b, 0f).endVertex(); .color(r, g, b, 0f)
bufferbuilder.vertex(mat, 6, -6, 0).color(r, g, b, 0f).endVertex(); .endVertex();
bufferbuilder.vertex(mat, 9, -3, 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(); tessellator.end();
RenderSystem.disableBlend(); RenderSystem.disableBlend();
@ -256,12 +278,13 @@ public class PlacementHelpers {
ms.pushPose(); ms.pushPose();
ms.translate(centerX, centerY, 50); 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(scale, scale, 1);
ms.scale(12, 12, 1); ms.scale(12, 12, 1);
float index = snappedAngle / 22.5f; float index = snappedAngle / 22.5f;
float tex_size = 16f/256f; float tex_size = 16f / 256f;
float tx = 0; float tx = 0;
float ty = index * tex_size; float ty = index * tex_size;
@ -272,11 +295,24 @@ public class PlacementHelpers {
BufferBuilder buffer = tessellator.getBuilder(); BufferBuilder buffer = tessellator.getBuilder();
buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR_TEX); buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR_TEX);
Matrix4f mat = ms.last().pose(); Matrix4f mat = ms.last()
buffer.vertex(mat, -1, -1, 0).color(1f, 1f, 1f, alpha).uv(tx, ty).endVertex(); .pose();
buffer.vertex(mat, -1, 1, 0).color(1f, 1f, 1f, alpha).uv(tx, ty + th).endVertex(); buffer.vertex(mat, -1, -1, 0)
buffer.vertex(mat, 1, 1, 0).color(1f, 1f, 1f, alpha).uv(tx + tw, ty + th).endVertex(); .color(1f, 1f, 1f, alpha)
buffer.vertex(mat, 1, -1, 0).color(1f, 1f, 1f, alpha).uv(tx + tw, ty).endVertex(); .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(); tessellator.end();

View file

@ -171,11 +171,6 @@ public class WrappedWorld extends Level {
return world.getShade(p_230487_1_, p_230487_2_); return world.getShade(p_230487_1_, p_230487_2_);
} }
@Override
public boolean hasChunkAt(BlockPos p_175667_1_) {
return world.hasChunkAt(p_175667_1_);
}
@Override @Override
public void updateNeighbourForOutputSignal(BlockPos p_175666_1_, Block p_175666_2_) {} public void updateNeighbourForOutputSignal(BlockPos p_175666_1_, Block p_175666_2_) {}