Found and Replaced

- Progress on compilation errors
This commit is contained in:
simibubi 2023-06-28 01:04:43 +02:00
parent 133756f571
commit 55562e5d16
301 changed files with 1092 additions and 1156 deletions

File diff suppressed because it is too large Load diff

View file

@ -7,6 +7,7 @@ import java.util.Set;
import java.util.function.Function;
import java.util.function.Predicate;
import com.simibubi.create.AllCreativeModeTabs.RegistrateDisplayItemsGenerator.ItemOrdering.Type;
import com.simibubi.create.content.contraptions.actors.seat.SeatBlock;
import com.simibubi.create.content.decoration.palettes.AllPaletteBlocks;
import com.simibubi.create.content.equipment.armor.BacktankUtil;

View file

@ -332,7 +332,7 @@ public class AllSoundEvents {
}
public static void playItemPickup(Player player) {
player.level.playSound(null, player.blockPosition(), SoundEvents.ITEM_PICKUP, SoundSource.PLAYERS, .2f,
player.level().playSound(null, player.blockPosition(), SoundEvents.ITEM_PICKUP, SoundSource.PLAYERS, .2f,
1f + Create.RANDOM.nextFloat());
}
@ -509,7 +509,7 @@ public class AllSoundEvents {
public void playFrom(Entity entity, float volume, float pitch) {
if (!entity.isSilent())
play(entity.level, null, entity.blockPosition(), volume, pitch);
play(entity.level(), null, entity.blockPosition(), volume, pitch);
}
public void play(Level world, Player entity, Vec3i pos, float volume, float pitch) {

View file

@ -23,11 +23,10 @@ import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraftforge.common.capabilities.ForgeCapabilities;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidTank;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.fluids.capability.IFluidHandler;
import net.minecraftforge.items.CapabilityItemHandler;
public class ConnectivityHandler {
@ -361,10 +360,10 @@ public class ConnectivityHandler {
}
if (be instanceof IMultiBlockEntityContainer.Inventory inv && inv.hasInventory())
be.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
be.getCapability(ForgeCapabilities.ITEM_HANDLER)
.invalidate();
if (be instanceof IMultiBlockEntityContainer.Fluid fluid && fluid.hasTank())
be.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY)
be.getCapability(ForgeCapabilities.FLUID_HANDLER)
.invalidate();
if (tryReconnect)

View file

@ -14,12 +14,12 @@ import net.minecraft.client.model.geom.builders.CubeDeformation;
import net.minecraft.client.model.geom.builders.CubeListBuilder;
import net.minecraft.client.model.geom.builders.MeshDefinition;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.block.model.ItemTransforms;
import net.minecraft.client.renderer.entity.RenderLayerParent;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ItemDisplayContext;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@ -60,7 +60,7 @@ public class GogglesCurioRenderer implements ICurioRenderer {
}
// Render
Minecraft.getInstance().getItemRenderer().renderStatic(stack, ItemTransforms.TransformType.HEAD, light, OverlayTexture.NO_OVERLAY, matrixStack, renderTypeBuffer, 0);
Minecraft.getInstance().getItemRenderer().renderStatic(stack, ItemDisplayContext.HEAD, light, OverlayTexture.NO_OVERLAY, matrixStack, renderTypeBuffer, 0);
matrixStack.popPose();
}

View file

@ -4,7 +4,7 @@ import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.foundation.gui.AllGuiTextures;
import mezz.jei.api.gui.drawable.IDrawable;
import net.minecraft.client.gui.GuiComponent;
import net.minecraft.client.gui.GuiGraphics;
public class ScreenResourceWrapper implements IDrawable {
@ -27,7 +27,7 @@ public class ScreenResourceWrapper implements IDrawable {
@Override
public void draw(PoseStack matrixStack, int xOffset, int yOffset) {
resource.bind();
GuiComponent.blit(matrixStack, xOffset, yOffset, 0, resource.startX, resource.startY, resource.width,
GuiGraphics.blit(matrixStack, xOffset, yOffset, 0, resource.startX, resource.startY, resource.width,
resource.height, 256, 256);
}

View file

@ -25,9 +25,9 @@ import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.PotionItem;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraftforge.common.capabilities.ForgeCapabilities;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction;
import net.minecraftforge.fluids.capability.IFluidHandlerItem;
@ -54,12 +54,12 @@ public class ItemDrainCategory extends CreateRecipeCategory<EmptyingRecipe> {
}
LazyOptional<IFluidHandlerItem> capability =
stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY);
stack.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM);
if (!capability.isPresent())
continue;
ItemStack copy = stack.copy();
capability = copy.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY);
capability = copy.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM);
IFluidHandlerItem handler = capability.orElse(null);
FluidStack extracted = handler.drain(1000, FluidAction.EXECUTE);
ItemStack result = handler.getContainer();

View file

@ -28,9 +28,9 @@ import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.PotionItem;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraftforge.common.capabilities.ForgeCapabilities;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction;
import net.minecraftforge.fluids.capability.IFluidHandlerItem;
@ -58,13 +58,13 @@ public class SpoutCategory extends CreateRecipeCategory<FillingRecipe> {
}
LazyOptional<IFluidHandlerItem> capability =
stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY);
stack.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM);
if (!capability.isPresent())
continue;
for (FluidStack fluidStack : fluidStacks) {
ItemStack copy = stack.copy();
copy.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY)
copy.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM)
.ifPresent(fhi -> {
if (!GenericItemFilling.isFluidHandlerValid(copy, fhi))
return;

View file

@ -12,8 +12,8 @@ import net.minecraft.core.Direction;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraftforge.common.capabilities.ForgeCapabilities;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.fluids.capability.IFluidHandler;
import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction;
@ -34,7 +34,7 @@ public class SpoutCasting extends BlockSpoutingBehaviour {
if (blockEntity == null)
return 0;
IFluidHandler handler = blockEntity.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, Direction.UP)
IFluidHandler handler = blockEntity.getCapability(ForgeCapabilities.FLUID_HANDLER, Direction.UP)
.orElse(null);
if (handler == null)
return 0;

View file

@ -112,7 +112,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
this.contraption = contraption;
if (contraption == null)
return;
if (level.isClientSide)
if (level().isClientSide)
return;
contraption.onEntityCreated(this);
}
@ -133,7 +133,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
}
protected void contraptionInitialize() {
contraption.onEntityInitialize(level, this);
contraption.onEntityInitialize(level(), this);
initialized = true;
}
@ -160,7 +160,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
passenger.startRiding(this, true);
if (passenger instanceof TamableAnimal ta)
ta.setInSittingPose(true);
if (level.isClientSide)
if (level().isClientSide)
return;
contraption.getSeatMapping()
.put(passenger.getUUID(), seatIndex);
@ -174,7 +174,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
super.removePassenger(passenger);
if (passenger instanceof TamableAnimal ta)
ta.setInSittingPose(false);
if (level.isClientSide)
if (level().isClientSide)
return;
if (transformedVector != null)
passenger.getPersistentData()
@ -269,7 +269,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
}
public void stopControlling(BlockPos controlsLocalPos) {
getControllingPlayer().map(level::getPlayerByUUID)
getControllingPlayer().map(level()::getPlayerByUUID)
.map(p -> (p instanceof ServerPlayer) ? ((ServerPlayer) p) : null)
.ifPresent(p -> AllPackets.getChannel().send(PacketDistributor.PLAYER.with(() -> p),
new ControlsStopControllingPacket()));
@ -305,16 +305,16 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
}
}
if (toDismount != null && !level.isClientSide) {
if (toDismount != null && !level().isClientSide) {
Vec3 transformedVector = getPassengerPosition(toDismount, 1);
toDismount.stopRiding();
if (transformedVector != null)
toDismount.teleportTo(transformedVector.x, transformedVector.y, transformedVector.z);
}
if (level.isClientSide)
if (level().isClientSide)
return true;
addSittingPassenger(SeatBlock.getLeashed(level, player)
addSittingPassenger(SeatBlock.getLeashed(level(), player)
.or(player), indexOfSeat);
return true;
}
@ -370,7 +370,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
tickContraption();
super.tick();
if (level.isClientSide())
if (level().isClientSide())
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> {
if (!contraption.deferInvalidate)
return;
@ -378,7 +378,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
ContraptionRenderDispatcher.invalidate(contraption);
});
if (!(level instanceof ServerLevelAccessor sl))
if (!(level() instanceof ServerLevelAccessor sl))
return;
for (Entity entity : getPassengers()) {
@ -404,7 +404,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
float prevAngle = living.getYRot();
float angle = AngleHelper.deg(-Mth.atan2(motion.x, motion.z));
angle = AngleHelper.angleLerp(0.4f, prevAngle, angle);
if (level.isClientSide) {
if (level().isClientSide) {
living.lerpTo(0, 0, 0, 0, 0, 0, false);
living.lerpHeadTo(0, 0);
living.setYRot(angle);
@ -418,7 +418,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
public void setBlock(BlockPos localPos, StructureBlockInfo newInfo) {
contraption.blocks.put(localPos, newInfo);
AllPackets.getChannel().send(PacketDistributor.TRACKING_ENTITY.with(() -> this),
new ContraptionBlockChangedPacket(getId(), localPos, newInfo.state));
new ContraptionBlockChangedPacket(getId(), localPos, newInfo.state()));
}
protected abstract void tickContraption();
@ -430,22 +430,22 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
public void tickActors() {
boolean stalledPreviously = contraption.stalled;
if (!level.isClientSide)
if (!level().isClientSide)
contraption.stalled = false;
skipActorStop = true;
for (MutablePair<StructureBlockInfo, MovementContext> pair : contraption.getActors()) {
MovementContext context = pair.right;
StructureBlockInfo blockInfo = pair.left;
MovementBehaviour actor = AllMovementBehaviours.getBehaviour(blockInfo.state);
MovementBehaviour actor = AllMovementBehaviours.getBehaviour(blockInfo.state());
if (actor == null)
continue;
Vec3 oldMotion = context.motion;
Vec3 actorPosition = toGlobalVector(VecHelper.getCenterOf(blockInfo.pos)
Vec3 actorPosition = toGlobalVector(VecHelper.getCenterOf(blockInfo.pos())
.add(actor.getActiveAreaOffset(context)), 1);
BlockPos gridPosition = new BlockPos(actorPosition);
BlockPos gridPosition = BlockPos.containing(actorPosition);
boolean newPosVisited =
!context.stall && shouldActorTrigger(context, blockInfo, actor, actorPosition, gridPosition);
@ -470,7 +470,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
contraption.stalled |= context.stall;
}
if (!isAlive()) {
contraption.stop(level);
contraption.stop(level());
return;
}
skipActorStop = false;
@ -487,7 +487,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
}
}
if (!level.isClientSide) {
if (!level().isClientSide) {
if (!stalledPreviously && contraption.stalled)
onContraptionStalled();
entityData.set(STALLED, contraption.stalled);
@ -501,10 +501,10 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
for (MutablePair<StructureBlockInfo, MovementContext> pair : contraption.getActors()) {
MovementContext context = pair.right;
StructureBlockInfo blockInfo = pair.left;
MovementBehaviour actor = AllMovementBehaviours.getBehaviour(blockInfo.state);
MovementBehaviour actor = AllMovementBehaviours.getBehaviour(blockInfo.state());
if (actor instanceof PortableStorageInterfaceMovement && isActorActive(context, actor))
if (context.position != null)
actor.visitNewPosition(context, new BlockPos(context.position));
actor.visitNewPosition(context, BlockPos.containing(context.position));
}
}
@ -525,7 +525,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
context.motion = actorPosition.subtract(previousPosition);
if (!level.isClientSide() && context.contraption.entity instanceof CarriageContraptionEntity cce
if (!level().isClientSide() && context.contraption.entity instanceof CarriageContraptionEntity cce
&& cce.getCarriage() != null) {
Train train = cce.getCarriage().train;
double actualSpeed = train.speedBeforeStall != null ? train.speedBeforeStall : train.speed;
@ -537,7 +537,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
relativeMotion = reverseRotation(relativeMotion, 1);
context.relativeMotion = relativeMotion;
return !new BlockPos(previousPosition).equals(gridPosition)
return !BlockPos.containing(previousPosition).equals(gridPosition)
|| (context.relativeMotion.length() > 0 || context.contraption instanceof CarriageContraption)
&& context.firstMovement;
}
@ -640,7 +640,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
return;
initialized = compound.getBoolean("Initialized");
contraption = Contraption.fromNBT(level, compound.getCompound("Contraption"), spawnData);
contraption = Contraption.fromNBT(level(), compound.getCompound("Contraption"), spawnData);
contraption.entity = this;
entityData.set(STALLED, compound.getBoolean("Stalled"));
}
@ -653,12 +653,12 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
StructureTransform transform = makeStructureTransform();
contraption.stop(level);
contraption.stop(level());
AllPackets.getChannel().send(PacketDistributor.TRACKING_ENTITY.with(() -> this),
new ContraptionDisassemblyPacket(this.getId(), transform));
contraption.addBlocksToWorld(level, transform);
contraption.addPassengersToWorld(level, transform, getPassengers());
contraption.addBlocksToWorld(level(), transform);
contraption.addPassengersToWorld(level(), transform, getPassengers());
for (Entity entity : getPassengers()) {
if (!(entity instanceof OrientedContraptionEntity))
@ -677,14 +677,14 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
ejectPassengers();
moveCollidedEntitiesOnDisassembly(transform);
AllSoundEvents.CONTRAPTION_DISASSEMBLE.playOnServer(level, blockPosition());
AllSoundEvents.CONTRAPTION_DISASSEMBLE.playOnServer(level(), blockPosition());
}
private void moveCollidedEntitiesOnDisassembly(StructureTransform transform) {
for (Entity entity : collidingEntities.keySet()) {
Vec3 localVec = toLocalVector(entity.position(), 0);
Vec3 transformed = transform.apply(localVec);
if (level.isClientSide)
if (level().isClientSide)
entity.setPos(transformed.x, transformed.y + 1 / 16f, transformed.z);
else
entity.teleportTo(transformed.x, transformed.y + 1 / 16f, transformed.z);
@ -693,8 +693,8 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
@Override
public void remove(RemovalReason p_146834_) {
if (!level.isClientSide && !isRemoved() && contraption != null && !skipActorStop)
contraption.stop(level);
if (!level().isClientSide && !isRemoved() && contraption != null && !skipActorStop)
contraption.stop(level());
if (contraption != null)
contraption.onEntityRemoved(this);
super.remove(p_146834_);
@ -757,8 +757,8 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
if (contraption == null || !contraption.blocks.containsKey(localPos))
return;
StructureBlockInfo info = contraption.blocks.get(localPos);
contraption.blocks.put(localPos, new StructureBlockInfo(info.pos, newState, info.nbt));
if (info.state != newState && !(newState.getBlock() instanceof SlidingDoorBlock))
contraption.blocks.put(localPos, new StructureBlockInfo(info.pos(), newState, info.nbt()));
if (info.state() != newState && !(newState.getBlock() instanceof SlidingDoorBlock))
contraption.deferInvalidate = true;
contraption.invalidateColliders();
}
@ -918,7 +918,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
}
public boolean isAliveOrStale() {
return isAlive() || level.isClientSide() ? staleTicks > 0 : false;
return isAlive() || level().isClientSide() ? staleTicks > 0 : false;
}
}

View file

@ -177,8 +177,7 @@ public class BlockMovementChecks {
if (state.getCollisionShape(world, pos)
.isEmpty())
return false;
if (state.getMaterial()
.isReplaceable())
if (state.canBeReplaced())
return false;
return true;
}

View file

@ -189,7 +189,7 @@ public abstract class Contraption {
public ContraptionWorld getContraptionWorld() {
if (world == null)
world = new ContraptionWorld(entity.level, this);
world = new ContraptionWorld(entity.level(), this);
return world;
}
@ -251,7 +251,7 @@ public abstract class Contraption {
for (BlockFace blockFace : pendingSubContraptions) {
Direction face = blockFace.getFace();
StabilizedContraption subContraption = new StabilizedContraption(face);
Level world = entity.level;
Level world = entity.level();
BlockPos pos = blockFace.getPos();
try {
if (!subContraption.assemble(world, pos))
@ -635,7 +635,7 @@ public abstract class Contraption {
protected void addBlock(BlockPos pos, Pair<StructureBlockInfo, BlockEntity> pair) {
StructureBlockInfo captured = pair.getKey();
BlockPos localPos = pos.subtract(anchor);
StructureBlockInfo structureBlockInfo = new StructureBlockInfo(localPos, captured.state, captured.nbt);
StructureBlockInfo structureBlockInfo = new StructureBlockInfo(localPos, captured.state(), captured.nbt());
if (blocks.put(localPos, structureBlockInfo) != null)
return;
@ -644,10 +644,10 @@ public abstract class Contraption {
BlockEntity be = pair.getValue();
storage.addBlock(localPos, be);
if (AllMovementBehaviours.getBehaviour(captured.state) != null)
if (AllMovementBehaviours.getBehaviour(captured.state()) != null)
actors.add(MutablePair.of(structureBlockInfo, null));
MovingInteractionBehaviour interactionBehaviour = AllInteractionBehaviours.getBehaviour(captured.state);
MovingInteractionBehaviour interactionBehaviour = AllInteractionBehaviours.getBehaviour(captured.state());
if (interactionBehaviour != null)
interactors.put(localPos, interactionBehaviour);
@ -735,7 +735,7 @@ public abstract class Contraption {
StructureBlockInfo structureBlockInfo = getBlocks().get(pos);
if (structureBlockInfo == null)
return;
MovingInteractionBehaviour behaviour = AllInteractionBehaviours.getBehaviour(structureBlockInfo.state);
MovingInteractionBehaviour behaviour = AllInteractionBehaviours.getBehaviour(structureBlockInfo.state());
if (behaviour != null)
interactors.put(pos, behaviour);
});
@ -758,11 +758,11 @@ public abstract class Contraption {
ListTag actorsNBT = new ListTag();
for (MutablePair<StructureBlockInfo, MovementContext> actor : getActors()) {
MovementBehaviour behaviour = AllMovementBehaviours.getBehaviour(actor.left.state);
MovementBehaviour behaviour = AllMovementBehaviours.getBehaviour(actor.left.state());
if (behaviour == null)
continue;
CompoundTag compound = new CompoundTag();
compound.put("Pos", NbtUtils.writeBlockPos(actor.left.pos));
compound.put("Pos", NbtUtils.writeBlockPos(actor.left.pos()));
behaviour.writeExtraData(actor.right);
actor.right.writeToNBT(compound);
actorsNBT.add(compound);
@ -833,12 +833,12 @@ public abstract class Contraption {
ListTag blockList = new ListTag();
for (StructureBlockInfo block : this.blocks.values()) {
int id = palette.idFor(block.state);
int id = palette.idFor(block.state());
CompoundTag c = new CompoundTag();
c.putLong("Pos", block.pos.asLong());
c.putLong("Pos", block.pos().asLong());
c.putInt("State", id);
if (block.nbt != null)
c.put("Data", block.nbt);
if (block.nbt() != null)
c.put("Data", block.nbt());
blockList.add(c);
}
@ -879,36 +879,36 @@ public abstract class Contraption {
StructureBlockInfo info =
usePalettedDeserialization ? readStructureBlockInfo(c, finalPalette) : legacyReadStructureBlockInfo(c, holderGetter);
this.blocks.put(info.pos, info);
this.blocks.put(info.pos(), info);
if (!world.isClientSide)
return;
CompoundTag tag = info.nbt;
CompoundTag tag = info.nbt();
if (tag == null)
return;
tag.putInt("x", info.pos.getX());
tag.putInt("y", info.pos.getY());
tag.putInt("z", info.pos.getZ());
tag.putInt("x", info.pos().getX());
tag.putInt("y", info.pos().getY());
tag.putInt("z", info.pos().getZ());
BlockEntity be = BlockEntity.loadStatic(info.pos, info.state, tag);
BlockEntity be = BlockEntity.loadStatic(info.pos(), info.state(), tag);
if (be == null)
return;
be.setLevel(world);
modelData.put(info.pos, be.getModelData());
modelData.put(info.pos(), be.getModelData());
if (be instanceof KineticBlockEntity kbe)
kbe.setSpeed(0);
be.getBlockState();
MovementBehaviour movementBehaviour = AllMovementBehaviours.getBehaviour(info.state);
MovementBehaviour movementBehaviour = AllMovementBehaviours.getBehaviour(info.state());
if (movementBehaviour == null || !movementBehaviour.hasSpecialInstancedRendering())
maybeInstancedBlockEntities.add(be);
if (movementBehaviour != null && !movementBehaviour.renderAsNormalBlockEntity())
return;
presentBlockEntities.put(info.pos, be);
presentBlockEntities.put(info.pos(), be);
specialRenderedBlockEntities.add(be);
});
}
@ -944,28 +944,28 @@ public abstract class Contraption {
for (Iterator<StructureBlockInfo> iterator = blocks.values()
.iterator(); iterator.hasNext();) {
StructureBlockInfo block = iterator.next();
if (brittles != BlockMovementChecks.isBrittle(block.state))
if (brittles != BlockMovementChecks.isBrittle(block.state()))
continue;
for (int i = 0; i < superglue.size(); i++) {
AABB aabb = superglue.get(i);
if (aabb == null
|| !aabb.contains(block.pos.getX() + .5, block.pos.getY() + .5, block.pos.getZ() + .5))
|| !aabb.contains(block.pos().getX() + .5, block.pos().getY() + .5, block.pos().getZ() + .5))
continue;
if (minimisedGlue.get(i) == null)
minimisedGlue.set(i, new BoundingBox(block.pos));
minimisedGlue.set(i, new BoundingBox(block.pos()));
else
minimisedGlue.set(i, BBHelper.encapsulate(minimisedGlue.get(i), block.pos));
minimisedGlue.set(i, BBHelper.encapsulate(minimisedGlue.get(i), block.pos()));
}
BlockPos add = block.pos.offset(anchor)
BlockPos add = block.pos().offset(anchor)
.offset(offset);
if (customBlockRemoval(world, add, block.state))
if (customBlockRemoval(world, add, block.state()))
continue;
BlockState oldState = world.getBlockState(add);
Block blockIn = oldState.getBlock();
boolean blockMismatch = block.state.getBlock() != blockIn;
blockMismatch &= !AllBlocks.POWERED_SHAFT.is(blockIn) || !AllBlocks.SHAFT.has(block.state);
boolean blockMismatch = block.state().getBlock() != blockIn;
blockMismatch &= !AllBlocks.POWERED_SHAFT.is(blockIn) || !AllBlocks.SHAFT.has(block.state());
if (blockMismatch)
iterator.remove();
world.removeBlockEntity(add);
@ -990,13 +990,13 @@ public abstract class Contraption {
}
for (StructureBlockInfo block : blocks.values()) {
BlockPos add = block.pos.offset(anchor)
BlockPos add = block.pos().offset(anchor)
.offset(offset);
// if (!shouldUpdateAfterMovement(block))
// continue;
int flags = Block.UPDATE_MOVE_BY_PISTON | Block.UPDATE_ALL;
world.sendBlockUpdated(add, block.state, Blocks.AIR.defaultBlockState(), flags);
world.sendBlockUpdated(add, block.state(), Blocks.AIR.defaultBlockState(), flags);
// when the blockstate is set to air, the block's POI data is removed, but
// markAndNotifyBlock tries to
@ -1004,7 +1004,7 @@ public abstract class Contraption {
// we add the POI data back now
// (code copied from ServerWorld.onBlockStateChange)
ServerLevel serverWorld = (ServerLevel) world;
PoiTypes.forState(block.state)
PoiTypes.forState(block.state())
.ifPresent(poiType -> {
world.getServer()
.execute(() -> {
@ -1014,9 +1014,9 @@ public abstract class Contraption {
});
});
world.markAndNotifyBlock(add, world.getChunkAt(add), block.state, Blocks.AIR.defaultBlockState(), flags,
world.markAndNotifyBlock(add, world.getChunkAt(add), block.state(), Blocks.AIR.defaultBlockState(), flags,
512);
block.state.updateIndirectNeighbourShapes(world, add, flags & -2);
block.state().updateIndirectNeighbourShapes(world, add, flags & -2);
}
}
@ -1027,11 +1027,11 @@ public abstract class Contraption {
for (boolean nonBrittles : Iterate.trueAndFalse) {
for (StructureBlockInfo block : blocks.values()) {
if (nonBrittles == BlockMovementChecks.isBrittle(block.state))
if (nonBrittles == BlockMovementChecks.isBrittle(block.state()))
continue;
BlockPos targetPos = transform.apply(block.pos);
BlockState state = transform.apply(block.state);
BlockPos targetPos = transform.apply(block.pos());
BlockState state = transform.apply(block.state());
if (customBlockPlacement(world, targetPos, state))
continue;
@ -1082,7 +1082,7 @@ public abstract class Contraption {
BlockEntity blockEntity = world.getBlockEntity(targetPos);
CompoundTag tag = block.nbt;
CompoundTag tag = block.nbt();
// Temporary fix: Calling load(CompoundTag tag) on a Sculk sensor causes it to not react to vibrations.
if(state.is(Blocks.SCULK_SENSOR) || state.is(Blocks.SCULK_SHRIEKER))
@ -1114,8 +1114,8 @@ public abstract class Contraption {
for (StructureBlockInfo block : blocks.values()) {
if (!shouldUpdateAfterMovement(block))
continue;
BlockPos targetPos = transform.apply(block.pos);
world.markAndNotifyBlock(targetPos, world.getChunkAt(targetPos), block.state, block.state,
BlockPos targetPos = transform.apply(block.pos());
world.markAndNotifyBlock(targetPos, world.getChunkAt(targetPos), block.state(), block.state(),
Block.UPDATE_MOVE_BY_PISTON | Block.UPDATE_ALL, 512);
}
@ -1152,7 +1152,7 @@ public abstract class Contraption {
for (MutablePair<StructureBlockInfo, MovementContext> pair : actors) {
MovementContext context = new MovementContext(world, pair.left, this);
MovementBehaviour behaviour = AllMovementBehaviours.getBehaviour(pair.left.state);
MovementBehaviour behaviour = AllMovementBehaviours.getBehaviour(pair.left.state());
if (behaviour != null)
behaviour.startMoving(context);
pair.setRight(context);
@ -1182,7 +1182,7 @@ public abstract class Contraption {
public void setActorsActive(ItemStack referenceStack, boolean enable) {
for (MutablePair<StructureBlockInfo, MovementContext> pair : actors) {
MovementBehaviour behaviour = AllMovementBehaviours.getBehaviour(pair.left.state);
MovementBehaviour behaviour = AllMovementBehaviours.getBehaviour(pair.left.state());
if (behaviour == null)
continue;
ItemStack behaviourStack = behaviour.canBeDisabledVia(pair.right);
@ -1212,7 +1212,7 @@ public abstract class Contraption {
public void forEachActor(Level world, BiConsumer<MovementBehaviour, MovementContext> callBack) {
for (MutablePair<StructureBlockInfo, MovementContext> pair : actors) {
MovementBehaviour behaviour = AllMovementBehaviours.getBehaviour(pair.getLeft().state);
MovementBehaviour behaviour = AllMovementBehaviours.getBehaviour(pair.getLeft().state());
if (behaviour == null)
continue;
callBack.accept(behaviour, pair.getRight());
@ -1220,10 +1220,10 @@ public abstract class Contraption {
}
protected boolean shouldUpdateAfterMovement(StructureBlockInfo info) {
if (PoiTypes.forState(info.state)
if (PoiTypes.forState(info.state())
.isPresent())
return false;
if (info.state.getBlock() instanceof SlidingDoorBlock)
if (info.state().getBlock() instanceof SlidingDoorBlock)
return false;
return true;
}
@ -1293,7 +1293,7 @@ public abstract class Contraption {
@Nullable
public MutablePair<StructureBlockInfo, MovementContext> getActorAt(BlockPos localPos) {
for (MutablePair<StructureBlockInfo, MovementContext> pair : actors)
if (localPos.equals(pair.left.pos))
if (localPos.equals(pair.left.pos()))
return pair;
return null;
}
@ -1320,7 +1320,7 @@ public abstract class Contraption {
for (Entry<BlockPos, StructureBlockInfo> entry : blocks.entrySet()) {
StructureBlockInfo info = entry.getValue();
BlockPos localPos = entry.getKey();
VoxelShape collisionShape = info.state.getCollisionShape(world, localPos, CollisionContext.empty());
VoxelShape collisionShape = info.state().getCollisionShape(world, localPos, CollisionContext.empty());
if (collisionShape.isEmpty())
continue;
combinedShape = Shapes.joinUnoptimized(combinedShape,
@ -1421,7 +1421,7 @@ public abstract class Contraption {
public boolean containsBlockBreakers() {
for (MutablePair<StructureBlockInfo, MovementContext> pair : actors) {
MovementBehaviour behaviour = AllMovementBehaviours.getBehaviour(pair.getLeft().state);
MovementBehaviour behaviour = AllMovementBehaviours.getBehaviour(pair.getLeft().state());
if (behaviour instanceof BlockBreakingMovementBehaviour || behaviour instanceof HarvesterMovementBehaviour)
return true;
}

View file

@ -272,22 +272,22 @@ public class ContraptionCollider {
if (temporalCollision)
collisionLocation = collisionLocation.add(0, motionResponse.y, 0);
BlockPos pos = new BlockPos(contraptionEntity.toLocalVector(entity.position(), 0));
BlockPos pos = BlockPos.containing(contraptionEntity.toLocalVector(entity.position(), 0));
if (contraption.getBlocks()
.containsKey(pos)) {
BlockState blockState = contraption.getBlocks()
.get(pos).state;
.get(pos).state();
if (blockState.is(BlockTags.CLIMBABLE)) {
surfaceCollision.setTrue();
totalResponse = totalResponse.add(0, .1f, 0);
}
}
pos = new BlockPos(contraptionEntity.toLocalVector(collisionLocation, 0));
pos = BlockPos.containing(contraptionEntity.toLocalVector(collisionLocation, 0));
if (contraption.getBlocks()
.containsKey(pos)) {
BlockState blockState = contraption.getBlocks()
.get(pos).state;
.get(pos).state();
MovingInteractionBehaviour movingInteractionBehaviour = contraption.interactors.get(pos);
if (movingInteractionBehaviour != null)
@ -303,7 +303,7 @@ public class ContraptionCollider {
if (bounce > 0 && hasNormal && anyCollision
&& bounceEntity(entity, collisionNormal, contraptionEntity, bounce)) {
entity.level.playSound(playerType == PlayerType.CLIENT ? (Player) entity : null, entity.getX(),
entity.level().playSound(playerType == PlayerType.CLIENT ? (Player) entity : null, entity.getX(),
entity.getY(), entity.getZ(), SoundEvents.SLIME_BLOCK_FALL, SoundSource.BLOCKS, .5f, 1);
continue;
}
@ -397,7 +397,7 @@ public class ContraptionCollider {
AllPackets.getChannel()
.sendToServer(new ClientMotionPacket(entityMotion, true, limbSwing));
if (entity.isOnGround() && contraption instanceof TranslatingContraption) {
if (entity.onGround() && contraption instanceof TranslatingContraption) {
safetyLock.setLeft(new WeakReference<>(contraptionEntity));
safetyLock.setRight(entity.getY() - contraptionEntity.getY());
}
@ -506,7 +506,7 @@ public class ContraptionCollider {
if (!(contraptionEntity instanceof CarriageContraptionEntity cce))
return entityMotion;
if (!entity.isOnGround())
if (!entity.onGround())
return entityMotion;
CompoundTag persistentData = entity.getPersistentData();
@ -612,20 +612,20 @@ public class ContraptionCollider {
/** From Entity#collide **/
static Vec3 collide(Vec3 p_20273_, Entity e) {
AABB aabb = e.getBoundingBox();
List<VoxelShape> list = e.level.getEntityCollisions(e, aabb.expandTowards(p_20273_));
Vec3 vec3 = p_20273_.lengthSqr() == 0.0D ? p_20273_ : collideBoundingBox(e, p_20273_, aabb, e.level, list);
List<VoxelShape> list = e.level().getEntityCollisions(e, aabb.expandTowards(p_20273_));
Vec3 vec3 = p_20273_.lengthSqr() == 0.0D ? p_20273_ : collideBoundingBox(e, p_20273_, aabb, e.level(), list);
boolean flag = p_20273_.x != vec3.x;
boolean flag1 = p_20273_.y != vec3.y;
boolean flag2 = p_20273_.z != vec3.z;
boolean flag3 = flag1 && p_20273_.y < 0.0D;
if (e.getStepHeight() > 0.0F && flag3 && (flag || flag2)) {
Vec3 vec31 = collideBoundingBox(e, new Vec3(p_20273_.x, (double) e.getStepHeight(), p_20273_.z), aabb,
e.level, list);
e.level(), list);
Vec3 vec32 = collideBoundingBox(e, new Vec3(0.0D, (double) e.getStepHeight(), 0.0D),
aabb.expandTowards(p_20273_.x, 0.0D, p_20273_.z), e.level, list);
aabb.expandTowards(p_20273_.x, 0.0D, p_20273_.z), e.level(), list);
if (vec32.y < (double) e.getStepHeight()) {
Vec3 vec33 =
collideBoundingBox(e, new Vec3(p_20273_.x, 0.0D, p_20273_.z), aabb.move(vec32), e.level, list)
collideBoundingBox(e, new Vec3(p_20273_.x, 0.0D, p_20273_.z), aabb.move(vec32), e.level(), list)
.add(vec32);
if (vec33.horizontalDistanceSqr() > vec31.horizontalDistanceSqr()) {
vec31 = vec33;
@ -634,7 +634,7 @@ public class ContraptionCollider {
if (vec31.horizontalDistanceSqr() > vec3.horizontalDistanceSqr()) {
return vec31.add(collideBoundingBox(e, new Vec3(0.0D, -vec31.y + p_20273_.y, 0.0D), aabb.move(vec31),
e.level, list));
e.level(), list));
}
}
@ -644,7 +644,7 @@ public class ContraptionCollider {
private static PlayerType getPlayerType(Entity entity) {
if (!(entity instanceof Player))
return PlayerType.NONE;
if (!entity.level.isClientSide)
if (!entity.level().isClientSide)
return PlayerType.SERVER;
MutableBoolean isClient = new MutableBoolean(false);
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> isClient.setValue(isClientPlayerEntity(entity)));
@ -665,17 +665,17 @@ public class ContraptionCollider {
AABB blockScanBB = localBB.inflate(0.5f);
blockScanBB = blockScanBB.inflate(horizontalFactor, verticalFactor, horizontalFactor);
BlockPos min = new BlockPos(blockScanBB.minX, blockScanBB.minY, blockScanBB.minZ);
BlockPos max = new BlockPos(blockScanBB.maxX, blockScanBB.maxY, blockScanBB.maxZ);
BlockPos min = BlockPos.containing(blockScanBB.minX, blockScanBB.minY, blockScanBB.minZ);
BlockPos max = BlockPos.containing(blockScanBB.maxX, blockScanBB.maxY, blockScanBB.maxZ);
List<VoxelShape> potentialHits = BlockPos.betweenClosedStream(min, max)
.filter(contraption.getBlocks()::containsKey)
.filter(Predicates.not(contraption::isHiddenInPortal))
.map(p -> {
BlockState blockState = contraption.getBlocks()
.get(p).state;
.get(p).state();
BlockPos pos = contraption.getBlocks()
.get(p).pos;
.get(p).pos();
VoxelShape collisionShape = blockState.getCollisionShape(world, p);
return collisionShape.move(pos.getX(), pos.getY(), pos.getZ());
})
@ -694,7 +694,7 @@ public class ContraptionCollider {
TranslatingContraption contraption = (TranslatingContraption) contraptionEntity.getContraption();
AABB bounds = contraptionEntity.getBoundingBox();
Vec3 position = contraptionEntity.position();
BlockPos gridPos = new BlockPos(position);
BlockPos gridPos = BlockPos.containing(position);
if (contraption == null)
return false;
@ -734,7 +734,7 @@ public class ContraptionCollider {
for (BlockPos colliderPos : contraption.getOrCreateColliders(world, movementDirection)) {
colliderPos = colliderPos.offset(gridPos)
.subtract(new BlockPos(otherPosition));
.subtract(BlockPos.containing(otherPosition));
if (!otherContraption.getBlocks()
.containsKey(colliderPos))
continue;
@ -762,7 +762,7 @@ public class ContraptionCollider {
if (collidedState.getBlock() instanceof CocoaBlock)
continue;
MovementBehaviour movementBehaviour = AllMovementBehaviours.getBehaviour(blockInfo.state);
MovementBehaviour movementBehaviour = AllMovementBehaviours.getBehaviour(blockInfo.state());
if (movementBehaviour != null) {
if (movementBehaviour instanceof BlockBreakingMovementBehaviour) {
BlockBreakingMovementBehaviour behaviour = (BlockBreakingMovementBehaviour) movementBehaviour;
@ -784,8 +784,7 @@ public class ContraptionCollider {
if (AllBlocks.PULLEY_MAGNET.has(collidedState) && pos.equals(BlockPos.ZERO)
&& movementDirection == Direction.UP)
continue;
if (!collidedState.getMaterial()
.isReplaceable() && !emptyCollider) {
if (!collidedState.canBeReplaced() && !emptyCollider) {
return true;
}

View file

@ -156,7 +156,7 @@ public class ContraptionHandlerClient {
.get(pos);
if (blockInfo == null)
continue;
BlockState state = blockInfo.state;
BlockState state = blockInfo.state();
VoxelShape raytraceShape = state.getShape(contraption.getContraptionWorld(), BlockPos.ZERO.below());
if (raytraceShape.isEmpty())
continue;

View file

@ -39,7 +39,7 @@ public enum ContraptionMovementSetting {
}
public static boolean allAre(Collection<StructureTemplate.StructureBlockInfo> blocks, ContraptionMovementSetting are) {
return blocks.stream().anyMatch(b -> get(b.state.getBlock()) == are);
return blocks.stream().anyMatch(b -> get(b.state().getBlock()) == are);
}
public static boolean isNoPickup(Collection<StructureTemplate.StructureBlockInfo> blocks) {

View file

@ -37,7 +37,7 @@ public class ContraptionWorld extends WrappedWorld {
StructureTemplate.StructureBlockInfo blockInfo = contraption.getBlocks().get(pos);
if (blockInfo != null)
return blockInfo.state;
return blockInfo.state();
return Blocks.AIR.defaultBlockState();
}

View file

@ -55,7 +55,7 @@ public class ControlledContraptionEntity extends AbstractContraptionEntity {
@Override
public void setPos(double x, double y, double z) {
super.setPos(x, y, z);
if (!level.isClientSide())
if (!level().isClientSide())
return;
for (Entity entity : getPassengers())
positionRider(entity);
@ -125,7 +125,7 @@ public class ControlledContraptionEntity extends AbstractContraptionEntity {
public void setAngle(float angle) {
this.angle = angle;
if (!level.isClientSide())
if (!level().isClientSide())
return;
for (Entity entity : getPassengers())
positionRider(entity);
@ -157,7 +157,7 @@ public class ControlledContraptionEntity extends AbstractContraptionEntity {
if (controllerPos == null)
return;
if (!level.isLoaded(controllerPos))
if (!level().isLoaded(controllerPos))
return;
IControlContraption controller = getController();
if (controller == null) {
@ -166,7 +166,7 @@ public class ControlledContraptionEntity extends AbstractContraptionEntity {
}
if (!controller.isAttachedTo(this)) {
controller.attach(this);
if (level.isClientSide)
if (level().isClientSide)
setPos(getX(), getY(), getZ());
}
}
@ -186,7 +186,7 @@ public class ControlledContraptionEntity extends AbstractContraptionEntity {
if (!activeAreaOffset.multiply(VecHelper.axisAlingedPlaneOf(Vec3.atLowerCornerOf(facing.getNormal())))
.equals(Vec3.ZERO))
return false;
if (!VecHelper.onSameAxis(blockInfo.pos, BlockPos.ZERO, facing.getAxis()))
if (!VecHelper.onSameAxis(blockInfo.pos(), BlockPos.ZERO, facing.getAxis()))
return false;
context.motion = Vec3.atLowerCornerOf(facing.getNormal())
.scale(angleDelta / 360.0);
@ -204,9 +204,9 @@ public class ControlledContraptionEntity extends AbstractContraptionEntity {
protected IControlContraption getController() {
if (controllerPos == null)
return null;
if (!level.isLoaded(controllerPos))
if (!level().isLoaded(controllerPos))
return null;
BlockEntity be = level.getBlockEntity(controllerPos);
BlockEntity be = level().getBlockEntity(controllerPos);
if (!(be instanceof IControlContraption))
return null;
return (IControlContraption) be;
@ -214,7 +214,7 @@ public class ControlledContraptionEntity extends AbstractContraptionEntity {
@Override
protected StructureTransform makeStructureTransform() {
BlockPos offset = new BlockPos(getAnchorVec().add(.5, .5, .5));
BlockPos offset = BlockPos.containing(getAnchorVec().add(.5, .5, .5));
float xRot = rotationAxis == Axis.X ? angle : 0;
float yRot = rotationAxis == Axis.Y ? angle : 0;
float zRot = rotationAxis == Axis.Z ? angle : 0;

View file

@ -14,6 +14,7 @@ import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraftforge.common.capabilities.ForgeCapabilities;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidTank;
@ -98,7 +99,7 @@ public class MountedFluidStorage {
if (blockEntity == null)
return;
IFluidHandler teHandler = blockEntity.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY)
IFluidHandler teHandler = blockEntity.getCapability(ForgeCapabilities.FLUID_HANDLER)
.orElse(null);
if (!(teHandler instanceof SmartFluidTank))
return;
@ -116,7 +117,7 @@ public class MountedFluidStorage {
if (tank instanceof CreativeSmartFluidTank)
return;
LazyOptional<IFluidHandler> capability = be.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY);
LazyOptional<IFluidHandler> capability = be.getCapability(ForgeCapabilities.FLUID_HANDLER);
IFluidHandler teHandler = capability.orElse(null);
if (!(teHandler instanceof SmartFluidTank))
return;

View file

@ -17,8 +17,8 @@ import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.ChestBlockEntity;
import net.minecraft.world.level.block.entity.ShulkerBoxBlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.common.capabilities.ForgeCapabilities;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.IItemHandlerModifiable;
import net.minecraftforge.items.ItemStackHandler;
@ -51,7 +51,7 @@ public class MountedStorage {
return true;
try {
LazyOptional<IItemHandler> capability = be.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY);
LazyOptional<IItemHandler> capability = be.getCapability(ForgeCapabilities.ITEM_HANDLER);
IItemHandler handler = capability.orElse(null);
if (handler instanceof ItemStackHandler)
return !(handler instanceof ProcessingInventory);
@ -102,7 +102,7 @@ public class MountedStorage {
return;
}
IItemHandler beHandler = blockEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
IItemHandler beHandler = blockEntity.getCapability(ForgeCapabilities.ITEM_HANDLER)
.orElse(dummyHandler);
if (beHandler == dummyHandler)
return;
@ -156,7 +156,7 @@ public class MountedStorage {
return;
}
LazyOptional<IItemHandler> capability = be.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY);
LazyOptional<IItemHandler> capability = be.getCapability(ForgeCapabilities.ITEM_HANDLER);
IItemHandler teHandler = capability.orElse(null);
if (!(teHandler instanceof IItemHandlerModifiable))
return;

View file

@ -53,7 +53,7 @@ public class MountedStorageManager {
}
public void entityTick(AbstractContraptionEntity entity) {
fluidStorage.forEach((pos, mfs) -> mfs.tick(entity, pos, entity.level.isClientSide));
fluidStorage.forEach((pos, mfs) -> mfs.tick(entity, pos, entity.level().isClientSide));
}
public void createHandlers() {
@ -169,14 +169,14 @@ public class MountedStorageManager {
}
public void addStorageToWorld(StructureBlockInfo block, BlockEntity blockEntity) {
if (storage.containsKey(block.pos)) {
MountedStorage mountedStorage = storage.get(block.pos);
if (storage.containsKey(block.pos())) {
MountedStorage mountedStorage = storage.get(block.pos());
if (mountedStorage.isValid())
mountedStorage.addStorageToWorld(blockEntity);
}
if (fluidStorage.containsKey(block.pos)) {
MountedFluidStorage mountedStorage = fluidStorage.get(block.pos);
if (fluidStorage.containsKey(block.pos())) {
MountedFluidStorage mountedStorage = fluidStorage.get(block.pos());
if (mountedStorage.isValid())
mountedStorage.addStorageToWorld(blockEntity);
}
@ -214,7 +214,7 @@ public class MountedStorageManager {
}
public boolean handlePlayerStorageInteraction(Contraption contraption, Player player, BlockPos localPos) {
if (player.level.isClientSide()) {
if (player.level().isClientSide()) {
BlockEntity localBE = contraption.presentBlockEntities.get(localPos);
return MountedStorage.canUseAsStorage(localBE);
}
@ -227,9 +227,9 @@ public class MountedStorageManager {
StructureBlockInfo info = contraption.getBlocks()
.get(localPos);
if (info != null && info.state.hasProperty(ChestBlock.TYPE)) {
ChestType chestType = info.state.getValue(ChestBlock.TYPE);
Direction facing = info.state.getOptionalValue(ChestBlock.FACING)
if (info != null && info.state().hasProperty(ChestBlock.TYPE)) {
ChestType chestType = info.state().getValue(ChestBlock.TYPE);
Direction facing = info.state().getOptionalValue(ChestBlock.FACING)
.orElse(Direction.SOUTH);
Direction connectedDirection =
chestType == ChestType.LEFT ? facing.getClockWise() : facing.getCounterClockWise();
@ -250,12 +250,12 @@ public class MountedStorageManager {
Supplier<Boolean> stillValid = () -> contraption.entity.isAlive()
&& player.distanceToSqr(contraption.entity.toGlobalVector(Vec3.atCenterOf(localPos), 0)) < 64;
Component name = info != null ? info.state.getBlock()
Component name = info != null ? info.state().getBlock()
.getName() : Components.literal("Container");
player.openMenu(MountedStorageInteraction.createMenuProvider(name, handler, slotCount, stillValid));
Vec3 soundPos = contraption.entity.toGlobalVector(Vec3.atCenterOf(localPos), 0);
player.level.playSound(null, new BlockPos(soundPos), SoundEvents.BARREL_OPEN, SoundSource.BLOCKS, 0.75f, 1f);
player.level().playSound(null, BlockPos.containing(soundPos), SoundEvents.BARREL_OPEN, SoundSource.BLOCKS, 0.75f, 1f);
return true;
}

View file

@ -145,7 +145,7 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity {
@Override
public void stopRiding() {
if (!level.isClientSide && isAlive())
if (!level().isClientSide && isAlive())
disassemble();
super.stopRiding();
}
@ -283,7 +283,7 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity {
LazyOptional<MinecartController> capability =
riding.getCapability(CapabilityMinecartController.MINECART_CONTROLLER_CAPABILITY);
if (capability.isPresent()) {
if (!level.isClientSide())
if (!level().isClientSide())
capability.orElse(null)
.setStalledExternally(isStalled);
} else {
@ -298,7 +298,7 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity {
}
}
if (level.isClientSide)
if (level().isClientSide)
return;
if (!isStalled()) {
@ -373,11 +373,11 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity {
if (riding instanceof AbstractMinecart) {
AbstractMinecart minecartEntity = (AbstractMinecart) riding;
BlockPos railPosition = minecartEntity.getCurrentRailPosition();
BlockState blockState = level.getBlockState(railPosition);
BlockState blockState = level().getBlockState(railPosition);
if (blockState.getBlock() instanceof BaseRailBlock) {
BaseRailBlock abstractRailBlock = (BaseRailBlock) blockState.getBlock();
RailShape railDirection =
abstractRailBlock.getRailDirection(blockState, level, railPosition, minecartEntity);
abstractRailBlock.getRailDirection(blockState, level(), railPosition, minecartEntity);
motion = VecHelper.project(motion, MinecartSim2020.getRailVec(railDirection));
}
}
@ -422,12 +422,12 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity {
int i = Mth.floor(furnaceCart.getX());
int j = Mth.floor(furnaceCart.getY());
int k = Mth.floor(furnaceCart.getZ());
if (furnaceCart.level.getBlockState(new BlockPos(i, j - 1, k))
if (furnaceCart.level().getBlockState(new BlockPos(i, j - 1, k))
.is(BlockTags.RAILS))
--j;
BlockPos blockpos = new BlockPos(i, j, k);
BlockState blockstate = this.level.getBlockState(blockpos);
BlockState blockstate = this.level().getBlockState(blockpos);
if (furnaceCart.canUseRail() && blockstate.is(BlockTags.RAILS))
if (fuel > 1)
riding.setDeltaMovement(riding.getDeltaMovement()
@ -452,11 +452,11 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity {
UUID couplingId = getCouplingId();
if (couplingId == null)
return null;
MinecartController controller = CapabilityMinecartController.getIfPresent(level, couplingId);
MinecartController controller = CapabilityMinecartController.getIfPresent(level(), couplingId);
if (controller == null || !controller.isPresent())
return null;
UUID coupledCart = controller.getCoupledCart(true);
MinecartController coupledController = CapabilityMinecartController.getIfPresent(level, coupledCart);
MinecartController coupledController = CapabilityMinecartController.getIfPresent(level(), coupledCart);
if (coupledController == null || !coupledController.isPresent())
return null;
return Couple.create(controller, coupledController);
@ -505,7 +505,7 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity {
@Override
protected StructureTransform makeStructureTransform() {
BlockPos offset = new BlockPos(getAnchorVec().add(.5, .5, .5));
BlockPos offset = BlockPos.containing(getAnchorVec().add(.5, .5, .5));
return new StructureTransform(offset, 0, -yaw + getInitialYaw(), 0);
}

View file

@ -103,7 +103,7 @@ public class StructureTransform {
}
public BlockPos applyWithoutOffset(BlockPos localPos) {
return new BlockPos(applyWithoutOffset(VecHelper.getCenterOf(localPos)));
return BlockPos.containing(applyWithoutOffset(VecHelper.getCenterOf(localPos)));
}
public BlockPos apply(BlockPos localPos) {

View file

@ -37,14 +37,14 @@ public class TrainCollisionPacket extends SimplePacketBase {
public boolean handle(Context context) {
context.enqueueWork(() -> {
ServerPlayer player = context.getSender();
Level level = player.level;
Level level = player.level();
Entity entity = level.getEntity(contraptionEntityId);
if (!(entity instanceof CarriageContraptionEntity cce))
return;
player.hurt(new EntityDamageSource("create.run_over", cce), (int) damage);
player.level.playSound(player, entity.blockPosition(), SoundEvents.PLAYER_ATTACK_CRIT, SoundSource.NEUTRAL,
player.level().playSound(player, entity.blockPosition(), SoundEvents.PLAYER_ATTACK_CRIT, SoundSource.NEUTRAL,
1, .75f);
});
return true;

View file

@ -27,15 +27,15 @@ public abstract class TranslatingContraption extends Contraption {
public Set<BlockPos> createColliders(Level world, Direction movementDirection) {
Set<BlockPos> colliders = new HashSet<>();
for (StructureBlockInfo info : getBlocks().values()) {
BlockPos offsetPos = info.pos.relative(movementDirection);
if (info.state.getCollisionShape(world, offsetPos)
BlockPos offsetPos = info.pos().relative(movementDirection);
if (info.state().getCollisionShape(world, offsetPos)
.isEmpty())
continue;
if (getBlocks().containsKey(offsetPos)
&& !getBlocks().get(offsetPos).state.getCollisionShape(world, offsetPos)
&& !getBlocks().get(offsetPos).state().getCollisionShape(world, offsetPos)
.isEmpty())
continue;
colliders.add(info.pos);
colliders.add(info.pos());
}
return colliders;
}

View file

@ -21,6 +21,7 @@ import net.minecraft.core.BlockPos;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.network.PacketDistributor;
@ -40,7 +41,7 @@ public class ContraptionControlsMovingInteraction extends MovingInteractionBehav
return false;
if (contraption instanceof ElevatorContraption ec)
return elevatorInteraction(localPos, contraptionEntity, ec, ctx);
if (contraptionEntity.level.isClientSide()) {
if (contraptionEntity.level().isClientSide()) {
if (contraption.presentBlockEntities.get(ctx.localPos) instanceof ContraptionControlsBlockEntity cbe)
cbe.pressButton();
return true;
@ -70,7 +71,7 @@ public class ContraptionControlsMovingInteraction extends MovingInteractionBehav
if (invert) {
for (MutablePair<StructureBlockInfo, MovementContext> pair : contraption.getActors()) {
MovementBehaviour behaviour = AllMovementBehaviours.getBehaviour(pair.left.state);
MovementBehaviour behaviour = AllMovementBehaviours.getBehaviour(pair.left.state());
if (behaviour == null)
continue;
ItemStack behaviourStack = behaviour.canBeDisabledVia(pair.right);
@ -94,8 +95,8 @@ public class ContraptionControlsMovingInteraction extends MovingInteractionBehav
ContraptionControlsBlockEntity.sendStatus(player, filter, !disable);
send(contraptionEntity, filter, disable);
AllSoundEvents.CONTROLLER_CLICK.play(player.level, null,
new BlockPos(contraptionEntity.toGlobalVector(Vec3.atCenterOf(localPos), 1)), 1, disable ? 0.8f : 1.5f);
AllSoundEvents.CONTROLLER_CLICK.play(player.level(), null,
BlockPos.containing(contraptionEntity.toGlobalVector(Vec3.atCenterOf(localPos), 1)), 1, disable ? 0.8f : 1.5f);
return true;
}
@ -107,10 +108,11 @@ public class ContraptionControlsMovingInteraction extends MovingInteractionBehav
private boolean elevatorInteraction(BlockPos localPos, AbstractContraptionEntity contraptionEntity,
ElevatorContraption contraption, MovementContext ctx) {
if (!contraptionEntity.level.isClientSide()) {
BlockPos pos = new BlockPos(contraptionEntity.toGlobalVector(Vec3.atCenterOf(localPos), 1));
AllSoundEvents.CONTROLLER_CLICK.play(contraptionEntity.level, null, pos, 1, 1.5f);
AllSoundEvents.CONTRAPTION_ASSEMBLE.play(contraptionEntity.level, null, pos, 0.75f, 0.8f);
Level level = contraptionEntity.level();
if (!level.isClientSide()) {
BlockPos pos = BlockPos.containing(contraptionEntity.toGlobalVector(Vec3.atCenterOf(localPos), 1));
AllSoundEvents.CONTROLLER_CLICK.play(level, null, pos, 1, 1.5f);
AllSoundEvents.CONTRAPTION_ASSEMBLE.play(level, null, pos, 0.75f, 0.8f);
return true;
}
if (!(ctx.temporaryData instanceof ElevatorFloorSelection efs))

View file

@ -79,7 +79,7 @@ public class PloughMovementBehaviour extends BlockBreakingMovementBehaviour {
if (entity.getDeltaMovement()
.length() < 0.25f)
return;
entity.level.getEntitiesOfClass(Player.class, new AABB(entity.blockPosition()).inflate(32))
entity.level().getEntitiesOfClass(Player.class, new AABB(entity.blockPosition()).inflate(32))
.forEach(AllAdvancements.ANVIL_PLOUGH::awardTo);
}

View file

@ -78,7 +78,7 @@ public class PortableStorageInterfaceMovement implements MovementBehaviour {
return;
if (context.world.isClientSide) {
BlockPos pos = new BlockPos(context.position);
BlockPos pos = BlockPos.containing(context.position);
if (!findInterface(context, pos))
reset(context);
return;

View file

@ -200,7 +200,7 @@ public class RollerMovementBehaviour extends BlockBreakingMovementBehaviour {
if (profileForTracks != null) {
for (Couple<Integer> coords : profileForTracks.keys()) {
float height = profileForTracks.get(coords);
BlockPos targetPosition = new BlockPos(coords.getFirst(), height, coords.getSecond());
BlockPos targetPosition = BlockPos.containing(coords.getFirst(), height, coords.getSecond());
boolean shouldPlaceSlab = height > Math.floor(height) + .45;
if (startingY == 1 && shouldPlaceSlab && context.world.getBlockState(targetPosition.above())
.getOptionalValue(SlabBlock.TYPE)
@ -256,8 +256,8 @@ public class RollerMovementBehaviour extends BlockBreakingMovementBehaviour {
Axis axis = Axis.X;
StructureBlockInfo info = context.contraption.getBlocks()
.get(BlockPos.ZERO);
if (info != null && info.state.hasProperty(StandardBogeyBlock.AXIS))
axis = info.state.getValue(StandardBogeyBlock.AXIS);
if (info != null && info.state().hasProperty(StandardBogeyBlock.AXIS))
axis = info.state().getValue(StandardBogeyBlock.AXIS);
Direction orientation = cce.getInitialOrientation();
Direction rollerFacing = context.state.getValue(RollerBlock.FACING);
@ -308,7 +308,7 @@ public class RollerMovementBehaviour extends BlockBreakingMovementBehaviour {
for (Couple<Integer> coords : profileForTracks.keys()) {
float height = profileForTracks.get(coords);
boolean shouldPlaceSlab = height > Math.floor(height) + .45;
BlockPos targetPosition = new BlockPos(coords.getFirst(), height, coords.getSecond());
BlockPos targetPosition = BlockPos.containing(coords.getFirst(), height, coords.getSecond());
paveSet.add(Pair.of(targetPosition, shouldPlaceSlab));
}
@ -451,8 +451,7 @@ public class RollerMovementBehaviour extends BlockBreakingMovementBehaviour {
BlockState existing = level.getBlockState(targetPos);
if (existing.is(toPlace.getBlock()))
return PaveResult.PASS;
if (!existing.is(BlockTags.LEAVES) && !existing.getMaterial()
.isReplaceable()
if (!existing.is(BlockTags.LEAVES) && !existing.canBeReplaced()
&& !existing.getCollisionShape(level, targetPos)
.isEmpty())
return PaveResult.FAIL;

View file

@ -36,7 +36,7 @@ public class TrackPaverV2 {
int extent = (int) Math.round((to - from) / direction.length());
double length = edge.getLength();
BlockPos pos = new BlockPos(edge.getPosition(graph, Mth.clamp(from, 1 / 16f, length - 1 / 16f) / length)
BlockPos pos = BlockPos.containing(edge.getPosition(graph, Mth.clamp(from, 1 / 16f, length - 1 / 16f) / length)
.subtract(0, diff.y != 0 ? 1 : 0.5, 0));
paveStraight(task, pos, direction, extent);
@ -69,7 +69,7 @@ public class TrackPaverV2 {
Vec3 targetVec = mainPos.add(mainNormal.scale(flip * (int) (currentOffset / 2.0)));
if (!isDiagonalTrack) {
toPlaceOn.add(new BlockPos(targetVec));
toPlaceOn.add(BlockPos.containing(targetVec));
continue;
}
@ -82,14 +82,14 @@ public class TrackPaverV2 {
.add(mainNormal.normalize()
.scale(flip))
.scale(.5);
toPlaceOn.add(new BlockPos(targetVec.add(sideOffset)));
toPlaceOn.add(BlockPos.containing(targetVec.add(sideOffset)));
}
}
if (placeRow) {
if (Math.abs(currentOffset % 2) == 1)
targetVec = mainPos.add(mainNormal.scale(flip * (int) ((currentOffset + 1) / 2.0)));
toPlaceOn.add(new BlockPos(targetVec));
toPlaceOn.add(BlockPos.containing(targetVec));
}
}

View file

@ -84,7 +84,7 @@ public class SeatBlock extends Block implements ProperWaterloggedBlock {
public void updateEntityAfterFallOn(BlockGetter reader, Entity entity) {
BlockPos pos = entity.blockPosition();
if (entity instanceof Player || !(entity instanceof LivingEntity) || !canBePickedUp(entity)
|| isSeatOccupied(entity.level, pos)) {
|| isSeatOccupied(entity.level(), pos)) {
if (entity.isSuppressingBounce()) {
super.updateEntityAfterFallOn(reader, entity);
return;
@ -101,7 +101,7 @@ public class SeatBlock extends Block implements ProperWaterloggedBlock {
if (reader.getBlockState(pos)
.getBlock() != this)
return;
sitDown(entity.level, pos, entity);
sitDown(entity.level(), pos, entity);
}
@Override
@ -165,7 +165,7 @@ public class SeatBlock extends Block implements ProperWaterloggedBlock {
}
public static Optional<Entity> getLeashed(Level level, Player player) {
List<Entity> entities = player.level.getEntities((Entity) null, player.getBoundingBox()
List<Entity> entities = player.level().getEntities((Entity) null, player.getBoundingBox()
.inflate(10), e -> true);
for (Entity e : entities)
if (e instanceof Mob mob && mob.getLeashHolder() == player && SeatBlock.canBePickedUp(e))

View file

@ -85,9 +85,9 @@ public class SeatEntity extends Entity implements IEntityAdditionalSpawnData {
@Override
public void tick() {
if (level.isClientSide)
if (level().isClientSide)
return;
boolean blockPresent = level.getBlockState(blockPosition())
boolean blockPresent = level().getBlockState(blockPosition())
.getBlock() instanceof SeatBlock;
if (isVehicle() && blockPresent)
return;

View file

@ -34,7 +34,7 @@ public class ControlsInteractionBehaviour extends MovingInteractionBehaviour {
return false;
contraptionEntity.setControllingPlayer(player.getUUID());
if (player.level.isClientSide)
if (player.level().isClientSide)
DistExecutor.unsafeRunWhenOn(Dist.CLIENT,
() -> () -> ControlsHandler.startControlling(contraptionEntity, localPos));
return true;

View file

@ -68,8 +68,8 @@ public class ControlsMovementBehaviour implements MovementBehaviour {
Direction initialOrientation = cce.getInitialOrientation()
.getCounterClockWise();
boolean inverted = false;
if (info != null && info.state.hasProperty(ControlsBlock.FACING))
inverted = !info.state.getValue(ControlsBlock.FACING)
if (info != null && info.state().hasProperty(ControlsBlock.FACING))
inverted = !info.state().getValue(ControlsBlock.FACING)
.equals(initialOrientation);
if (ControlsHandler.getContraption() == entity && ControlsHandler.getControlsPos() != null

View file

@ -68,7 +68,7 @@ public class BearingContraption extends Contraption {
}
private BlockState getSailBlock(Pair<StructureBlockInfo, BlockEntity> capture) {
BlockState state = capture.getKey().state;
BlockState state = capture.getKey().state();
if (AllBlocks.COPYCAT_PANEL.has(state) && capture.getRight() instanceof CopycatBlockEntity cbe)
return cbe.getMaterial();
return state;

View file

@ -342,8 +342,7 @@ public class MechanicalBearingBlockEntity extends GeneratingKineticBlockEntity
return false;
BlockState attachedState = level.getBlockState(worldPosition.relative(state.getValue(BearingBlock.FACING)));
if (attachedState.getMaterial()
.isReplaceable())
if (attachedState.canBeReplaced())
return false;
TooltipHelper.addHint(tooltip, "hint.empty_bearing");
return true;

View file

@ -247,8 +247,7 @@ public class SailBlock extends WrenchableDirectionalBlock {
state.getValue(SailBlock.FACING)
.getAxis(),
dir -> world.getBlockState(pos.relative(dir))
.getMaterial()
.isReplaceable());
.canBeReplaced());
if (directions.isEmpty())
return PlacementOffset.fail();

View file

@ -38,7 +38,7 @@ public class BellMovementBehaviour implements MovementBehaviour {
public static void playSound(MovementContext context) {
Level world = context.world;
BlockPos pos = new BlockPos(context.position);
BlockPos pos = BlockPos.containing(context.position);
Block block = context.state.getBlock();
if (block instanceof AbstractBellBlock) {

View file

@ -29,9 +29,9 @@ public class DoorMovingInteraction extends SimpleBlockMovingInteraction {
BlockPos otherPos = currentState.getValue(DoorBlock.HALF) == DoubleBlockHalf.LOWER ? pos.above() : pos.below();
StructureBlockInfo info = contraption.getBlocks()
.get(otherPos);
if (info.state.hasProperty(DoorBlock.OPEN)) {
BlockState newState = info.state.cycle(DoorBlock.OPEN);
setContraptionBlockData(contraption.entity, otherPos, new StructureBlockInfo(info.pos, newState, info.nbt));
if (info.state().hasProperty(DoorBlock.OPEN)) {
BlockState newState = info.state().cycle(DoorBlock.OPEN);
setContraptionBlockData(contraption.entity, otherPos, new StructureBlockInfo(info.pos(), newState, info.nbt()));
}
currentState = currentState.cycle(DoorBlock.OPEN);
@ -45,11 +45,11 @@ public class DoorMovingInteraction extends SimpleBlockMovingInteraction {
pos.relative(hinge == DoorHingeSide.LEFT ? facing.getClockWise() : facing.getCounterClockWise());
StructureBlockInfo doubleInfo = contraption.getBlocks()
.get(doublePos);
if (doubleInfo != null && SlidingDoorBlock.isDoubleDoor(currentState, hinge, facing, doubleInfo.state))
if (doubleInfo != null && SlidingDoorBlock.isDoubleDoor(currentState, hinge, facing, doubleInfo.state()))
handlePlayerInteraction(null, InteractionHand.MAIN_HAND, doublePos, contraption.entity);
}
float pitch = player.level.random.nextFloat() * 0.1F + 0.9F;
float pitch = player.level().random.nextFloat() * 0.1F + 0.9F;
if (sound != null)
playSound(player, sound, pitch);
}

View file

@ -34,10 +34,10 @@ public class MovementContext {
public MovementContext(Level world, StructureBlockInfo info, Contraption contraption) {
this.world = world;
this.state = info.state;
this.blockEntityData = info.nbt;
this.state = info.state();
this.blockEntityData = info.nbt();
this.contraption = contraption;
localPos = info.pos;
localPos = info.pos();
disabled = false;
firstMovement = true;

View file

@ -16,13 +16,13 @@ public abstract class MovingInteractionBehaviour {
StructureBlockInfo info, MovementContext ctx) {
contraptionEntity.getContraption().getActors().remove(index);
contraptionEntity.getContraption().getActors().add(index, MutablePair.of(info, ctx));
if (contraptionEntity.level.isClientSide)
if (contraptionEntity.level().isClientSide)
contraptionEntity.getContraption().deferInvalidate = true;
}
protected void setContraptionBlockData(AbstractContraptionEntity contraptionEntity, BlockPos pos,
StructureBlockInfo info) {
if (contraptionEntity.level.isClientSide())
if (contraptionEntity.level().isClientSide())
return;
contraptionEntity.setBlock(pos, info);
}

View file

@ -20,11 +20,11 @@ public abstract class SimpleBlockMovingInteraction extends MovingInteractionBeha
StructureBlockInfo info = contraption.getBlocks()
.get(localPos);
BlockState newState = handle(player, contraption, localPos, info.state);
if (info.state == newState)
BlockState newState = handle(player, contraption, localPos, info.state());
if (info.state() == newState)
return false;
setContraptionBlockData(contraptionEntity, localPos, new StructureBlockInfo(info.pos, newState, info.nbt));
setContraptionBlockData(contraptionEntity, localPos, new StructureBlockInfo(info.pos(), newState, info.nbt()));
if (updateColliders())
contraption.invalidateColliders();
return true;
@ -35,7 +35,7 @@ public abstract class SimpleBlockMovingInteraction extends MovingInteractionBeha
}
protected void playSound(Player player, SoundEvent sound, float pitch) {
player.level.playSound(player, player.blockPosition(), sound, SoundSource.BLOCKS, 0.3f, pitch);
player.level().playSound(player, player.blockPosition(), sound, SoundSource.BLOCKS, 0.3f, pitch);
}
protected abstract BlockState handle(Player player, Contraption contraption, BlockPos pos,

View file

@ -15,7 +15,7 @@ public class TrapdoorMovingInteraction extends SimpleBlockMovingInteraction {
protected BlockState handle(Player player, Contraption contraption, BlockPos pos, BlockState currentState) {
SoundEvent sound = currentState.getValue(TrapDoorBlock.OPEN) ? SoundEvents.WOODEN_TRAPDOOR_CLOSE
: SoundEvents.WOODEN_TRAPDOOR_OPEN;
float pitch = player.level.random.nextFloat() * 0.1F + 0.9F;
float pitch = player.level().random.nextFloat() * 0.1F + 0.9F;
playSound(player, sound, pitch);
return currentState.cycle(TrapDoorBlock.OPEN);
}

View file

@ -62,7 +62,7 @@ public class ElevatorContraption extends PulleyContraption {
return;
ColumnCoords coords = getGlobalColumn();
ElevatorColumn column = ElevatorColumn.get(entity.level, coords);
ElevatorColumn column = ElevatorColumn.get(entity.level(), coords);
if (column == null)
return;

View file

@ -91,10 +91,10 @@ public class ElevatorControlsHandler {
if (info == null)
continue;
if (!AllBlocks.CONTRAPTION_CONTROLS.has(info.state))
if (!AllBlocks.CONTRAPTION_CONTROLS.has(info.state()))
continue;
if (!slot.testHit(info.state, rayTraceResult.getLocation()
if (!slot.testHit(info.state(), rayTraceResult.getLocation()
.subtract(Vec3.atLowerCornerOf(pos))))
continue;
@ -117,8 +117,8 @@ public class ElevatorControlsHandler {
if (prev != efs.currentIndex && !ec.namesList.isEmpty()) {
float pitch = (efs.currentIndex) / (float) (ec.namesList.size());
pitch = Mth.lerp(pitch, 1f, 1.5f);
AllSoundEvents.SCROLL_VALUE.play(mc.player.level, mc.player,
new BlockPos(contraptionEntity.toGlobalVector(rayTraceResult.getLocation(), 1)), 1, pitch);
AllSoundEvents.SCROLL_VALUE.play(mc.player.level(), mc.player,
BlockPos.containing(contraptionEntity.toGlobalVector(rayTraceResult.getLocation(), 1)), 1, pitch);
}
return true;

View file

@ -81,7 +81,7 @@ public class ElevatorFloorListPacket extends SimplePacketBase {
public boolean handle(Context context) {
context.enqueueWork(() -> {
ServerPlayer sender = context.getSender();
Entity entityByID = sender.getLevel()
Entity entityByID = sender.level()
.getEntity(entityId);
if (!(entityByID instanceof AbstractContraptionEntity ace))
return;

View file

@ -246,8 +246,7 @@ public class ElevatorPulleyBlockEntity extends PulleyBlockEntity {
BlockState ropeState = level.getBlockState(ropePos);
if (!ropeState.getCollisionShape(level, ropePos)
.isEmpty()
&& !ropeState.getMaterial()
.isReplaceable()) {
&& !ropeState.canBeReplaced()) {
break;
}
++i;

View file

@ -36,7 +36,7 @@ public class ElevatorTargetFloorPacket extends SimplePacketBase {
public boolean handle(Context context) {
context.enqueueWork(() -> {
ServerPlayer sender = context.getSender();
Entity entityByID = sender.getLevel()
Entity entityByID = sender.serverLevel()
.getEntity(entityId);
if (!(entityByID instanceof AbstractContraptionEntity ace))
return;
@ -45,7 +45,7 @@ public class ElevatorTargetFloorPacket extends SimplePacketBase {
if (ace.distanceToSqr(sender) > 50 * 50)
return;
Level level = sender.level;
Level level = sender.level();
ElevatorColumn elevatorColumn = ElevatorColumn.get(level, ec.getGlobalColumn());
if (!elevatorColumn.contacts.contains(targetY))
return;

View file

@ -62,7 +62,7 @@ public class GantryContraption extends TranslatingContraption {
@Override
protected boolean shouldUpdateAfterMovement(StructureBlockInfo info) {
return super.shouldUpdateAfterMovement(info) && !AllBlocks.GANTRY_CARRIAGE.has(info.state);
return super.shouldUpdateAfterMovement(info) && !AllBlocks.GANTRY_CARRIAGE.has(info.state());
}
@Override

View file

@ -59,7 +59,7 @@ public class GantryContraptionEntity extends AbstractContraptionEntity {
return;
double prevAxisMotion = axisMotion;
if (level.isClientSide) {
if (level().isClientSide) {
clientOffsetDiff *= .75f;
updateClientMotion();
}
@ -69,7 +69,7 @@ public class GantryContraptionEntity extends AbstractContraptionEntity {
Vec3 movementVec = getDeltaMovement();
if (ContraptionCollider.collideBlocks(this)) {
if (!level.isClientSide)
if (!level().isClientSide)
disassemble();
return;
}
@ -83,8 +83,8 @@ public class GantryContraptionEntity extends AbstractContraptionEntity {
}
if (Math.signum(prevAxisMotion) != Math.signum(axisMotion) && prevAxisMotion != 0)
contraption.stop(level);
if (!level.isClientSide && (prevAxisMotion != axisMotion || tickCount % 3 == 0))
contraption.stop(level());
if (!level().isClientSide && (prevAxisMotion != axisMotion || tickCount % 3 == 0))
sendPacket();
}
@ -98,11 +98,11 @@ public class GantryContraptionEntity extends AbstractContraptionEntity {
Vec3 movementVec;
Direction facing = ((GantryContraption) contraption).getFacing();
Vec3 currentPosition = getAnchorVec().add(.5, .5, .5);
BlockPos gantryShaftPos = new BlockPos(currentPosition).relative(facing.getOpposite());
BlockPos gantryShaftPos = BlockPos.containing(currentPosition).relative(facing.getOpposite());
BlockEntity be = level.getBlockEntity(gantryShaftPos);
BlockEntity be = level().getBlockEntity(gantryShaftPos);
if (!(be instanceof GantryShaftBlockEntity) || !AllBlocks.GANTRY_SHAFT.has(be.getBlockState())) {
if (!level.isClientSide) {
if (!level().isClientSide) {
setContraptionMotion(Vec3.ZERO);
disassemble();
}
@ -116,7 +116,7 @@ public class GantryContraptionEntity extends AbstractContraptionEntity {
float pinionMovementSpeed = gantryShaftBlockEntity.getPinionMovementSpeed();
if (blockState.getValue(GantryShaftBlock.POWERED) || pinionMovementSpeed == 0) {
setContraptionMotion(Vec3.ZERO);
if (!level.isClientSide)
if (!level().isClientSide)
disassemble();
return;
}
@ -136,12 +136,12 @@ public class GantryContraptionEntity extends AbstractContraptionEntity {
.getStep() < 0)))
if (!gantryShaftBlockEntity.canAssembleOn()) {
setContraptionMotion(Vec3.ZERO);
if (!level.isClientSide)
if (!level().isClientSide)
disassemble();
return;
}
if (level.isClientSide)
if (level().isClientSide)
return;
axisMotion = pinionMovementSpeed;
@ -175,7 +175,7 @@ public class GantryContraptionEntity extends AbstractContraptionEntity {
@Override
protected StructureTransform makeStructureTransform() {
return new StructureTransform(new BlockPos(getAnchorVec().add(.5, .5, .5)), 0, 0, 0);
return new StructureTransform(BlockPos.containing(getAnchorVec().add(.5, .5, .5)), 0, 0, 0);
}
@Override

View file

@ -178,13 +178,13 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat
@Override
public void move(MoverType typeIn, Vec3 pos) {
if (!level.isClientSide && isAlive() && pos.lengthSqr() > 0.0D)
if (!level().isClientSide && isAlive() && pos.lengthSqr() > 0.0D)
discard();
}
@Override
public void push(double x, double y, double z) {
if (!level.isClientSide && isAlive() && x * x + y * y + z * z > 0.0D)
if (!level().isClientSide && isAlive() && x * x + y * y + z * z > 0.0D)
discard();
}
@ -307,7 +307,7 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat
Vec3 origin = new Vec3(bb.minX, bb.minY, bb.minZ);
Vec3 extents = new Vec3(bb.getXsize(), bb.getYsize(), bb.getZsize());
if (!(level instanceof ServerLevel slevel))
if (!(level() instanceof ServerLevel slevel))
return;
for (Axis axis : Iterate.axes) {

View file

@ -49,7 +49,7 @@ public class SuperGlueHandler {
for (Direction direction : Iterate.directions) {
BlockPos relative = pos.relative(direction);
if (SuperGlueEntity.isGlued(world, pos, direction, cached)
&& BlockMovementChecks.isMovementNecessary(world.getBlockState(relative), entity.level, relative))
&& BlockMovementChecks.isMovementNecessary(world.getBlockState(relative), entity.level(), relative))
AllPackets.getChannel().send(PacketDistributor.TRACKING_ENTITY_AND_SELF.with(() -> entity),
new GlueEffectPacket(pos, direction, true));
}
@ -60,7 +60,7 @@ public class SuperGlueHandler {
public static void glueInOffHandAppliesOnBlockPlace(EntityPlaceEvent event, BlockPos pos, Player placer) {
ItemStack itemstack = placer.getOffhandItem();
AttributeInstance reachAttribute = placer.getAttribute(ForgeMod.REACH_DISTANCE.get());
AttributeInstance reachAttribute = placer.getAttribute(ForgeMod.BLOCK_REACH.get());
if (!AllItems.SUPER_GLUE.isIn(itemstack) || reachAttribute == null)
return;
if (AllItems.WRENCH.isIn(placer.getMainHandItem()))
@ -72,7 +72,7 @@ public class SuperGlueHandler {
Vec3 start = placer.getEyePosition(1);
Vec3 look = placer.getViewVector(1);
Vec3 end = start.add(look.x * distance, look.y * distance, look.z * distance);
Level world = placer.level;
Level world = placer.level();
RayTraceWorld rayTraceWorld =
new RayTraceWorld(world, (p, state) -> p.equals(pos) ? Blocks.AIR.defaultBlockState() : state);

View file

@ -34,13 +34,13 @@ public class SuperGlueRemovalPacket extends SimplePacketBase {
public boolean handle(Context context) {
context.enqueueWork(() -> {
ServerPlayer player = context.getSender();
Entity entity = player.level.getEntity(entityId);
Entity entity = player.level().getEntity(entityId);
if (!(entity instanceof SuperGlueEntity superGlue))
return;
double range = 32;
if (player.distanceToSqr(superGlue.position()) > range * range)
return;
AllSoundEvents.SLIME_ADDED.play(player.level, null, soundSource, 0.5F, 0.5F);
AllSoundEvents.SLIME_ADDED.play(player.level(), null, soundSource, 0.5F, 0.5F);
superGlue.spawnParticles();
entity.discard();
});

View file

@ -74,7 +74,7 @@ public class SuperGlueSelectionHandler {
selected = null;
if (firstPos == null) {
double range = player.getAttribute(ForgeMod.REACH_DISTANCE.get())
double range = player.getAttribute(ForgeMod.BLOCK_REACH.get())
.getValue() + 1;
Vec3 traceOrigin = RaycastHelper.getTraceOrigin(player);
Vec3 traceTarget = RaycastHelper.getTraceTarget(player, range, traceOrigin);
@ -90,7 +90,7 @@ public class SuperGlueSelectionHandler {
if (distanceToSqr > bestDistance)
continue;
selected = glueEntity;
soundSourceForRemoval = new BlockPos(vec3);
soundSourceForRemoval = BlockPos.containing(vec3);
bestDistance = distanceToSqr;
}
@ -252,8 +252,8 @@ public class SuperGlueSelectionHandler {
public void confirm() {
LocalPlayer player = Minecraft.getInstance().player;
AllPackets.getChannel().sendToServer(new SuperGlueSelectionPacket(firstPos, hoveredPos));
AllSoundEvents.SLIME_ADDED.playAt(player.level, hoveredPos, 0.5F, 0.95F, false);
player.level.playSound(player, hoveredPos, SoundEvents.ITEM_FRAME_ADD_ITEM, SoundSource.BLOCKS, 0.75f, 1);
AllSoundEvents.SLIME_ADDED.playAt(player.level(), hoveredPos, 0.5F, 0.95F, false);
player.level().playSound(player, hoveredPos, SoundEvents.ITEM_FRAME_ADD_ITEM, SoundSource.BLOCKS, 0.75f, 1);
if (currentCluster != null)
CreateClient.OUTLINER.showCluster(clusterOutlineSlot, currentCluster)

View file

@ -39,14 +39,14 @@ public class SuperGlueSelectionPacket extends SimplePacketBase {
context.enqueueWork(() -> {
ServerPlayer player = context.getSender();
double range = player.getAttribute(ForgeMod.REACH_DISTANCE.get())
double range = player.getAttribute(ForgeMod.BLOCK_REACH.get())
.getValue() + 2;
if (player.distanceToSqr(Vec3.atCenterOf(to)) > range * range)
return;
if (!to.closerThan(from, 25))
return;
Set<BlockPos> group = SuperGlueSelectionHelper.searchGlueGroup(player.level, from, to, false);
Set<BlockPos> group = SuperGlueSelectionHelper.searchGlueGroup(player.level(), from, to, false);
if (group == null)
return;
if (!group.contains(to))
@ -56,8 +56,8 @@ public class SuperGlueSelectionPacket extends SimplePacketBase {
AABB bb = SuperGlueEntity.span(from, to);
SuperGlueSelectionHelper.collectGlueFromInventory(player, 1, false);
SuperGlueEntity entity = new SuperGlueEntity(player.level, bb);
player.level.addFreshEntity(entity);
SuperGlueEntity entity = new SuperGlueEntity(player.level(), bb);
player.level().addFreshEntity(entity);
entity.spawnParticles();
AllAdvancements.SUPER_GLUE.awardTo(player);

View file

@ -32,7 +32,7 @@ public class CouplingCreationPacket extends SimplePacketBase {
context.enqueueWork(() -> {
ServerPlayer sender = context.getSender();
if (sender != null)
CouplingHandler.tryToCoupleCarts(sender, sender.level, id1, id2);
CouplingHandler.tryToCoupleCarts(sender, sender.level(), id1, id2);
});
return true;
}

View file

@ -105,7 +105,7 @@ public class CouplingPhysics {
int y = Mth.floor(vec.y());
int z = Mth.floor(vec.z());
BlockPos pos = new BlockPos(x, y - 1, z);
if (minecart.level.getBlockState(pos).is(BlockTags.RAILS)) pos = pos.below();
if (minecart.level().getBlockState(pos).is(BlockTags.RAILS)) pos = pos.below();
BlockPos railPosition = pos;
BlockState railState = world.getBlockState(railPosition.above());
if (!(railState.getBlock() instanceof BaseRailBlock))

View file

@ -51,8 +51,9 @@ public class CouplingRenderer {
if (carts.getFirst() == null || carts.getSecond() == null)
return;
Couple<Integer> lightValues = carts.map(c -> LevelRenderer.getLightColor(world, new BlockPos(c.getBoundingBox()
.getCenter())));
Couple<Integer> lightValues =
carts.map(c -> LevelRenderer.getLightColor(world, BlockPos.containing(c.getBoundingBox()
.getCenter())));
Vec3 center = carts.getFirst()
.position()

View file

@ -83,7 +83,7 @@ public class MinecartSim2020 {
actualY = cartPos.getY() + 1;
BaseRailBlock abstractrailblock = (BaseRailBlock) trackState.getBlock();
RailShape railshape = abstractrailblock.getRailDirection(trackState, cart.level, cartPos, cart);
RailShape railshape = abstractrailblock.getRailDirection(trackState, cart.level(), cartPos, cart);
switch (railshape) {
case ASCENDING_EAST:
forcedMovement = forcedMovement.add(-1 * cart.getSlopeAdjustment(), 0.0D, 0.0D);

View file

@ -99,7 +99,7 @@ public class MinecartController implements INBTSerializable<CompoundTag> {
if (passengers.isEmpty() || !(passengers.get(0) instanceof AbstractContraptionEntity)) {
return;
}
Level world = cart.level;
Level world = cart.level();
int i = Mth.floor(cart.getX());
int j = Mth.floor(cart.getY());
int k = Mth.floor(cart.getZ());

View file

@ -44,7 +44,6 @@ import net.minecraft.world.level.block.DispenserBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.RailShape;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo;
import net.minecraft.world.level.material.Material;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
@ -103,7 +102,7 @@ public class MinecartContraptionItem extends Item {
d3 = 0.1D;
}
} else {
if (blockstate.getMaterial() != Material.AIR || !world.getBlockState(blockpos.below())
if (!blockstate.isAir() || !world.getBlockState(blockpos.below())
.is(BlockTags.RAILS)) {
return this.behaviourDefaultDispenseItem.dispense(source, stack);
}
@ -244,7 +243,7 @@ public class MinecartContraptionItem extends Item {
contraption.stop(event.getLevel());
for (MutablePair<StructureBlockInfo, MovementContext> pair : contraption.getActors())
if (AllMovementBehaviours.getBehaviour(pair.left.state)instanceof PortableStorageInterfaceMovement psim)
if (AllMovementBehaviours.getBehaviour(pair.left.state())instanceof PortableStorageInterfaceMovement psim)
psim.reset(pair.right);
ItemStack generatedStack = create(type, oce).setHoverName(entity.getCustomName());

View file

@ -83,11 +83,11 @@ public class MountedContraption extends Contraption {
protected Pair<StructureBlockInfo, BlockEntity> capture(Level world, BlockPos pos) {
Pair<StructureBlockInfo, BlockEntity> pair = super.capture(world, pos);
StructureBlockInfo capture = pair.getKey();
if (!AllBlocks.CART_ASSEMBLER.has(capture.state))
if (!AllBlocks.CART_ASSEMBLER.has(capture.state()))
return pair;
Pair<StructureBlockInfo, BlockEntity> anchorSwap =
Pair.of(new StructureBlockInfo(pos, CartAssemblerBlock.createAnchor(capture.state), null), pair.getValue());
Pair.of(new StructureBlockInfo(pos, CartAssemblerBlock.createAnchor(capture.state()), null), pair.getValue());
if (pos.equals(anchor) || connectedCart != null)
return anchorSwap;

View file

@ -139,9 +139,9 @@ public class PistonContraption extends TranslatingContraption {
bounds = new AABB(0, 0, 0, 0, 0, 0);
for (StructureBlockInfo pole : poles) {
BlockPos relPos = pole.pos.relative(direction, -extensionsInFront);
BlockPos relPos = pole.pos().relative(direction, -extensionsInFront);
BlockPos localPos = relPos.subtract(anchor);
getBlocks().put(localPos, new StructureBlockInfo(localPos, pole.state, null));
getBlocks().put(localPos, new StructureBlockInfo(localPos, pole.state(), null));
//pistonExtensionCollisionBox = pistonExtensionCollisionBox.union(new AABB(localPos));
}

View file

@ -17,7 +17,7 @@ public class PulleyLighter extends ContraptionLighter<PulleyContraption> {
GridAlignedBB bounds = GridAlignedBB.from(contraption.bounds);
Level world = contraption.entity.level;
Level world = contraption.entity.level();
BlockPos.MutableBlockPos pos = contraption.anchor.mutable();
while (!AllBlocks.ROPE_PULLEY.has(world.getBlockState(pos)) && pos.getY() < world.getMaxBuildHeight())

View file

@ -63,7 +63,7 @@ public class ContraptionInstanceManager extends BlockEntityInstanceManager {
if (contraption.isHiddenInPortal(context.localPos))
return null;
MovementBehaviour movementBehaviour = AllMovementBehaviours.getBehaviour(blockInfo.state);
MovementBehaviour movementBehaviour = AllMovementBehaviours.getBehaviour(blockInfo.state());
if (movementBehaviour != null && movementBehaviour.hasSpecialInstancedRendering()) {
ActorInstance instance = movementBehaviour.createInstance(materialManager, renderWorld, context);

View file

@ -20,12 +20,12 @@ public abstract class ContraptionLighter<C extends Contraption> implements Light
protected ContraptionLighter(C contraption) {
this.contraption = contraption;
lightUpdater = LightUpdater.get(contraption.entity.level);
lightUpdater = LightUpdater.get(contraption.entity.level());
bounds = getContraptionBounds();
growBoundsForEdgeData(bounds);
lightVolume = new GPULightVolume(contraption.entity.level, bounds);
lightVolume = new GPULightVolume(contraption.entity.level(), bounds);
lightVolume.initialize();
scheduleRebuild = true;

View file

@ -54,7 +54,7 @@ public class ContraptionRenderDispatcher {
* @return true if there was a renderer associated with the given contraption.
*/
public static boolean invalidate(Contraption contraption) {
Level level = contraption.entity.level;
Level level = contraption.entity.level();
return WORLDS.get(level)
.invalidate(contraption);
@ -94,7 +94,7 @@ public class ContraptionRenderDispatcher {
public static void renderFromEntity(AbstractContraptionEntity entity, Contraption contraption,
MultiBufferSource buffers) {
Level world = entity.level;
Level world = entity.level();
ContraptionRenderInfo renderInfo = WORLDS.get(world)
.getRenderInfo(contraption);
@ -131,7 +131,7 @@ public class ContraptionRenderDispatcher {
for (StructureTemplate.StructureBlockInfo info : c.getBlocks()
.values())
// Skip individual lighting updates to prevent lag with large contraptions
renderWorld.setBlock(info.pos, info.state, Block.UPDATE_SUPPRESS_LIGHT);
renderWorld.setBlock(info.pos(), info.state(), Block.UPDATE_SUPPRESS_LIGHT);
renderWorld.runLightingEngine();
return renderWorld;
@ -155,13 +155,13 @@ public class ContraptionRenderDispatcher {
context.world = world;
StructureTemplate.StructureBlockInfo blockInfo = actor.getLeft();
MovementBehaviour movementBehaviour = AllMovementBehaviours.getBehaviour(blockInfo.state);
MovementBehaviour movementBehaviour = AllMovementBehaviours.getBehaviour(blockInfo.state());
if (movementBehaviour != null) {
if (c.isHiddenInPortal(blockInfo.pos))
if (c.isHiddenInPortal(blockInfo.pos()))
continue;
m.pushPose();
TransformStack.cast(m)
.translate(blockInfo.pos);
.translate(blockInfo.pos());
movementBehaviour.renderInContraption(context, renderWorld, matrices, buffer);
m.popPose();
}

View file

@ -49,13 +49,13 @@ public class ContraptionInteractionPacket extends SimplePacketBase {
ServerPlayer sender = context.getSender();
if (sender == null)
return;
Entity entityByID = sender.getLevel().getEntity(target);
Entity entityByID = sender.level().getEntity(target);
if (!(entityByID instanceof AbstractContraptionEntity))
return;
AbstractContraptionEntity contraptionEntity = (AbstractContraptionEntity) entityByID;
AABB bb = contraptionEntity.getBoundingBox();
double boundsExtra = Math.max(bb.getXsize(), bb.getYsize());
double d = sender.getAttribute(ForgeMod.REACH_DISTANCE.get()).getValue() + 10 + boundsExtra;
double d = sender.getAttribute(ForgeMod.BLOCK_REACH.get()).getValue() + 10 + boundsExtra;
if (!sender.hasLineOfSight(entityByID))
d -= 3;
d *= d;

View file

@ -92,7 +92,7 @@ public class MetalLadderBlock extends LadderBlock implements IWrenchable {
int range = AllConfigs.server().equipment.placementAssistRange.get();
if (player != null) {
AttributeInstance reach = player.getAttribute(ForgeMod.REACH_DISTANCE.get());
AttributeInstance reach = player.getAttribute(ForgeMod.BLOCK_REACH.get());
if (reach != null && reach.hasModifier(ExtendoGripItem.singleRangeAttributeModifier))
range += 4;
}
@ -107,8 +107,7 @@ public class MetalLadderBlock extends LadderBlock implements IWrenchable {
if (!state.canSurvive(world, newPos))
return PlacementOffset.fail();
if (newState.getMaterial()
.isReplaceable())
if (newState.canBeReplaced())
return PlacementOffset.success(newPos, bState -> bState.setValue(FACING, state.getValue(FACING)));
return PlacementOffset.fail();
}

View file

@ -225,8 +225,7 @@ public class CopycatPanelBlock extends WaterloggedCopycatBlock {
state.getValue(FACING)
.getAxis(),
dir -> world.getBlockState(pos.relative(dir))
.getMaterial()
.isReplaceable());
.canBeReplaced());
if (directions.isEmpty())
return PlacementOffset.fail();

View file

@ -332,8 +332,7 @@ public class GirderBlock extends Block implements SimpleWaterloggedBlock, IWrenc
VoxelShape shape = blockState.getShape(world, relative);
if (shape.isEmpty())
return false;
if (Block.isFaceFull(shape, side.getOpposite()) && blockState.getMaterial()
.isSolidBlocking())
if (Block.isFaceFull(shape, side.getOpposite()) && blockState.isSolid())
return true;
return AbstractChuteBlock.getChuteFacing(blockState) == Direction.DOWN;
}

View file

@ -81,7 +81,7 @@ public class GirderPlacementHelper implements IPlacementHelper {
for (Direction dir : directions) {
int range = AllConfigs.server().equipment.placementAssistRange.get();
if (player != null) {
AttributeInstance reach = player.getAttribute(ForgeMod.REACH_DISTANCE.get());
AttributeInstance reach = player.getAttribute(ForgeMod.BLOCK_REACH.get());
if (reach != null && reach.hasModifier(ExtendoGripItem.singleRangeAttributeModifier))
range += 4;
}
@ -92,8 +92,7 @@ public class GirderPlacementHelper implements IPlacementHelper {
BlockPos newPos = pos.relative(dir, poles + 1);
BlockState newState = world.getBlockState(newPos);
if (!newState.getMaterial()
.isReplaceable())
if (!newState.canBeReplaced())
continue;
return PlacementOffset.success(newPos,

View file

@ -25,7 +25,7 @@ import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.GlassBlock;
import net.minecraft.world.level.block.state.properties.WoodType;
import net.minecraft.world.level.material.MaterialColor;
import net.minecraft.world.level.material.MapColor;
import net.minecraftforge.common.Tags;
public class AllPaletteBlocks {
@ -73,7 +73,7 @@ public class AllPaletteBlocks {
WARPED_WINDOW = woodenWindowBlock(WoodType.WARPED, Blocks.WARPED_PLANKS),
ORNATE_IRON_WINDOW =
customWindowBlock("ornate_iron_window", () -> Items.IRON_NUGGET, () -> AllSpriteShifts.ORNATE_IRON_WINDOW,
() -> RenderType::cutout, false, () -> MaterialColor.TERRACOTTA_LIGHT_GRAY);
() -> RenderType::cutout, false, () -> MapColor.TERRACOTTA_LIGHT_GRAY);
public static final BlockEntry<ConnectedGlassPaneBlock> OAK_WINDOW_PANE =
woodenWindowPane(WoodType.OAK, OAK_WINDOW),

View file

@ -15,7 +15,7 @@ import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.material.MaterialColor;
import net.minecraft.world.level.material.MapColor;
import net.minecraftforge.registries.ForgeRegistries;
public enum AllPaletteStoneTypes {
@ -30,35 +30,35 @@ public enum AllPaletteStoneTypes {
ASURINE(STANDARD_RANGE, r -> r.paletteStoneBlock("asurine", () -> Blocks.DEEPSLATE, true, true)
.properties(p -> p.destroyTime(1.25f)
.color(MaterialColor.COLOR_BLUE))
.mapColor(MapColor.COLOR_BLUE))
.register()),
CRIMSITE(STANDARD_RANGE, r -> r.paletteStoneBlock("crimsite", () -> Blocks.DEEPSLATE, true, true)
.properties(p -> p.destroyTime(1.25f)
.color(MaterialColor.COLOR_RED))
.mapColor(MapColor.COLOR_RED))
.register()),
LIMESTONE(STANDARD_RANGE, r -> r.paletteStoneBlock("limestone", () -> Blocks.SANDSTONE, true, false)
.properties(p -> p.destroyTime(1.25f)
.color(MaterialColor.SAND))
.mapColor(MapColor.SAND))
.register()),
OCHRUM(STANDARD_RANGE, r -> r.paletteStoneBlock("ochrum", () -> Blocks.CALCITE, true, true)
.properties(p -> p.destroyTime(1.25f)
.color(MaterialColor.TERRACOTTA_YELLOW))
.mapColor(MapColor.TERRACOTTA_YELLOW))
.register()),
SCORIA(STANDARD_RANGE, r -> r.paletteStoneBlock("scoria", () -> Blocks.BLACKSTONE, true, false)
.properties(p -> p.color(MaterialColor.COLOR_BROWN))
.properties(p -> p.mapColor(MapColor.COLOR_BROWN))
.register()),
SCORCHIA(STANDARD_RANGE, r -> r.paletteStoneBlock("scorchia", () -> Blocks.BLACKSTONE, true, false)
.properties(p -> p.color(MaterialColor.TERRACOTTA_GRAY))
.properties(p -> p.mapColor(MapColor.TERRACOTTA_GRAY))
.register()),
VERIDIUM(STANDARD_RANGE, r -> r.paletteStoneBlock("veridium", () -> Blocks.TUFF, true, true)
.properties(p -> p.destroyTime(1.25f)
.color(MaterialColor.WARPED_NYLIUM))
.mapColor(MapColor.WARPED_NYLIUM))
.register())
;

View file

@ -7,11 +7,11 @@ import com.simibubi.create.foundation.utility.AngleHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
import net.minecraft.client.renderer.entity.ItemRenderer;
import net.minecraft.core.Direction;
import net.minecraft.util.Mth;
import net.minecraft.world.item.ItemDisplayContext;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.AttachFace;
@ -46,7 +46,7 @@ public class PlacardRenderer extends SafeBlockEntityRenderer<PlacardBlockEntity>
.translate(0, 0, 4.5 / 16f)
.scale(blockItem ? .5f : .375f);
itemRenderer.renderStatic(heldItem, TransformType.FIXED, light, overlay, ms, buffer, 0);
itemRenderer.renderStatic(heldItem, ItemDisplayContext.FIXED, light, overlay, ms, buffer, 0);
ms.popPose();
}

View file

@ -49,7 +49,7 @@ public class SlidingDoorMovementBehaviour implements MovementBehaviour {
.get(context.localPos);
if (structureBlockInfo == null)
return;
boolean open = SlidingDoorBlockEntity.isOpen(structureBlockInfo.state);
boolean open = SlidingDoorBlockEntity.isOpen(structureBlockInfo.state());
if (!context.world.isClientSide())
tickOpen(context, open);
@ -78,26 +78,26 @@ public class SlidingDoorMovementBehaviour implements MovementBehaviour {
StructureBlockInfo info = contraption.getBlocks()
.get(pos);
if (info == null || !info.state.hasProperty(DoorBlock.OPEN))
if (info == null || !info.state().hasProperty(DoorBlock.OPEN))
return;
toggleDoor(pos, contraption, info);
if (shouldOpen)
context.world.playSound(null, new BlockPos(context.position), SoundEvents.IRON_DOOR_OPEN,
context.world.playSound(null, BlockPos.containing(context.position), SoundEvents.IRON_DOOR_OPEN,
SoundSource.BLOCKS, .125f, 1);
}
private void toggleDoor(BlockPos pos, Contraption contraption, StructureBlockInfo info) {
BlockState newState = info.state.cycle(DoorBlock.OPEN);
contraption.entity.setBlock(pos, new StructureBlockInfo(info.pos, newState, info.nbt));
BlockState newState = info.state().cycle(DoorBlock.OPEN);
contraption.entity.setBlock(pos, new StructureBlockInfo(info.pos(), newState, info.nbt()));
BlockPos otherPos = newState.getValue(DoorBlock.HALF) == DoubleBlockHalf.LOWER ? pos.above() : pos.below();
info = contraption.getBlocks()
.get(otherPos);
if (info != null && info.state.hasProperty(DoorBlock.OPEN)) {
newState = info.state.cycle(DoorBlock.OPEN);
contraption.entity.setBlock(otherPos, new StructureBlockInfo(info.pos, newState, info.nbt));
if (info != null && info.state().hasProperty(DoorBlock.OPEN)) {
newState = info.state().cycle(DoorBlock.OPEN);
contraption.entity.setBlock(otherPos, new StructureBlockInfo(info.pos(), newState, info.nbt()));
contraption.invalidateColliders();
}
}

View file

@ -156,8 +156,7 @@ public class WhistleBlock extends Block implements IBE<WhistleBlockEntity>, IWre
continue;
}
if (!blockState.getMaterial()
.isReplaceable())
if (!blockState.canBeReplaced())
return;
pLevel.setBlock(currentPos, AllBlocks.STEAM_WHISTLE_EXTENSION.getDefaultState()

View file

@ -63,7 +63,7 @@ public class BacktankArmorLayer<T extends LivingEntity, M extends EntityModel<T>
.rotateY(180)
.unCentre()
.translate(0, 6.5f / 16, 11f / 16)
.rotate(Direction.EAST, AngleHelper.rad(2 * AnimationTickHolder.getRenderTime(entity.level) % 360))
.rotate(Direction.EAST, AngleHelper.rad(2 * AnimationTickHolder.getRenderTime(entity.level()) % 360))
.translate(0, -6.5f / 16, -11f / 16);
cogs.forEntityRender()

View file

@ -63,8 +63,8 @@ public class BacktankUtil {
boolean depleted = threshold == 1;
MutableComponent component = Lang.translateDirect(depleted ? "backtank.depleted" : "backtank.low");
AllSoundEvents.DENY.play(player.level, null, player.blockPosition(), 1, 1.25f);
AllSoundEvents.STEAM.play(player.level, null, player.blockPosition(), .5f, .5f);
AllSoundEvents.DENY.play(player.level(), null, player.blockPosition(), 1, 1.25f);
AllSoundEvents.STEAM.play(player.level(), null, player.blockPosition(), .5f, .5f);
player.connection.send(new ClientboundSetTitlesAnimationPacket(10, 40, 10));
player.connection.send(new ClientboundSetSubtitleTextPacket(

View file

@ -50,9 +50,9 @@ public class DivingBootsItem extends BaseArmorItem {
Vec3 motion = entity.getDeltaMovement();
boolean isJumping = entity.jumping;
entity.setOnGround(entity.isOnGround() || entity.verticalCollision);
entity.setOnGround(entity.onGround() || entity.verticalCollision);
if (isJumping && entity.isOnGround()) {
if (isJumping && entity.onGround()) {
motion = motion.add(0, .5f, 0);
entity.setOnGround(false);
} else {
@ -90,7 +90,7 @@ public class DivingBootsItem extends BaseArmorItem {
double yMotion = entity.getDeltaMovement().y;
double vMultiplier = yMotion < 0 ? Math.max(0, 2.5 - Math.abs(yMotion) * 2) : 1;
if (!entity.isOnGround()) {
if (!entity.onGround()) {
if (entity.jumping && entity.getPersistentData()
.contains("LavaGrounded")) {
boolean eyeInFluid = entity.isEyeInFluid(FluidTags.LAVA);

View file

@ -75,7 +75,7 @@ public class DivingHelmetItem extends BaseArmorItem {
@SubscribeEvent
public static void breatheUnderwater(LivingTickEvent event) {
LivingEntity entity = event.getEntity();
Level world = entity.level;
Level world = entity.level();
boolean second = world.getGameTime() % 20 == 0;
boolean drowning = entity.getAirSupply() == 0;

View file

@ -55,9 +55,9 @@ public class HauntedBellPulser {
} catch (ExecutionException e) {
}
long gameTime = player.level.getGameTime();
long gameTime = player.level().getGameTime();
if (firstPulse || gameTime % RECHARGE_TICKS != 0)
sendPulse(player.level, event.player.blockPosition(), DISTANCE, false);
sendPulse(player.level(), event.player.blockPosition(), DISTANCE, false);
}
public static void sendPulse(Level world, BlockPos pos, int distance, boolean canOverlap) {

View file

@ -31,7 +31,7 @@ public class SoulBaseParticle extends CustomRotationParticle {
public void tick() {
selectSpriteLoopingWithAge(animatedSprite);
BlockPos pos = new BlockPos(x, y, z);
BlockPos pos = BlockPos.containing(x, y, z);
if (age++ >= lifetime || !SoulPulseEffect.isDark(level, pos))
remove();
}

View file

@ -72,7 +72,7 @@ public class SoulParticle extends CustomRotationParticle {
animationStage.tick();
animationStage = animationStage.getNext();
BlockPos pos = new BlockPos(x, y, z);
BlockPos pos = BlockPos.containing(x, y, z);
if (animationStage == null)
remove();
if (!SoulPulseEffect.isDark(level, pos)) {

View file

@ -32,7 +32,7 @@ public class BlueprintAssignCompleteRecipePacket extends SimplePacketBase {
return;
if (player.containerMenu instanceof BlueprintMenu) {
BlueprintMenu c = (BlueprintMenu) player.containerMenu;
player.getLevel()
player.level()
.getRecipeManager()
.byKey(recipeID)
.ifPresent(r -> BlueprintItem.assignCompleteRecipe(c.ghostInventory, r));

View file

@ -209,7 +209,7 @@ public class BlueprintEntity extends HangingEntity
@Override
public boolean survives() {
if (!level.noCollision(this))
if (!level().noCollision(this))
return false;
int i = Math.max(1, this.getWidth() / 16);
@ -229,17 +229,16 @@ public class BlueprintEntity extends HangingEntity
blockpos$mutable.set(blockpos)
.move(newDirection, k + i1)
.move(upDirection, l + j1);
BlockState blockstate = this.level.getBlockState(blockpos$mutable);
if (Block.canSupportCenter(this.level, blockpos$mutable, this.direction))
BlockState blockstate = this.level().getBlockState(blockpos$mutable);
if (Block.canSupportCenter(this.level(), blockpos$mutable, this.direction))
continue;
if (!blockstate.getMaterial()
.isSolid() && !DiodeBlock.isDiode(blockstate)) {
if (!blockstate.isSolid() && !DiodeBlock.isDiode(blockstate)) {
return false;
}
}
}
return this.level.getEntities(this, this.getBoundingBox(), HANGING_ENTITY)
return this.level().getEntities(this, this.getBoundingBox(), HANGING_ENTITY)
.isEmpty();
}
@ -255,11 +254,11 @@ public class BlueprintEntity extends HangingEntity
@Override
public boolean skipAttackInteraction(Entity source) {
if (!(source instanceof Player) || level.isClientSide)
if (!(source instanceof Player) || level().isClientSide)
return super.skipAttackInteraction(source);
Player player = (Player) source;
double attrib = player.getAttribute(ForgeMod.REACH_DISTANCE.get())
double attrib = player.getAttribute(ForgeMod.BLOCK_REACH.get())
.getValue() + (player.isCreative() ? 0 : -0.5F);
Vec3 eyePos = source.getEyePosition(1);
@ -285,7 +284,7 @@ public class BlueprintEntity extends HangingEntity
@Override
public void dropItem(@Nullable Entity p_110128_1_) {
if (!level.getGameRules()
if (!level().getGameRules()
.getBoolean(GameRules.RULE_DOENTITYDROPS))
return;
@ -324,7 +323,7 @@ public class BlueprintEntity extends HangingEntity
public void lerpTo(double p_180426_1_, double p_180426_3_, double p_180426_5_, float p_180426_7_, float p_180426_8_,
int p_180426_9_, boolean p_180426_10_) {
BlockPos blockpos =
this.pos.offset(p_180426_1_ - this.getX(), p_180426_3_ - this.getY(), p_180426_5_ - this.getZ());
this.pos.offset(BlockPos.containing(p_180426_1_ - this.getX(), p_180426_3_ - this.getY(), p_180426_5_ - this.getZ()));
this.setPos((double) blockpos.getX(), (double) blockpos.getY(), (double) blockpos.getZ());
}
@ -351,7 +350,7 @@ public class BlueprintEntity extends HangingEntity
BlueprintSection section = getSectionAt(vec);
ItemStackHandler items = section.getItems();
if (!holdingWrench && !level.isClientSide && !items.getStackInSlot(9)
if (!holdingWrench && !level().isClientSide && !items.getStackInSlot(9)
.isEmpty()) {
IItemHandlerModifiable playerInv = new InvWrapper(player.getInventory());
@ -373,7 +372,7 @@ public class BlueprintEntity extends HangingEntity
}
for (int slot = 0; slot < playerInv.getSlots(); slot++) {
if (!FilterItem.test(level, playerInv.getStackInSlot(slot), requestedItem))
if (!FilterItem.test(level(), playerInv.getStackInSlot(slot), requestedItem))
continue;
ItemStack currentItem = playerInv.extractItem(slot, 1, false);
if (stacksTaken.containsKey(slot))
@ -393,9 +392,9 @@ public class BlueprintEntity extends HangingEntity
CraftingContainer craftingInventory = new BlueprintCraftingInventory(craftingGrid);
if (!recipe.isPresent())
recipe = level.getRecipeManager()
.getRecipeFor(RecipeType.CRAFTING, craftingInventory, level);
ItemStack result = recipe.filter(r -> r.matches(craftingInventory, level))
recipe = level().getRecipeManager()
.getRecipeFor(RecipeType.CRAFTING, craftingInventory, level());
ItemStack result = recipe.filter(r -> r.matches(craftingInventory, level()))
.map(r -> r.assemble(craftingInventory))
.orElse(ItemStack.EMPTY);
@ -405,13 +404,13 @@ public class BlueprintEntity extends HangingEntity
success = false;
} else {
amountCrafted += result.getCount();
result.onCraftedBy(player.level, player, 1);
result.onCraftedBy(player.level(), player, 1);
ForgeEventFactory.firePlayerCraftingEvent(player, result, craftingInventory);
NonNullList<ItemStack> nonnulllist = level.getRecipeManager()
.getRemainingItemsFor(RecipeType.CRAFTING, craftingInventory, level);
NonNullList<ItemStack> nonnulllist = level().getRecipeManager()
.getRemainingItemsFor(RecipeType.CRAFTING, craftingInventory, level());
if (firstPass)
level.playSound(null, player.blockPosition(), SoundEvents.ITEM_PICKUP, SoundSource.PLAYERS,
level().playSound(null, player.blockPosition(), SoundEvents.ITEM_PICKUP, SoundSource.PLAYERS,
.2f, 1f + Create.RANDOM.nextFloat());
player.getInventory()
.placeItemBackInInventory(result);
@ -434,7 +433,7 @@ public class BlueprintEntity extends HangingEntity
}
int i = section.index;
if (!level.isClientSide && player instanceof ServerPlayer) {
if (!level().isClientSide && player instanceof ServerPlayer) {
NetworkHooks.openScreen((ServerPlayer) player, section, buf -> {
buf.writeVarInt(getId());
buf.writeVarInt(i);
@ -530,7 +529,7 @@ public class BlueprintEntity extends HangingEntity
list.put(index + "", inventory.serializeNBT());
list.putBoolean("InferredIcon", inferredIcon);
cachedDisplayItems = null;
if (!level.isClientSide)
if (!level().isClientSide)
syncPersistentDataWithTracking(BlueprintEntity.this);
}
@ -539,7 +538,7 @@ public class BlueprintEntity extends HangingEntity
}
public Level getBlueprintWorld() {
return level;
return level();
}
@Override

View file

@ -14,12 +14,12 @@ import com.simibubi.create.foundation.utility.Couple;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.Sheets;
import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType;
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.world.item.ItemDisplayContext;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Blocks;
@ -106,7 +106,7 @@ public class BlueprintRenderer extends EntityRenderer<BlueprintEntity> {
Minecraft.getInstance()
.getItemRenderer()
.renderStatic(stack, TransformType.GUI, itemLight, OverlayTexture.NO_OVERLAY, squashedMS, buffer, 0);
.renderStatic(stack, ItemDisplayContext.GUI, itemLight, OverlayTexture.NO_OVERLAY, squashedMS, buffer, 0);
squashedMS.popPose();
});
squashedMS.popPose();

View file

@ -80,8 +80,7 @@ public class ClipboardBlock extends FaceAttachedHorizontalDirectionalBlock
public boolean canSurvive(BlockState pState, LevelReader pLevel, BlockPos pPos) {
return !pLevel.getBlockState(pPos.relative(getConnectedDirection(pState).getOpposite()))
.getMaterial()
.isReplaceable();
.canBeReplaced();
}
@Override

View file

@ -47,7 +47,7 @@ public class ClipboardEditPacket extends SimplePacketBase {
ServerPlayer sender = context.getSender();
if (targetedBlock != null) {
Level world = sender.level;
Level world = sender.level();
if (world == null || !world.isLoaded(targetedBlock))
return;
if (!targetedBlock.closerThan(sender.blockPosition(), 20))

View file

@ -34,7 +34,7 @@ import net.minecraft.SharedConstants;
import net.minecraft.Util;
import net.minecraft.client.StringSplitter;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.GuiComponent;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.font.TextFieldHelper;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.inventory.PageButton;
@ -524,7 +524,7 @@ public class ClipboardScreen extends AbstractSimiScreen {
return;
pCursorPos = convertLocalToScreen(pCursorPos);
if (!pIsEndOfText) {
GuiComponent.fill(pPoseStack, pCursorPos.x, pCursorPos.y - 1, pCursorPos.x + 1, pCursorPos.y + 9,
GuiGraphics.fill(pPoseStack, pCursorPos.x, pCursorPos.y - 1, pCursorPos.x + 1, pCursorPos.y + 9,
-16777216);
} else {
font.draw(pPoseStack, "_", (float) pCursorPos.x, (float) pCursorPos.y, 0);

View file

@ -56,10 +56,10 @@ public class ExtendoGripInteractionPacket extends SimplePacketBase {
ServerPlayer sender = context.getSender();
if (sender == null)
return;
Entity entityByID = sender.getLevel()
Entity entityByID = sender.level()
.getEntity(target);
if (entityByID != null && ExtendoGripItem.isHoldingExtendoGrip(sender)) {
double d = sender.getAttribute(ForgeMod.REACH_DISTANCE.get())
double d = sender.getAttribute(ForgeMod.BLOCK_REACH.get())
.getValue();
if (!sender.hasLineOfSight(entityByID))
d -= 3;

View file

@ -64,10 +64,10 @@ public class ExtendoGripItem extends Item {
private static final Supplier<Multimap<Attribute, AttributeModifier>> rangeModifier = Suppliers.memoize(() ->
// Holding an ExtendoGrip
ImmutableMultimap.of(ForgeMod.REACH_DISTANCE.get(), singleRangeAttributeModifier));
ImmutableMultimap.of(ForgeMod.BLOCK_REACH.get(), singleRangeAttributeModifier));
private static final Supplier<Multimap<Attribute, AttributeModifier>> doubleRangeModifier = Suppliers.memoize(() ->
// Holding two ExtendoGrips o.O
ImmutableMultimap.of(ForgeMod.REACH_DISTANCE.get(), doubleRangeAttributeModifier));
ImmutableMultimap.of(ForgeMod.BLOCK_REACH.get(), doubleRangeAttributeModifier));
private static DamageSource lastActiveDamageSource;
@ -148,7 +148,7 @@ public class ExtendoGripItem extends Item {
return;
// Modified version of GameRenderer#getMouseOver
double d0 = player.getAttribute(ForgeMod.REACH_DISTANCE.get())
double d0 = player.getAttribute(ForgeMod.BLOCK_REACH.get())
.getValue();
if (!player.isCreative())
d0 -= 0.5f;
@ -194,7 +194,7 @@ public class ExtendoGripItem extends Item {
private static void findAndDamageExtendoGrip(Player player) {
if (player == null)
return;
if (player.level.isClientSide)
if (player.level().isClientSide)
return;
InteractionHand hand = InteractionHand.MAIN_HAND;
ItemStack extendo = player.getMainHandItem();
@ -258,7 +258,7 @@ public class ExtendoGripItem extends Item {
// Server ignores entity interaction further than 6m
if (entity.distanceToSqr(target) < 36)
return false;
if (!entity.level.isClientSide)
if (!entity.level().isClientSide)
return false;
if (!(entity instanceof Player))
return false;

View file

@ -11,8 +11,8 @@ import com.simibubi.create.foundation.item.render.PartialItemModelRenderer;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType;
import net.minecraft.util.Mth;
import net.minecraft.world.item.ItemDisplayContext;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.phys.Vec3;
@ -28,12 +28,12 @@ public class ExtendoGripItemRenderer extends CustomRenderedItemModelRenderer {
private static final Vec3 COG_ROTATION_OFFSET = new Vec3(0, 1 / 16f, 0);
@Override
protected void render(ItemStack stack, CustomRenderedItemModel model, PartialItemModelRenderer renderer, TransformType transformType,
protected void render(ItemStack stack, CustomRenderedItemModel model, PartialItemModelRenderer renderer, ItemDisplayContext transformType,
PoseStack ms, MultiBufferSource buffer, int light, int overlay) {
TransformStack stacker = TransformStack.cast(ms);
float animation = 0.25f;
boolean leftHand = transformType == TransformType.FIRST_PERSON_LEFT_HAND;
boolean rightHand = transformType == TransformType.FIRST_PERSON_RIGHT_HAND;
boolean leftHand = transformType == ItemDisplayContext.FIRST_PERSON_LEFT_HAND;
boolean rightHand = transformType == ItemDisplayContext.FIRST_PERSON_RIGHT_HAND;
if (leftHand || rightHand)
animation = Mth.lerp(AnimationTickHolder.getPartialTicks(),
ExtendoGripRenderHandler.lastMainHandAnimation,

View file

@ -12,12 +12,12 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.player.AbstractClientPlayer;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.renderer.ItemInHandRenderer;
import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType;
import net.minecraft.client.renderer.entity.player.PlayerRenderer;
import net.minecraft.util.Mth;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.HumanoidArm;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.ItemDisplayContext;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.ForgeHooksClient;
@ -110,8 +110,8 @@ public class ExtendoGripRenderHandler {
ms.pushPose();
ms.translate(flip * -0.1f, 0, -0.3f);
ItemInHandRenderer firstPersonRenderer = mc.getEntityRenderDispatcher().getItemInHandRenderer();
TransformType transform =
rightHand ? TransformType.FIRST_PERSON_RIGHT_HAND : TransformType.FIRST_PERSON_LEFT_HAND;
ItemDisplayContext transform =
rightHand ? ItemDisplayContext.FIRST_PERSON_RIGHT_HAND : ItemDisplayContext.FIRST_PERSON_LEFT_HAND;
firstPersonRenderer.renderItem(mc.player, notInOffhand ? heldItem : offhandItem, transform, !rightHand,
event.getPoseStack(), event.getMultiBufferSource(), event.getPackedLight());

View file

@ -3,8 +3,8 @@ package com.simibubi.create.content.equipment.goggles;
import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.AllPartialModels;
import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.world.item.ItemDisplayContext;
import net.minecraftforge.client.model.BakedModelWrapper;
public class GogglesModel extends BakedModelWrapper<BakedModel> {
@ -14,11 +14,11 @@ public class GogglesModel extends BakedModelWrapper<BakedModel> {
}
@Override
public BakedModel applyTransform(TransformType cameraTransformType, PoseStack mat, boolean leftHanded) {
if (cameraTransformType == TransformType.HEAD)
public BakedModel applyTransform(ItemDisplayContext cameraItemDisplayContext, PoseStack mat, boolean leftHanded) {
if (cameraItemDisplayContext == ItemDisplayContext.HEAD)
return AllPartialModels.GOGGLES.get()
.applyTransform(cameraTransformType, mat, leftHanded);
return super.applyTransform(cameraTransformType, mat, leftHanded);
.applyTransform(cameraItemDisplayContext, mat, leftHanded);
return super.applyTransform(cameraItemDisplayContext, mat, leftHanded);
}
}

View file

@ -160,7 +160,7 @@ public class BuiltinPotatoProjectileTypes {
.soundPitch(1.1f)
.onEntityHit(ray -> {
Entity entity = ray.getEntity();
Level world = entity.level;
Level world = entity.level();
if (!(entity instanceof ZombieVillager) || !((ZombieVillager) entity).hasEffect(MobEffects.WEAKNESS))
return foodEffects(Foods.GOLDEN_APPLE, false).test(ray);
@ -271,7 +271,7 @@ public class BuiltinPotatoProjectileTypes {
private static Predicate<EntityHitResult> potion(MobEffect effect, int level, int ticks, boolean recoverable) {
return ray -> {
Entity entity = ray.getEntity();
if (entity.level.isClientSide)
if (entity.level().isClientSide)
return true;
if (entity instanceof LivingEntity)
applyEffect((LivingEntity) entity, new MobEffectInstance(effect, ticks, level - 1));
@ -282,7 +282,7 @@ public class BuiltinPotatoProjectileTypes {
private static Predicate<EntityHitResult> foodEffects(FoodProperties food, boolean recoverable) {
return ray -> {
Entity entity = ray.getEntity();
if (entity.level.isClientSide)
if (entity.level().isClientSide)
return true;
if (entity instanceof LivingEntity) {
@ -315,8 +315,7 @@ public class BuiltinPotatoProjectileTypes {
Direction face = ray.getDirection();
BlockPos placePos = hitPos.relative(face);
if (!world.getBlockState(placePos)
.getMaterial()
.isReplaceable())
.canBeReplaced())
return false;
if (!(cropBlock.get() instanceof IPlantable))
return false;
@ -345,8 +344,7 @@ public class BuiltinPotatoProjectileTypes {
Direction face = ray.getDirection();
BlockPos placePos = hitPos.relative(face);
if (!world.getBlockState(placePos)
.getMaterial()
.isReplaceable())
.canBeReplaced())
return false;
if (face == Direction.UP) {

View file

@ -14,11 +14,11 @@ import com.simibubi.create.foundation.utility.AnimationTickHolder;
import net.minecraft.client.Minecraft;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType;
import net.minecraft.client.renderer.entity.ItemRenderer;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.HumanoidArm;
import net.minecraft.world.item.ItemDisplayContext;
import net.minecraft.world.item.ItemStack;
public class PotatoCannonItemRenderer extends CustomRenderedItemModelRenderer {
@ -27,7 +27,7 @@ public class PotatoCannonItemRenderer extends CustomRenderedItemModelRenderer {
@Override
protected void render(ItemStack stack, CustomRenderedItemModel model, PartialItemModelRenderer renderer,
TransformType transformType, PoseStack ms, MultiBufferSource buffer, int light, int overlay) {
ItemDisplayContext transformType, PoseStack ms, MultiBufferSource buffer, int light, int overlay) {
ItemRenderer itemRenderer = Minecraft.getInstance()
.getItemRenderer();
renderer.render(model.getOriginalModel(), light);
@ -53,7 +53,7 @@ public class PotatoCannonItemRenderer extends CustomRenderedItemModelRenderer {
renderer.render(COG.get(), light);
ms.popPose();
if (transformType == TransformType.GUI) {
if (transformType == ItemDisplayContext.GUI) {
PotatoCannonItem.getAmmoforPreview(stack)
.ifPresent(ammo -> {
PoseStack localMs = new PoseStack();
@ -61,7 +61,7 @@ public class PotatoCannonItemRenderer extends CustomRenderedItemModelRenderer {
localMs.scale(.5f, .5f, .5f);
TransformStack.cast(localMs)
.rotateY(-34);
itemRenderer.renderStatic(ammo, TransformType.GUI, light, OverlayTexture.NO_OVERLAY, localMs, buffer, 0);
itemRenderer.renderStatic(ammo, ItemDisplayContext.GUI, light, OverlayTexture.NO_OVERLAY, localMs, buffer, 0);
});
}

View file

@ -208,7 +208,7 @@ public class PotatoProjectileEntity extends AbstractHurtingProjectile implements
if (this.isOnFire() && !targetIsEnderman)
target.setSecondsOnFire(5);
boolean onServer = !level.isClientSide;
boolean onServer = !level().isClientSide;
if (onServer && !target.hurt(causePotatoDamage(), damage)) {
target.setRemainingFireTicks(k);
kill();
@ -223,7 +223,7 @@ public class PotatoProjectileEntity extends AbstractHurtingProjectile implements
recoverItem();
if (!(target instanceof LivingEntity)) {
playHitSound(level, position());
playHitSound(level(), position());
kill();
return;
}
@ -274,7 +274,7 @@ public class PotatoProjectileEntity extends AbstractHurtingProjectile implements
}
public static void playHitSound(Level world, Vec3 location) {
AllSoundEvents.POTATO_HIT.playOnServer(world, new BlockPos(location));
AllSoundEvents.POTATO_HIT.playOnServer(world, BlockPos.containing(location));
}
public static void playLaunchSound(Level world, Vec3 location, float pitch) {
@ -285,7 +285,7 @@ public class PotatoProjectileEntity extends AbstractHurtingProjectile implements
protected void onHitBlock(BlockHitResult ray) {
Vec3 hit = ray.getLocation();
pop(hit);
if (!getProjectileType().onBlockHit(level, ray) && !level.isClientSide)
if (!getProjectileType().onBlockHit(level(), ray) && !level().isClientSide)
if (random.nextDouble() <= recoveryChance)
recoverItem();
super.onHitBlock(ray);
@ -307,12 +307,12 @@ public class PotatoProjectileEntity extends AbstractHurtingProjectile implements
if (!stack.isEmpty()) {
for (int i = 0; i < 7; i++) {
Vec3 m = VecHelper.offsetRandomly(Vec3.ZERO, this.random, .25f);
level.addParticle(new ItemParticleOption(ParticleTypes.ITEM, stack), hit.x, hit.y, hit.z, m.x, m.y,
level().addParticle(new ItemParticleOption(ParticleTypes.ITEM, stack), hit.x, hit.y, hit.z, m.x, m.y,
m.z);
}
}
if (!level.isClientSide)
playHitSound(level, position());
if (!level().isClientSide)
playHitSound(level(), position());
}
private DamageSource causePotatoDamage() {

View file

@ -4,11 +4,11 @@ import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType;
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemDisplayContext;
import net.minecraft.world.item.ItemStack;
public class PotatoProjectileRenderer extends EntityRenderer<PotatoProjectileEntity> {
@ -31,7 +31,7 @@ public class PotatoProjectileRenderer extends EntityRenderer<PotatoProjectileEnt
Minecraft.getInstance()
.getItemRenderer()
.renderStatic(item, TransformType.GROUND, light, OverlayTexture.NO_OVERLAY, ms, buffer, 0);
.renderStatic(item, ItemDisplayContext.GROUND, light, OverlayTexture.NO_OVERLAY, ms, buffer, 0);
ms.popPose();
}

View file

@ -10,23 +10,23 @@ import com.simibubi.create.foundation.utility.AnimationTickHolder;
import net.minecraft.client.Minecraft;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType;
import net.minecraft.client.renderer.entity.ItemRenderer;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.Mth;
import net.minecraft.world.item.ItemDisplayContext;
import net.minecraft.world.item.ItemStack;
public class SandPaperItemRenderer extends CustomRenderedItemModelRenderer {
@Override
protected void render(ItemStack stack, CustomRenderedItemModel model, PartialItemModelRenderer renderer,
TransformType transformType, PoseStack ms, MultiBufferSource buffer, int light, int overlay) {
ItemDisplayContext transformType, PoseStack ms, MultiBufferSource buffer, int light, int overlay) {
ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer();
LocalPlayer player = Minecraft.getInstance().player;
float partialTicks = AnimationTickHolder.getPartialTicks();
boolean leftHand = transformType == TransformType.FIRST_PERSON_LEFT_HAND;
boolean firstPerson = leftHand || transformType == TransformType.FIRST_PERSON_RIGHT_HAND;
boolean leftHand = transformType == ItemDisplayContext.FIRST_PERSON_LEFT_HAND;
boolean firstPerson = leftHand || transformType == ItemDisplayContext.FIRST_PERSON_RIGHT_HAND;
CompoundTag tag = stack.getOrCreateTag();
boolean jeiMode = tag.contains("JEI");
@ -36,7 +36,7 @@ public class SandPaperItemRenderer extends CustomRenderedItemModelRenderer {
if (tag.contains("Polishing")) {
ms.pushPose();
if (transformType == TransformType.GUI) {
if (transformType == ItemDisplayContext.GUI) {
ms.translate(0.0F, .2f, 1.0F);
ms.scale(.75f, .75f, .75f);
} else {
@ -50,14 +50,14 @@ public class SandPaperItemRenderer extends CustomRenderedItemModelRenderer {
if (time / (float) stack.getUseDuration() < 0.8F) {
float bobbing = -Mth.abs(Mth.cos(time / 4.0F * (float) Math.PI) * 0.1F);
if (transformType == TransformType.GUI)
if (transformType == ItemDisplayContext.GUI)
ms.translate(bobbing, bobbing, 0.0F);
else
ms.translate(0.0f, bobbing, 0.0F);
}
ItemStack toPolish = ItemStack.of(tag.getCompound("Polishing"));
itemRenderer.renderStatic(toPolish, TransformType.NONE, light, overlay, ms, buffer, 0);
itemRenderer.renderStatic(toPolish, ItemDisplayContext.NONE, light, overlay, ms, buffer, 0);
ms.popPose();
}
@ -73,7 +73,7 @@ public class SandPaperItemRenderer extends CustomRenderedItemModelRenderer {
}
}
itemRenderer.render(stack, TransformType.NONE, false, ms, buffer, light, overlay, model.getOriginalModel());
itemRenderer.render(stack, ItemDisplayContext.NONE, false, ms, buffer, light, overlay, model.getOriginalModel());
ms.popPose();
}

View file

@ -61,7 +61,7 @@ public class SymmetryHandler {
.isEmpty()
&& inv.getItem(i)
.getItem() == AllItems.WAND_OF_SYMMETRY.get()) {
SymmetryWandItem.apply(player.level, inv.getItem(i), player, event.getPos(), event.getPlacedBlock());
SymmetryWandItem.apply(player.level(), inv.getItem(i), player, event.getPos(), event.getPlacedBlock());
}
}
}
@ -77,7 +77,7 @@ public class SymmetryHandler {
for (int i = 0; i < Inventory.getSelectionSize(); i++) {
if (!inv.getItem(i)
.isEmpty() && AllItems.WAND_OF_SYMMETRY.isIn(inv.getItem(i))) {
SymmetryWandItem.remove(player.level, inv.getItem(i), player, event.getPos());
SymmetryWandItem.remove(player.level(), inv.getItem(i), player, event.getPos());
}
}
}
@ -100,7 +100,7 @@ public class SymmetryHandler {
if (mirror instanceof EmptyMirror)
continue;
BlockPos pos = new BlockPos(mirror.getPosition());
BlockPos pos = BlockPos.containing(mirror.getPosition());
float yShift = 0;
double speed = 1 / 16d;
@ -122,7 +122,7 @@ public class SymmetryHandler {
mc.getBlockRenderer()
.getModelRenderer()
.tesselateBlock(player.level, model, Blocks.AIR.defaultBlockState(), pos, ms, builder, true,
.tesselateBlock(player.level(), model, Blocks.AIR.defaultBlockState(), pos, ms, builder, true,
random, Mth.getSeed(pos), OverlayTexture.NO_OVERLAY, ModelData.EMPTY, RenderType.solid());
ms.popPose();

Some files were not shown because too many files have changed in this diff Show more