Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/mc1.18/dev' into mc1.18/fabric…
Browse files Browse the repository at this point in the history
…/dev

# Conflicts:
#	gradle.properties
#	src/generated/resources/.cache/cache
#	src/main/java/com/simibubi/create/content/equipment/toolbox/ToolboxInventory.java
#	src/main/java/com/simibubi/create/content/fluids/drain/ItemDrainItemHandler.java
#	src/main/java/com/simibubi/create/content/kinetics/belt/BeltBlock.java
#	src/main/java/com/simibubi/create/content/kinetics/belt/transport/ItemHandlerBeltSegment.java
#	src/main/java/com/simibubi/create/content/kinetics/deployer/DeployerItemHandler.java
#	src/main/java/com/simibubi/create/content/logistics/chute/ChuteItemHandler.java
#	src/main/java/com/simibubi/create/content/logistics/tunnel/BrassTunnelItemHandler.java
#	src/main/java/com/simibubi/create/content/processing/basin/BasinBlockEntity.java
#	src/main/java/com/simibubi/create/foundation/item/ItemHelper.java
#	src/main/java/com/simibubi/create/foundation/ponder/PonderWorld.java
  • Loading branch information
IThundxr committed Oct 9, 2024
2 parents 76489aa + 2828c88 commit 5e3dbd3
Show file tree
Hide file tree
Showing 33 changed files with 176 additions and 62 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ loader_version = 0.15.7
fabric_version = 0.77.0+1.18.2

# Mod Properties
mod_version = 0.5.1-h
mod_version = 0.5.1-i
maven_group = com.simibubi.create

# Dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"parent": "minecraft:recipes/root",
"rewards": {
"recipes": [
"create:blasting/ingot_aluminum_compat_ic2"
"create:blasting/ingot_aluminium_compat_ic2"
]
},
"criteria": {
Expand All @@ -21,7 +21,7 @@
"has_the_recipe": {
"trigger": "minecraft:recipe_unlocked",
"conditions": {
"recipe": "create:blasting/ingot_aluminum_compat_ic2"
"recipe": "create:blasting/ingot_aluminium_compat_ic2"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"parent": "minecraft:recipes/root",
"rewards": {
"recipes": [
"create:smelting/ingot_aluminum_compat_ic2"
"create:smelting/ingot_aluminium_compat_ic2"
]
},
"criteria": {
Expand All @@ -21,7 +21,7 @@
"has_the_recipe": {
"trigger": "minecraft:recipe_unlocked",
"conditions": {
"recipe": "create:smelting/ingot_aluminum_compat_ic2"
"recipe": "create:smelting/ingot_aluminium_compat_ic2"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"ingredient": {
"item": "create:crushed_raw_aluminum"
},
"result": "ic2:ingot_aluminum",
"result": "ic2:ingot_aluminium",
"experience": 0.1,
"cookingtime": 100,
"fabric:load_conditions": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"ingredient": {
"item": "create:crushed_raw_aluminum"
},
"result": "ic2:ingot_aluminum",
"result": "ic2:ingot_aluminium",
"experience": 0.1,
"cookingtime": 200,
"fabric:load_conditions": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
],
"results": [
{
"item": "ic2:nugget_aluminum",
"item": "ic2:nugget_aluminium",
"count": 9
}
],
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/simibubi/create/Create.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public class Create implements ModInitializer {

public static final String ID = "create";
public static final String NAME = "Create";
public static final String VERSION = "0.5.1h";
public static final String VERSION = "0.5.1i";

public static final Logger LOGGER = LogUtils.getLogger();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1138,6 +1138,7 @@ public void addBlocksToWorld(Level world, StructureTransform transform) {
if (blockEntity instanceof IMultiBlockEntityContainer) {
if (tag.contains("LastKnownPos") || capturedMultiblocks.isEmpty()) {
tag.put("LastKnownPos", NbtUtils.writeBlockPos(BlockPos.ZERO.below(Integer.MAX_VALUE - 1)));
tag.remove("Controller");
}
}

Expand Down Expand Up @@ -1194,6 +1195,9 @@ protected void translateMultiblockControllers(StructureTransform transform) {
// swap nbt data to the new controller position
StructureBlockInfo prevControllerInfo = blocks.get(controllerPos);
StructureBlockInfo newControllerInfo = blocks.get(otherPos);
if (prevControllerInfo == null || newControllerInfo == null)
return;

blocks.put(otherPos, new StructureBlockInfo(newControllerInfo.pos, newControllerInfo.state, prevControllerInfo.nbt));
blocks.put(controllerPos, new StructureBlockInfo(prevControllerInfo.pos, prevControllerInfo.state, newControllerInfo.nbt));
});
Expand Down Expand Up @@ -1385,6 +1389,9 @@ public void invalidateColliders() {

private void gatherBBsOffThread() {
getContraptionWorld();
if (simplifiedEntityColliderProvider != null) {
simplifiedEntityColliderProvider.cancel(false);
}
simplifiedEntityColliderProvider = CompletableFuture.supplyAsync(() -> {
VoxelShape combinedShape = Shapes.empty();
for (Entry<BlockPos, StructureBlockInfo> entry : blocks.entrySet()) {
Expand All @@ -1401,7 +1408,6 @@ private void gatherBBsOffThread() {
})
.thenAccept(r -> {
simplifiedEntityColliders = Optional.of(r);
simplifiedEntityColliderProvider = null;
});
}

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

import com.simibubi.create.AllBlockEntityTypes;
import com.simibubi.create.AllTags.AllBlockTags;
import com.simibubi.create.content.equipment.toolbox.ToolboxInventory;
import com.simibubi.create.content.kinetics.crafter.MechanicalCrafterBlockEntity;
import com.simibubi.create.content.logistics.crate.BottomlessItemHandler;
import com.simibubi.create.content.logistics.vault.ItemVaultBlockEntity;
Expand Down Expand Up @@ -185,6 +186,8 @@ public CompoundTag serialize() {
CompoundTag tag = handler.serializeNBT();
if (noFuel)
NBTHelper.putMarker(tag, "NoFuel");
if (handler instanceof ToolboxInventory)
NBTHelper.putMarker(tag, "Toolbox");
if (!(handler instanceof BottomlessItemHandler))
return tag;

Expand All @@ -198,6 +201,9 @@ public static MountedStorage deserialize(CompoundTag nbt) {
storage.handler = new ItemStackHandler();
if (nbt == null)
return storage;
if (nbt.contains("Toolbox"))
storage.handler = new ToolboxInventory(null);

storage.valid = true;
storage.noFuel = nbt.contains("NoFuel");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ protected void write(CompoundTag tag, boolean clientPacket) {
protected void read(CompoundTag tag, boolean clientPacket) {
super.read(tag, clientPacket);
dataContainer = ItemStack.of(tag.getCompound("Item"));
if (!AllBlocks.CLIPBOARD.isIn(dataContainer))
dataContainer = AllBlocks.CLIPBOARD.asStack();

if (clientPacket)
EnvExecutor.runWhenOn(EnvType.CLIENT, () -> () -> readClientSide(tag));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ else if (!stackInSlot.isEmpty()) {
}
}
settling = false;
blockEntity.sendData();
notifyUpdate();
}

@Override
Expand Down Expand Up @@ -131,8 +131,8 @@ private void updateCompartmentFilters(int slot, ItemStack stack, @Nullable Trans
if (!stack.isEmpty() && filters.get(compartment)
.isEmpty()) {
filters.set(compartment, ItemHandlerHelper.copyStackWithSize(stack, 1));
if (ctx != null) TransactionCallback.onSuccess(ctx, blockEntity::sendData);
else blockEntity.sendData();
if (ctx != null) TransactionCallback.onSuccess(ctx, blockEntity::notifyUpdate);
else notifyUpdate();
}
}

Expand All @@ -145,10 +145,9 @@ public CompoundTag serializeNBT() {

@Override
protected void onContentsChanged(int slot) {
if (!settling && !blockEntity.getLevel().isClientSide)
if (!settling && (blockEntity == null || !blockEntity.getLevel().isClientSide))
settle(slot / STACKS_PER_COMPARTMENT);
blockEntity.sendData();
blockEntity.setChanged();
notifyUpdate();
super.onContentsChanged(slot);
}

Expand Down Expand Up @@ -240,6 +239,11 @@ public static boolean canItemsShareCompartment(ItemStack stack1, ItemStack stack
return ItemHandlerHelper.canItemStacksStack(stack1, stack2);
}

private void notifyUpdate() {
if (blockEntity != null)
blockEntity.notifyUpdate();
}

public static class ToolboxSnapshotData implements ItemStackHandlerSnapshot {
public final ItemStackHandlerSnapshot base;
public final List<ItemStack> filters;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.simibubi.create.content.fluids.transfer.GenericItemEmptying;
import com.simibubi.create.content.kinetics.belt.transport.TransportedItemStack;
import com.simibubi.create.foundation.item.ItemHelper;

import net.fabricmc.fabric.api.transfer.v1.item.ItemVariant;
import net.fabricmc.fabric.api.transfer.v1.storage.base.SingleSlotStorage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,8 @@ public boolean addToGoggleTooltip(List<Component> tooltip, boolean isPlayerSneak
float speed = getTheoreticalSpeed();
if (speed != getGeneratedSpeed() && speed != 0)
stressBase *= getGeneratedSpeed() / speed;
speed = Math.abs(speed);

float stressTotal = stressBase * speed;
float stressTotal = Math.abs(stressBase * speed);

Lang.number(stressTotal)
.translate("generic.unit.stress")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ protected void renderItems(BeltBlockEntity be, float partialTicks, PoseStack ms,
be.getBlockPos().getZ())
.add(offsetVec);

if (this.shouldCullItem(itemPos)) {
if (this.shouldCullItem(itemPos, be.getLevel())) {
continue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.function.Supplier;

import com.simibubi.create.foundation.blockEntity.behaviour.filtering.FilteringBehaviour;
import com.simibubi.create.foundation.item.ItemHelper;

import io.github.fabricators_of_create.porting_lib.transfer.item.ItemHandlerHelper;
import net.fabricmc.fabric.api.transfer.v1.item.ItemVariant;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import com.simibubi.create.foundation.item.ItemHelper;

import com.simibubi.create.foundation.item.ItemHelper;

import net.fabricmc.fabric.api.transfer.v1.item.ItemVariant;
import net.fabricmc.fabric.api.transfer.v1.storage.base.SingleVariantStorage;
import net.fabricmc.fabric.api.transfer.v1.transaction.TransactionContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public InteractionResult use(BlockState state, Level worldIn, BlockPos pos, Play
withBlockEntityDo(worldIn, pos, be -> {
ItemStack toInsert = heldItem.copy();
ItemStack remainder = tryInsert(worldIn, pos, toInsert, false);
if (!ItemStack.matches(remainder, toInsert))
if (!ItemStack.matches(remainder, toInsert) || remainder.getCount() != heldItem.getCount())
player.setItemInHand(handIn, remainder);
});
return InteractionResult.SUCCESS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,8 @@ private void tryClearingSpoutputOverflow() {
if (filter != null && !filter.test(itemStack))
continue;

visualizedOutputItems.add(LongAttached.withZero(itemStack));
if (visualizedOutputItems.size() < 3)
visualizedOutputItems.add(LongAttached.withZero(itemStack));
update = true;

inserted = TransferUtil.insertItem(targetInv, itemStack.copy());
Expand Down Expand Up @@ -492,6 +493,7 @@ private void tryClearingSpoutputOverflow() {

update = true;
iterator.remove();
if (visualizedOutputFluids.size() < 3)
visualizedOutputFluids.add(LongAttached.withZero(fluidStack));
nested.commit();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.simibubi.create.content.trains.display.FlapDisplayLayout;
import com.simibubi.create.foundation.gui.ModularGuiLineBuilder;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.NBTProcessors;

import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
Expand All @@ -38,6 +39,12 @@ public void transferData(DisplayLinkContext context, DisplayTarget activeTarget,
List<MutableComponent> text = provideText(context, stats);
if (text.isEmpty())
text = EMPTY;

if (activeTarget.requiresComponentSanitization())
for (MutableComponent component : text)
if (NBTProcessors.textComponentHasClickEvent(component))
return; // Naughty

activeTarget.acceptText(line, text, context);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,9 @@ public boolean isReserved(int line, BlockEntity target, DisplayLinkContext conte
tag.remove("DisplayLink");
return false;
}

public boolean requiresComponentSanitization() {
return false;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,10 @@ private ItemStack signBook(ItemStack book) {

return written;
}

@Override
public boolean requiresComponentSanitization() {
return true;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,10 @@ public void acceptText(int line, List<MutableComponent> text, DisplayLinkContext
public DisplayTargetStats provideStats(DisplayLinkContext context) {
return new DisplayTargetStats(4, 15, this);
}

@Override
public boolean requiresComponentSanitization() {
return true;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import java.util.stream.Stream;

import com.simibubi.create.Create;
import com.simibubi.create.foundation.blockEntity.IMultiBlockEntityContainer;
import com.simibubi.create.foundation.blockEntity.SmartBlockEntity;
import com.simibubi.create.foundation.utility.BBHelper;
import com.simibubi.create.foundation.utility.NBTProcessors;
import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld;
Expand Down Expand Up @@ -250,5 +252,25 @@ public ServerLevel getLevel() {
}
throw new IllegalStateException("Cannot use IServerWorld#getWorld in a client environment");
}

public void fixControllerBlockEntities() {
for (BlockEntity blockEntity : blockEntities.values()) {
if (!(blockEntity instanceof IMultiBlockEntityContainer multiBlockEntity))
continue;
BlockPos lastKnown = multiBlockEntity.getLastKnownPos();
BlockPos current = blockEntity.getBlockPos();
if (lastKnown == null || current == null)
continue;
if (multiBlockEntity.isController())
continue;
if (!lastKnown.equals(current)) {
BlockPos newControllerPos = multiBlockEntity.getController()
.offset(current.subtract(lastKnown));
if (multiBlockEntity instanceof SmartBlockEntity sbe)
sbe.markVirtual();
multiBlockEntity.setController(newControllerPos);
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ private void setupRenderer() {
schematic.placeInWorld(w, pos, pos, placementSettings, w.getRandom(), Block.UPDATE_CLIENTS);
for (BlockEntity blockEntity : w.getBlockEntities())
blockEntity.setLevel(w);
w.fixControllerBlockEntities();
} catch (Exception e) {
Minecraft.getInstance().player.displayClientMessage(Lang.translate("schematic.error")
.component(), false);
Expand All @@ -179,6 +180,7 @@ private void setupRenderer() {
placementSettings.getMirror());
for (BlockEntity be : wMirroredFB.getRenderedBlockEntities())
transform.apply(be);
wMirroredFB.fixControllerBlockEntities();

placementSettings.setMirror(Mirror.LEFT_RIGHT);
pos = BlockPos.ZERO.south(size.getZ() - 1);
Expand All @@ -187,6 +189,7 @@ private void setupRenderer() {
placementSettings.getMirror());
for (BlockEntity be : wMirroredLR.getRenderedBlockEntities())
transform.apply(be);
wMirroredLR.fixControllerBlockEntities();

renderers.get(0)
.display(w);
Expand Down
Loading

0 comments on commit 5e3dbd3

Please sign in to comment.