mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-01-27 21:38:05 +01:00
Sisyphus's broken printer
- Fixed Schematics failing to load when containing items with sensitive nbt #5680 - Fixed Turntable handler causing a crash during world shutdown #5696 - Cached outputs of BeltHelper.isItemUpright()
This commit is contained in:
parent
eea8bb2607
commit
962f03c1c5
5 changed files with 17 additions and 5 deletions
|
@ -1,11 +1,16 @@
|
|||
package com.simibubi.create.content.kinetics.belt;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.simibubi.create.AllTags.AllItemTags;
|
||||
import com.simibubi.create.foundation.utility.VecHelper;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.Object2BooleanOpenHashMap;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Vec3i;
|
||||
import net.minecraft.server.packs.resources.ResourceManagerReloadListener;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
|
@ -16,9 +21,13 @@ import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
|||
|
||||
public class BeltHelper {
|
||||
|
||||
public static Map<Item, Boolean> uprightCache = new Object2BooleanOpenHashMap<>();
|
||||
public static final ResourceManagerReloadListener LISTENER = resourceManager -> uprightCache.clear();
|
||||
|
||||
public static boolean isItemUpright(ItemStack stack) {
|
||||
return stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY)
|
||||
.isPresent() || AllItemTags.UPRIGHT_ON_BELT.matches(stack);
|
||||
return uprightCache.computeIfAbsent(stack.getItem(),
|
||||
item -> stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY)
|
||||
.isPresent() || AllItemTags.UPRIGHT_ON_BELT.matches(stack));
|
||||
}
|
||||
|
||||
public static BeltBlockEntity getSegmentBE(LevelAccessor world, BlockPos pos) {
|
||||
|
|
|
@ -16,6 +16,8 @@ public class TurntableHandler {
|
|||
Minecraft mc = Minecraft.getInstance();
|
||||
BlockPos pos = mc.player.blockPosition();
|
||||
|
||||
if (mc.gameMode == null)
|
||||
return;
|
||||
if (!AllBlocks.TURNTABLE.has(mc.level.getBlockState(pos)))
|
||||
return;
|
||||
if (!mc.player.isOnGround())
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.simibubi.create.foundation;
|
||||
|
||||
import com.simibubi.create.CreateClient;
|
||||
import com.simibubi.create.content.kinetics.belt.BeltHelper;
|
||||
import com.simibubi.create.foundation.sound.SoundScapes;
|
||||
import com.simibubi.create.foundation.utility.LangNumberFormat;
|
||||
|
||||
|
@ -14,6 +15,7 @@ public class ClientResourceReloadListener implements ResourceManagerReloadListen
|
|||
CreateClient.invalidateRenderers();
|
||||
SoundScapes.invalidateAll();
|
||||
LangNumberFormat.numberFormat.update();
|
||||
BeltHelper.uprightCache.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import com.simibubi.create.content.equipment.toolbox.ToolboxHandler;
|
|||
import com.simibubi.create.content.equipment.wrench.WrenchItem;
|
||||
import com.simibubi.create.content.equipment.zapper.ZapperInteractionHandler;
|
||||
import com.simibubi.create.content.equipment.zapper.ZapperItem;
|
||||
import com.simibubi.create.content.kinetics.belt.BeltHelper;
|
||||
import com.simibubi.create.content.redstone.link.controller.LinkedControllerServerHandler;
|
||||
import com.simibubi.create.content.trains.entity.CarriageEntityHandler;
|
||||
import com.simibubi.create.foundation.ModFilePackResources;
|
||||
|
@ -171,6 +172,7 @@ public class CommonEvents {
|
|||
public static void addReloadListeners(AddReloadListenerEvent event) {
|
||||
event.addListener(RecipeFinder.LISTENER);
|
||||
event.addListener(PotatoProjectileTypeManager.ReloadListener.INSTANCE);
|
||||
event.addListener(BeltHelper.LISTENER);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
|
|
@ -91,9 +91,6 @@ public final class NBTProcessors {
|
|||
.stream()
|
||||
.filter(NBTProcessors::isUnsafeItemNBTKey)
|
||||
.forEach(copy::removeTagKey);
|
||||
if (copy.getTag()
|
||||
.isEmpty())
|
||||
copy.setTag(null);
|
||||
return copy;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue