Skip to content

Commit

Permalink
Merge branch 'mc1.20.1/0.5.1' into mc1.20.1/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
simibubi committed Oct 23, 2024
2 parents 03a94dd + d39f899 commit 1935b79
Show file tree
Hide file tree
Showing 13 changed files with 18 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -545,9 +545,12 @@ protected boolean shouldActorTrigger(MovementContext context, StructureBlockInfo
relativeMotion = reverseRotation(relativeMotion, 1);
context.relativeMotion = relativeMotion;

return !BlockPos.containing(previousPosition).equals(gridPosition)
|| (context.relativeMotion.length() > 0 || context.contraption instanceof CarriageContraption)
&& context.firstMovement;
boolean ignoreMotionForFirstMovement =
context.contraption instanceof CarriageContraption || actor instanceof PortableStorageInterfaceMovement;

return !BlockPos.containing(previousPosition)
.equals(gridPosition)
|| (context.relativeMotion.length() > 0 || ignoreMotionForFirstMovement) && context.firstMovement;
}

public void move(double x, double y, double z) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ protected void createBlockStateDefinition(Builder<Block, BlockState> p_206840_1_
@Override
public int getLightEmission(BlockState state, BlockGetter world, BlockPos pos) {
FluidTankBlockEntity tankAt = ConnectivityHandler.partAt(getBlockEntityType(), world, pos);
if (tankAt == null)
if (tankAt == null || !tankAt.hasLevel())
return 0;
FluidTankBlockEntity controllerBE = tankAt.getControllerBE();
if (controllerBE == null || !controllerBE.window)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ protected void setLuminosity(int luminosity) {
@SuppressWarnings("unchecked")
@Override
public FluidTankBlockEntity getControllerBE() {
if (isController())
if (isController() || !hasLevel())
return this;
BlockEntity blockEntity = level.getBlockEntity(controller);
if (blockEntity instanceof FluidTankBlockEntity)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,6 @@ public void addBehaviours(List<BlockEntityBehaviour> behaviours) {
registerAwardables(behaviours, AllAdvancements.CRAFTER, AllAdvancements.CRAFTER_LAZY);
}

@Override
public void invalidateCaps() {
inserting.removeListener();
super.invalidateCaps();
}

@Override
public void onSpeedChanged(float previousSpeed) {
super.onSpeedChanged(previousSpeed);
Expand All @@ -138,7 +132,6 @@ public void onSpeedChanged(float previousSpeed) {

public void blockChanged() {
removeBehaviour(InvManipulationBehaviour.TYPE);
inserting.removeListener();
inserting = new InvManipulationBehaviour(this, this::getTargetFace);
attachBehaviourLate(inserting);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ public void tick() {
}
if (level.isClientSide)
return;
if (player == null)
return;

ItemStack stack = player.getMainHandItem();
if (state == State.WAITING) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,12 +273,6 @@ public void addBehaviours(List<BlockEntityBehaviour> behaviours) {
registerAwardables(behaviours, AllAdvancements.FUNNEL);
}

@Override
public void invalidateCaps() {
invManipulation.removeListener();
super.invalidateCaps();
}

private boolean supportsAmountOnFilter() {
BlockState blockState = getBlockState();
boolean beltFunnelsupportsAmount = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,6 @@ public void addBehaviours(List<BlockEntityBehaviour> behaviours) {
behaviours.add(observedTank = new TankManipulationBehaviour(this, towardBlockFacing).bypassSidedness());
}

@Override
public void invalidateCaps() {
observedInventory.removeListener();
observedTank.removeListener();
super.invalidateCaps();
}

@Override
public void tick() {
super.tick();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,6 @@ public void addBehaviours(List<BlockEntityBehaviour> behaviours) {
behaviours.add(observedTank = new TankManipulationBehaviour(this, towardBlockFacing).bypassSidedness());
}

@Override
public void invalidateCaps() {
observedInventory.removeListener();
observedTank.removeListener();
super.invalidateCaps();
}

public float getLevelForDisplay() {
return currentLevel == -1 ? 0 : currentLevel;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,8 @@ private void invalidate(CarriageContraptionEntity entity) {
}

private void createEntity(Level level, boolean loadPassengers) {
if (positionAnchor != null)
serialisedEntity.put("Pos", VecHelper.writeNBT(positionAnchor));
Entity entity = EntityType.create(serialisedEntity, level)
.orElse(null);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import com.simibubi.create.foundation.blockEntity.behaviour.filtering.FilteringBehaviour;
import com.simibubi.create.foundation.item.ItemHelper.ExtractionCountMode;
import com.simibubi.create.foundation.utility.BlockFace;
import com.simibubi.create.foundation.utility.HashableNonNullConsumer;

import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
Expand Down Expand Up @@ -80,10 +79,6 @@ protected void onHandlerInvalidated(LazyOptional<T> handler) {
targetCapability = LazyOptional.empty();
}

public void removeListener() {
targetCapability.removeListener(new HashableNonNullConsumer<>(this::onHandlerInvalidated, this));
}

@Override
public void lazyTick() {
super.lazyTick();
Expand Down Expand Up @@ -132,8 +127,6 @@ public void findNewCapability() {
Capability<T> capability = capability();
targetCapability =
bypassSided ? invBE.getCapability(capability) : invBE.getCapability(capability, targetBlockFace.getFace());
if (targetCapability.isPresent())
targetCapability.addListener(new HashableNonNullConsumer<>(this::onHandlerInvalidated, this));
}

@FunctionalInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ public static boolean isWater(Fluid fluid) {
public static boolean isLava(Fluid fluid) {
return convertToStill(fluid) == Fluids.LAVA;
}

public static boolean isSame(FluidStack fluidStack, FluidStack fluidStack2) {
return fluidStack.getFluid() == fluidStack2.getFluid();
}

public static boolean isSame(FluidStack fluidStack, Fluid fluid) {
return fluidStack.getFluid() == fluid;
}
Expand Down Expand Up @@ -147,6 +147,8 @@ public static FluidStack deserializeFluidStack(JsonObject json) {
Fluid fluid = ForgeRegistries.FLUIDS.getValue(id);
if (fluid == null)
throw new JsonSyntaxException("Unknown fluid '" + id + "'");
if (fluid == Fluids.EMPTY)
throw new JsonSyntaxException("Invalid empty fluid '" + id + "'");
int amount = GsonHelper.getAsInt(json, "amount");
FluidStack stack = new FluidStack(fluid, amount);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ else if (json.has("fluid"))

public static FluidIngredient deserialize(@Nullable JsonElement je) {
if (!isFluidIngredient(je))
throw new JsonSyntaxException("Invalid fluid ingredient: " + Objects.toString(je));
throw new JsonSyntaxException("Invalid fluid ingredient: " + je);

JsonObject json = je.getAsJsonObject();
FluidIngredient ingredient = json.has("fluidTag") ? new FluidTagIngredient() : new FluidStackIngredient();
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Technology that empowers the player.'''
[[dependencies.create]]
modId="forge"
mandatory=true
versionRange="[47.1.43,)"
versionRange="[47.1.3,)"
ordering="NONE"
side="BOTH"

Expand Down

0 comments on commit 1935b79

Please sign in to comment.