Merge remote-tracking branch 'concealed/mc1.20.1/feature-dev' into mc1.20.1/feature-dev

This commit is contained in:
IThundxr 2025-02-14 08:13:25 -05:00
commit b6d25705ac
Failed to generate hash of commit
13 changed files with 94 additions and 14 deletions

View file

@ -383,8 +383,7 @@ public class AllBlocks {
public static final BlockEntry<ShaftBlock> SHAFT = REGISTRATE.block("shaft", ShaftBlock::new)
.initialProperties(SharedProperties::stone)
.properties(p -> p.mapColor(MapColor.METAL)
.forceSolidOn())
.properties(p -> p.mapColor(MapColor.METAL).forceSolidOff())
.transform(BlockStressDefaults.setNoImpact())
.transform(pickaxeOnly())
.blockstate(BlockStateGen.axisBlockProvider(false))
@ -891,7 +890,7 @@ public class AllBlocks {
public static final BlockEntry<FluidPipeBlock> FLUID_PIPE = REGISTRATE.block("fluid_pipe", FluidPipeBlock::new)
.initialProperties(SharedProperties::copperMetal)
.properties(p -> p.forceSolidOn())
.properties(p -> p.forceSolidOff())
.transform(pickaxeOnly())
.blockstate(BlockStateGen.pipe())
.onRegister(CreateRegistrate.blockModel(() -> PipeAttachmentModel::withoutAO))

View file

@ -1,5 +1,7 @@
package com.simibubi.create.compat.computercraft.implementation.peripherals;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import org.jetbrains.annotations.NotNull;
@ -8,7 +10,11 @@ import com.simibubi.create.content.redstone.displayLink.DisplayLinkBlockEntity;
import com.simibubi.create.content.redstone.displayLink.DisplayLinkContext;
import com.simibubi.create.content.redstone.displayLink.target.DisplayTargetStats;
import dan200.computercraft.api.lua.IArguments;
import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.api.lua.LuaFunction;
import dan200.computercraft.api.lua.LuaValues;
import dan200.computercraft.api.lua.ObjectLuaTable;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.StringTag;
import net.minecraft.nbt.Tag;
@ -53,6 +59,28 @@ public class DisplayLinkPeripheral extends SyncedPeripheral<DisplayLinkBlockEnti
@LuaFunction
public final void write(String text) {
writeImpl(text);
}
@LuaFunction
public final void writeBytes(IArguments args) throws LuaException {
Object data = args.get(0);
byte[] bytes;
if (data instanceof String str) {
bytes = str.getBytes(StandardCharsets.US_ASCII);
} else if (data instanceof Map<?, ?> map) {
ObjectLuaTable table = new ObjectLuaTable(map);
bytes = new byte[table.length()];
for (int i = 0; i < bytes.length; i++) {
bytes[i] = (byte) (table.getInt(i + 1) & 0xff);
}
} else {
throw LuaValues.badArgumentOf(args, 0, "string or table");
}
writeImpl(new String(bytes, StandardCharsets.UTF_8));
}
protected final void writeImpl(String text) {
ListTag tag = blockEntity.getSourceConfig().getList(TAG_KEY, Tag.TAG_STRING);
int x = cursorX.get();

View file

@ -115,6 +115,7 @@ public class SpoutBlockEntity extends SmartBlockEntity implements IHaveGoggleInf
// Process finished
ItemStack out = FillingBySpout.fillItem(level, requiredAmountForItem, transported.stack, fluid);
if (!out.isEmpty()) {
transported.clearFanProcessingData();
List<TransportedItemStack> outList = new ArrayList<>();
TransportedItemStack held = null;
TransportedItemStack result = transported.copy();

View file

@ -2,12 +2,15 @@ package com.simibubi.create.content.kinetics.belt.transport;
import java.util.Random;
import com.simibubi.create.AllRegistries;
import com.simibubi.create.content.kinetics.belt.BeltHelper;
import com.simibubi.create.content.kinetics.fan.processing.AllFanProcessingTypes;
import com.simibubi.create.content.kinetics.fan.processing.FanProcessingType;
import com.simibubi.create.content.logistics.box.PackageItem;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
public class TransportedItemStack implements Comparable<TransportedItemStack> {
@ -77,6 +80,16 @@ public class TransportedItemStack implements Comparable<TransportedItemStack> {
nbt.putInt("InSegment", insertedAt);
nbt.putInt("Angle", angle);
nbt.putInt("InDirection", insertedFrom.get3DDataValue());
if (processedBy != null && processedBy != AllFanProcessingTypes.NONE) {
ResourceLocation key = AllRegistries.FAN_PROCESSING_TYPES.get().getKey(processedBy);
if (key == null)
throw new IllegalArgumentException("Could not get id for FanProcessingType " + processedBy + "!");
nbt.putString("FanProcessingType", key.toString());
nbt.putInt("FanProcessingTime", processingTime);
}
if (locked)
nbt.putBoolean("Locked", locked);
if (lockedExternally)
@ -95,7 +108,18 @@ public class TransportedItemStack implements Comparable<TransportedItemStack> {
stack.insertedFrom = Direction.from3DDataValue(nbt.getInt("InDirection"));
stack.locked = nbt.getBoolean("Locked");
stack.lockedExternally = nbt.getBoolean("LockedExternally");
if (nbt.contains("FanProcessingType")) {
stack.processedBy = AllFanProcessingTypes.parseLegacy(nbt.getString("FanProcessingType"));
stack.processingTime = nbt.getInt("FanProcessingTime");
}
return stack;
}
public void clearFanProcessingData() {
processedBy = null;
processingTime = 0;
}
}

View file

@ -113,6 +113,8 @@ public class BeltDeployerCallbacks {
.collect(Collectors.toList());
blockEntity.award(AllAdvancements.DEPLOYER);
transported.clearFanProcessingData();
TransportedItemStack left = transported.copy();
blockEntity.player.spawnedItemEffects = transported.stack.copy();

View file

@ -49,6 +49,8 @@ public class BeltPressingCallbacks {
boolean bulk = behaviour.specifics.canProcessInBulk() || transported.stack.getCount() == 1;
transported.clearFanProcessingData();
List<TransportedItemStack> collect = results.stream()
.map(stack -> {
TransportedItemStack copy = transported.copy();

View file

@ -22,6 +22,8 @@ import com.simibubi.create.foundation.recipe.IRecipeTypeInfo;
import net.createmod.catnip.data.Iterate;
import net.minecraft.client.Minecraft;
import net.minecraft.world.Container;
import net.minecraft.world.inventory.CraftingContainer;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.CraftingRecipe;
import net.minecraft.world.item.crafting.Ingredient;
@ -33,7 +35,7 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.IFluidHandler;
import net.minecraftforge.items.IItemHandler;
public class BasinRecipe extends ProcessingRecipe<SmartInventory> {
public class BasinRecipe extends ProcessingRecipe<Container> {
public static boolean match(BasinBlockEntity basin, Recipe<?> recipe) {
FilteringBehaviour filter = basin.getFilter();
@ -147,13 +149,15 @@ public class BasinRecipe extends ProcessingRecipe<SmartInventory> {
}
if (simulate) {
CraftingContainer remainderContainer = new DummyCraftingContainer(availableItems, extractedItemsFromSlot);
if (recipe instanceof BasinRecipe basinRecipe) {
recipeOutputItems.addAll(basinRecipe.rollResults());
for (FluidStack fluidStack : basinRecipe.getFluidResults())
if (!fluidStack.isEmpty())
recipeOutputFluids.add(fluidStack);
for (ItemStack stack : basinRecipe.getRemainingItems(basin.getInputInventory()))
for (ItemStack stack : basinRecipe.getRemainingItems(remainderContainer))
if (!stack.isEmpty())
recipeOutputItems.add(stack);
@ -162,8 +166,7 @@ public class BasinRecipe extends ProcessingRecipe<SmartInventory> {
.registryAccess()));
if (recipe instanceof CraftingRecipe craftingRecipe) {
for (ItemStack stack : craftingRecipe
.getRemainingItems(new DummyCraftingContainer(availableItems, extractedItemsFromSlot)))
for (ItemStack stack : craftingRecipe.getRemainingItems(remainderContainer))
if (!stack.isEmpty())
recipeOutputItems.add(stack);
}
@ -224,7 +227,7 @@ public class BasinRecipe extends ProcessingRecipe<SmartInventory> {
}
@Override
public boolean matches(SmartInventory inv, @Nonnull Level worldIn) {
public boolean matches(Container inv, @Nonnull Level worldIn) {
return false;
}

View file

@ -34,7 +34,7 @@ public class ValueBoxRenderer {
float zOffset = (!blockItem ? -.15f : 0) + customZOffset(filter.getItem());
ms.scale(scale, scale, scale);
ms.translate(0, 0, zOffset);
itemRenderer.renderStatic(filter, ItemDisplayContext.FIXED, light, overlay, ms, buffer, mc.level, 0);
itemRenderer.render(filter, ItemDisplayContext.FIXED, false, ms, buffer, light, overlay, modelWithOverrides);
}
public static void renderFlatItemIntoValueBox(ItemStack filter, PoseStack ms, MultiBufferSource buffer, int light,

View file

@ -5,6 +5,7 @@ import com.simibubi.create.AllTags.AllItemTags;
import com.simibubi.create.CreateClient;
import com.simibubi.create.foundation.blockEntity.SmartBlockEntity;
import com.simibubi.create.foundation.blockEntity.behaviour.filtering.SidedFilteringBehaviour;
import com.simibubi.create.foundation.utility.AdventureUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.world.InteractionHand;
@ -95,7 +96,6 @@ public class ValueSettingsInputHandler {
}
public static boolean canInteract(Player player) {
return player != null && !player.isSpectator() && !player.isShiftKeyDown();
return player != null && !player.isSpectator() && !player.isShiftKeyDown() && !AdventureUtil.isAdventure(player);
}
}

View file

@ -22,7 +22,7 @@ public class CountedItemStackList {
public CountedItemStackList(IItemHandler inventory, FilteringBehaviour filteringBehaviour) {
for (int slot = 0; slot < inventory.getSlots(); slot++) {
ItemStack extractItem = inventory.extractItem(slot, inventory.getSlotLimit(slot), true);
ItemStack extractItem = inventory.getStackInSlot(slot);
if (filteringBehaviour.test(extractItem))
add(extractItem);
}

View file

@ -2,6 +2,8 @@ package com.simibubi.create.foundation.networking;
import com.simibubi.create.foundation.blockEntity.SyncedBlockEntity;
import com.simibubi.create.foundation.utility.AdventureUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.server.level.ServerPlayer;
@ -33,7 +35,7 @@ public abstract class BlockEntityConfigurationPacket<BE extends SyncedBlockEntit
public boolean handle(Context context) {
context.enqueueWork(() -> {
ServerPlayer player = context.getSender();
if (player == null)
if (player == null || player.isSpectator() || AdventureUtil.isAdventure(player))
return;
Level world = player.level();
if (world == null || !world.isLoaded(pos))
@ -63,7 +65,7 @@ public abstract class BlockEntityConfigurationPacket<BE extends SyncedBlockEntit
protected void applySettings(ServerPlayer player, BE be) {
applySettings(be);
}
protected boolean causeUpdate() {
return true;
}

View file

@ -0,0 +1,11 @@
package com.simibubi.create.foundation.utility;
import net.minecraft.world.entity.player.Player;
import org.jetbrains.annotations.Nullable;
public class AdventureUtil {
public static boolean isAdventure(@Nullable Player player) {
return player != null && !player.mayBuild() && !player.isSpectator();
}
}

View file

@ -9,7 +9,10 @@ import net.createmod.catnip.nbt.NBTProcessors;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.Tag;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraftforge.registries.ForgeRegistries;
public class CreateNBTProcessors {
public static void register() {
@ -26,6 +29,11 @@ public class CreateNBTProcessors {
if (!data.contains("Book", Tag.TAG_COMPOUND))
return data;
CompoundTag book = data.getCompound("Book");
// Writable books can't have click events, so they're safe to keep
ResourceLocation writableBookResource = ForgeRegistries.ITEMS.getKey(Items.WRITABLE_BOOK);
if (writableBookResource != null && book.getString("id").equals(writableBookResource.toString()))
return data;
if (!book.contains("tag", Tag.TAG_COMPOUND))
return data;