Using deferred registry for Randomizer Bag container, which fixes startup crash in 1.16.4 and 1.16.5.
This commit is contained in:
@@ -13,7 +13,7 @@ apply plugin: 'net.minecraftforge.gradle'
|
||||
apply plugin: 'eclipse'
|
||||
apply plugin: 'maven-publish'
|
||||
|
||||
version = '1.16.3-2.21'
|
||||
version = '1.16.3-2.22'
|
||||
group = 'nl.requios.effortlessbuilding' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
archivesBaseName = 'effortlessbuilding'
|
||||
|
||||
@@ -28,8 +28,6 @@ minecraft {
|
||||
mappings channel: 'snapshot', version: '20201028-1.16.3'
|
||||
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
|
||||
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
|
||||
|
||||
// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
|
||||
|
||||
// Default run configurations.
|
||||
// These can be tweaked, removed, or duplicated as needed.
|
||||
@@ -75,7 +73,8 @@ minecraft {
|
||||
// Recommended logging level for the console
|
||||
property 'forge.logging.console.level', 'debug'
|
||||
|
||||
args '--mod', 'effortlessbuilding', '--all', '--output', file('src/generated/resources/')
|
||||
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
|
||||
args '--mod', 'effortlessbuilding', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
|
||||
|
||||
mods {
|
||||
effortlessbuilding {
|
||||
|
||||
@@ -13,6 +13,7 @@ import net.minecraftforge.common.capabilities.CapabilityManager;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import net.minecraftforge.fml.RegistryObject;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.config.ModConfig;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
@@ -21,6 +22,9 @@ import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent;
|
||||
import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent;
|
||||
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.network.IContainerFactory;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import nl.requios.effortlessbuilding.capability.ModeCapabilityManager;
|
||||
import nl.requios.effortlessbuilding.capability.ModifierCapabilityManager;
|
||||
import nl.requios.effortlessbuilding.command.CommandReach;
|
||||
@@ -42,8 +46,6 @@ import org.apache.logging.log4j.Logger;
|
||||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public class EffortlessBuilding {
|
||||
public static final String MODID = "effortlessbuilding";
|
||||
public static final String NAME = "Effortless Building";
|
||||
public static final String VERSION = "1.15.2-2.21";
|
||||
public static final Logger logger = LogManager.getLogger();
|
||||
public static final ItemRandomizerBag ITEM_RANDOMIZER_BAG = new ItemRandomizerBag();
|
||||
public static final ItemReachUpgrade1 ITEM_REACH_UPGRADE_1 = new ItemReachUpgrade1();
|
||||
@@ -57,7 +59,8 @@ public class EffortlessBuilding {
|
||||
ITEM_REACH_UPGRADE_2,
|
||||
ITEM_REACH_UPGRADE_3
|
||||
};
|
||||
public static final ContainerType<RandomizerBagContainer> RANDOMIZER_BAG_CONTAINER = register("randomizer_bag", RandomizerBagContainer::new);
|
||||
public static final DeferredRegister<ContainerType<?>> CONTAINERS = DeferredRegister.create(ForgeRegistries.CONTAINERS, EffortlessBuilding.MODID);
|
||||
public static final RegistryObject<ContainerType<RandomizerBagContainer>> RANDOMIZER_BAG_CONTAINER = CONTAINERS.register("randomizer_bag", () -> registerContainer(RandomizerBagContainer::new));
|
||||
public static final ResourceLocation RANDOMIZER_BAG_GUI = new ResourceLocation(EffortlessBuilding.MODID, "randomizer_bag");
|
||||
public static EffortlessBuilding instance;
|
||||
public static IProxy proxy = DistExecutor.runForDist(() -> ClientProxy::new, () -> ServerProxy::new);
|
||||
@@ -79,10 +82,13 @@ public class EffortlessBuilding {
|
||||
|
||||
// Register ourselves for server and other game events we are interested in
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
|
||||
CONTAINERS.register(FMLJavaModLoadingContext.get().getModEventBus());
|
||||
}
|
||||
|
||||
private static <T extends Container> ContainerType<T> register(String key, ContainerType.IFactory<T> factory) {
|
||||
return Registry.register(Registry.MENU, key, new ContainerType<>(factory));
|
||||
public static <T extends Container> ContainerType<T> registerContainer(IContainerFactory<T> fact){
|
||||
ContainerType<T> type = new ContainerType<T>(fact);
|
||||
return type;
|
||||
}
|
||||
|
||||
public static void log(String msg) {
|
||||
|
||||
@@ -4,8 +4,10 @@ import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.ClickType;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
@@ -19,12 +21,23 @@ public class RandomizerBagContainer extends Container {
|
||||
HOTBAR_START = INV_END + 1, HOTBAR_END = HOTBAR_START + 8;
|
||||
private final IItemHandler bagInventory;
|
||||
|
||||
public RandomizerBagContainer(ContainerType<?> type, int id){
|
||||
super(type, id);
|
||||
bagInventory = null;
|
||||
}
|
||||
|
||||
//Client
|
||||
public RandomizerBagContainer(int id, PlayerInventory playerInventory, PacketBuffer packetBuffer) {
|
||||
this(id, playerInventory);
|
||||
}
|
||||
|
||||
//Server?
|
||||
public RandomizerBagContainer(int containerId, PlayerInventory playerInventory) {
|
||||
this(containerId, playerInventory, new ItemStackHandler(ItemRandomizerBag.INV_SIZE));
|
||||
}
|
||||
|
||||
public RandomizerBagContainer(int containerId, PlayerInventory playerInventory, IItemHandler inventory) {
|
||||
super(EffortlessBuilding.RANDOMIZER_BAG_CONTAINER, containerId);
|
||||
super(EffortlessBuilding.RANDOMIZER_BAG_CONTAINER.get(), containerId);
|
||||
bagInventory = inventory;
|
||||
|
||||
for (int i = 0; i < ItemRandomizerBag.INV_SIZE; ++i) {
|
||||
|
||||
@@ -279,7 +279,7 @@ public class PlayerSettingsGui extends Screen {
|
||||
RenderSystem.disableBlend();
|
||||
}
|
||||
|
||||
private int getMaxScroll() {
|
||||
public int getMaxScroll() {
|
||||
return Math.max(0, this.getMaxPosition() - (this.y1 - this.y0 - 4));
|
||||
}
|
||||
|
||||
|
||||
@@ -372,7 +372,7 @@ public class ClientProxy implements IProxy {
|
||||
ClientRegistry.registerKeyBinding(keyBinding);
|
||||
}
|
||||
|
||||
DeferredWorkQueue.runLater(() -> ScreenManager.registerFactory(EffortlessBuilding.RANDOMIZER_BAG_CONTAINER, RandomizerBagScreen::new));
|
||||
DeferredWorkQueue.runLater(() -> ScreenManager.registerFactory(EffortlessBuilding.RANDOMIZER_BAG_CONTAINER.get(), RandomizerBagScreen::new));
|
||||
}
|
||||
|
||||
public PlayerEntity getPlayerEntityFromContext(Supplier<NetworkEvent.Context> ctx) {
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
public net.minecraft.client.gui.widget.list.AbstractList field_230680_q_ # renderHeader
|
||||
public net.minecraft.client.gui.FontRenderer func_228078_a_(Ljava/lang/String;FFILnet/minecraft/util/math/vector/Matrix4f;ZZ)I # renderString
|
||||
public net.minecraft.client.gui.FontRenderer func_228078_a_(Ljava/lang/String;FFILnet/minecraft/util/math/vector/Matrix4f;ZZ)I # renderString
|
||||
public net.minecraft.inventory.container.ContainerType func_221505_a(Ljava/lang/String;Lnet/minecraft/inventory/container/ContainerType$IFactory;)Lnet/minecraft/inventory/container/ContainerType; # register
|
||||
Reference in New Issue
Block a user