Merge branch 'mc1.18/dev' into mc1.19/dev

This commit is contained in:
simibubi 2023-05-24 18:03:43 +02:00
commit 1c30b235dd
149 changed files with 4756 additions and 2680 deletions

View file

@ -49,6 +49,7 @@ body:
label: Mod Version
description: The version of the mod you were using when the bug occured
options:
- "0.5.1b"
- "0.5.1a"
- "0.5.0i"
- "0.5.0h"

View file

@ -4,7 +4,7 @@ org.gradle.jvmargs = -Xmx3G
org.gradle.daemon = false
# mod version info
mod_version = 0.5.1.a
mod_version = 0.5.1.b
artifact_minecraft_version = 1.19.2
minecraft_version = 1.19.2

View file

@ -890,6 +890,9 @@
"itemGroup.create.base": "Create",
"itemGroup.create.palettes": "Create's Building Blocks",
"block.create.mangrove_window": "Mangrove Window",
"block.create.mangrove_window_pane": "Mangrove Window Pane",
"death.attack.create.crush": "%1$s was processed by Crushing Wheels",
"death.attack.create.crush.player": "%1$s was thrown into Crushing Wheels by %2$s",
"death.attack.create.fan_fire": "%1$s got smoked by an Encased Fan",
@ -2527,7 +2530,7 @@
"create.ponder.encased_fluid_pipe.header": "Encasing Fluid Pipes",
"create.ponder.encased_fluid_pipe.text_1": "Copper Casing can be used to decorate Fluid Pipes",
"create.ponder.encased_fluid_pipe.text_2": "Aside from being conceiled, Encased Pipes are locked into their connectivity state",
"create.ponder.encased_fluid_pipe.text_2": "Aside from being concealed, Encased Pipes are locked into their connectivity state",
"create.ponder.encased_fluid_pipe.text_3": "It will no longer react to any neighbouring blocks being added or removed",
"create.ponder.fan_direction.header": "Air flow of Encased Fans",
@ -2995,7 +2998,7 @@
"create.ponder.smart_chute.text_4": "Redstone power will prevent Smart Chutes from acting.",
"create.ponder.smart_observer.header": "Advanced detection with Smart Observers",
"create.ponder.smart_observer.text_1": "Smart Observers can be used detect a variety of events",
"create.ponder.smart_observer.text_1": "Smart Observers can be used to detect a variety of events",
"create.ponder.smart_observer.text_2": "It can detect items or fluids inside of generic containers",
"create.ponder.smart_observer.text_3": "The filter slot can be used to look for specific contents only",
"create.ponder.smart_observer.text_4": "It also activates when the block itself matches the filter",

View file

@ -1,5 +1,5 @@
{
"parent": "minecraft:block/iron_bars_cap",
"parent": "create:block/bars/cap",
"textures": {
"bars": "create:block/bars/andesite_bars",
"edge": "create:block/bars/andesite_bars_edge",

View file

@ -1,5 +1,5 @@
{
"parent": "minecraft:block/iron_bars_cap_alt",
"parent": "create:block/bars/cap_alt",
"textures": {
"bars": "create:block/bars/andesite_bars",
"edge": "create:block/bars/andesite_bars_edge",

View file

@ -1,5 +1,5 @@
{
"parent": "minecraft:block/iron_bars_post",
"parent": "create:block/bars/post",
"textures": {
"bars": "create:block/bars/andesite_bars",
"edge": "create:block/bars/andesite_bars_edge",

View file

@ -1,5 +1,5 @@
{
"parent": "minecraft:block/iron_bars_post_ends",
"parent": "create:block/bars/post_ends",
"textures": {
"bars": "create:block/bars/andesite_bars",
"edge": "create:block/bars/andesite_bars_edge",

View file

@ -1,5 +1,5 @@
{
"parent": "minecraft:block/iron_bars_side",
"parent": "create:block/bars/side",
"textures": {
"bars": "create:block/bars/andesite_bars",
"edge": "create:block/bars/andesite_bars_edge",

View file

@ -1,5 +1,5 @@
{
"parent": "minecraft:block/iron_bars_side_alt",
"parent": "create:block/bars/side_alt",
"textures": {
"bars": "create:block/bars/andesite_bars",
"edge": "create:block/bars/andesite_bars_edge",

View file

@ -1,5 +1,5 @@
{
"parent": "minecraft:block/iron_bars_cap",
"parent": "create:block/bars/cap",
"textures": {
"bars": "create:block/bars/brass_bars",
"edge": "create:block/bars/brass_bars_edge",

View file

@ -1,5 +1,5 @@
{
"parent": "minecraft:block/iron_bars_cap_alt",
"parent": "create:block/bars/cap_alt",
"textures": {
"bars": "create:block/bars/brass_bars",
"edge": "create:block/bars/brass_bars_edge",

View file

@ -1,5 +1,5 @@
{
"parent": "minecraft:block/iron_bars_post",
"parent": "create:block/bars/post",
"textures": {
"bars": "create:block/bars/brass_bars",
"edge": "create:block/bars/brass_bars_edge",

View file

@ -1,5 +1,5 @@
{
"parent": "minecraft:block/iron_bars_post_ends",
"parent": "create:block/bars/post_ends",
"textures": {
"bars": "create:block/bars/brass_bars",
"edge": "create:block/bars/brass_bars_edge",

View file

@ -1,5 +1,5 @@
{
"parent": "minecraft:block/iron_bars_side",
"parent": "create:block/bars/side",
"textures": {
"bars": "create:block/bars/brass_bars",
"edge": "create:block/bars/brass_bars_edge",

View file

@ -1,5 +1,5 @@
{
"parent": "minecraft:block/iron_bars_side_alt",
"parent": "create:block/bars/side_alt",
"textures": {
"bars": "create:block/bars/brass_bars",
"edge": "create:block/bars/brass_bars_edge",

View file

@ -1,5 +1,5 @@
{
"parent": "minecraft:block/iron_bars_cap",
"parent": "create:block/bars/cap",
"textures": {
"bars": "create:block/bars/copper_bars",
"edge": "create:block/bars/copper_bars_edge",

View file

@ -1,5 +1,5 @@
{
"parent": "minecraft:block/iron_bars_cap_alt",
"parent": "create:block/bars/cap_alt",
"textures": {
"bars": "create:block/bars/copper_bars",
"edge": "create:block/bars/copper_bars_edge",

View file

@ -1,5 +1,5 @@
{
"parent": "minecraft:block/iron_bars_post",
"parent": "create:block/bars/post",
"textures": {
"bars": "create:block/bars/copper_bars",
"edge": "create:block/bars/copper_bars_edge",

View file

@ -1,5 +1,5 @@
{
"parent": "minecraft:block/iron_bars_post_ends",
"parent": "create:block/bars/post_ends",
"textures": {
"bars": "create:block/bars/copper_bars",
"edge": "create:block/bars/copper_bars_edge",

View file

@ -1,5 +1,5 @@
{
"parent": "minecraft:block/iron_bars_side",
"parent": "create:block/bars/side",
"textures": {
"bars": "create:block/bars/copper_bars",
"edge": "create:block/bars/copper_bars_edge",

View file

@ -1,5 +1,5 @@
{
"parent": "minecraft:block/iron_bars_side_alt",
"parent": "create:block/bars/side_alt",
"textures": {
"bars": "create:block/bars/copper_bars",
"edge": "create:block/bars/copper_bars_edge",

View file

@ -23,8 +23,6 @@
"create:pulse_repeater",
"create:pulse_extender",
"create:clipboard",
"create:copycat_step",
"create:copycat_panel",
"#minecraft:banners",
"#minecraft:signs"
]

View file

@ -160,6 +160,9 @@
"create:andesite_ladder",
"create:brass_ladder",
"create:copper_ladder",
"create:andesite_bars",
"create:brass_bars",
"create:copper_bars",
"create:andesite_scaffolding",
"create:brass_scaffolding",
"create:copper_scaffolding",

View file

@ -787,6 +787,7 @@ public class AllBlocks {
.properties(p -> p.color(MaterialColor.COLOR_GRAY))
.properties(p -> p.sound(SoundType.NETHERITE_BLOCK))
.properties(p -> p.noOcclusion())
.properties(p -> p.isRedstoneConductor((level, pos, state) -> false))
.transform(pickaxeOnly())
.blockstate((c, p) -> BlockStateGen.simpleBlock(c, p, AssetLookup.forPowered(c, p)))
.item()

View file

@ -55,7 +55,8 @@ public class AllBogeyStyles {
public static void register() {}
public static class BogeyStyleBuilder {
protected final Map<BogeySizes.BogeySize, Supplier<BogeyStyle.SizeData>> sizes = new HashMap<>();
protected final Map<BogeySizes.BogeySize, Supplier<BogeyStyle.SizeRenderData>> sizeRenderers = new HashMap<>();
protected final Map<BogeySizes.BogeySize, ResourceLocation> sizes = new HashMap<>();
protected final ResourceLocation name;
protected final ResourceLocation cycleGroup;
@ -94,8 +95,9 @@ public class AllBogeyStyles {
public BogeyStyleBuilder size(BogeySizes.BogeySize size, Supplier<Supplier<? extends BogeyRenderer>> renderer,
ResourceLocation location) {
this.sizes.put(size, location);
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> {
this.sizes.put(size, () -> new BogeyStyle.SizeData(location, renderer.get(), renderer.get()
this.sizeRenderers.put(size, () -> new BogeyStyle.SizeRenderData(renderer.get(), renderer.get()
.get()));
});
return this;
@ -120,7 +122,7 @@ public class AllBogeyStyles {
public BogeyStyle build() {
BogeyStyle entry = new BogeyStyle(name, cycleGroup, displayName, soundType, contactParticle, smokeParticle,
defaultData, sizes, commonRenderer);
defaultData, sizes, sizeRenderers, commonRenderer);
BOGEY_STYLES.put(name, entry);
CYCLE_GROUPS.computeIfAbsent(cycleGroup, l -> new HashMap<>())
.put(name, entry);

View file

@ -25,8 +25,8 @@ import com.simibubi.create.content.kinetics.press.PressingRecipe;
import com.simibubi.create.content.kinetics.saw.CuttingRecipe;
import com.simibubi.create.content.processing.basin.BasinRecipe;
import com.simibubi.create.content.processing.recipe.ProcessingRecipeBuilder.ProcessingRecipeFactory;
import com.simibubi.create.content.processing.sequenced.SequencedAssemblyRecipeSerializer;
import com.simibubi.create.content.processing.recipe.ProcessingRecipeSerializer;
import com.simibubi.create.content.processing.sequenced.SequencedAssemblyRecipeSerializer;
import com.simibubi.create.foundation.recipe.IRecipeTypeInfo;
import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.RegisteredObjects;

View file

@ -67,7 +67,7 @@ public class Create {
public static final String ID = "create";
public static final String NAME = "Create";
public static final String VERSION = "0.5.1a";
public static final String VERSION = "0.5.1b";
public static final Logger LOGGER = LogUtils.getLogger();

View file

@ -11,8 +11,8 @@ public class AttachedComputerPacket extends BlockEntityDataPacket<SyncedBlockEnt
private final boolean hasAttachedComputer;
public AttachedComputerPacket(BlockPos tilePos, boolean hasAttachedComputer) {
super(tilePos);
public AttachedComputerPacket(BlockPos blockEntityPos, boolean hasAttachedComputer) {
super(blockEntityPos);
this.hasAttachedComputer = hasAttachedComputer;
}
@ -27,9 +27,9 @@ public class AttachedComputerPacket extends BlockEntityDataPacket<SyncedBlockEnt
}
@Override
protected void handlePacket(SyncedBlockEntity tile) {
if (tile instanceof SmartBlockEntity smartTile) {
smartTile.getBehaviour(AbstractComputerBehaviour.TYPE)
protected void handlePacket(SyncedBlockEntity blockEntity) {
if (blockEntity instanceof SmartBlockEntity sbe) {
sbe.getBehaviour(AbstractComputerBehaviour.TYPE)
.setHasAttachedComputer(hasAttachedComputer);
}
}

View file

@ -37,18 +37,18 @@ public class ComputerBehaviour extends AbstractComputerBehaviour {
}
public static NonNullSupplier<IPeripheral> getPeripheralFor(SmartBlockEntity te) {
if (te instanceof SpeedControllerBlockEntity scte)
return () -> new SpeedControllerPeripheral(scte, scte.targetSpeed);
if (te instanceof DisplayLinkBlockEntity dlte)
return () -> new DisplayLinkPeripheral(dlte);
if (te instanceof SequencedGearshiftBlockEntity sgte)
return () -> new SequencedGearshiftPeripheral(sgte);
if (te instanceof SpeedGaugeBlockEntity sgte)
return () -> new SpeedGaugePeripheral(sgte);
if (te instanceof StressGaugeBlockEntity sgte)
return () -> new StressGaugePeripheral(sgte);
if (te instanceof StationBlockEntity ste)
return () -> new StationPeripheral(ste);
if (te instanceof SpeedControllerBlockEntity scbe)
return () -> new SpeedControllerPeripheral(scbe, scbe.targetSpeed);
if (te instanceof DisplayLinkBlockEntity dlbe)
return () -> new DisplayLinkPeripheral(dlbe);
if (te instanceof SequencedGearshiftBlockEntity sgbe)
return () -> new SequencedGearshiftPeripheral(sgbe);
if (te instanceof SpeedGaugeBlockEntity sgbe)
return () -> new SpeedGaugePeripheral(sgbe);
if (te instanceof StressGaugeBlockEntity sgbe)
return () -> new StressGaugePeripheral(sgbe);
if (te instanceof StationBlockEntity sbe)
return () -> new StationPeripheral(sbe);
throw new IllegalArgumentException(
"No peripheral available for " + ForgeRegistries.BLOCK_ENTITY_TYPES.getKey(te.getType()));

View file

@ -19,8 +19,8 @@ public class DisplayLinkPeripheral extends SyncedPeripheral<DisplayLinkBlockEnti
private final AtomicInteger cursorX = new AtomicInteger();
private final AtomicInteger cursorY = new AtomicInteger();
public DisplayLinkPeripheral(DisplayLinkBlockEntity tile) {
super(tile);
public DisplayLinkPeripheral(DisplayLinkBlockEntity blockEntity) {
super(blockEntity);
}
@LuaFunction
@ -36,7 +36,7 @@ public class DisplayLinkPeripheral extends SyncedPeripheral<DisplayLinkBlockEnti
@LuaFunction(mainThread = true)
public final Object[] getSize() {
DisplayTargetStats stats = tile.activeTarget.provideStats(new DisplayLinkContext(tile.getLevel(), tile));
DisplayTargetStats stats = blockEntity.activeTarget.provideStats(new DisplayLinkContext(blockEntity.getLevel(), blockEntity));
return new Object[]{stats.maxRows(), stats.maxColumns()};
}
@ -52,7 +52,7 @@ public class DisplayLinkPeripheral extends SyncedPeripheral<DisplayLinkBlockEnti
@LuaFunction
public final void write(String text) {
ListTag tag = tile.getSourceConfig().getList(TAG_KEY, Tag.TAG_STRING);
ListTag tag = blockEntity.getSourceConfig().getList(TAG_KEY, Tag.TAG_STRING);
int x = cursorX.get();
int y = cursorY.get();
@ -68,8 +68,8 @@ public class DisplayLinkPeripheral extends SyncedPeripheral<DisplayLinkBlockEnti
tag.set(y, StringTag.valueOf(builder.toString()));
synchronized (tile) {
tile.getSourceConfig().put(TAG_KEY, tag);
synchronized (blockEntity) {
blockEntity.getSourceConfig().put(TAG_KEY, tag);
}
cursorX.set(x + text.length());
@ -77,26 +77,26 @@ public class DisplayLinkPeripheral extends SyncedPeripheral<DisplayLinkBlockEnti
@LuaFunction
public final void clearLine() {
ListTag tag = tile.getSourceConfig().getList(TAG_KEY, Tag.TAG_STRING);
ListTag tag = blockEntity.getSourceConfig().getList(TAG_KEY, Tag.TAG_STRING);
if (tag.size() > cursorY.get())
tag.set(cursorY.get(), StringTag.valueOf(""));
synchronized (tile) {
tile.getSourceConfig().put(TAG_KEY, tag);
synchronized (blockEntity) {
blockEntity.getSourceConfig().put(TAG_KEY, tag);
}
}
@LuaFunction
public final void clear() {
synchronized (tile) {
tile.getSourceConfig().put(TAG_KEY, new ListTag());
synchronized (blockEntity) {
blockEntity.getSourceConfig().put(TAG_KEY, new ListTag());
}
}
@LuaFunction(mainThread = true)
public final void update() {
tile.tickSource();
blockEntity.tickSource();
}
@NotNull

View file

@ -13,8 +13,8 @@ import dan200.computercraft.api.lua.LuaFunction;
public class SequencedGearshiftPeripheral extends SyncedPeripheral<SequencedGearshiftBlockEntity> {
public SequencedGearshiftPeripheral(SequencedGearshiftBlockEntity tile) {
super(tile);
public SequencedGearshiftPeripheral(SequencedGearshiftBlockEntity blockEntity) {
super(blockEntity);
}
@LuaFunction(mainThread = true)
@ -29,20 +29,20 @@ public class SequencedGearshiftPeripheral extends SyncedPeripheral<SequencedGear
@LuaFunction
public final boolean isRunning() {
return !this.tile.isIdle();
return !this.blockEntity.isIdle();
}
private void runInstruction(IArguments arguments, SequencerInstructions instructionType) throws LuaException {
int speedModifier = arguments.count() > 1 ? arguments.getInt(1) : 1;
this.tile.getInstructions().clear();
this.blockEntity.getInstructions().clear();
this.tile.getInstructions().add(new Instruction(
this.blockEntity.getInstructions().add(new Instruction(
instructionType,
InstructionSpeedModifiers.getByModifier(speedModifier),
Math.abs(arguments.getInt(0))));
this.tile.getInstructions().add(new Instruction(SequencerInstructions.END));
this.blockEntity.getInstructions().add(new Instruction(SequencerInstructions.END));
this.tile.run(0);
this.blockEntity.run(0);
}
@NotNull

View file

@ -11,8 +11,8 @@ public class SpeedControllerPeripheral extends SyncedPeripheral<SpeedControllerB
private final ScrollValueBehaviour targetSpeed;
public SpeedControllerPeripheral(SpeedControllerBlockEntity tile, ScrollValueBehaviour targetSpeed) {
super(tile);
public SpeedControllerPeripheral(SpeedControllerBlockEntity blockEntity, ScrollValueBehaviour targetSpeed) {
super(blockEntity);
this.targetSpeed = targetSpeed;
}

View file

@ -8,13 +8,13 @@ import dan200.computercraft.api.lua.LuaFunction;
public class SpeedGaugePeripheral extends SyncedPeripheral<SpeedGaugeBlockEntity> {
public SpeedGaugePeripheral(SpeedGaugeBlockEntity tile) {
super(tile);
public SpeedGaugePeripheral(SpeedGaugeBlockEntity blockEntity) {
super(blockEntity);
}
@LuaFunction
public final float getSpeed() {
return this.tile.getSpeed();
return this.blockEntity.getSpeed();
}
@NotNull

View file

@ -32,54 +32,54 @@ import net.minecraftforge.network.PacketDistributor;
public class StationPeripheral extends SyncedPeripheral<StationBlockEntity> {
public StationPeripheral(StationBlockEntity tile) {
super(tile);
public StationPeripheral(StationBlockEntity blockEntity) {
super(blockEntity);
}
@LuaFunction(mainThread = true)
public final void assemble() throws LuaException {
if (!tile.isAssembling())
if (!blockEntity.isAssembling())
throw new LuaException("station must be in assembly mode");
tile.assemble(null);
blockEntity.assemble(null);
if (tile.getStation() == null || tile.getStation().getPresentTrain() == null)
if (blockEntity.getStation() == null || blockEntity.getStation().getPresentTrain() == null)
throw new LuaException("failed to assemble train");
if (!tile.exitAssemblyMode())
if (!blockEntity.exitAssemblyMode())
throw new LuaException("failed to exit assembly mode");
}
@LuaFunction(mainThread = true)
public final void disassemble() throws LuaException {
if (tile.isAssembling())
if (blockEntity.isAssembling())
throw new LuaException("station must not be in assembly mode");
getTrainOrThrow();
if (!tile.enterAssemblyMode(null))
if (!blockEntity.enterAssemblyMode(null))
throw new LuaException("could not disassemble train");
}
@LuaFunction(mainThread = true)
public final void setAssemblyMode(boolean assemblyMode) throws LuaException {
if (assemblyMode) {
if (!tile.enterAssemblyMode(null))
if (!blockEntity.enterAssemblyMode(null))
throw new LuaException("failed to enter assembly mode");
} else {
if (!tile.exitAssemblyMode())
if (!blockEntity.exitAssemblyMode())
throw new LuaException("failed to exit assembly mode");
}
}
@LuaFunction
public final boolean isInAssemblyMode() {
return tile.isAssembling();
return blockEntity.isAssembling();
}
@LuaFunction
public final String getStationName() throws LuaException {
GlobalStation station = tile.getStation();
GlobalStation station = blockEntity.getStation();
if (station == null)
throw new LuaException("station is not connected to a track");
@ -88,13 +88,13 @@ public class StationPeripheral extends SyncedPeripheral<StationBlockEntity> {
@LuaFunction(mainThread = true)
public final void setStationName(String name) throws LuaException {
if (!tile.updateName(name))
if (!blockEntity.updateName(name))
throw new LuaException("could not set station name");
}
@LuaFunction
public final boolean isTrainPresent() throws LuaException {
GlobalStation station = tile.getStation();
GlobalStation station = blockEntity.getStation();
if (station == null)
throw new LuaException("station is not connected to a track");
@ -103,7 +103,7 @@ public class StationPeripheral extends SyncedPeripheral<StationBlockEntity> {
@LuaFunction
public final boolean isTrainImminent() throws LuaException {
GlobalStation station = tile.getStation();
GlobalStation station = blockEntity.getStation();
if (station == null)
throw new LuaException("station is not connected to a track");
@ -112,7 +112,7 @@ public class StationPeripheral extends SyncedPeripheral<StationBlockEntity> {
@LuaFunction
public final boolean isTrainEnroute() throws LuaException {
GlobalStation station = tile.getStation();
GlobalStation station = blockEntity.getStation();
if (station == null)
throw new LuaException("station is not connected to a track");
@ -158,7 +158,7 @@ public class StationPeripheral extends SyncedPeripheral<StationBlockEntity> {
}
private @NotNull Train getTrainOrThrow() throws LuaException {
GlobalStation station = tile.getStation();
GlobalStation station = blockEntity.getStation();
if (station == null)
throw new LuaException("station is not connected to a track");

View file

@ -8,18 +8,18 @@ import dan200.computercraft.api.lua.LuaFunction;
public class StressGaugePeripheral extends SyncedPeripheral<StressGaugeBlockEntity> {
public StressGaugePeripheral(StressGaugeBlockEntity tile) {
super(tile);
public StressGaugePeripheral(StressGaugeBlockEntity blockEntity) {
super(blockEntity);
}
@LuaFunction
public final float getStress() {
return this.tile.getNetworkStress();
return this.blockEntity.getNetworkStress();
}
@LuaFunction
public final float getStressCapacity() {
return this.tile.getNetworkCapacity();
return this.blockEntity.getNetworkCapacity();
}
@NotNull

View file

@ -16,30 +16,30 @@ import net.minecraftforge.network.PacketDistributor;
public abstract class SyncedPeripheral<T extends SmartBlockEntity> implements IPeripheral {
protected final T tile;
protected final T blockEntity;
private final AtomicInteger computers = new AtomicInteger();
public SyncedPeripheral(T tile) {
this.tile = tile;
public SyncedPeripheral(T blockEntity) {
this.blockEntity = blockEntity;
}
@Override
public void attach(@NotNull IComputerAccess computer) {
computers.incrementAndGet();
updateTile();
updateBlockEntity();
}
@Override
public void detach(@NotNull IComputerAccess computer) {
computers.decrementAndGet();
updateTile();
updateBlockEntity();
}
private void updateTile() {
private void updateBlockEntity() {
boolean hasAttachedComputer = computers.get() > 0;
tile.getBehaviour(ComputerBehaviour.TYPE).setHasAttachedComputer(hasAttachedComputer);
AllPackets.getChannel().send(PacketDistributor.ALL.noArg(), new AttachedComputerPacket(tile.getBlockPos(), hasAttachedComputer));
blockEntity.getBehaviour(ComputerBehaviour.TYPE).setHasAttachedComputer(hasAttachedComputer);
AllPackets.getChannel().send(PacketDistributor.ALL.noArg(), new AttachedComputerPacket(blockEntity.getBlockPos(), hasAttachedComputer));
}
@Override

View file

@ -323,8 +323,8 @@ public abstract class Contraption {
if (AllBlocks.BELT.has(state))
moveBelt(pos, frontier, visited, state);
if (AllBlocks.WINDMILL_BEARING.has(state) && world.getBlockEntity(pos)instanceof WindmillBearingBlockEntity wbte)
wbte.disassembleForMovement();
if (AllBlocks.WINDMILL_BEARING.has(state) && world.getBlockEntity(pos)instanceof WindmillBearingBlockEntity wbbe)
wbbe.disassembleForMovement();
if (AllBlocks.GANTRY_CARRIAGE.has(state))
moveGantryPinion(world, pos, frontier, visited, state);
@ -894,8 +894,8 @@ public abstract class Contraption {
return;
be.setLevel(world);
modelData.put(info.pos, be.getModelData());
if (be instanceof KineticBlockEntity kte)
kte.setSpeed(0);
if (be instanceof KineticBlockEntity kbe)
kbe.setSpeed(0);
be.getBlockState();
MovementBehaviour movementBehaviour = AllMovementBehaviours.getBehaviour(info.state);

View file

@ -72,6 +72,8 @@ public class MountedStorage {
// There doesn't appear to be much of a standard for tagging chests/barrels
String blockId = ForgeRegistries.BLOCKS.getKey(blockState.getBlock())
.getPath();
if (blockId.contains("ender"))
return false;
return blockId.endsWith("_chest") || blockId.endsWith("_barrel");
}

View file

@ -41,8 +41,8 @@ public class ContraptionControlsMovingInteraction extends MovingInteractionBehav
if (contraption instanceof ElevatorContraption ec)
return elevatorInteraction(localPos, contraptionEntity, ec, ctx);
if (contraptionEntity.level.isClientSide()) {
if (contraption.presentBlockEntities.get(ctx.localPos)instanceof ContraptionControlsBlockEntity cte)
cte.pressButton();
if (contraption.presentBlockEntities.get(ctx.localPos) instanceof ContraptionControlsBlockEntity cbe)
cbe.pressButton();
return true;
}
@ -119,8 +119,8 @@ public class ContraptionControlsMovingInteraction extends MovingInteractionBehav
return true;
AllPackets.getChannel().sendToServer(new ElevatorTargetFloorPacket(contraptionEntity, efs.currentTargetY));
if (contraption.presentBlockEntities.get(ctx.localPos)instanceof ContraptionControlsBlockEntity cte)
cte.pressButton();
if (contraption.presentBlockEntities.get(ctx.localPos) instanceof ContraptionControlsBlockEntity cbe)
cbe.pressButton();
return true;
}

View file

@ -103,8 +103,8 @@ public class ContraptionControlsRenderer extends SmartBlockEntityRenderer<Contra
msr.rotate(Direction.WEST, AngleHelper.rad(67.5f));
float buttondepth = -.25f;
if (ctx.contraption.presentBlockEntities.get(ctx.localPos)instanceof ContraptionControlsBlockEntity cte)
buttondepth += -1 / 24f * cte.button.getValue(AnimationTickHolder.getPartialTicks(renderWorld));
if (ctx.contraption.presentBlockEntities.get(ctx.localPos) instanceof ContraptionControlsBlockEntity cbe)
buttondepth += -1 / 24f * cbe.button.getValue(AnimationTickHolder.getPartialTicks(renderWorld));
if (!text.isBlank() && playerDistance < 100) {
int actualWidth = fontRenderer.width(text);

View file

@ -35,8 +35,9 @@ public class TrackPaverV2 {
Vec3 direction = VecHelper.clampComponentWise(diff, 1);
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)
.subtract(0, 0.5, 0));
.subtract(0, diff.y != 0 ? 1 : 0.5, 0));
paveStraight(task, pos, direction, extent);
}

View file

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

View file

@ -54,16 +54,16 @@ public class ElevatorColumn {
public void markDirty() {
for (BlockPos pos : getContacts()) {
BlockEntity blockEntity = level.getBlockEntity(pos);
if (blockEntity instanceof ElevatorContactBlockEntity ecte)
ecte.setChanged();
if (blockEntity instanceof ElevatorContactBlockEntity ecbe)
ecbe.setChanged();
}
}
public void floorReached(LevelAccessor level, String name) {
getContacts().stream()
.forEach(p -> {
if (level.getBlockEntity(p)instanceof ElevatorContactBlockEntity ecte)
ecte.updateDisplayedFloor(name);
if (level.getBlockEntity(p) instanceof ElevatorContactBlockEntity ecbe)
ecbe.updateDisplayedFloor(name);
});
}
@ -72,8 +72,8 @@ public class ElevatorColumn {
public List<IntAttached<Couple<String>>> compileNamesList() {
return getContacts().stream()
.map(p -> {
if (level.getBlockEntity(p)instanceof ElevatorContactBlockEntity ecte)
return IntAttached.with(p.getY(), ecte.getNames());
if (level.getBlockEntity(p) instanceof ElevatorContactBlockEntity ecbe)
return IntAttached.with(p.getY(), ecbe.getNames());
return null;
})
.filter(Objects::nonNull)
@ -126,13 +126,13 @@ public class ElevatorColumn {
Integer y = contacts.get(i);
BlockPos pos = contactAt(y);
if (!(level.getBlockEntity(pos)instanceof ElevatorContactBlockEntity ecte))
if (!(level.getBlockEntity(pos) instanceof ElevatorContactBlockEntity ecbe))
continue;
Integer currentLevel = null;
if (!ecte.shortName.isBlank()) {
Integer tryValueOf = tryValueOf(ecte.shortName);
if (!ecbe.shortName.isBlank()) {
Integer tryValueOf = tryValueOf(ecbe.shortName);
if (tryValueOf != null)
currentLevel = tryValueOf;
if (currentLevel == null)
@ -146,13 +146,13 @@ public class ElevatorColumn {
for (int peekI = i + 1; peekI < contacts.size(); peekI++) {
BlockPos peekPos = contactAt(contacts.get(peekI));
if (!(level.getBlockEntity(peekPos)instanceof ElevatorContactBlockEntity peekEcte))
if (!(level.getBlockEntity(peekPos) instanceof ElevatorContactBlockEntity peekEcbe))
continue;
Integer tryValueOf = tryValueOf(peekEcte.shortName);
Integer tryValueOf = tryValueOf(peekEcbe.shortName);
if (tryValueOf == null)
continue;
if (currentLevel != null && currentLevel >= tryValueOf) {
peekEcte.shortName = "";
peekEcbe.shortName = "";
break;
}
nextLevel = tryValueOf;
@ -162,7 +162,7 @@ public class ElevatorColumn {
if (currentLevel == null)
currentLevel = nextLevel != null ? nextLevel - 1 : 0;
ecte.updateName(String.valueOf(currentLevel), ecte.longName);
ecbe.updateName(String.valueOf(currentLevel), ecbe.longName);
prevLevel = currentLevel;
}

View file

@ -248,7 +248,7 @@ public class ElevatorContactBlock extends WrenchableDirectionalBlock
}
public static int getLight(BlockState state) {
return state.getValue(POWERING) ? 10 : state.getValue(CALLING) ? 5 : 0;
return state.getValue(POWERING) ? 10 : 0;
}
}

View file

@ -141,10 +141,10 @@ public class ElevatorContraption extends PulleyContraption {
public void broadcastFloorData(Level level, BlockPos contactPos) {
ElevatorColumn column = ElevatorColumn.get(level, getGlobalColumn());
if (!(world.getBlockEntity(contactPos)instanceof ElevatorContactBlockEntity ecte))
if (!(world.getBlockEntity(contactPos) instanceof ElevatorContactBlockEntity ecbe))
return;
if (column != null)
column.floorReached(level, ecte.shortName);
column.floorReached(level, ecbe.shortName);
}
@Override

View file

@ -81,13 +81,19 @@ public class ElevatorPulleyBlockEntity extends PulleyBlockEntity {
return;
double y = movedContraption.getY();
int targetLevel = Mth.floor(0.5f + y);
int targetLevel = Mth.floor(0.5f + y) + ec.contactYOffset;
Integer ecCurrentTargetY = ec.getCurrentTargetY(level);
if (ecCurrentTargetY != null)
targetLevel = ecCurrentTargetY;
if (level.isClientSide())
targetLevel = ec.clientYTarget;
if (!wasArrived && !level.isClientSide()) {
triggerContact(ec, targetLevel);
AllSoundEvents.CONTRAPTION_DISASSEMBLE.play(level, null, worldPosition.below((int) offset), 0.75f, 0.8f);
}
double diff = targetLevel - y;
double diff = targetLevel - y - ec.contactYOffset;
if (Math.abs(diff) > 1f / 128)
diff *= 0.25f;
movedContraption.setPos(movedContraption.position()
@ -284,8 +290,8 @@ public class ElevatorPulleyBlockEntity extends PulleyBlockEntity {
continue;
pos = pos.offset(anchor);
if (level.getBlockEntity(new BlockPos(pos.getX(), worldPosition.getY(),
pos.getZ()))instanceof ElevatorPulleyBlockEntity pte)
pte.startMirroringOther(worldPosition);
pos.getZ())) instanceof ElevatorPulleyBlockEntity pbe)
pbe.startMirroringOther(worldPosition);
}
ElevatorColumn column = ElevatorColumn.getOrCreate(level, contraption.getGlobalColumn());

View file

@ -158,8 +158,8 @@ public class PulleyBlockEntity extends LinearActuatorBlockEntity implements Thre
continue;
pos = pos.offset(anchor);
if (level.getBlockEntity(
new BlockPos(pos.getX(), worldPosition.getY(), pos.getZ()))instanceof PulleyBlockEntity pte)
pte.startMirroringOther(worldPosition);
new BlockPos(pos.getX(), worldPosition.getY(), pos.getZ())) instanceof PulleyBlockEntity pbe)
pbe.startMirroringOther(worldPosition);
}
}
}
@ -307,14 +307,14 @@ public class PulleyBlockEntity extends LinearActuatorBlockEntity implements Thre
public void startMirroringOther(BlockPos parent) {
if (parent.equals(worldPosition))
return;
if (!(level.getBlockEntity(parent)instanceof PulleyBlockEntity pte))
if (!(level.getBlockEntity(parent) instanceof PulleyBlockEntity pbe))
return;
if (pte.getType() != getType())
if (pbe.getType() != getType())
return;
if (pte.mirrorChildren == null)
pte.mirrorChildren = new ArrayList<>();
pte.mirrorChildren.add(worldPosition);
pte.notifyUpdate();
if (pbe.mirrorChildren == null)
pbe.mirrorChildren = new ArrayList<>();
pbe.mirrorChildren.add(worldPosition);
pbe.notifyUpdate();
mirrorParent = parent;
try {
@ -328,12 +328,12 @@ public class PulleyBlockEntity extends LinearActuatorBlockEntity implements Thre
if (mirrorChildren == null)
return;
for (BlockPos blockPos : mirrorChildren) {
if (!(level.getBlockEntity(blockPos)instanceof PulleyBlockEntity pte))
if (!(level.getBlockEntity(blockPos) instanceof PulleyBlockEntity pbe))
continue;
pte.offset = offset;
pte.disassemble();
pte.mirrorParent = null;
pte.notifyUpdate();
pbe.offset = offset;
pbe.disassemble();
pbe.mirrorParent = null;
pbe.notifyUpdate();
}
mirrorChildren.clear();
notifyUpdate();

View file

@ -181,15 +181,17 @@ public abstract class CopycatBlock extends Block implements IBE<CopycatBlockEnti
if (block instanceof StairBlock)
return null;
VoxelShape shape = appliedState.getShape(pLevel, pPos);
if (shape.isEmpty() || !shape.bounds()
.equals(Shapes.block()
.bounds()))
return null;
if (pLevel != null) {
VoxelShape shape = appliedState.getShape(pLevel, pPos);
if (shape.isEmpty() || !shape.bounds()
.equals(Shapes.block()
.bounds()))
return null;
VoxelShape collisionShape = appliedState.getCollisionShape(pLevel, pPos);
if (collisionShape.isEmpty())
return null;
VoxelShape collisionShape = appliedState.getCollisionShape(pLevel, pPos);
if (collisionShape.isEmpty())
return null;
}
}
if (face != null) {
@ -270,8 +272,8 @@ public abstract class CopycatBlock extends Block implements IBE<CopycatBlockEnti
//
public static BlockState getMaterial(BlockGetter reader, BlockPos targetPos) {
if (reader.getBlockEntity(targetPos) instanceof CopycatBlockEntity ufte)
return ufte.getMaterial();
if (reader.getBlockEntity(targetPos) instanceof CopycatBlockEntity cbe)
return cbe.getMaterial();
return Blocks.AIR.defaultBlockState();
}
@ -314,7 +316,7 @@ public abstract class CopycatBlock extends Block implements IBE<CopycatBlockEnti
public ItemStack getCloneItemStack(BlockState state, HitResult target, BlockGetter level, BlockPos pos,
Player player) {
BlockState material = getMaterial(level, pos);
if (AllBlocks.COPYCAT_BASE.has(material))
if (AllBlocks.COPYCAT_BASE.has(material) || player != null && player.isSteppingCarefully())
return new ItemStack(this);
return material.getCloneItemStack(target, level, pos, player);
}

View file

@ -11,6 +11,7 @@ import com.simibubi.create.content.schematics.requirement.ItemRequirement;
import com.simibubi.create.content.schematics.requirement.ItemRequirement.ItemUseType;
import com.simibubi.create.foundation.blockEntity.SmartBlockEntity;
import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour;
import com.simibubi.create.foundation.utility.IPartialSafeNBT;
import com.simibubi.create.foundation.utility.Iterate;
import net.minecraft.core.BlockPos;
@ -26,7 +27,7 @@ import net.minecraftforge.client.model.data.ModelData;
import net.minecraftforge.items.ItemHandlerHelper;
public class CopycatBlockEntity extends SmartBlockEntity
implements ISpecialBlockEntityItemRequirement, ITransformableBlockEntity {
implements ISpecialBlockEntityItemRequirement, ITransformableBlockEntity, IPartialSafeNBT {
private BlockState material;
private ItemStack consumedItem;
@ -138,19 +139,49 @@ public class CopycatBlockEntity extends SmartBlockEntity
consumedItem = ItemStack.of(tag.getCompound("Item"));
BlockState prevMaterial = material;
if (!tag.contains("Material"))
if (!tag.contains("Material")) {
consumedItem = ItemStack.EMPTY;
return;
}
material = NbtUtils.readBlockState(tag.getCompound("Material"));
// Validate Material
if (material != null && !clientPacket) {
BlockState blockState = getBlockState();
if (blockState == null)
return;
if (!(blockState.getBlock() instanceof CopycatBlock cb))
return;
BlockState acceptedBlockState = cb.getAcceptedBlockState(level, worldPosition, consumedItem, null);
if (acceptedBlockState != null && material.is(acceptedBlockState.getBlock()))
return;
consumedItem = ItemStack.EMPTY;
material = AllBlocks.COPYCAT_BASE.getDefaultState();
}
if (clientPacket && prevMaterial != material)
redraw();
}
@Override
public void writeSafe(CompoundTag tag) {
super.writeSafe(tag);
ItemStack stackWithoutNBT = consumedItem.copy();
stackWithoutNBT.setTag(null);
write(tag, stackWithoutNBT, material);
}
@Override
protected void write(CompoundTag tag, boolean clientPacket) {
super.write(tag, clientPacket);
tag.put("Item", consumedItem.serializeNBT());
write(tag, consumedItem, material);
}
protected void write(CompoundTag tag, ItemStack stack, BlockState material) {
tag.put("Item", stack.serializeNBT());
tag.put("Material", NbtUtils.writeBlockState(material));
}

View file

@ -236,9 +236,9 @@ public class GirderBlock extends Block implements SimpleWaterloggedBlock, IWrenc
public static boolean isFacingBracket(BlockAndTintGetter level, BlockPos pos, Direction d) {
BlockEntity blockEntity = level.getBlockEntity(pos.relative(d));
if (!(blockEntity instanceof SmartBlockEntity ste))
if (!(blockEntity instanceof SmartBlockEntity sbe))
return false;
BracketedBlockEntityBehaviour behaviour = ste.getBehaviour(BracketedBlockEntityBehaviour.TYPE);
BracketedBlockEntityBehaviour behaviour = sbe.getBehaviour(BracketedBlockEntityBehaviour.TYPE);
if (behaviour == null)
return false;
BlockState bracket = behaviour.getBracket();

View file

@ -55,13 +55,13 @@ public class SlidingDoorMovementBehaviour implements MovementBehaviour {
tickOpen(context, open);
Map<BlockPos, BlockEntity> tes = context.contraption.presentBlockEntities;
if (!(tes.get(context.localPos)instanceof SlidingDoorBlockEntity doorTE))
if (!(tes.get(context.localPos) instanceof SlidingDoorBlockEntity sdbe))
return;
boolean wasSettled = doorTE.animation.settled();
doorTE.animation.chase(open ? 1 : 0, .15f, Chaser.LINEAR);
doorTE.animation.tickChaser();
boolean wasSettled = sdbe.animation.settled();
sdbe.animation.chase(open ? 1 : 0, .15f, Chaser.LINEAR);
sdbe.animation.tickChaser();
if (!wasSettled && doorTE.animation.settled() && !open)
if (!wasSettled && sdbe.animation.settled() && !open)
context.world.playLocalSound(context.position.x, context.position.y, context.position.z,
SoundEvents.IRON_DOOR_CLOSE, SoundSource.BLOCKS, .125f, 1, false);
}

View file

@ -186,8 +186,8 @@ public class WhistleBlockEntity extends SmartBlockEntity implements IHaveGoggleI
source = new WeakReference<>(null);
Direction facing = WhistleBlock.getAttachedDirection(getBlockState());
BlockEntity be = level.getBlockEntity(worldPosition.relative(facing));
if (be instanceof FluidTankBlockEntity tankTe)
source = new WeakReference<>(tank = tankTe);
if (be instanceof FluidTankBlockEntity tankBe)
source = new WeakReference<>(tank = tankBe);
}
if (tank == null)
return null;

View file

@ -5,6 +5,7 @@ import org.jetbrains.annotations.Nullable;
import com.simibubi.create.foundation.utility.NBTHelper;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.FluidTags;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
@ -92,7 +93,8 @@ public class DivingBootsItem extends BaseArmorItem {
if (!entity.isOnGround()) {
if (entity.jumping && entity.getPersistentData()
.contains("LavaGrounded")) {
vMultiplier = yMotion == 0 ? 0 : 1 / yMotion;
boolean eyeInFluid = entity.isEyeInFluid(FluidTags.LAVA);
vMultiplier = yMotion == 0 ? 0 : (eyeInFluid ? 1 : 0.5) / yMotion;
} else if (yMotion > 0)
vMultiplier = 1.3;

View file

@ -19,7 +19,6 @@ import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.enchantment.Enchantment;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.level.Level;
import net.minecraftforge.common.ForgeMod;
import net.minecraftforge.event.entity.living.LivingEvent.LivingTickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
@ -84,7 +83,7 @@ public class DivingHelmetItem extends BaseArmorItem {
entity.getPersistentData()
.remove("VisualBacktankAir");
boolean lavaDiving = entity.isEyeInFluidType(ForgeMod.LAVA_TYPE.get());
boolean lavaDiving = entity.isInLava();
if (!isWornBy(entity, lavaDiving))
return;

View file

@ -33,7 +33,7 @@ public class RemainingAirOverlay implements IGuiOverlay {
if (!player.getPersistentData()
.contains("VisualBacktankAir"))
return;
if (!player.isEyeInFluid(FluidTags.WATER) && !player.isEyeInFluid(FluidTags.LAVA))
if (!player.isEyeInFluid(FluidTags.WATER) && !player.isInLava())
return;
int timeLeft = player.getPersistentData()

View file

@ -60,6 +60,8 @@ public class ClipboardBlock extends FaceAttachedHorizontalDirectionalBlock
@Override
public BlockState getStateForPlacement(BlockPlaceContext pContext) {
BlockState stateForPlacement = super.getStateForPlacement(pContext);
if (stateForPlacement == null)
return null;
if (stateForPlacement.getValue(FACE) != AttachFace.WALL)
stateForPlacement = stateForPlacement.setValue(FACING, stateForPlacement.getValue(FACING)
.getOpposite());

View file

@ -327,8 +327,8 @@ public class BoilerData {
if (AllBlocks.STEAM_WHISTLE.has(attachedState)
&& WhistleBlock.getAttachedDirection(attachedState)
.getOpposite() == d) {
if (level.getBlockEntity(attachedPos)instanceof WhistleBlockEntity wte)
whistlePitches.add(wte.getPitchId());
if (level.getBlockEntity(attachedPos) instanceof WhistleBlockEntity wbe)
whistlePitches.add(wbe.getPitchId());
}
}
}

View file

@ -315,8 +315,8 @@ public class FluidTankBlockEntity extends SmartBlockEntity implements IHaveGoggl
for (int xOffset = 0; xOffset < width; xOffset++)
for (int zOffset = 0; zOffset < width; zOffset++)
if (level.getBlockEntity(
worldPosition.offset(xOffset, yOffset, zOffset)) instanceof FluidTankBlockEntity fte)
fte.refreshCapability();
worldPosition.offset(xOffset, yOffset, zOffset)) instanceof FluidTankBlockEntity fbe)
fbe.refreshCapability();
}
if (changed) {

View file

@ -145,14 +145,14 @@ public class CrushingWheelControllerBlock extends DirectionalBlock implements IB
if (neighbour.getValue(BlockStateProperties.AXIS) == d.getAxis())
continue;
BlockEntity adjBE = world.getBlockEntity(pos.relative(d));
if (!(adjBE instanceof CrushingWheelBlockEntity cwte))
if (!(adjBE instanceof CrushingWheelBlockEntity cwbe))
continue;
be.crushingspeed = Math.abs(cwte.getSpeed() / 50f);
be.crushingspeed = Math.abs(cwbe.getSpeed() / 50f);
be.sendData();
cwte.award(AllAdvancements.CRUSHING_WHEEL);
if (cwte.getSpeed() > 255)
cwte.award(AllAdvancements.CRUSHER_MAXED);
cwbe.award(AllAdvancements.CRUSHING_WHEEL);
if (cwbe.getSpeed() > 255)
cwbe.award(AllAdvancements.CRUSHER_MAXED);
break;
}

View file

@ -12,7 +12,6 @@ import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllItems;
import com.simibubi.create.AllTags.AllBlockTags;
import com.simibubi.create.content.contraptions.AbstractContraptionEntity;
import com.simibubi.create.content.contraptions.OrientedContraptionEntity;
import com.simibubi.create.content.contraptions.behaviour.MovementBehaviour;
@ -33,7 +32,6 @@ import com.simibubi.create.foundation.item.ItemHelper;
import com.simibubi.create.foundation.item.ItemHelper.ExtractionCountMode;
import com.simibubi.create.foundation.utility.BlockHelper;
import com.simibubi.create.foundation.utility.NBTHelper;
import com.simibubi.create.foundation.utility.NBTProcessors;
import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.client.renderer.MultiBufferSource;
@ -48,7 +46,6 @@ import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.common.util.BlockSnapshot;
@ -155,15 +152,7 @@ public class DeployerMovementBehaviour implements MovementBehaviour {
ExtractionCountMode.EXACTLY, required.stack.getCount(), false);
}
CompoundTag data = null;
if (AllBlockTags.SAFE_NBT.matches(blockState)) {
BlockEntity blockEntity = schematicWorld.getBlockEntity(pos);
if (blockEntity != null) {
data = blockEntity.saveWithFullMetadata();
data = NBTProcessors.process(blockEntity, data, true);
}
}
CompoundTag data = BlockHelper.prepareBlockEntityData(blockState, schematicWorld.getBlockEntity(pos));
BlockSnapshot blocksnapshot = BlockSnapshot.create(world.dimension(), world, pos);
BlockHelper.placeSchematicBlock(world, blockState, pos, contextStack, data);
if (ForgeEventFactory.onBlockPlace(player, blocksnapshot, Direction.UP))

View file

@ -29,6 +29,7 @@ import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.Vec3;
@ -266,8 +267,12 @@ public class AirCurrent {
.below(offset);
TransportedItemStackHandlerBehaviour behaviour =
BlockEntityBehaviour.get(world, pos, TransportedItemStackHandlerBehaviour.TYPE);
FanProcessing.Type typeAtHandler = type;
if (world.getFluidState(pos)
.is(Fluids.WATER))
typeAtHandler = Type.SPLASHING;
if (behaviour != null)
affectedItemHandlers.add(Pair.of(behaviour, type));
affectedItemHandlers.add(Pair.of(behaviour, typeAtHandler));
if (direction.getAxis()
.isVertical())
break;

View file

@ -166,8 +166,8 @@ public class SteamEngineBlockEntity extends SmartBlockEntity implements IHaveGog
source = new WeakReference<>(null);
Direction facing = SteamEngineBlock.getFacing(getBlockState());
BlockEntity be = level.getBlockEntity(worldPosition.relative(facing.getOpposite()));
if (be instanceof FluidTankBlockEntity tankTe)
source = new WeakReference<>(tank = tankTe);
if (be instanceof FluidTankBlockEntity tankBe)
source = new WeakReference<>(tank = tankBe);
}
if (tank == null)
return null;

View file

@ -782,7 +782,7 @@ public class ChuteBlockEntity extends SmartBlockEntity implements IHaveGoggleInf
//
// @Override
// public Direction getAirflowOriginSide() {
// return world != null && !(world.getTileEntity(pos.down()) instanceof
// return world != null && !(world.getBlockEntity(pos.down()) instanceof
// IAirCurrentSource)
// && getBlockState().get(ChuteBlock.FACING) == Direction.DOWN ? Direction.DOWN
// : Direction.UP;

View file

@ -49,7 +49,7 @@ public class FunnelRenderer extends SmartBlockEntityRenderer<FunnelBlockEntity>
msr.centre()
.rotateY(horizontalAngle)
.unCentre();
ms.translate(0.075f, 0, -be.getFlapOffset());
ms.translate(0.075f / 16f, 0, -be.getFlapOffset());
for (int segment = 0; segment <= 3; segment++) {
ms.pushPose();

View file

@ -86,14 +86,14 @@ public class DisplayLinkBlock extends WrenchableDirectionalBlock implements IBE<
continue;
BlockEntity blockEntity = level.getBlockEntity(offsetPos);
if (!(blockEntity instanceof DisplayLinkBlockEntity dgte))
if (!(blockEntity instanceof DisplayLinkBlockEntity dlbe))
continue;
if (dgte.activeSource == null)
if (dlbe.activeSource == null)
continue;
if (dgte.getDirection() != d.getOpposite())
if (dlbe.getDirection() != d.getOpposite())
continue;
callback.accept(dgte);
callback.accept(dlbe);
}
}

View file

@ -11,9 +11,9 @@ public class CurrentFloorDisplaySource extends SingleLineDisplaySource {
@Override
protected MutableComponent provideLine(DisplayLinkContext context, DisplayTargetStats stats) {
if (!(context.getSourceBlockEntity() instanceof ElevatorContactBlockEntity ecte))
if (!(context.getSourceBlockEntity() instanceof ElevatorContactBlockEntity ecbe))
return EMPTY_LINE;
return Components.literal(ecte.lastReportedCurrentFloor);
return Components.literal(ecbe.lastReportedCurrentFloor);
}
@Override

View file

@ -14,9 +14,9 @@ public class FillLevelDisplaySource extends PercentOrProgressBarDisplaySource {
@Override
protected Float getProgress(DisplayLinkContext context) {
BlockEntity be = context.getSourceBlockEntity();
if (!(be instanceof ThresholdSwitchBlockEntity sste))
if (!(be instanceof ThresholdSwitchBlockEntity tsbe))
return null;
return sste.currentLevel;
return tsbe.currentLevel;
}
@Override

View file

@ -15,9 +15,9 @@ public class ObservedTrainNameSource extends SingleLineDisplaySource {
@Override
protected MutableComponent provideLine(DisplayLinkContext context, DisplayTargetStats stats) {
if (!(context.getSourceBlockEntity() instanceof TrackObserverBlockEntity observerTE))
if (!(context.getSourceBlockEntity() instanceof TrackObserverBlockEntity observerBE))
return EMPTY_LINE;
TrackObserver observer = observerTE.getObserver();
TrackObserver observer = observerBE.getObserver();
if (observer == null)
return EMPTY_LINE;
UUID currentTrain = observer.getCurrentTrain();

View file

@ -172,9 +172,9 @@ public class StationSummaryDisplaySource extends DisplaySource {
if (conf.contains("Filter"))
return;
if (!(context.getSourceBlockEntity() instanceof StationBlockEntity stationTe))
if (!(context.getSourceBlockEntity() instanceof StationBlockEntity stationBe))
return;
GlobalStation station = stationTe.getStation();
GlobalStation station = stationBe.getStation();
if (station == null)
return;
conf.putString("Filter", station.name);

View file

@ -12,9 +12,9 @@ public class StopWatchDisplaySource extends SingleLineDisplaySource {
@Override
protected MutableComponent provideLine(DisplayLinkContext context, DisplayTargetStats stats) {
if (!(context.getSourceBlockEntity()instanceof CuckooClockBlockEntity ccte))
if (!(context.getSourceBlockEntity() instanceof CuckooClockBlockEntity ccbe))
return TimeOfDayDisplaySource.EMPTY_TIME;
if (ccte.getSpeed() == 0)
if (ccbe.getSpeed() == 0)
return TimeOfDayDisplaySource.EMPTY_TIME;
if (!context.sourceConfig()

View file

@ -22,9 +22,9 @@ public class TimeOfDayDisplaySource extends SingleLineDisplaySource {
protected MutableComponent provideLine(DisplayLinkContext context, DisplayTargetStats stats) {
if (!(context.level()instanceof ServerLevel sLevel))
return EMPTY_TIME;
if (!(context.getSourceBlockEntity() instanceof CuckooClockBlockEntity ccte))
if (!(context.getSourceBlockEntity() instanceof CuckooClockBlockEntity ccbe))
return EMPTY_TIME;
if (ccte.getSpeed() == 0)
if (ccbe.getSpeed() == 0)
return EMPTY_TIME;
boolean c12 = context.sourceConfig()

View file

@ -15,9 +15,9 @@ public class TrainStatusDisplaySource extends SingleLineDisplaySource {
@Override
protected MutableComponent provideLine(DisplayLinkContext context, DisplayTargetStats stats) {
if (!(context.getSourceBlockEntity() instanceof StationBlockEntity observerTE))
if (!(context.getSourceBlockEntity() instanceof StationBlockEntity observerBE))
return EMPTY_LINE;
GlobalStation observer = observerTE.getStation();
GlobalStation observer = observerBE.getStation();
if (observer == null)
return EMPTY_LINE;
Train currentTrain = observer.getPresentTrain();

View file

@ -90,10 +90,10 @@ public class DisplayBoardTarget extends DisplayTarget {
AABB baseShape = super.getMultiblockBounds(level, pos);
BlockEntity be = level.getBlockEntity(pos);
if (!(be instanceof FlapDisplayBlockEntity fdte))
if (!(be instanceof FlapDisplayBlockEntity fdbe))
return baseShape;
FlapDisplayBlockEntity controller = fdte.getController();
FlapDisplayBlockEntity controller = fdbe.getController();
if (controller == null)
return baseShape;

View file

@ -124,7 +124,7 @@ public class SchematicWorld extends WrappedWorld implements ServerLevelAccessor
BlockPos pos = globalPos.subtract(anchor);
if (pos.getY() - bounds.minY() == -1 && !renderMode)
return Blocks.GRASS_BLOCK.defaultBlockState();
return Blocks.DIRT.defaultBlockState();
if (getBounds().isInside(pos) && blocks.containsKey(pos))
return processBlockStateForPrinting(blocks.get(pos));
return Blocks.AIR.defaultBlockState();

View file

@ -10,7 +10,6 @@ import javax.annotation.Nullable;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllItems;
import com.simibubi.create.AllSoundEvents;
import com.simibubi.create.AllTags.AllBlockTags;
import com.simibubi.create.content.kinetics.belt.BeltBlock;
import com.simibubi.create.content.kinetics.belt.BeltBlockEntity;
import com.simibubi.create.content.kinetics.belt.BeltBlockEntity.CasingType;
@ -24,10 +23,9 @@ import com.simibubi.create.foundation.blockEntity.SmartBlockEntity;
import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour;
import com.simibubi.create.foundation.item.ItemHelper;
import com.simibubi.create.foundation.item.ItemHelper.ExtractionCountMode;
import com.simibubi.create.foundation.utility.IPartialSafeNBT;
import com.simibubi.create.foundation.utility.BlockHelper;
import com.simibubi.create.foundation.utility.Iterate;
import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.NBTProcessors;
import com.simibubi.create.infrastructure.config.AllConfigs;
import com.simibubi.create.infrastructure.config.CSchematics;
@ -773,18 +771,7 @@ public class SchematicannonBlockEntity extends SmartBlockEntity implements MenuP
return;
}
CompoundTag data = null;
if (blockEntity != null) {
if (AllBlockTags.SAFE_NBT.matches(blockState)) {
data = blockEntity.saveWithFullMetadata();
data = NBTProcessors.process(blockEntity, data, true);
} else if (blockEntity instanceof IPartialSafeNBT) {
data = new CompoundTag();
((IPartialSafeNBT) blockEntity).writeSafe(data);
data = NBTProcessors.process(blockEntity, data, true);
}
}
CompoundTag data = BlockHelper.prepareBlockEntityData(blockState, blockEntity);
launchBlock(target, icon, blockState, data);
}

View file

@ -214,7 +214,7 @@ public class SchematicAndQuillHandler {
return;
}
Path file = result.file();
Lang.translate("schematicAndQuill.saved", file)
Lang.translate("schematicAndQuill.saved", file.getFileName())
.sendStatus(player);
firstPos = null;
secondPos = null;

View file

@ -55,7 +55,7 @@ public class SchematicPlacePacket extends SimplePacketBase {
if (placingAir && !includeAir)
return;
CompoundTag data = blockEntity != null ? blockEntity.saveWithFullMetadata() : null;
CompoundTag data = BlockHelper.prepareBlockEntityData(state, blockEntity);
BlockHelper.placeSchematicBlock(world, state, pos, null, data);
}, (pos, entity) -> {
world.addFreshEntity(entity);

View file

@ -137,9 +137,9 @@ public abstract class AbstractBogeyBlock<T extends AbstractBogeyBlockEntity> ext
public abstract BogeyStyle getDefaultStyle();
/**
* Legacy system doesn't capture bogey tile entities when constructing a train
* Legacy system doesn't capture bogey block entities when constructing a train
*/
public boolean captureTileEntityForTrain() {
public boolean captureBlockEntityForTrain() {
return false;
}
@ -198,11 +198,11 @@ public abstract class AbstractBogeyBlock<T extends AbstractBogeyBlockEntity> ext
BlockEntity be = level.getBlockEntity(pos);
if (!(be instanceof AbstractBogeyBlockEntity sbte))
if (!(be instanceof AbstractBogeyBlockEntity sbbe))
return InteractionResult.FAIL;
player.getCooldowns().addCooldown(stack.getItem(), 20);
BogeyStyle currentStyle = sbte.getStyle();
BogeyStyle currentStyle = sbbe.getStyle();
BogeySizes.BogeySize size = getSize();
@ -217,21 +217,21 @@ public abstract class AbstractBogeyBlock<T extends AbstractBogeyBlockEntity> ext
size = size.increment();
}
sbte.setBogeyStyle(style);
sbbe.setBogeyStyle(style);
CompoundTag defaultData = style.defaultData;
sbte.setBogeyData(sbte.getBogeyData().merge(defaultData));
sbbe.setBogeyData(sbbe.getBogeyData().merge(defaultData));
if (size == getSize()) {
player.displayClientMessage(Lang.translateDirect("bogey.style.updated_style")
.append(": ").append(style.displayName), true);
} else {
CompoundTag oldData = sbte.getBogeyData();
level.setBlock(pos, this.getStateOfSize(sbte, size), 3);
CompoundTag oldData = sbbe.getBogeyData();
level.setBlock(pos, this.getStateOfSize(sbbe, size), 3);
BlockEntity newBlockEntity = level.getBlockEntity(pos);
if (!(newBlockEntity instanceof AbstractBogeyBlockEntity newTileEntity))
if (!(newBlockEntity instanceof AbstractBogeyBlockEntity newBlockEntity1))
return InteractionResult.FAIL;
newTileEntity.setBogeyData(oldData);
newBlockEntity1.setBogeyData(oldData);
player.displayClientMessage(Lang.translateDirect("bogey.style.updated_style_and_size")
.append(": ").append(style.displayName), true);
}
@ -276,9 +276,9 @@ public abstract class AbstractBogeyBlock<T extends AbstractBogeyBlockEntity> ext
}
public BlockState getNextSize(Level level, BlockPos pos) {
BlockEntity te = level.getBlockEntity(pos);
if (te instanceof AbstractBogeyBlockEntity sbte)
return this.getNextSize(sbte);
BlockEntity be = level.getBlockEntity(pos);
if (be instanceof AbstractBogeyBlockEntity sbbe)
return this.getNextSize(sbbe);
return level.getBlockState(pos);
}
@ -319,8 +319,8 @@ public abstract class AbstractBogeyBlock<T extends AbstractBogeyBlockEntity> ext
public BogeyStyle getNextStyle(Level level, BlockPos pos) {
BlockEntity te = level.getBlockEntity(pos);
if (te instanceof AbstractBogeyBlockEntity sbte)
return this.getNextStyle(sbte.getStyle());
if (te instanceof AbstractBogeyBlockEntity sbbe)
return this.getNextStyle(sbbe.getStyle());
return getDefaultStyle();
}

View file

@ -16,10 +16,10 @@ public class BogeyBlockEntityRenderer<T extends BlockEntity> extends SafeBlockEn
protected void renderSafe(T be, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light,
int overlay) {
BlockState blockState = be.getBlockState();
if (be instanceof AbstractBogeyBlockEntity sbte) {
float angle = sbte.getVirtualAngle(partialTicks);
if (be instanceof AbstractBogeyBlockEntity sbbe) {
float angle = sbbe.getVirtualAngle(partialTicks);
if (blockState.getBlock() instanceof AbstractBogeyBlock<?> bogey)
bogey.render(blockState, angle, ms, partialTicks, buffer, light, overlay, sbte.getStyle(), sbte.getBogeyData());
bogey.render(blockState, angle, ms, partialTicks, buffer, light, overlay, sbbe.getStyle(), sbbe.getBogeyData());
}
}

View file

@ -38,15 +38,20 @@ public class BogeyStyle {
public final CompoundTag defaultData;
private Optional<Supplier<? extends CommonRenderer>> commonRendererFactory;
private Map<BogeySizes.BogeySize, ResourceLocation> sizes;
@OnlyIn(Dist.CLIENT)
private Map<BogeySizes.BogeySize, SizeData> sizes;
private Map<BogeySizes.BogeySize, SizeRenderData> sizeRenderers;
@OnlyIn(Dist.CLIENT)
private Optional<CommonRenderer> commonRenderer;
public BogeyStyle(ResourceLocation name, ResourceLocation cycleGroup, Component displayName, ResourceLocation soundType, ParticleOptions contactParticle, ParticleOptions smokeParticle,
CompoundTag defaultData, Map<BogeySizes.BogeySize, Supplier<SizeData>> sizes, Optional<Supplier<? extends CommonRenderer>> commonRenderer) {
public BogeyStyle(ResourceLocation name, ResourceLocation cycleGroup, Component displayName,
ResourceLocation soundType, ParticleOptions contactParticle, ParticleOptions smokeParticle,
CompoundTag defaultData, Map<BogeySizes.BogeySize, ResourceLocation> sizes,
Map<BogeySizes.BogeySize, Supplier<SizeRenderData>> sizeRenderers,
Optional<Supplier<? extends CommonRenderer>> commonRenderer) {
this.name = name;
this.cycleGroup = cycleGroup;
this.displayName = displayName;
@ -54,10 +59,11 @@ public class BogeyStyle {
this.contactParticle = contactParticle;
this.smokeParticle = smokeParticle;
this.defaultData = defaultData;
this.sizes = sizes;
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> {
this.sizes = new HashMap<>();
sizes.forEach((k, v) -> this.sizes.put(k, v.get()));
this.sizeRenderers = new HashMap<>();
sizeRenderers.forEach((k, v) -> this.sizeRenderers.put(k, v.get()));
this.commonRendererFactory = commonRenderer;
this.commonRenderer = commonRenderer.map(Supplier::get);
@ -72,12 +78,12 @@ public class BogeyStyle {
return Stream.iterate(currentSize.increment(), BogeySizes.BogeySize::increment)
.filter(sizes::containsKey)
.findFirst()
.map(size -> ForgeRegistries.BLOCKS.getValue(sizes.get(size).block()))
.orElse(ForgeRegistries.BLOCKS.getValue(sizes.get(currentSize).block()));
.map(this::getBlockOfSize)
.orElse(getBlockOfSize(currentSize));
}
public Block getBlockOfSize(BogeySizes.BogeySize size) {
return ForgeRegistries.BLOCKS.getValue(sizes.get(size).block());
return ForgeRegistries.BLOCKS.getValue(sizes.get(size));
}
public Set<BogeySizes.BogeySize> validSizes() {
@ -93,12 +99,12 @@ public class BogeyStyle {
@OnlyIn(Dist.CLIENT)
public BogeyRenderer createRendererInstance(BogeySizes.BogeySize size) {
return this.sizes.get(size).createRenderInstance();
return this.sizeRenderers.get(size).createRenderInstance();
}
@OnlyIn(Dist.CLIENT)
public BogeyRenderer getInWorldRenderInstance(BogeySizes.BogeySize size) {
SizeData sizeData = this.sizes.get(size);
SizeRenderData sizeData = this.sizeRenderers.get(size);
return sizeData != null ? sizeData.getInWorldInstance() : BackupBogeyRenderer.INSTANCE;
}
@ -115,7 +121,7 @@ public class BogeyStyle {
}
@OnlyIn(Dist.CLIENT)
public record SizeData(ResourceLocation block, Supplier<? extends BogeyRenderer> rendererFactory, BogeyRenderer instance) {
public record SizeRenderData(Supplier<? extends BogeyRenderer> rendererFactory, BogeyRenderer instance) {
public BogeyRenderer createRenderInstance() {
return rendererFactory.get();
}

View file

@ -163,12 +163,12 @@ public class CarriageContraption extends Contraption {
}
if (blockState.getBlock() instanceof AbstractBogeyBlock<?> bogey) {
boolean captureTE = bogey.captureTileEntityForTrain();
boolean captureBE = bogey.captureBlockEntityForTrain();
bogeys++;
if (bogeys == 2)
secondBogeyPos = pos;
return Pair.of(new StructureBlockInfo(pos, blockState, captureTE ? getBlockEntityNBT(world, pos) : null),
captureTE ? world.getBlockEntity(pos) : null);
return Pair.of(new StructureBlockInfo(pos, blockState, captureBE ? getBlockEntityNBT(world, pos) : null),
captureBE ? world.getBlockEntity(pos) : null);
}
if (AllBlocks.BLAZE_BURNER.has(blockState)

View file

@ -29,12 +29,12 @@ import com.simibubi.create.content.trains.bogey.AbstractBogeyBlockEntity;
import com.simibubi.create.content.trains.entity.Carriage.DimensionalCarriageEntity;
import com.simibubi.create.content.trains.entity.TravellingPoint.IEdgePointListener;
import com.simibubi.create.content.trains.entity.TravellingPoint.SteerDirection;
import com.simibubi.create.content.trains.graph.TrackGraphLocation;
import com.simibubi.create.content.trains.graph.DimensionPalette;
import com.simibubi.create.content.trains.graph.EdgeData;
import com.simibubi.create.content.trains.graph.EdgePointType;
import com.simibubi.create.content.trains.graph.TrackEdge;
import com.simibubi.create.content.trains.graph.TrackGraph;
import com.simibubi.create.content.trains.graph.TrackGraphLocation;
import com.simibubi.create.content.trains.graph.TrackNode;
import com.simibubi.create.content.trains.observer.TrackObserver;
import com.simibubi.create.content.trains.schedule.ScheduleRuntime;
@ -740,9 +740,9 @@ public class Train {
Vec3 bogeyPosition = bogey.getAnchorPosition();
if (bogeyPosition == null) continue;
BlockEntity be = level.getBlockEntity(new BlockPos(bogeyPosition));
if (!(be instanceof AbstractBogeyBlockEntity sbte))
if (!(be instanceof AbstractBogeyBlockEntity sbbe))
continue;
sbte.setBogeyData(bogey.bogeyData);
sbbe.setBogeyData(bogey.bogeyData);
}
offset += carriage.bogeySpacing;
@ -755,8 +755,8 @@ public class Train {
if (currentStation != null) {
currentStation.cancelReservation(this);
BlockPos blockEntityPos = currentStation.getBlockEntityPos();
if (level.getBlockEntity(blockEntityPos) instanceof StationBlockEntity ste)
ste.lastDisassembledTrainName = name.copy();
if (level.getBlockEntity(blockEntityPos) instanceof StationBlockEntity sbe)
sbe.lastDisassembledTrainName = name.copy();
}
Create.RAILWAYS.removeTrain(id);

View file

@ -2,10 +2,10 @@ package com.simibubi.create.content.trains.entity;
import java.util.Map.Entry;
import com.simibubi.create.content.trains.graph.TrackGraphLocation;
import com.simibubi.create.content.trains.graph.DimensionPalette;
import com.simibubi.create.content.trains.graph.TrackEdge;
import com.simibubi.create.content.trains.graph.TrackGraph;
import com.simibubi.create.content.trains.graph.TrackGraphLocation;
import com.simibubi.create.content.trains.graph.TrackNode;
import com.simibubi.create.content.trains.graph.TrackNodeLocation;
import com.simibubi.create.foundation.utility.Couple;

View file

@ -22,10 +22,10 @@ import com.simibubi.create.content.trains.entity.TravellingPoint.IEdgePointListe
import com.simibubi.create.content.trains.entity.TravellingPoint.ITrackSelector;
import com.simibubi.create.content.trains.entity.TravellingPoint.ITurnListener;
import com.simibubi.create.content.trains.entity.TravellingPoint.SteerDirection;
import com.simibubi.create.content.trains.graph.TrackGraphLocation;
import com.simibubi.create.content.trains.graph.TrackEdge;
import com.simibubi.create.content.trains.graph.TrackGraph;
import com.simibubi.create.content.trains.graph.TrackGraphHelper;
import com.simibubi.create.content.trains.graph.TrackGraphLocation;
import com.simibubi.create.content.trains.graph.TrackNode;
import com.simibubi.create.content.trains.track.BezierTrackPointLocation;
import com.simibubi.create.content.trains.track.ITrackBlock;

View file

@ -16,11 +16,11 @@ import java.util.function.Predicate;
import javax.annotation.Nullable;
import com.simibubi.create.Create;
import com.simibubi.create.content.trains.graph.TrackGraphLocation;
import com.simibubi.create.content.trains.graph.DimensionPalette;
import com.simibubi.create.content.trains.graph.EdgeData;
import com.simibubi.create.content.trains.graph.TrackEdge;
import com.simibubi.create.content.trains.graph.TrackGraph;
import com.simibubi.create.content.trains.graph.TrackGraphLocation;
import com.simibubi.create.content.trains.graph.TrackNode;
import com.simibubi.create.content.trains.graph.TrackNodeLocation;
import com.simibubi.create.content.trains.signal.TrackEdgePoint;

View file

@ -149,11 +149,11 @@ public class TrackGraphHelper {
BezierTrackPointLocation targetBezier) {
BlockState state = level.getBlockState(pos);
if (!(state.getBlock()instanceof ITrackBlock track))
if (!(state.getBlock() instanceof ITrackBlock track))
return null;
if (!(level.getBlockEntity(pos)instanceof TrackBlockEntity trackTE))
if (!(level.getBlockEntity(pos) instanceof TrackBlockEntity trackBE))
return null;
BezierConnection bc = trackTE.getConnections()
BezierConnection bc = trackBE.getConnections()
.get(targetBezier.curveTarget());
if (bc == null || !bc.isPrimary())
return null;

View file

@ -36,10 +36,10 @@ import com.simibubi.create.content.trains.entity.CarriageContraption;
import com.simibubi.create.content.trains.entity.Train;
import com.simibubi.create.content.trains.entity.TrainPacket;
import com.simibubi.create.content.trains.entity.TravellingPoint;
import com.simibubi.create.content.trains.graph.TrackGraphLocation;
import com.simibubi.create.content.trains.graph.EdgePointType;
import com.simibubi.create.content.trains.graph.TrackEdge;
import com.simibubi.create.content.trains.graph.TrackGraph;
import com.simibubi.create.content.trains.graph.TrackGraphLocation;
import com.simibubi.create.content.trains.graph.TrackNode;
import com.simibubi.create.content.trains.graph.TrackNodeLocation;
import com.simibubi.create.content.trains.graph.TrackNodeLocation.DiscoveredLocation;
@ -296,18 +296,18 @@ public class StationBlockEntity extends SmartBlockEntity implements ITransformab
if (!(blockState.getBlock() instanceof AbstractBogeyBlock<?> bogey))
continue;
BlockEntity be = level.getBlockEntity(bogeyPos);
if (!(be instanceof AbstractBogeyBlockEntity oldTE))
if (!(be instanceof AbstractBogeyBlockEntity oldBE))
continue;
CompoundTag oldData = oldTE.getBogeyData();
BlockState newBlock = bogey.getNextSize(oldTE);
CompoundTag oldData = oldBE.getBogeyData();
BlockState newBlock = bogey.getNextSize(oldBE);
if (newBlock.getBlock() == bogey)
player.displayClientMessage(Lang.translateDirect("bogey.style.no_other_sizes")
.withStyle(ChatFormatting.RED), true);
level.setBlock(bogeyPos, newBlock, 3);
BlockEntity newEntity = level.getBlockEntity(bogeyPos);
if (!(newEntity instanceof AbstractBogeyBlockEntity newTE))
if (!(newEntity instanceof AbstractBogeyBlockEntity newBE))
continue;
newTE.setBogeyData(oldData);
newBE.setBogeyData(oldData);
bogey.playRotateSound(level, bogeyPos);
return true;
}
@ -748,9 +748,9 @@ public class StationBlockEntity extends SmartBlockEntity implements ITransformab
AbstractBogeyBlock<?> typeOfFirstBogey = bogeyTypes[bogeyIndex];
boolean firstBogeyIsUpsideDown = upsideDownBogeys[bogeyIndex];
BlockPos firstBogeyPos = contraption.anchor;
AbstractBogeyBlockEntity firstBogeyTileEntity = (AbstractBogeyBlockEntity) level.getBlockEntity(firstBogeyPos);
AbstractBogeyBlockEntity firstBogeyBlockEntity = (AbstractBogeyBlockEntity) level.getBlockEntity(firstBogeyPos);
CarriageBogey firstBogey =
new CarriageBogey(typeOfFirstBogey, firstBogeyIsUpsideDown, firstBogeyTileEntity.getBogeyData(), points.get(pointIndex), points.get(pointIndex + 1));
new CarriageBogey(typeOfFirstBogey, firstBogeyIsUpsideDown, firstBogeyBlockEntity.getBogeyData(), points.get(pointIndex), points.get(pointIndex + 1));
CarriageBogey secondBogey = null;
BlockPos secondBogeyPos = contraption.getSecondBogeyPos();
int bogeySpacing = 0;
@ -762,10 +762,10 @@ public class StationBlockEntity extends SmartBlockEntity implements ITransformab
contraptions.size() + 1);
return;
}
AbstractBogeyBlockEntity secondBogeyTileEntity =
AbstractBogeyBlockEntity secondBogeyBlockEntity =
(AbstractBogeyBlockEntity) level.getBlockEntity(secondBogeyPos);
bogeySpacing = bogeyLocations[bogeyIndex + 1] - bogeyLocations[bogeyIndex];
secondBogey = new CarriageBogey(bogeyTypes[bogeyIndex + 1], upsideDownBogeys[bogeyIndex + 1], secondBogeyTileEntity.getBogeyData(),
secondBogey = new CarriageBogey(bogeyTypes[bogeyIndex + 1], upsideDownBogeys[bogeyIndex + 1], secondBogeyBlockEntity.getBogeyData(),
points.get(pointIndex + 2), points.get(pointIndex + 3));
bogeyIndex++;

View file

@ -281,8 +281,8 @@ public class TrackBlock extends Block
level.setBlock(pos, state.setValue(SHAPE, TrackShape.asPortal(d))
.setValue(HAS_BE, true), 3);
BlockEntity be = level.getBlockEntity(pos);
if (be instanceof TrackBlockEntity tte)
tte.bind(otherLevel.dimension(), otherTrackPos);
if (be instanceof TrackBlockEntity tbe)
tbe.bind(otherLevel.dimension(), otherTrackPos);
otherLevel.setBlock(otherTrackPos, state.setValue(SHAPE, TrackShape.asPortal(otherTrack.getFace()))
.setValue(HAS_BE, true), 3);
@ -403,24 +403,24 @@ public class TrackBlock extends Block
return list;
BlockEntity blockEntity = world.getBlockEntity(pos);
if (!(blockEntity instanceof TrackBlockEntity trackTE))
if (!(blockEntity instanceof TrackBlockEntity trackBE))
return list;
Map<BlockPos, BezierConnection> connections = trackTE.getConnections();
Map<BlockPos, BezierConnection> connections = trackBE.getConnections();
connections.forEach((connectedPos, bc) -> ITrackBlock.addToListIfConnected(connectedTo, list,
(d, b) -> d == 1 ? Vec3.atLowerCornerOf(bc.tePositions.get(b)) : bc.starts.get(b), bc.normals::get,
b -> world instanceof Level l ? l.dimension() : Level.OVERWORLD, bc::yOffsetAt, null, bc,
(b, v) -> ITrackBlock.getMaterialSimple(world, v, bc.getMaterial())));
if (trackTE.boundLocation == null || !(world instanceof ServerLevel level))
if (trackBE.boundLocation == null || !(world instanceof ServerLevel level))
return list;
ResourceKey<Level> otherDim = trackTE.boundLocation.getFirst();
ResourceKey<Level> otherDim = trackBE.boundLocation.getFirst();
ServerLevel otherLevel = level.getServer()
.getLevel(otherDim);
if (otherLevel == null)
return list;
BlockPos boundPos = trackTE.boundLocation.getSecond();
BlockPos boundPos = trackBE.boundLocation.getSecond();
BlockState boundState = otherLevel.getBlockState(boundPos);
if (!AllTags.AllBlockTags.TRACKS.matches(boundState))
return list;
@ -628,9 +628,9 @@ public class TrackBlock extends Block
Level level = context.getLevel();
if (!level.isClientSide && !player.isCreative() && state.getValue(HAS_BE)) {
BlockEntity blockEntity = level.getBlockEntity(context.getClickedPos());
if (blockEntity instanceof TrackBlockEntity trackTE) {
trackTE.cancelDrops = true;
trackTE.connections.values()
if (blockEntity instanceof TrackBlockEntity trackBE) {
trackBE.cancelDrops = true;
trackBE.connections.values()
.forEach(bc -> bc.addItemsToPlayer(player));
}
}
@ -707,8 +707,8 @@ public class TrackBlock extends Block
Vec3 normal = null;
Vec3 offset = null;
if (bezierPoint != null && world.getBlockEntity(pos) instanceof TrackBlockEntity trackTE) {
BezierConnection bc = trackTE.connections.get(bezierPoint.curveTarget());
if (bezierPoint != null && world.getBlockEntity(pos) instanceof TrackBlockEntity trackBE) {
BezierConnection bc = trackBE.connections.get(bezierPoint.curveTarget());
if (bc != null) {
double length = Mth.floor(bc.getLength() * 2);
int seg = bezierPoint.segment() + 1;

View file

@ -107,14 +107,14 @@ public class TrackBlockEntity extends SmartBlockEntity implements ITransformable
}
BlockEntity blockEntity = level.getBlockEntity(key);
if (!(blockEntity instanceof TrackBlockEntity trackTE) || blockEntity.isRemoved()) {
if (!(blockEntity instanceof TrackBlockEntity trackBE) || blockEntity.isRemoved()) {
invalid.add(key);
continue;
}
if (!trackTE.connections.containsKey(worldPosition)) {
trackTE.addConnection(bc.secondary());
trackTE.tilt.tryApplySmoothing();
if (!trackBE.connections.containsKey(worldPosition)) {
trackBE.addConnection(bc.secondary());
trackBE.tilt.tryApplySmoothing();
}
}

View file

@ -59,7 +59,7 @@ public class TrackBlockItem extends BlockItem {
Vec3 lookAngle = player.getLookAngle();
if (!isFoil(stack)) {
if (state.getBlock()instanceof TrackBlock track && track.getTrackAxes(level, pos, state)
if (state.getBlock() instanceof TrackBlock track && track.getTrackAxes(level, pos, state)
.size() > 1) {
if (!level.isClientSide)
player.displayClientMessage(Lang.translateDirect("track.junction_start")

View file

@ -269,8 +269,8 @@ public class TrackTargetingBehaviour<T extends TrackEdgePoint> extends BlockEnti
public BlockPos getPositionForMapMarker() {
BlockPos target = targetTrack.offset(blockEntity.getBlockPos());
if (targetBezier != null && getWorld().getBlockEntity(target) instanceof TrackBlockEntity tte) {
BezierConnection bc = tte.getConnections()
if (targetBezier != null && getWorld().getBlockEntity(target) instanceof TrackBlockEntity tbe) {
BezierConnection bc = tbe.getConnections()
.get(targetBezier.curveTarget());
if (bc == null)
return target;

View file

@ -44,8 +44,8 @@ public interface IBE<T extends BlockEntity> extends EntityBlock {
if (blockState.is(newBlockState.getBlock()) && newBlockState.hasBlockEntity())
return;
BlockEntity blockEntity = level.getBlockEntity(pos);
if (blockEntity instanceof SmartBlockEntity ste)
ste.destroy();
if (blockEntity instanceof SmartBlockEntity sbe)
sbe.destroy();
level.removeBlockEntity(pos);
}

View file

@ -4,6 +4,7 @@ import java.util.function.Consumer;
import org.lwjgl.glfw.GLFW;
import com.mojang.blaze3d.platform.Window;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.AllKeys;
@ -222,7 +223,7 @@ public class ValueSettingsScreen extends AbstractSimiScreen {
.format(closest);
AllIcons cursorIcon = null;
if (board.formatter()instanceof ScrollOptionSettingsFormatter sosf)
if (board.formatter() instanceof ScrollOptionSettingsFormatter sosf)
cursorIcon = sosf.getIcon(closest);
int cursorWidth = ((cursorIcon != null ? 16 : font.width(cursorText)) / 2) * 2 + 3;
@ -293,20 +294,36 @@ public class ValueSettingsScreen extends AbstractSimiScreen {
return true;
}
@Override
public boolean keyReleased(int pKeyCode, int pScanCode, int pModifiers) {
if (minecraft.options.keyUse.matches(pKeyCode, pScanCode)) {
Window window = minecraft.getWindow();
double x = minecraft.mouseHandler.xpos() * window.getGuiScaledWidth() / window.getScreenWidth();
double y = minecraft.mouseHandler.ypos() * window.getGuiScaledHeight() / window.getScreenHeight();
saveAndClose(x, y);
return true;
}
return super.keyReleased(pKeyCode, pScanCode, pModifiers);
}
@Override
public boolean mouseReleased(double pMouseX, double pMouseY, int pButton) {
if (pButton == 1) {
ValueSettings closest = getClosestCoordinate((int) pMouseX, (int) pMouseY);
// FIXME: value settings may be face-sensitive on future components
AllPackets.getChannel()
.sendToServer(new ValueSettingsPacket(pos, closest.row(), closest.value(), null, Direction.UP,
AllKeys.ctrlDown()));
onClose();
if (minecraft.options.keyUse.matchesMouse(pButton)) {
saveAndClose(pMouseX, pMouseY);
return true;
}
return super.mouseReleased(pMouseX, pMouseY, pButton);
}
protected void saveAndClose(double pMouseX, double pMouseY) {
ValueSettings closest = getClosestCoordinate((int) pMouseX, (int) pMouseY);
// FIXME: value settings may be face-sensitive on future components
AllPackets.getChannel()
.sendToServer(new ValueSettingsPacket(pos, closest.row(), closest.value(), null, Direction.UP,
AllKeys.ctrlDown()));
onClose();
}
@Override
public void onClose() {
super.onClose();

View file

@ -263,7 +263,7 @@ public class FilteringBehaviour extends BlockEntityBehaviour implements ValueSet
public MutableComponent formatValue(ValueSettings value) {
if (value.row() == 0 && value.value() == filter.getMaxStackSize())
return Components.literal("Any");
return Lang.translateDirect("logistics.filter.any_amount_short");
return Components.literal(((value.row() == 0) ? "\u2264" : "=") + Math.max(1, value.value()));
}

View file

@ -13,14 +13,18 @@ import com.simibubi.create.foundation.blockEntity.behaviour.ValueSettingsBehavio
import com.simibubi.create.foundation.blockEntity.behaviour.ValueSettingsBoard;
import com.simibubi.create.foundation.blockEntity.behaviour.ValueSettingsFormatter;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.util.Mth;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.common.util.FakePlayer;
public class ScrollValueBehaviour extends BlockEntityBehaviour implements ValueSettingsBehaviour {
@ -175,4 +179,12 @@ public class ScrollValueBehaviour extends BlockEntityBehaviour implements ValueS
return needsWrench;
}
@Override
public void onShortInteract(Player player, InteractionHand hand, Direction side) {
if (player instanceof FakePlayer)
blockEntity.getBlockState()
.use(getWorld(), player, hand,
new BlockHitResult(VecHelper.getCenterOf(getPos()), side, getPos(), true));
}
}

View file

@ -119,7 +119,6 @@ public class BuilderTransformers {
.addLayer(() -> RenderType::cutoutMipped)
.addLayer(() -> RenderType::translucent)
.color(() -> CopycatBlock::wrappedColor)
.tag(AllBlockTags.SAFE_NBT.tag)
.transform(TagGen.axeOrPickaxe());
}

View file

@ -31,12 +31,12 @@ public class MetalBarsGen {
String name, boolean specialEdge) {
return (c, p) -> {
ModelFile post_ends = barsSubModel(p, name, "_post_ends", specialEdge);
ModelFile post = barsSubModel(p, name, "_post", specialEdge);
ModelFile cap = barsSubModel(p, name, "_cap", specialEdge);
ModelFile cap_alt = barsSubModel(p, name, "_cap_alt", specialEdge);
ModelFile side = barsSubModel(p, name, "_side", specialEdge);
ModelFile side_alt = barsSubModel(p, name, "_side_alt", specialEdge);
ModelFile post_ends = barsSubModel(p, name, "post_ends", specialEdge);
ModelFile post = barsSubModel(p, name, "post", specialEdge);
ModelFile cap = barsSubModel(p, name, "cap", specialEdge);
ModelFile cap_alt = barsSubModel(p, name, "cap_alt", specialEdge);
ModelFile side = barsSubModel(p, name, "side", specialEdge);
ModelFile side_alt = barsSubModel(p, name, "side_alt", specialEdge);
p.getMultipartBuilder(c.get())
.part()
@ -115,7 +115,7 @@ public class MetalBarsGen {
ResourceLocation barsTexture = p.modLoc("block/bars/" + name + "_bars");
ResourceLocation edgeTexture = specialEdge ? p.modLoc("block/bars/" + name + "_bars_edge") : barsTexture;
return p.models()
.withExistingParent(name + suffix, p.mcLoc("block/iron_bars" + suffix))
.withExistingParent(name + "_" + suffix, p.modLoc("block/bars/" + suffix))
.texture("bars", barsTexture)
.texture("particle", barsTexture)
.texture("edge", edgeTexture);
@ -130,6 +130,7 @@ public class MetalBarsGen {
.color(color))
.tag(AllBlockTags.WRENCH_PICKUP.tag)
.tag(AllBlockTags.FAN_TRANSPARENT.tag)
.transform(TagGen.pickaxeOnly())
.blockstate(barsBlockState(name, specialEdge))
.item()
.model((c, p) -> {

View file

@ -25,6 +25,7 @@ public class ScrollInput extends AbstractSimiWidget {
protected Component hint = null;
protected Label displayLabel;
protected boolean inverted;
protected boolean soundPlayed;
protected Function<Integer, Component> formatter;
protected int min, max;
@ -39,6 +40,7 @@ public class ScrollInput extends AbstractSimiWidget {
shiftStep = 5;
step = standardStep();
formatter = i -> Components.literal(String.valueOf(i));
soundPlayed = false;
}
public Function<StepContext, Integer> standardStep() {
@ -95,6 +97,12 @@ public class ScrollInput extends AbstractSimiWidget {
return this;
}
@Override
public void tick() {
super.tick();
soundPlayed = false;
}
public int getState() {
return state;
}
@ -135,10 +143,12 @@ public class ScrollInput extends AbstractSimiWidget {
clampState();
if (priorState != state) {
Minecraft.getInstance()
.getSoundManager()
.play(SimpleSoundInstance.forUI(AllSoundEvents.SCROLL_VALUE.getMainEvent(),
1.5f + 0.1f * (state - min) / (max - min)));
if (!soundPlayed)
Minecraft.getInstance()
.getSoundManager()
.play(SimpleSoundInstance.forUI(AllSoundEvents.SCROLL_VALUE.getMainEvent(),
1.5f + 0.1f * (state - min) / (max - min)));
soundPlayed = true;
onChanged();
}

View file

@ -9,14 +9,17 @@ import com.simibubi.create.content.equipment.armor.NetheriteDivingHandler;
import net.minecraft.world.entity.Entity;
@Mixin(Entity.class)
@Mixin(value = Entity.class, priority = 900)
public class EntityMixin {
@Inject(method = "fireImmune()Z", at = @At("RETURN"), cancellable = true)
public void create$onFireImmune(CallbackInfoReturnable<Boolean> cir) {
if (!cir.getReturnValueZ()) {
Entity self = (Entity) (Object) this;
boolean immune = self.getPersistentData().getBoolean(NetheriteDivingHandler.FIRE_IMMUNE_KEY);
cir.setReturnValue(immune);
if (immune)
cir.setReturnValue(immune);
}
}
}

View file

@ -5,6 +5,7 @@ import java.util.function.Consumer;
import javax.annotation.Nullable;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllTags.AllBlockTags;
import com.simibubi.create.content.kinetics.base.KineticBlockEntity;
import com.simibubi.create.foundation.blockEntity.IMergeableBE;
@ -233,6 +234,21 @@ public class BlockHelper {
.getBlock(), target.below());
}
public static CompoundTag prepareBlockEntityData(BlockState blockState, BlockEntity blockEntity) {
CompoundTag data = null;
if (blockEntity == null)
return data;
if (AllBlockTags.SAFE_NBT.matches(blockState)) {
data = blockEntity.saveWithFullMetadata();
data = NBTProcessors.process(blockEntity, data, true);
} else if (blockEntity instanceof IPartialSafeNBT) {
data = new CompoundTag();
((IPartialSafeNBT) blockEntity).writeSafe(data);
data = NBTProcessors.process(blockEntity, data, true);
}
return data;
}
public static void placeSchematicBlock(Level world, BlockState state, BlockPos target, ItemStack stack,
@Nullable CompoundTag data) {
BlockEntity existingBlockEntity = world.getBlockEntity(target);

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