Fix copycat model modifying potentially immutable list

- Perform minor mod initialization clean up
- Bump version to patch E
- Organize imports
This commit is contained in:
PepperCode1 2023-08-16 17:03:07 -07:00
parent 56923db317
commit c052807773
16 changed files with 52 additions and 57 deletions

View file

@ -4,7 +4,7 @@ org.gradle.jvmargs = -Xmx3G
org.gradle.daemon = false
# mod version info
mod_version = 0.5.1.c
mod_version = 0.5.1.e
artifact_minecraft_version = 1.18.2
minecraft_version = 1.18.2

View file

@ -1,12 +1,10 @@
package com.simibubi.create;
import java.util.Optional;
import java.util.Set;
import java.util.function.Supplier;
import org.jetbrains.annotations.Nullable;
import com.google.common.collect.ImmutableSet;
import com.simibubi.create.compat.jei.ConversionRecipe;
import com.simibubi.create.content.equipment.sandPaper.SandPaperPolishingRecipe;
import com.simibubi.create.content.equipment.toolbox.ToolboxDyeingRecipe;

View file

@ -20,7 +20,6 @@ import com.simibubi.create.content.kinetics.TorquePropagator;
import com.simibubi.create.content.kinetics.mechanicalArm.AllArmInteractionPointTypes;
import com.simibubi.create.content.redstone.displayLink.AllDisplayBehaviours;
import com.simibubi.create.content.redstone.link.RedstoneLinkNetworkHandler;
import com.simibubi.create.content.schematics.SchematicInstances;
import com.simibubi.create.content.schematics.ServerSchematicLoader;
import com.simibubi.create.content.trains.GlobalRailwayManager;
import com.simibubi.create.content.trains.bogey.BogeySizes;
@ -70,7 +69,7 @@ public class Create {
public static final String ID = "create";
public static final String NAME = "Create";
public static final String VERSION = "0.5.1c";
public static final String VERSION = "0.5.1e";
public static final Logger LOGGER = LogUtils.getLogger();
@ -125,21 +124,27 @@ public class Create {
AllParticleTypes.register(modEventBus);
AllStructureProcessorTypes.register(modEventBus);
AllEntityDataSerializers.register(modEventBus);
AllPackets.registerPackets();
AllOreFeatureConfigEntries.init();
AllFeatures.register(modEventBus);
AllPlacementModifiers.register(modEventBus);
BuiltinRegistration.register(modEventBus);
BogeySizes.init();
AllBogeyStyles.register();
AllConfigs.register(modLoadingContext);
// FIXME: some of these registrations are not thread-safe
AllMovementBehaviours.registerDefaults();
AllInteractionBehaviours.registerDefaults();
AllDisplayBehaviours.registerDefaults();
ContraptionMovementSetting.registerDefaults();
AllArmInteractionPointTypes.register();
BlockSpoutingBehaviour.registerDefaults();
BoilerHeaters.registerDefaults();
BuiltinPotatoProjectileTypes.register();
BogeySizes.init();
AllBogeyStyles.register();
// ----
ComputerCraftProxy.register();
ForgeMod.enableMilkFluid();
@ -153,19 +158,15 @@ public class Create {
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> CreateClient.onCtorClient(modEventBus, forgeEventBus));
// FIXME: this is not thread-safe
Mods.CURIOS.executeIfInstalled(() -> () -> Curios.init(modEventBus, forgeEventBus));
}
public static void init(final FMLCommonSetupEvent event) {
AllPackets.registerPackets();
SchematicInstances.register();
BuiltinPotatoProjectileTypes.register();
event.enqueueWork(() -> {
AttachedRegistry.unwrapAll();
AllAdvancements.register();
AllTriggers.register();
BoilerHeaters.registerDefaults();
});
}

View file

@ -1,9 +1,14 @@
package com.simibubi.create.compat.curios;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import com.simibubi.create.AllItems;
import com.simibubi.create.AllTags;
import com.simibubi.create.content.equipment.armor.BacktankUtil;
import com.simibubi.create.content.equipment.goggles.GogglesItem;
import com.simibubi.create.AllTags;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ItemStack;
@ -19,11 +24,6 @@ import top.theillusivec4.curios.api.SlotTypePreset;
import top.theillusivec4.curios.api.type.capability.ICuriosItemHandler;
import top.theillusivec4.curios.api.type.inventory.ICurioStacksHandler;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
public class Curios {
/**

View file

@ -30,15 +30,14 @@ public class CopycatBarsModel extends CopycatModel {
protected List<BakedQuad> getCroppedQuads(BlockState state, Direction side, Random rand, BlockState material,
IModelData wrappedData) {
BakedModel model = getModelOf(material);
List<BakedQuad> templateQuads = model.getQuads(material, null, rand, wrappedData);
List<BakedQuad> superQuads = originalModel.getQuads(state, side, rand, wrappedData);
List<BakedQuad> quads = new ArrayList<>();
TextureAtlasSprite targetSprite = model.getParticleIcon(wrappedData);
boolean vertical = state.getValue(CopycatPanelBlock.FACING)
.getAxis() == Axis.Y;
if (side != null && (vertical || side.getAxis() == Axis.Y))
if (side != null && (vertical || side.getAxis() == Axis.Y)) {
List<BakedQuad> templateQuads = model.getQuads(material, null, rand, wrappedData);
for (int i = 0; i < templateQuads.size(); i++) {
BakedQuad quad = templateQuads.get(i);
if (quad.getDirection() != Direction.UP)
@ -46,10 +45,13 @@ public class CopycatBarsModel extends CopycatModel {
targetSprite = quad.getSprite();
break;
}
}
if (targetSprite == null)
return superQuads;
List<BakedQuad> quads = new ArrayList<>();
for (int i = 0; i < superQuads.size(); i++) {
BakedQuad quad = superQuads.get(i);
TextureAtlasSprite original = quad.getSprite();

View file

@ -1,5 +1,6 @@
package com.simibubi.create.content.decoration.copycat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;
@ -107,14 +108,24 @@ public abstract class CopycatModel extends BakedModelWrapperWithData {
// Rubidium: render side!=null versions of the base material during side==null,
// to avoid getting culled away
if (side == null && state.getBlock() instanceof CopycatBlock ccb)
if (side == null && state.getBlock() instanceof CopycatBlock ccb) {
boolean immutable = true;
for (Direction nonOcclusionSide : Iterate.directions)
if (ccb.shouldFaceAlwaysRender(state, nonOcclusionSide))
if (ccb.shouldFaceAlwaysRender(state, nonOcclusionSide)) {
if (immutable) {
croppedQuads = new ArrayList<>(croppedQuads);
immutable = false;
}
croppedQuads.addAll(getCroppedQuads(state, nonOcclusionSide, rand, material, wrappedData));
}
}
return croppedQuads;
}
/**
* The returned list must not be mutated.
*/
protected abstract List<BakedQuad> getCroppedQuads(BlockState state, Direction side, Random rand,
BlockState material, IModelData wrappedData);

View file

@ -1,5 +1,7 @@
package com.simibubi.create.content.equipment.armor;
import java.util.List;
import com.simibubi.create.foundation.advancement.AllAdvancements;
import net.minecraft.resources.ResourceLocation;
@ -20,8 +22,6 @@ import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import java.util.List;
@EventBusSubscriber
public class DivingHelmetItem extends BaseArmorItem {
public static final EquipmentSlot SLOT = EquipmentSlot.HEAD;

View file

@ -1,5 +1,7 @@
package com.simibubi.create.content.equipment.armor;
import java.util.List;
import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.AllItems;
import com.simibubi.create.foundation.gui.element.GuiGameElement;
@ -16,8 +18,6 @@ import net.minecraft.world.level.GameType;
import net.minecraftforge.client.gui.ForgeIngameGui;
import net.minecraftforge.client.gui.IIngameOverlay;
import java.util.List;
public class RemainingAirOverlay implements IIngameOverlay {
public static final RemainingAirOverlay INSTANCE = new RemainingAirOverlay();

View file

@ -23,19 +23,13 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemp
public class SchematicInstances {
public static final WorldAttached<Cache<Integer, SchematicWorld>> loadedSchematics;
static {
loadedSchematics = new WorldAttached<>($ -> CacheBuilder.newBuilder()
private static final WorldAttached<Cache<Integer, SchematicWorld>> LOADED_SCHEMATICS = new WorldAttached<>($ -> CacheBuilder.newBuilder()
.expireAfterAccess(5, TimeUnit.MINUTES)
.build());
}
public static void register() {}
@Nullable
public static SchematicWorld get(Level world, ItemStack schematic) {
Cache<Integer, SchematicWorld> map = loadedSchematics.get(world);
Cache<Integer, SchematicWorld> map = LOADED_SCHEMATICS.get(world);
int hash = getHash(schematic);
SchematicWorld ifPresent = map.getIfPresent(hash);
if (ifPresent != null)

View file

@ -3,7 +3,6 @@ package com.simibubi.create.content.trains.bogey;
import com.jozufozu.flywheel.api.MaterialManager;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.simibubi.create.content.trains.entity.CarriageBogey;
import net.minecraft.nbt.CompoundTag;

View file

@ -6,11 +6,6 @@ import java.util.HashMap;
import java.util.Map;
import java.util.stream.IntStream;
import com.mojang.math.Matrix3f;
import com.mojang.math.Matrix4f;
import com.mojang.math.Quaternion;
import com.simibubi.create.content.trains.entity.CarriageBogey;
import org.jetbrains.annotations.Nullable;
import com.jozufozu.flywheel.api.MaterialManager;
@ -20,6 +15,10 @@ import com.jozufozu.flywheel.core.materials.model.ModelData;
import com.jozufozu.flywheel.util.transform.Transform;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Matrix3f;
import com.mojang.math.Matrix4f;
import com.mojang.math.Quaternion;
import com.simibubi.create.content.trains.entity.CarriageBogey;
import com.simibubi.create.foundation.render.CachedBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer;

View file

@ -8,7 +8,6 @@ import static com.simibubi.create.AllPartialModels.LARGE_BOGEY_WHEELS;
import static com.simibubi.create.AllPartialModels.SMALL_BOGEY_WHEELS;
import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.util.transform.Transform;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.simibubi.create.AllBlocks;

View file

@ -5,21 +5,17 @@ import java.util.List;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicBoolean;
import com.simibubi.create.content.contraptions.Contraption;
import com.simibubi.create.content.contraptions.actors.contraptionControls.ContraptionControlsMovement;
import com.simibubi.create.content.contraptions.actors.contraptionControls.ContraptionControlsMovingInteraction;
import com.simibubi.create.content.contraptions.behaviour.MovementContext;
import com.simibubi.create.content.kinetics.gauge.SpeedGaugeBlockEntity;
import com.simibubi.create.content.kinetics.gauge.StressGaugeBlockEntity;
import net.minecraftforge.registries.ForgeRegistries;
import org.apache.commons.lang3.tuple.MutablePair;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import com.simibubi.create.AllBlockEntityTypes;
import com.simibubi.create.content.contraptions.Contraption;
import com.simibubi.create.content.contraptions.actors.contraptionControls.ContraptionControlsMovement;
import com.simibubi.create.content.contraptions.actors.contraptionControls.ContraptionControlsMovingInteraction;
import com.simibubi.create.content.contraptions.behaviour.MovementContext;
import com.simibubi.create.content.kinetics.gauge.SpeedGaugeBlockEntity;
import com.simibubi.create.content.kinetics.gauge.StressGaugeBlockEntity;
import com.simibubi.create.content.logistics.tunnel.BrassTunnelBlockEntity.SelectionMode;
import com.simibubi.create.content.redstone.nixieTube.NixieTubeBlockEntity;
import com.simibubi.create.foundation.blockEntity.IMultiBlockEntityContainer;
@ -35,7 +31,6 @@ import it.unimi.dsi.fastutil.objects.Object2LongArrayMap;
import it.unimi.dsi.fastutil.objects.Object2LongMap;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Registry;
import net.minecraft.gametest.framework.GameTestHelper;
import net.minecraft.gametest.framework.GameTestInfo;
import net.minecraft.server.level.ServerLevel;
@ -62,6 +57,7 @@ import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.ItemHandlerHelper;
import net.minecraftforge.registries.ForgeRegistries;
/**
* A helper class expanding the functionality of {@link GameTestHelper}.

View file

@ -14,7 +14,6 @@ import com.simibubi.create.infrastructure.gametest.CreateGameTestHelper;
import com.simibubi.create.infrastructure.gametest.GameTestGroup;
import it.unimi.dsi.fastutil.objects.Object2LongMap;
import net.minecraft.core.BlockPos;
import net.minecraft.gametest.framework.GameTest;
import net.minecraft.world.entity.EntityType;

View file

@ -14,8 +14,6 @@ import com.simibubi.create.infrastructure.gametest.CreateGameTestHelper;
import com.simibubi.create.infrastructure.gametest.GameTestGroup;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Holder;
import net.minecraft.core.Registry;
import net.minecraft.gametest.framework.GameTest;
import net.minecraft.gametest.framework.GameTestAssertException;
import net.minecraft.tags.BlockTags;

View file

@ -21,7 +21,6 @@ import com.simibubi.create.infrastructure.gametest.GameTestGroup;
import it.unimi.dsi.fastutil.objects.Object2LongMap;
import net.minecraft.Util;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Registry;
import net.minecraft.gametest.framework.GameTest;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.world.item.EnchantedBookItem;