Merge branch 'refs/heads/mc1.20.1/feature-dev' into mc1.21.1/dev

# Conflicts:
#	src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/ItemAttribute.java
#	src/main/java/com/simibubi/create/content/processing/basin/BasinRecipe.java
#	src/main/java/com/simibubi/create/foundation/mixin/ContraptionDriverInteractMixin.java
#	src/main/java/com/simibubi/create/foundation/mixin/EntityMixin.java
#	src/main/java/com/simibubi/create/foundation/mixin/accessor/LevelRendererAccessor.java
#	src/main/java/com/simibubi/create/foundation/mixin/client/CameraMixin.java
#	src/main/java/com/simibubi/create/foundation/mixin/client/EntityContraptionInteractionMixin.java
#	src/main/java/com/simibubi/create/foundation/mixin/client/HumanoidArmorLayerMixin.java
#	src/main/java/com/simibubi/create/foundation/mixin/client/LevelRendererMixin.java
#	src/main/java/com/simibubi/create/foundation/mixin/client/ModelDataRefreshMixin.java
#	src/main/java/com/simibubi/create/foundation/networking/BlockEntityConfigurationPacket.java
#	src/main/resources/create.mixins.json
This commit is contained in:
IThundxr 2025-02-14 08:20:59 -05:00
commit f66d29e34c
Failed to generate hash of commit
34 changed files with 172 additions and 137 deletions

View file

@ -385,8 +385,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))
@ -897,7 +896,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

@ -10,6 +10,7 @@ import com.simibubi.create.foundation.item.CustomUseEffectsItem;
import com.simibubi.create.foundation.item.render.SimpleCustomRenderer;
import com.simibubi.create.foundation.mixin.accessor.LivingEntityAccessor;
import net.createmod.catnip.data.TriState;
import net.createmod.catnip.math.VecHelper;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.core.BlockPos;
@ -200,9 +201,9 @@ public class SandPaperItem extends Item implements CustomUseEffectsItem {
}
@Override
public Boolean shouldTriggerUseEffects(ItemStack stack, LivingEntity entity) {
public TriState shouldTriggerUseEffects(ItemStack stack, LivingEntity entity) {
// Trigger every tick so that we have more fine grain control over the animation
return true;
return TriState.TRUE;
}
@Override

View file

@ -128,6 +128,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,13 +2,16 @@ 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.core.HolderLookup;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
public class TransportedItemStack implements Comparable<TransportedItemStack> {
@ -78,6 +81,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.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)
@ -96,7 +109,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

@ -116,6 +116,8 @@ public class BeltDeployerCallbacks {
blockEntity.award(AllAdvancements.DEPLOYER);
transported.clearFanProcessingData();
TransportedItemStack left = transported.copy();
blockEntity.player.spawnedItemEffects = transported.stack.copy();
left.stack.shrink(1);

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

@ -13,9 +13,7 @@ import com.simibubi.create.foundation.utility.CreateLang;
import net.createmod.catnip.codecs.CatnipCodecUtils;
import net.minecraft.core.HolderLookup;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtOps;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.resources.RegistryOps;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
@ -33,7 +31,7 @@ public interface ItemAttribute {
@Nullable
static ItemAttribute loadStatic(CompoundTag nbt, HolderLookup.Provider registries) {
return CODEC.decode(RegistryOps.create(NbtOps.INSTANCE, registries), nbt.get("attribute")).getOrThrow().getFirst();
return CatnipCodecUtils.decode(CODEC, registries, nbt.get("attribute")).orElse(null);
}
static List<ItemAttribute> getAllAttributes(ItemStack stack, Level level) {

View file

@ -16,17 +16,18 @@ import com.simibubi.create.foundation.blockEntity.behaviour.filtering.FilteringB
import com.simibubi.create.foundation.blockEntity.behaviour.fluid.SmartFluidTankBehaviour;
import com.simibubi.create.foundation.blockEntity.behaviour.fluid.SmartFluidTankBehaviour.TankSegment;
import com.simibubi.create.foundation.fluid.FluidIngredient;
import com.simibubi.create.foundation.item.SmartInventory;
import com.simibubi.create.foundation.recipe.DummyCraftingContainer;
import com.simibubi.create.foundation.recipe.IRecipeTypeInfo;
import net.createmod.catnip.data.Iterate;
import net.minecraft.client.Minecraft;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.CraftingInput;
import net.minecraft.world.item.crafting.CraftingRecipe;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.item.crafting.RecipeHolder;
import net.minecraft.world.item.crafting.RecipeInput;
import net.minecraft.world.level.Level;
import net.neoforged.neoforge.capabilities.Capabilities;
@ -34,7 +35,7 @@ import net.neoforged.neoforge.fluids.FluidStack;
import net.neoforged.neoforge.fluids.capability.IFluidHandler;
import net.neoforged.neoforge.items.IItemHandler;
public class BasinRecipe extends ProcessingRecipe<SmartInventory> {
public class BasinRecipe extends ProcessingRecipe<RecipeInput> {
public static boolean match(BasinBlockEntity basin, Recipe<?> recipe) {
FilteringBehaviour filter = basin.getFilter();
@ -146,13 +147,16 @@ public class BasinRecipe extends ProcessingRecipe<SmartInventory> {
}
if (simulate) {
CraftingInput remainderInput = new DummyCraftingContainer(availableItems, extractedItemsFromSlot)
.asCraftInput();
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(remainderInput))
if (!stack.isEmpty())
recipeOutputItems.add(stack);
@ -161,8 +165,7 @@ public class BasinRecipe extends ProcessingRecipe<SmartInventory> {
.registryAccess()));
if (recipe instanceof CraftingRecipe craftingRecipe) {
for (ItemStack stack : craftingRecipe
.getRemainingItems(new DummyCraftingContainer(availableItems, extractedItemsFromSlot).asCraftInput()))
for (ItemStack stack : craftingRecipe.getRemainingItems(remainderInput))
if (!stack.isEmpty())
recipeOutputItems.add(stack);
}
@ -223,7 +226,7 @@ public class BasinRecipe extends ProcessingRecipe<SmartInventory> {
}
@Override
public boolean matches(SmartInventory inv, @Nonnull Level worldIn) {
public boolean matches(RecipeInput input, @Nonnull Level worldIn) {
return false;
}

View file

@ -8,7 +8,7 @@ import net.minecraft.core.BlockPos;
public interface BlockDestructionProgressExtension {
@Nullable
Set<BlockPos> getExtraPositions();
Set<BlockPos> create$getExtraPositions();
void setExtraPositions(@Nullable Set<BlockPos> positions);
void create$setExtraPositions(@Nullable Set<BlockPos> positions);
}

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.createmod.catnip.platform.CatnipServices;
import net.minecraft.core.BlockPos;
@ -93,7 +94,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

@ -1,5 +1,6 @@
package com.simibubi.create.foundation.item;
import net.createmod.catnip.data.TriState;
import net.minecraft.util.RandomSource;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ItemStack;
@ -10,10 +11,10 @@ public interface CustomUseEffectsItem {
*
* @param stack The ItemStack being used.
* @param entity The LivingEntity using the item.
* @return null for default behavior, or boolean to override default behavior
* @return {@link TriState#DEFAULT} for default behavior, or {@link TriState#TRUE}/{@link TriState#FALSE} to override default behavior
*/
default Boolean shouldTriggerUseEffects(ItemStack stack, LivingEntity entity) {
return null;
default TriState shouldTriggerUseEffects(ItemStack stack, LivingEntity entity) {
return TriState.DEFAULT;
}
/**

View file

@ -1,24 +0,0 @@
package com.simibubi.create.foundation.mixin;
import org.spongepowered.asm.mixin.Implements;
import org.spongepowered.asm.mixin.Interface;
import org.spongepowered.asm.mixin.Intrinsic;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import com.simibubi.create.content.contraptions.AbstractContraptionEntity;
import net.minecraft.world.entity.Entity;
import net.neoforged.neoforge.common.extensions.IEntityExtension;
@Mixin(Entity.class)
@Implements(@Interface(iface = IEntityExtension.class, prefix = "iForgeEntity$"))
public abstract class ContraptionDriverInteractMixin {
@Shadow
public abstract Entity getRootVehicle();
@Intrinsic
public boolean iForgeEntity$canRiderInteract() {
return getRootVehicle() instanceof AbstractContraptionEntity;
}
}

View file

@ -9,6 +9,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import com.simibubi.create.foundation.item.CustomUseEffectsItem;
import net.createmod.catnip.data.TriState;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
@ -30,9 +31,9 @@ public abstract class CustomItemUseEffectsMixin extends Entity {
ItemStack using = getUseItem();
Item item = using.getItem();
if (item instanceof CustomUseEffectsItem handler) {
Boolean result = handler.shouldTriggerUseEffects(using, (LivingEntity) (Object) this);
if (result != null) {
cir.setReturnValue(result);
TriState result = handler.shouldTriggerUseEffects(using, (LivingEntity) (Object) this);
if (result != TriState.DEFAULT) {
cir.setReturnValue(result.getValue());
}
}
}

View file

@ -2,22 +2,16 @@ package com.simibubi.create.foundation.mixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import com.simibubi.create.content.equipment.armor.NetheriteDivingHandler;
import net.minecraft.world.entity.Entity;
@Mixin(value = Entity.class, priority = 900)
@Mixin(Entity.class)
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);
if (immune)
cir.setReturnValue(immune);
}
@ModifyReturnValue(method = "fireImmune()Z", at = @At("RETURN"))
public boolean create$onFireImmune(boolean original) {
return ((Entity) (Object) this).getPersistentData().getBoolean(NetheriteDivingHandler.FIRE_IMMUNE_KEY) || original;
}
}

View file

@ -0,0 +1,19 @@
package com.simibubi.create.foundation.mixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.simibubi.create.content.contraptions.AbstractContraptionEntity;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.projectile.ProjectileUtil;
@Mixin(ProjectileUtil.class)
public class ProjectileUtilMixin {
@WrapOperation(method = "getEntityHitResult(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/phys/Vec3;Lnet/minecraft/world/phys/Vec3;Lnet/minecraft/world/phys/AABB;Ljava/util/function/Predicate;D)Lnet/minecraft/world/phys/EntityHitResult;", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;canRiderInteract()Z"))
private static boolean create$interactWithEntitiesOnContraptions(Entity instance, Operation<Boolean> original) {
return original.call(instance) || instance.getRootVehicle() instanceof AbstractContraptionEntity;
}
}

View file

@ -1,18 +1,17 @@
package com.simibubi.create.foundation.mixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import net.minecraft.world.Container;
import net.minecraft.world.level.block.ShulkerBoxBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
@Mixin(ShulkerBoxBlock.class)
public class ShulkerBoxBlockMixin {
@ModifyExpressionValue(method = "getAnalogOutputSignal",at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;getBlockEntity(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/entity/BlockEntity;"))
@ModifyExpressionValue(method = "getAnalogOutputSignal", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;getBlockEntity(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/entity/BlockEntity;"))
private BlockEntity create$backportCCESuppressionFix(BlockEntity original) {
return original instanceof Container ? original : null;
}

View file

@ -26,5 +26,4 @@ public interface HumanoidArmorLayerAccessor {
@Invoker("setPartVisibility")
void create$callSetPartVisibility(HumanoidModel<?> model, EquipmentSlot slot);
}

View file

@ -1,13 +1,13 @@
package com.simibubi.create.foundation.mixin.accessor;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import net.minecraft.client.renderer.LevelRenderer;
import net.minecraft.client.renderer.culling.Frustum;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(LevelRenderer.class)
public interface LevelRendererAccessor {
@Accessor("cullingFrustum")

View file

@ -7,7 +7,6 @@ import net.minecraft.client.MouseHandler;
@Mixin(MouseHandler.class)
public interface MouseHandlerAccessor {
@Accessor("xpos")
void create$setXPos(double xPos);

View file

@ -16,12 +16,12 @@ public class BlockDestructionProgressMixin implements BlockDestructionProgressEx
private Set<BlockPos> create$extraPositions;
@Override
public Set<BlockPos> getExtraPositions() {
public Set<BlockPos> create$getExtraPositions() {
return create$extraPositions;
}
@Override
public void setExtraPositions(Set<BlockPos> positions) {
public void create$setExtraPositions(Set<BlockPos> positions) {
create$extraPositions = positions;
}
}

View file

@ -93,7 +93,8 @@ public abstract class EntityContraptionInteractionMixin {
}
// involves block step sounds on contraptions
// IFNE line 661 injecting before `!blockstate.isAir(this.world, blockpos)`
// injecting before `!blockstate1.isAir(this.world, blockpos)`
// `if (this.moveDist > this.nextStep && !blockstate1.isAir())
@Inject(method = "move", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/state/BlockState;isAir()Z", ordinal = 0))
private void create$contraptionStepSounds(MoverType mover, Vec3 movement, CallbackInfo ci) {
Vec3 worldPos = position.add(0, -0.2, 0);

View file

@ -2,27 +2,22 @@ package com.simibubi.create.foundation.mixin.client;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import com.mojang.authlib.GameProfile;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.player.AbstractClientPlayer;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.nbt.CompoundTag;
@Mixin(LocalPlayer.class)
public abstract class HeavyBootsOnPlayerMixin extends AbstractClientPlayer {
private HeavyBootsOnPlayerMixin(ClientLevel level, GameProfile profile) {
super(level, profile);
}
@Inject(method = "isUnderWater()Z", at = @At("HEAD"), cancellable = true)
public void create$noSwimmingWithHeavyBootsOn(CallbackInfoReturnable<Boolean> cir) {
CompoundTag persistentData = getPersistentData();
if (persistentData.contains("HeavyBoots"))
cir.setReturnValue(false);
@ModifyReturnValue(method = "isUnderWater()Z", at = @At("RETURN"))
private boolean create$noSwimmingWithHeavyBootsOn(boolean original) {
return getPersistentData().contains("HeavyBoots") || original;
}
}

View file

@ -1,11 +1,13 @@
package com.simibubi.create.foundation.mixin.client;
import com.llamalad7.mixinextras.sugar.Local;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import com.llamalad7.mixinextras.sugar.Local;
import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.foundation.item.CustomRenderedArmorItem;
@ -18,7 +20,13 @@ import net.minecraft.world.item.ItemStack;
@Mixin(HumanoidArmorLayer.class)
public class HumanoidArmorLayerMixin {
@Inject(method = "renderArmorPiece(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;Lnet/minecraft/world/entity/LivingEntity;Lnet/minecraft/world/entity/EquipmentSlot;ILnet/minecraft/client/model/HumanoidModel;FFFFFF)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/ItemStack;getItem()Lnet/minecraft/world/item/Item;"), cancellable = true)
@Inject(
method = "renderArmorPiece(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;Lnet/minecraft/world/entity/LivingEntity;Lnet/minecraft/world/entity/EquipmentSlot;ILnet/minecraft/client/model/HumanoidModel;FFFFFF)V",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/item/ItemStack;getItem()Lnet/minecraft/world/item/Item;"),
cancellable = true
)
private void create$onRenderArmorPiece(PoseStack poseStack, MultiBufferSource bufferSource, LivingEntity entity, EquipmentSlot slot, int light, HumanoidModel<?> model, float limbSwing, float limbSwingAmount, float partialTick, float ageInTicks, float netHeadYaw, float headPitch, CallbackInfo ci, @Local ItemStack stack) {
if (stack.getItem() instanceof CustomRenderedArmorItem renderer) {
renderer.renderArmorPiece((HumanoidArmorLayer<?, ?, ?>) (Object) this, poseStack, bufferSource, entity, slot, light, model, stack);

View file

@ -16,7 +16,6 @@ import net.minecraft.world.entity.LivingEntity;
@Mixin(HumanoidModel.class)
public class HumanoidModelMixin<T extends LivingEntity> {
@Shadow
@Final
public ModelPart body;
@ -36,5 +35,4 @@ public class HumanoidModelMixin<T extends LivingEntity> {
PlayerSkyhookRenderer.beforeSetupAnim(player, (HumanoidModel<?>) (Object) this);
}
}

View file

@ -22,6 +22,7 @@ import net.minecraft.client.renderer.LevelRenderer;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.BlockDestructionProgress;
import net.minecraft.world.level.block.state.BlockState;
import net.neoforged.neoforge.client.extensions.common.IClientBlockExtensions;
@Mixin(LevelRenderer.class)
@ -41,7 +42,7 @@ public class LevelRendererMixin {
Set<BlockPos> extraPositions = handler.getExtraPositions(level, pos, state, progress);
if (extraPositions != null) {
extraPositions.remove(pos);
((BlockDestructionProgressExtension) progressObj).setExtraPositions(extraPositions);
((BlockDestructionProgressExtension) progressObj).create$setExtraPositions(extraPositions);
for (BlockPos extraPos : extraPositions) {
destructionProgress.computeIfAbsent(extraPos.asLong(), l -> Sets.newTreeSet()).add(progressObj);
}
@ -51,7 +52,7 @@ public class LevelRendererMixin {
@Inject(method = "removeProgress(Lnet/minecraft/server/level/BlockDestructionProgress;)V", at = @At("RETURN"))
private void create$onRemoveProgress(BlockDestructionProgress progress, CallbackInfo ci) {
Set<BlockPos> extraPositions = ((BlockDestructionProgressExtension) progress).getExtraPositions();
Set<BlockPos> extraPositions = ((BlockDestructionProgressExtension) progress).create$getExtraPositions();
if (extraPositions != null) {
for (BlockPos extraPos : extraPositions) {
long l = extraPos.asLong();

View file

@ -1,33 +0,0 @@
package com.simibubi.create.foundation.mixin.client;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import net.createmod.catnip.levelWrappers.SchematicLevel;
import net.minecraft.client.Minecraft;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.api.distmarker.OnlyIn;
import net.neoforged.neoforge.client.model.data.ModelDataManager;
@OnlyIn(Dist.CLIENT)
@Mixin(ModelDataManager.class)
public class ModelDataRefreshMixin {
/**
* Normally ModelDataManager will throw an exception if a block entity tries
* to refresh its model data from a world the client isn't currently in,
* but we need that to not happen for block entities in fake schematic
* worlds, so in those cases just do nothing instead.
*/
@Inject(method = "requestModelDataRefresh", at = @At("HEAD"), cancellable = true, remap = false)
private static void create$requestModelDataRefresh(BlockEntity be, CallbackInfo ci) {
if (be != null) {
Level world = be.getLevel();
if (world != Minecraft.getInstance().level && world instanceof SchematicLevel)
ci.cancel();
}
}
}

View file

@ -4,7 +4,6 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import com.simibubi.create.foundation.item.CustomArmPoseItem;
@ -16,8 +15,9 @@ import net.minecraft.world.item.ItemStack;
@Mixin(PlayerRenderer.class)
public class PlayerRendererMixin {
@Inject(method = "getArmPose(Lnet/minecraft/client/player/AbstractClientPlayer;Lnet/minecraft/world/InteractionHand;)Lnet/minecraft/client/model/HumanoidModel$ArmPose;", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/client/player/AbstractClientPlayer;getItemInHand(Lnet/minecraft/world/InteractionHand;)Lnet/minecraft/world/item/ItemStack;"), locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true)
private static void create$onGetArmPose(AbstractClientPlayer player, InteractionHand hand, CallbackInfoReturnable<ArmPose> cir, ItemStack stack) {
@Inject(method = "getArmPose(Lnet/minecraft/client/player/AbstractClientPlayer;Lnet/minecraft/world/InteractionHand;)Lnet/minecraft/client/model/HumanoidModel$ArmPose;", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/client/player/AbstractClientPlayer;getItemInHand(Lnet/minecraft/world/InteractionHand;)Lnet/minecraft/world/item/ItemStack;"), cancellable = true)
private static void create$onGetArmPose(AbstractClientPlayer player, InteractionHand hand, CallbackInfoReturnable<ArmPose> cir) {
ItemStack stack = player.getItemInHand(hand);
if (stack.getItem() instanceof CustomArmPoseItem armPoseProvider) {
ArmPose pose = armPoseProvider.getArmPose(stack, player, hand);
if (pose != null) {
@ -25,6 +25,4 @@ public class PlayerRendererMixin {
}
}
}
}

View file

@ -3,6 +3,8 @@ package com.simibubi.create.foundation.networking;
import com.simibubi.create.foundation.blockEntity.SyncedBlockEntity;
import net.createmod.catnip.net.base.ServerboundPacketPayload;
import com.simibubi.create.foundation.utility.AdventureUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.level.Level;
@ -19,7 +21,7 @@ public abstract class BlockEntityConfigurationPacket<BE extends SyncedBlockEntit
@SuppressWarnings("unchecked")
@Override
public void handle(ServerPlayer player) {
if (player == null)
if (player == null || player.isSpectator() || AdventureUtil.isAdventure(player))
return;
Level world = player.level();
if (!world.isLoaded(this.pos))

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

@ -6,9 +6,12 @@ import com.simibubi.create.AllBlockEntityTypes;
import net.createmod.catnip.nbt.NBTHelper;
import net.createmod.catnip.nbt.NBTProcessors;
import net.minecraft.core.registries.BuiltInRegistries;
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;
public class CreateNBTProcessors {
@ -27,6 +30,11 @@ public class CreateNBTProcessors {
return data;
CompoundTag book = data.getCompound("Book");
// Writable books can't have click events, so they're safe to keep
ResourceLocation writableBookResource = BuiltInRegistries.ITEM.getKey(Items.WRITABLE_BOOK);
if (writableBookResource != BuiltInRegistries.ITEM.getDefaultKey() && book.getString("id").equals(writableBookResource.toString()))
return data;
if (!book.contains("tag", Tag.TAG_COMPOUND))
return data;
CompoundTag tag = book.getCompound("tag");

View file

@ -9,7 +9,6 @@
"mixins": [
"ArmorTrimMixin",
"BlockItemMixin",
"ContraptionDriverInteractMixin",
"CustomItemUseEffectsMixin",
"EnchantedCountIncreaseFunctionMixin",
"EntityMixin",
@ -17,6 +16,7 @@
"MapItemSavedDataMixin",
"MobMixin",
"PlayerMixin",
"ProjectileUtilMixin",
"ShulkerBoxBlockMixin",
"SmithingMenuMixin",
"SmithingTrimRecipeMixin",