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

View file

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

View file

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

View file

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

View file

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

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.util.transform.TransformStack;
import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileInstance;
import com.simibubi.create.content.contraptions.base.flwdata.RotatingData;
import com.simibubi.create.foundation.utility.AngleHelper;

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -21,7 +21,7 @@ public class FluidReactions {
public static void handlePipeFlowCollision(Level world, BlockPos pos, FluidStack fluid, FluidStack fluid2) {
Fluid f1 = fluid.getFluid();
Fluid f2 = fluid2.getFluid();
AdvancementBehaviour.tryAward(world, pos, AllAdvancements.CROSS_STREAMS);
BlockHelper.destroyBlock(world, pos, 1);
@ -43,7 +43,7 @@ public class FluidReactions {
public static void handlePipeSpillCollision(Level world, BlockPos pos, Fluid pipeFluid, FluidState worldFluid) {
Fluid pf = FluidHelper.convertToStill(pipeFluid);
Fluid wf = worldFluid.getType();
if (pf.is(FluidTags.WATER) && wf == Fluids.LAVA)
if (FluidHelper.isTag(pf, FluidTags.WATER) && wf == Fluids.LAVA)
world.setBlockAndUpdate(pos, Blocks.OBSIDIAN.defaultBlockState());
else if (pf == Fluids.WATER && wf == Fluids.FLOWING_LAVA)
world.setBlockAndUpdate(pos, Blocks.COBBLESTONE.defaultBlockState());

View file

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

View file

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

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

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

View file

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

View file

@ -131,12 +131,12 @@ public class FluidTankBlock extends Block implements IWrenchable, ITE<FluidTankT
return CAMPFIRE_SMOKE_CLIP;
return pState.getShape(pLevel, pPos);
}
@Override
public VoxelShape getBlockSupportShape(BlockState pState, BlockGetter pReader, BlockPos pPos) {
return Shapes.block();
}
@Override
public BlockState updateShape(BlockState pState, Direction pDirection, BlockState pNeighborState,
LevelAccessor pLevel, BlockPos pCurrentPos, BlockPos pNeighborPos) {
@ -199,9 +199,10 @@ public class FluidTankBlock extends Block implements IWrenchable, ITE<FluidTankT
FluidAttributes attributes = fluid.getAttributes();
soundevent = attributes.getEmptySound();
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 (creative && !onClient)
if (fluidTank instanceof CreativeSmartFluidTank)
@ -213,7 +214,8 @@ public class FluidTankBlock extends Block implements IWrenchable, ITE<FluidTankT
soundevent = fluid.getAttributes()
.getFillSound();
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) {
@ -360,7 +362,7 @@ public class FluidTankBlock extends Block implements IWrenchable, ITE<FluidTankT
public static void updateBoilerState(BlockState pState, Level pLevel, BlockPos tankPos) {
BlockState tankState = pLevel.getBlockState(tankPos);
if (!(tankState.getBlock() instanceof FluidTankBlock tank))
if (!(tankState.getBlock()instanceof FluidTankBlock tank))
return;
FluidTankTileEntity tankTE = tank.getTileEntity(pLevel, tankPos);
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.RecipeManager;
import net.minecraft.world.item.crafting.RecipeSerializer;
import net.minecraftforge.common.crafting.conditions.ICondition.IContext;
import net.minecraftforge.registries.ForgeRegistries;
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) {
ResourceLocation parentId = parent.getId();
Recipe<?> recipe = RecipeManager.fromJson(
new ResourceLocation(parentId.getNamespace(), parentId.getPath() + "_step_" + index), json);
new ResourceLocation(parentId.getNamespace(), parentId.getPath() + "_step_" + index), json, IContext.EMPTY);
if (recipe instanceof ProcessingRecipe<?> && recipe instanceof IAssemblyRecipe) {
ProcessingRecipe<?> processingRecipe = (ProcessingRecipe<?>) recipe;
IAssemblyRecipe assemblyRecipe = (IAssemblyRecipe) recipe;

View file

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

View file

@ -7,6 +7,7 @@ import net.minecraft.core.BlockPos;
import net.minecraft.core.Vec3i;
import net.minecraft.util.Mth;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
@ -21,7 +22,7 @@ public class BeltHelper {
}
public static BeltTileEntity getSegmentTE(LevelAccessor world, BlockPos pos) {
if (!world.isAreaLoaded(pos, 0))
if (world instanceof Level l && !l.isLoaded(pos))
return null;
BlockEntity tileEntity = world.getBlockEntity(pos);
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) {
if (!world.isAreaLoaded(first, 1))
return false;
if (!world.isAreaLoaded(second, 1))
if (!world.isLoaded(first) || !world.isLoaded(second))
return false;
if (!second.closerThan(first, maxLength()))
return false;
@ -279,7 +277,7 @@ public class BeltConnectorItem extends BlockItem {
}
public static boolean validateAxis(Level world, BlockPos pos) {
if (!world.isAreaLoaded(pos, 1))
if (!world.isLoaded(pos))
return false;
if (!ShaftBlock.isShaft(world.getBlockState(pos)))
return false;

View file

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

View file

@ -9,11 +9,9 @@ import net.minecraft.world.InteractionResult;
import net.minecraft.world.item.BoneMealItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.level.block.AzaleaBlock;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.BonemealableBlock;
import net.minecraft.world.level.block.SaplingBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
@ -87,12 +85,10 @@ public class TreeFertilizerItem extends Item {
}
private static class TreesDreamWorld extends PlacementSimulationServerWorld {
private final BlockPos saplingPos;
private final BlockState soil;
protected TreesDreamWorld(ServerLevel wrapped, BlockPos saplingPos) {
super(wrapped);
this.saplingPos = saplingPos;
soil = wrapped.getBlockState(saplingPos.below());
}

View file

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

View file

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

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_ON;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

View file

@ -60,7 +60,8 @@ public class SandPaperItem extends Item implements CustomUseEffectsItem {
return new InteractionResultHolder<>(InteractionResult.PASS, itemstack);
}
InteractionHand otherHand = handIn == InteractionHand.MAIN_HAND ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND;
InteractionHand otherHand =
handIn == InteractionHand.MAIN_HAND ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND;
ItemStack itemInOtherHand = playerIn.getItemInHand(otherHand);
if (SandPaperPolishingRecipe.canPolish(worldIn, itemInOtherHand)) {
ItemStack item = itemInOtherHand.copy();
@ -137,7 +138,8 @@ public class SandPaperItem extends Item implements CustomUseEffectsItem {
if (player instanceof FakePlayer) {
player.drop(polished, false, false);
} else {
player.getInventory().placeItemBackInInventory(polished);
player.getInventory()
.placeItemBackInInventory(polished);
}
}
tag.remove("Polishing");
@ -163,7 +165,8 @@ public class SandPaperItem extends Item implements CustomUseEffectsItem {
CompoundTag tag = stack.getOrCreateTag();
if (tag.contains("Polishing")) {
ItemStack toPolish = ItemStack.of(tag.getCompound("Polishing"));
player.getInventory().placeItemBackInInventory(toPolish);
player.getInventory()
.placeItemBackInInventory(toPolish);
tag.remove("Polishing");
}
}
@ -176,14 +179,15 @@ public class SandPaperItem extends Item implements CustomUseEffectsItem {
BlockPos pos = context.getClickedPos();
BlockState state = level.getBlockState(pos);
BlockState newState = state.getToolModifiedState(level, pos, player, stack, ToolActions.AXE_SCRAPE);
BlockState newState = state.getToolModifiedState(context, ToolActions.AXE_SCRAPE, false);
if (newState != null) {
AllSoundEvents.SANDING_LONG.play(level, player, pos, 1, 1 + (level.random.nextFloat() * 0.5f - 1f) / 5f);
level.levelEvent(player, 3005, pos, 0); // Spawn particles
} else {
newState = state.getToolModifiedState(level, pos, player, stack, ToolActions.AXE_WAX_OFF);
newState = state.getToolModifiedState(context, ToolActions.AXE_WAX_OFF, false);
if (newState != null) {
AllSoundEvents.SANDING_LONG.play(level, player, pos, 1, 1 + (level.random.nextFloat() * 0.5f - 1f) / 5f);
AllSoundEvents.SANDING_LONG.play(level, player, pos, 1,
1 + (level.random.nextFloat() * 0.5f - 1f) / 5f);
level.levelEvent(player, 3004, pos, 0); // Spawn particles
}
}
@ -219,7 +223,8 @@ public class SandPaperItem extends Item implements CustomUseEffectsItem {
// After 6 ticks play the sound every 7th
if ((entity.getTicksUsingItem() - 6) % 7 == 0)
entity.playSound(entity.getEatingSound(stack), 0.9F + 0.2F * random.nextFloat(), random.nextFloat() * 0.2F + 0.9F);
entity.playSound(entity.getEatingSound(stack), 0.9F + 0.2F * random.nextFloat(),
random.nextFloat() * 0.2F + 0.9F);
return true;
}

View file

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

View file

@ -1,7 +1,5 @@
package com.simibubi.create.content.curiosities.weapons;
import static com.simibubi.create.content.curiosities.weapons.PotatoProjectileRenderMode.entityRandom;
import com.jozufozu.flywheel.util.transform.TransformStack;
import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.foundation.utility.AngleHelper;

View file

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

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

View file

@ -31,7 +31,8 @@ public class BeltTunnelRenderer extends SmartTileEntityRenderer<BeltTunnelTileEn
int light, int 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());
VertexConsumer vb = buffer.getBuffer(RenderType.solid());
@ -44,7 +45,7 @@ public class BeltTunnelRenderer extends SmartTileEntityRenderer<BeltTunnelTileEn
float horizontalAngle = AngleHelper.horizontalAngle(direction.getOpposite());
float f = te.flaps.get(direction)
.get(partialTicks);
.getValue(partialTicks);
ms.pushPose();
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.TileEntityBehaviour;
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.Direction;
@ -41,7 +42,7 @@ import net.minecraftforge.items.IItemHandler;
public class BeltTunnelTileEntity extends SmartTileEntity {
public Map<Direction, InterpolatedChasingValue> flaps;
public Map<Direction, LerpedFloat> flaps;
public Set<Direction> sides;
protected LazyOptional<IItemHandler> cap = LazyOptional.empty();
@ -93,9 +94,7 @@ public class BeltTunnelTileEntity extends SmartTileEntity {
if (!newFlaps.contains(d))
flaps.remove(d);
else if (!flaps.containsKey(d))
flaps.put(d, new InterpolatedChasingValue().start(.25f)
.target(0)
.withSpeed(.05f));
flaps.put(d, createChasingFlap());
// Backwards compat
if (!compound.contains("Sides") && compound.contains("Flaps"))
@ -105,6 +104,12 @@ public class BeltTunnelTileEntity extends SmartTileEntity {
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> InstancedRenderDispatcher.enqueueUpdate(this));
}
private LerpedFloat createChasingFlap() {
return LerpedFloat.linear()
.startWithValue(.25f)
.chase(0, .05f, Chaser.EXP);
}
public void updateTunnelConnections() {
flaps.clear();
sides.clear();
@ -133,9 +138,7 @@ public class BeltTunnelTileEntity extends SmartTileEntity {
&& nextState.getValue(BeltFunnelBlock.HORIZONTAL_FACING) == direction.getOpposite())
continue;
flaps.put(direction, new InterpolatedChasingValue().start(.25f)
.target(0)
.withSpeed(.05f));
flaps.put(direction, createChasingFlap());
}
sendData();
}
@ -144,7 +147,7 @@ public class BeltTunnelTileEntity extends SmartTileEntity {
if (level.isClientSide) {
if (flaps.containsKey(side))
flaps.get(side)
.set(inward ^ side.getAxis() == Axis.Z ? -1 : 1);
.setValue(inward ^ side.getAxis() == Axis.Z ? -1 : 1);
return;
}
@ -165,7 +168,7 @@ public class BeltTunnelTileEntity extends SmartTileEntity {
sendFlaps();
return;
}
flaps.forEach((d, value) -> value.tick());
flaps.forEach((d, value) -> value.tickChaser());
}
private void sendFlaps() {

View file

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

View file

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

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

View file

@ -18,7 +18,7 @@ public class SmartChuteRenderer extends SmartTileEntityRenderer<SmartChuteTileEn
super.renderSafe(tileEntityIn, partialTicks, ms, buffer, light, overlay);
if (tileEntityIn.item.isEmpty())
return;
if (tileEntityIn.itemPosition.get(partialTicks) > 0)
if (tileEntityIn.itemPosition.getValue(partialTicks) > 0)
return;
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.List;
import com.google.common.collect.ImmutableList;
import com.jozufozu.flywheel.util.transform.TransformStack;
import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.content.logistics.block.display.source.DisplaySource;
@ -25,8 +24,6 @@ import com.simibubi.create.foundation.gui.widget.ScrollInput;
import com.simibubi.create.foundation.gui.widget.SelectionScrollInput;
import com.simibubi.create.foundation.networking.AllPackets;
import com.simibubi.create.foundation.ponder.PonderTag;
import com.simibubi.create.foundation.ponder.ui.NavigatableSimiScreen;
import com.simibubi.create.foundation.ponder.ui.PonderButton;
import com.simibubi.create.foundation.ponder.ui.PonderTagScreen;
import com.simibubi.create.foundation.utility.Couple;
import com.simibubi.create.foundation.utility.Lang;

View file

@ -13,7 +13,6 @@ import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.LecternBlockEntity;

View file

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

View file

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

View file

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

View file

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

View file

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

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

View file

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

View file

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

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

View file

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

View file

@ -29,7 +29,7 @@ public class AnalogLeverRenderer extends SafeTileEntityRenderer<AnalogLeverTileE
if (Backend.canUseInstancing(te.getLevel())) return;
BlockState leverState = te.getBlockState();
float state = te.clientState.get(partialTicks);
float state = te.clientState.getValue(partialTicks);
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.TileEntityBehaviour;
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.nbt.CompoundTag;
@ -19,10 +20,11 @@ public class AnalogLeverTileEntity extends SmartTileEntity implements IHaveGoggl
int state = 0;
int lastChange;
InterpolatedChasingValue clientState = new InterpolatedChasingValue().withSpeed(.2f);
LerpedFloat clientState;
public AnalogLeverTileEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type, pos, state);
clientState = LerpedFloat.linear();
}
@Override
@ -36,7 +38,7 @@ public class AnalogLeverTileEntity extends SmartTileEntity implements IHaveGoggl
protected void read(CompoundTag compound, boolean clientPacket) {
state = compound.getInt("State");
lastChange = compound.getInt("ChangeTimer");
clientState.target(state);
clientState.chase(state, 0.2f, Chaser.EXP);
super.read(compound, clientPacket);
}
@ -49,7 +51,7 @@ public class AnalogLeverTileEntity extends SmartTileEntity implements IHaveGoggl
updateOutput();
}
if (level.isClientSide)
clientState.tick();
clientState.tickChaser();
}
@Override

View file

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

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -74,7 +74,7 @@ public class CClient extends ConfigBase {
Comments.ambientVolumeCap);
//train group
public final ConfigGroup trains = group(1, "trains");
public final ConfigGroup trains = group(1, "trains", Comments.trains);
public final ConfigFloat mountedZoomMultiplier = f(3, 0, "mountedZoomMultiplier", Comments.mountedZoomMultiplier);
@Override

View file

@ -35,24 +35,30 @@ public class ConfigHelper {
public static final Pattern annotationPattern = Pattern.compile("\\[@cui:([^:]*)(?::(.*))?]");
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(
new CacheLoader<String, EnumMap<ModConfig.Type, ModConfig>>() {
private static final LoadingCache<String, EnumMap<ModConfig.Type, ModConfig>> configCache =
CacheBuilder.newBuilder()
.expireAfterAccess(5, TimeUnit.MINUTES)
.build(new CacheLoader<String, EnumMap<ModConfig.Type, ModConfig>>() {
@Override
public EnumMap<ModConfig.Type, ModConfig> load(@Nonnull String key) {
return findModConfigsUncached(key);
}
}
);
});
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));
EnumMap<ModConfig.Type, ModConfig> configs = ObfuscationReflectionHelper.getPrivateValue(ModContainer.class, modContainer, "configs");
ModContainer modContainer = ModList.get()
.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);
}
public static IConfigSpec<?> findConfigSpecFor(ModConfig.Type type, String modID) {
if (!modID.equals(Create.ID))
return configCache.getUnchecked(modID).get(type).getSpec();
return configCache.getUnchecked(modID)
.get(type)
.getSpec();
return AllConfigs.byType(type).specification;
}
@ -67,13 +73,17 @@ public class ConfigHelper {
public static boolean hasAnyConfig(String modID) {
if (!modID.equals(Create.ID))
return !configCache.getUnchecked(modID).isEmpty();
return !configCache.getUnchecked(modID)
.isEmpty();
return true;
}
public static boolean hasAnyForgeConfig(String modID) {
if (!modID.equals(Create.ID))
return configCache.getUnchecked(modID).values().stream().anyMatch(config -> config.getSpec() instanceof ForgeConfigSpec);
return configCache.getUnchecked(modID)
.values()
.stream()
.anyMatch(config -> config.getSpec() instanceof ForgeConfigSpec);
return true;
}
@ -85,7 +95,8 @@ public class ConfigHelper {
List<String> pathList = Arrays.asList(path.getPath());
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);
if (!valueSpec.test(v))
throw new InvalidValueException();
@ -94,7 +105,8 @@ public class ConfigHelper {
}
// Add a value to the current UI's changes list
public static <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())) {
changes.remove(path);
} else {
@ -102,11 +114,12 @@ public class ConfigHelper {
}
}
// Get a value from the current UI's changes list or the config value, if its unchanged
// Get a value from the current UI's changes list or the config value, if its
// unchanged
public static <T> T getValue(String path, ForgeConfigSpec.ConfigValue<T> configValue) {
ConfigChange configChange = changes.get(path);
if (configChange != null)
//noinspection unchecked
// noinspection unchecked
return (T) configChange.value;
else
return configValue.get();
@ -117,7 +130,8 @@ public class ConfigHelper {
Map<String, String> annotations = new HashMap<>();
commentLines.removeIf(line -> {
if (line.trim().isEmpty()) {
if (line.trim()
.isEmpty()) {
return true;
}
@ -212,5 +226,7 @@ public class ConfigHelper {
}
}
public static class InvalidValueException extends Exception {}
public static class InvalidValueException extends Exception {
private static final long serialVersionUID = 1L;
}
}

View file

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

View file

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

View file

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

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

View file

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

View file

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

View file

@ -7,6 +7,10 @@ import java.util.List;
import java.util.stream.Collectors;
public class UniqueLinkedList<E> extends LinkedList<E> {
/**
*
*/
private static final long serialVersionUID = 1L;
private final HashSet<E> contained = new HashSet<>();
@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.util.Mth;
// Can replace all Interpolated value classes
// InterpolatedChasingValue, InterpolatedValue, InterpolatedChasingAngle, InterpolatedAngle
public class LerpedFloat {
protected Interpolator interpolator;
@ -16,6 +14,7 @@ public class LerpedFloat {
protected Chaser chaseFunction;
protected float chaseTarget;
protected float chaseSpeed;
protected boolean angularChase;
protected boolean forcedSync;
@ -30,7 +29,9 @@ public class LerpedFloat {
}
public static LerpedFloat angular() {
return new LerpedFloat(AngleHelper::angleLerp);
LerpedFloat lerpedFloat = new LerpedFloat(AngleHelper::angleLerp);
lerpedFloat.angularChase = true;
return lerpedFloat;
}
public LerpedFloat startWithValue(double value) {
@ -42,13 +43,15 @@ public class LerpedFloat {
}
public LerpedFloat chase(double value, double speed, Chaser chaseFunction) {
this.chaseTarget = (float) value;
updateChaseTarget((float) value);
this.chaseSpeed = (float) speed;
this.chaseFunction = chaseFunction;
return this;
}
public void updateChaseTarget(float target) {
if (angularChase)
target = value + AngleHelper.getShortestAngleDiff(value, target);
this.chaseTarget = target;
}
@ -72,7 +75,7 @@ public class LerpedFloat {
public void setValueNoUpdate(double value) {
this.value = (float) value;
}
public void setValue(double value) {
this.previousValue = this.value;
this.value = (float) value;

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.utility.AngleHelper;
import com.simibubi.create.foundation.utility.VecHelper;
import com.simibubi.create.foundation.utility.animation.InterpolatedChasingAngle;
import com.simibubi.create.foundation.utility.animation.InterpolatedChasingValue;
import com.simibubi.create.foundation.utility.animation.LerpedFloat;
import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientLevel;
@ -43,7 +43,8 @@ public class PlacementHelpers {
private static final List<IPlacementHelper> helpers = new ArrayList<>();
private static int animationTick = 0;
private static final InterpolatedChasingValue angle = new InterpolatedChasingAngle().withSpeed(0.25f);
private static final LerpedFloat angle = LerpedFloat.angular()
.chase(0, 0.25f, Chaser.EXP);
private static BlockPos target = null;
private static BlockPos lastTarget = null;
@ -92,20 +93,25 @@ public class PlacementHelpers {
if (mc.player == null)
return;
if (mc.player.isShiftKeyDown())//for now, disable all helpers when sneaking TODO add helpers that respect sneaking but still show position
if (mc.player.isShiftKeyDown())// for now, disable all helpers when sneaking TODO add helpers that respect
// sneaking but still show position
return;
for (InteractionHand hand : InteractionHand.values()) {
ItemStack heldItem = mc.player.getItemInHand(hand);
List<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())
continue;
BlockPos pos = ray.getBlockPos();
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())
continue;
@ -122,7 +128,8 @@ public class PlacementHelpers {
}
//at least one helper activated, no need to check the offhand if we are still in the mainhand
// at least one helper activated, no need to check the offhand if we are still
// in the mainhand
if (atLeastOneMatch)
return;
@ -165,11 +172,12 @@ public class PlacementHelpers {
}
public static float getCurrentAlpha() {
return Math.min(animationTick / 10f/* + event.getPartialTicks()*/, 1f);
return Math.min(animationTick / 10f/* + event.getPartialTicks() */, 1f);
}
@OnlyIn(Dist.CLIENT)
private static void drawDirectionIndicator(PoseStack ms, float partialTicks, float centerX, float centerY, float progress) {
private static void drawDirectionIndicator(PoseStack ms, float partialTicks, float centerX, float centerY,
float progress) {
float r = .8f;
float g = .8f;
float b = .8f;
@ -178,28 +186,24 @@ public class PlacementHelpers {
Vec3 projTarget = VecHelper.projectToPlayerView(VecHelper.getCenterOf(lastTarget), partialTicks);
Vec3 target = new Vec3(projTarget.x, projTarget.y, 0);
if (projTarget.z > 0) {
if (projTarget.z > 0)
target = target.reverse();
}
Vec3 norm = target.normalize();
Vec3 ref = new Vec3(0, 1, 0);
float targetAngle = AngleHelper.deg(Math.acos(norm.dot(ref)));
angle.withSpeed(0.25f);
if (norm.x < 0) {
if (norm.x < 0)
targetAngle = 360 - targetAngle;
}
if (animationTick < 10)
angle.set(targetAngle);
angle.setValue(targetAngle);
angle.target(targetAngle);
angle.tick();
angle.chase(targetAngle, .25f, Chaser.EXP);
angle.tickChaser();
float snapSize = 22.5f;
float snappedAngle = (snapSize * Math.round(angle.get(0f) / snapSize)) % 360f;
float snappedAngle = (snapSize * Math.round(angle.getValue(0f) / snapSize)) % 360f;
float length = 10;
@ -210,7 +214,8 @@ public class PlacementHelpers {
textured(ms, centerX, centerY, a, snappedAngle);
}
private static void fadedArrow(PoseStack ms, float centerX, float centerY, float r, float g, float b, float a, float length, float snappedAngle) {
private static void fadedArrow(PoseStack ms, float centerX, float centerY, float r, float g, float b, float a,
float length, float snappedAngle) {
RenderSystem.disableTexture();
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
@ -218,8 +223,8 @@ public class PlacementHelpers {
ms.pushPose();
ms.translate(centerX, centerY, 5);
ms.mulPose(Vector3f.ZP.rotationDegrees(angle.get(0)));
//RenderSystem.rotatef(snappedAngle, 0, 0, 1);
ms.mulPose(Vector3f.ZP.rotationDegrees(angle.getValue(0)));
// RenderSystem.rotatef(snappedAngle, 0, 0, 1);
double scale = AllConfigs.CLIENT.indicatorScale.get();
ms.scale((float) scale, (float) scale, 1);
@ -227,17 +232,34 @@ public class PlacementHelpers {
BufferBuilder bufferbuilder = tessellator.getBuilder();
bufferbuilder.begin(VertexFormat.Mode.TRIANGLE_FAN, DefaultVertexFormat.POSITION_COLOR);
Matrix4f mat = ms.last().pose();
Matrix4f mat = ms.last()
.pose();
bufferbuilder.vertex(mat, 0, -(10 + length), 0).color(r, g, b, a).endVertex();
bufferbuilder.vertex(mat, 0, -(10 + length), 0)
.color(r, g, b, a)
.endVertex();
bufferbuilder.vertex(mat, -9, -3, 0).color(r, g, b, 0f).endVertex();
bufferbuilder.vertex(mat, -6, -6, 0).color(r, g, b, 0f).endVertex();
bufferbuilder.vertex(mat, -3, -8, 0).color(r, g, b, 0f).endVertex();
bufferbuilder.vertex(mat, 0, -8.5f, 0).color(r, g, b, 0f).endVertex();
bufferbuilder.vertex(mat, 3, -8, 0).color(r, g, b, 0f).endVertex();
bufferbuilder.vertex(mat, 6, -6, 0).color(r, g, b, 0f).endVertex();
bufferbuilder.vertex(mat, 9, -3, 0).color(r, g, b, 0f).endVertex();
bufferbuilder.vertex(mat, -9, -3, 0)
.color(r, g, b, 0f)
.endVertex();
bufferbuilder.vertex(mat, -6, -6, 0)
.color(r, g, b, 0f)
.endVertex();
bufferbuilder.vertex(mat, -3, -8, 0)
.color(r, g, b, 0f)
.endVertex();
bufferbuilder.vertex(mat, 0, -8.5f, 0)
.color(r, g, b, 0f)
.endVertex();
bufferbuilder.vertex(mat, 3, -8, 0)
.color(r, g, b, 0f)
.endVertex();
bufferbuilder.vertex(mat, 6, -6, 0)
.color(r, g, b, 0f)
.endVertex();
bufferbuilder.vertex(mat, 9, -3, 0)
.color(r, g, b, 0f)
.endVertex();
tessellator.end();
RenderSystem.disableBlend();
@ -256,12 +278,13 @@ public class PlacementHelpers {
ms.pushPose();
ms.translate(centerX, centerY, 50);
float scale = AllConfigs.CLIENT.indicatorScale.get().floatValue() * .75f;
float scale = AllConfigs.CLIENT.indicatorScale.get()
.floatValue() * .75f;
ms.scale(scale, scale, 1);
ms.scale(12, 12, 1);
float index = snappedAngle / 22.5f;
float tex_size = 16f/256f;
float tex_size = 16f / 256f;
float tx = 0;
float ty = index * tex_size;
@ -272,11 +295,24 @@ public class PlacementHelpers {
BufferBuilder buffer = tessellator.getBuilder();
buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR_TEX);
Matrix4f mat = ms.last().pose();
buffer.vertex(mat, -1, -1, 0).color(1f, 1f, 1f, alpha).uv(tx, ty).endVertex();
buffer.vertex(mat, -1, 1, 0).color(1f, 1f, 1f, alpha).uv(tx, ty + th).endVertex();
buffer.vertex(mat, 1, 1, 0).color(1f, 1f, 1f, alpha).uv(tx + tw, ty + th).endVertex();
buffer.vertex(mat, 1, -1, 0).color(1f, 1f, 1f, alpha).uv(tx + tw, ty).endVertex();
Matrix4f mat = ms.last()
.pose();
buffer.vertex(mat, -1, -1, 0)
.color(1f, 1f, 1f, alpha)
.uv(tx, ty)
.endVertex();
buffer.vertex(mat, -1, 1, 0)
.color(1f, 1f, 1f, alpha)
.uv(tx, ty + th)
.endVertex();
buffer.vertex(mat, 1, 1, 0)
.color(1f, 1f, 1f, alpha)
.uv(tx + tw, ty + th)
.endVertex();
buffer.vertex(mat, 1, -1, 0)
.color(1f, 1f, 1f, alpha)
.uv(tx + tw, ty)
.endVertex();
tessellator.end();

View file

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