Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ local.properties
.settings/
.loadpath

## VSCode/VSCodium
.vscode/*

# External tool builders
.externalToolBuilders/

Expand All @@ -57,3 +60,4 @@ local.properties
Ponder
Ponder/
.Ponder/
.vscode/launch.json
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ val buildNum = providers.environmentVariable("GITHUB_RUN_NUMBER")
.orElse("-local")
.getOrElse("")

version = "6.0.4.0+mc$minecraftVersion$buildNum"
version = "6.0.6.0+mc$minecraftVersion$buildNum"

group = "com.simibubi.create"
base.archivesName = "create-fabric"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
Expand Down Expand Up @@ -119,7 +121,10 @@ public static void breatheUnderwater(LivingEntity entity) {
if (entity instanceof ServerPlayer sp)
AllAdvancements.DIVING_SUIT.awardTo(sp);

event.setCanBreathe(true);
event.setCanRefillAir(true);
// TODO: Find a way to make this work in Fabric if possible
// event.setCanBreathe(true);
// event.setCanRefillAir(true);
entity.setAirSupply(Math.min(entity.getMaxAirSupply(), entity.getAirSupply() + 10));
entity.addEffect(new MobEffectInstance(MobEffects.WATER_BREATHING, 30, 0, true, false, true));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.network.chat.Component;
import net.minecraft.tags.FluidTags;
import net.minecraft.util.StringUtil;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.GameType;
Expand All @@ -29,7 +30,8 @@ public static void render(GuiGraphics graphics, int width, int height) {
if (!player.getCustomData()
.contains("VisualBacktankAir"))
return;
if (!player.canDrownInFluidType(player.getEyeInFluidType()) && !player.isInLava())
// TODO: Find a way to make this work in Fabric if possible
if (/*!player.canDrownInFluidType(player.getEyeInFluidType())*/ !player.isEyeInFluid(FluidTags.WATER) && !player.isInLava())
return;

int timeLeft = player.getCustomData()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,19 +216,19 @@ public void entityInside(BlockState state, Level worldIn, BlockPos pos, Entity e
if (BeltTunnelInteractionHandler.getTunnelOnPosition(worldIn, pos) != null)
return;
withBlockEntityDo(worldIn, pos, be -> {
ItemEntity itemEntity = (ItemEntity) entityIn;
// ItemEntity itemEntity = (ItemEntity) entityIn;
Storage<ItemVariant> handler = be.getItemStorage(null);
if (handler == null)
return;
ItemStack inEntity = itemEntity.getItem();
try (Transaction t = TransferUtil.getTransaction()) {
long inserted = handler.insert(ItemVariant.of(inEntity), inEntity.getCount(), t);
long inserted = handler.insert(ItemVariant.of(asItem), asItem.getCount(), t);
asItem.shrink((int) inserted);
if (inserted == 0)
return;
if (inEntity.getCount() == inserted) {
itemEntity.discard();
} else {
inEntity.shrink((int) inserted);
if (asItem.getCount() == inserted) {
entityIn.discard();
} else if (entityIn instanceof ItemEntity itemEntity && asItem.getCount() != itemEntity.getItem().getCount()) {
itemEntity.setItem(asItem);
}
t.commit();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public EntityDimensions getDimensions(Pose pPose) {

@Override
public void recreateFromPacket(ClientboundAddEntityPacket packet) {
this.setDeltaMovement(packet.getXa(), packet.getYa(), packet.getZa());
super.recreateFromPacket(packet);
this.clientPosition = this.position();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,26 +358,22 @@ public boolean unwrapBox(ItemStack box, TransactionContext ctx) {
BlockPos target = worldPosition.relative(facing.getOpposite());
BlockState targetState = level.getBlockState(target);

UnpackingHandler handler = UnpackingHandler.REGISTRY.get(targetState);
UnpackingHandler handler = UnpackingHandler.REGISTRY.get(targetState);
UnpackingHandler toUse = handler != null ? handler : UnpackingHandler.DEFAULT;

// fabric: copy the items to actually unpack later
List<ItemStack> copy = items.stream().map(ItemStack::copy).toList();

// note: handler may modify the passed items
boolean unpacked = toUse.unpack(level, target, targetState, facing, items, orderContext, true);
boolean unpacked = toUse.unpack(level, target, targetState, facing, items, orderContext, false);

if (unpacked) {
TransactionCallback.onSuccess(ctx, () -> {
toUse.unpack(level, target, targetState, facing, copy, orderContext, false);
previouslyUnwrapped = box;
animationInward = true;
animationTicks = CYCLE;
notifyUpdate();
});
previouslyUnwrapped = box;
animationInward = true;
animationTicks = CYCLE;
}

return true;
return unpacked;
}

public void attemptToSend(List<PackagingRequest> queuedRequests) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@
import net.fabricmc.fabric.api.transfer.v1.storage.StoragePreconditions;
import net.fabricmc.fabric.api.transfer.v1.storage.base.SingleSlotStorage;
import net.fabricmc.fabric.api.transfer.v1.transaction.TransactionContext;

import net.fabricmc.fabric.api.transfer.v1.transaction.TransactionContext.Result;
import net.fabricmc.fabric.api.transfer.v1.transaction.base.SnapshotParticipant;
import io.github.fabricators_of_create.porting_lib.transfer.callbacks.TransactionCallback;

public class PackagerItemHandler implements SingleSlotStorage<ItemVariant> {
public class PackagerItemHandler extends SnapshotParticipant<ItemStack> implements SingleSlotStorage<ItemVariant> {

private final PackagerBlockEntity blockEntity;

private boolean unpackSuccessful = false;

public PackagerItemHandler(PackagerBlockEntity blockEntity) {
this.blockEntity = blockEntity;
}
Expand All @@ -27,8 +30,9 @@ public long insert(ItemVariant resource, long maxAmount, TransactionContext tran
if (!PackageItem.isPackage(resource))
return 0;
ItemStack stack = resource.toStack(1);
this.updateSnapshots(transaction);
if (blockEntity.unwrapBox(stack, transaction)) {
TransactionCallback.onSuccess(transaction, blockEntity::scheduleStockCheck);
this.unpackSuccessful = true;
return 1;
} else {
return 0;
Expand All @@ -43,9 +47,8 @@ public long extract(ItemVariant resource, long maxAmount, TransactionContext tra
ItemStack box = blockEntity.heldBox;
if (!resource.matches(box))
return 0;

this.updateSnapshots(transaction);
blockEntity.heldBox = ItemStack.EMPTY;
TransactionCallback.onSuccess(transaction, blockEntity::notifyUpdate);
return box.getCount();
}

Expand All @@ -68,4 +71,23 @@ public long getAmount() {
public long getCapacity() {
return 1;
}

@Override
protected ItemStack createSnapshot() {
return blockEntity.heldBox.copy();
}

@Override
protected void readSnapshot(ItemStack snapshot) {
blockEntity.heldBox = snapshot;
}

@Override
protected void onFinalCommit() {
if (this.unpackSuccessful) {
blockEntity.scheduleStockCheck();
this.unpackSuccessful = false;
}
blockEntity.notifyUpdate();
}
}
Copy link

@ner24 ner24 Aug 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like blockstate.onNeighborChange and blockstate.getWeakChanges are defined in IForgeBlock. Would it make sense to add default functions for these in io.github.fabricators_of_create.porting_lib.tool.extensions.BlockStateExtensions?
PS: Im brand new to this so I could be wrong

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would mean doing a PR for the porting lib

Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,13 @@ private static void updateComaratorsInner(Level level, Block provokingBlock, Blo
}

BlockState blockstate = level.getBlockState(updatePos);
blockstate.onNeighborChange(level, updatePos, provokingPos);
// TODO: Find a way to make this work in Fabric if possible
// blockstate.onNeighborChange(level, updatePos, provokingPos);
if (blockstate.isRedstoneConductor(level, updatePos)) {
updatePos.move(direction);
blockstate = level.getBlockState(updatePos);
if (blockstate.getWeakChanges(level, updatePos)) {
// TODO: Find a way to make this work in Fabric if possible
if (/*blockstate.getWeakChanges(level, updatePos)*/ blockstate.is(Blocks.COMPARATOR)) {
level.neighborChanged(blockstate, updatePos, provokingBlock, provokingPos, false);
}
}
Expand Down Expand Up @@ -359,7 +361,7 @@ protected void initCapability() {
}
}

Storage<ItemVariant> combinedInvWrapper = new CombinedStorage<>(SameSizeCombinedInvWrapper.create(invs));
Storage<ItemVariant> combinedInvWrapper = SameSizeCombinedInvWrapper.create(List.of(invs));
combinedInvWrapper = new VersionedInventoryWrapper(combinedInvWrapper);
itemCapability = combinedInvWrapper;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import net.fabricmc.fabric.api.transfer.v1.item.ItemVariant;
import net.fabricmc.fabric.api.transfer.v1.transaction.Transaction;

import io.github.fabricators_of_create.porting_lib.transfer.TransferUtil;
import io.github.fabricators_of_create.porting_lib.transfer.item.ItemHandlerHelper;

public enum CrafterUnpackingHandler implements UnpackingHandler {
Expand All @@ -43,7 +43,7 @@ public boolean unpack(Level level, BlockPos pos, BlockState state, Direction sid
if (inventories.isEmpty())
return false;

try (Transaction t = Transaction.openOuter()) {
try (Transaction t = TransferUtil.getTransaction()) {
// insert in the order's defined ordering
int max = Math.min(inventories.size(), craftingContext.size());
outer: for (int i = 0; i < max; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.simibubi.create.api.packager.unpacking.UnpackingHandler;
import com.simibubi.create.content.logistics.stockTicker.PackageOrderWithCrafts;

import io.github.fabricators_of_create.porting_lib.transfer.TransferUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.item.ItemStack;
Expand All @@ -30,7 +31,7 @@ public boolean unpack(Level level, BlockPos pos, BlockState state, Direction sid
if (targetInv == null)
return false;

try (Transaction t = Transaction.openOuter()) {
try (Transaction t = TransferUtil.getTransaction()) {
for (ItemStack stack : items) {
long inserted = targetInv.insert(ItemVariant.of(stack), stack.getCount(), t);
if (inserted != stack.getCount()) {
Expand Down