Skip to content

Fixed NullPointerException on startup #730

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: dev/1.20.4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public void registerCapabilities(RegisterCapabilitiesEvent event) {
});
});

if (APAddons.ae2Loaded)
if (APAddons.ae2Loaded())
event.registerBlockEntity(
AECapabilities.IN_WORLD_GRID_NODE_HOST,
BlockEntityTypes.ME_BRIDGE.get(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,33 @@ public class APAddons {
public static final String APP_MEKANISTICS_MODID = "appmek";
public static final String PATCHOULI_MODID = "patchouli";

public static boolean ae2Loaded;
public static boolean curiosLoaded;
public static boolean refinedStorageLoaded;
public static boolean appMekLoaded;
public static boolean patchouliLoaded;

private APAddons() {

}

public static void commonSetup() {
ModList modList = ModList.get();
ae2Loaded = modList.isLoaded(AE2_MODID);
curiosLoaded = modList.isLoaded(CURIOS_MODID);
refinedStorageLoaded = modList.isLoaded(REFINEDSTORAGE_MODID);
appMekLoaded = modList.isLoaded(APP_MEKANISTICS_MODID);
patchouliLoaded = modList.isLoaded(PATCHOULI_MODID);

if (refinedStorageLoaded)
if (refinedStorageLoaded())
RefinedStorage.instance = new RefinedStorage();
}

public static boolean ae2Loaded() {
return ModList.get().isLoaded(AE2_MODID);
}

public static boolean curiosLoaded() {
return ModList.get().isLoaded(CURIOS_MODID);
}

public static boolean refinedStorageLoaded() {
return ModList.get().isLoaded(REFINEDSTORAGE_MODID);
}

public static boolean appMekLoaded() {
return ModList.get().isLoaded(APP_MEKANISTICS_MODID);
}

public static boolean patchouliLoaded() {
return ModList.get().isLoaded(PATCHOULI_MODID);
}

@SubscribeEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public static List<Object> listFluids(MEStorage monitor, ICraftingService servic
public static List<Object> listGases(MEStorage monitor, ICraftingService service, int flag) {
List<Object> items = new ArrayList<>();
for (Object2LongMap.Entry<AEKey> aeKey : monitor.getAvailableStacks()) {
if (APAddons.appMekLoaded && aeKey.getKey() instanceof MekanismKey itemKey) {
if (APAddons.appMekLoaded() && aeKey.getKey() instanceof MekanismKey itemKey) {
items.add(getObjectFromStack(Pair.of(aeKey.getLongValue(), itemKey), service));
}
}
Expand All @@ -152,7 +152,7 @@ public static <T extends AEKey> Map<String, Object> getObjectFromStack(Pair<Long
return getObjectFromItemStack(Pair.of(stack.getLeft(), itemKey), service);
if (stack.getRight() instanceof AEFluidKey fluidKey)
return getObjectFromFluidStack(Pair.of(stack.getLeft(), fluidKey), service);
if (APAddons.appMekLoaded && (stack.getRight() instanceof MekanismKey gasKey))
if (APAddons.appMekLoaded() && (stack.getRight() instanceof MekanismKey gasKey))
return getObjectFromGasStack(Pair.of(stack.getLeft(), gasKey), service);

AdvancedPeripherals.debug("Could not create table from unknown stack " + stack.getRight().getClass() + " - Report this to the maintainer of ap", Level.ERROR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static void onWorldJoin(PlayerEvent.PlayerLoggedInEvent event) {
// We could switch to the advancement way to give new players the book. However, that would not allow us to create
// a config option for that. So we will stick with the custom solution here.
// See https://vazkiimods.github.io/Patchouli/docs/patchouli-basics/giving-new
if (APConfig.WORLD_CONFIG.givePlayerBookOnJoin.get() && APAddons.patchouliLoaded) {
if (APConfig.WORLD_CONFIG.givePlayerBookOnJoin.get() && APAddons.patchouliLoaded()) {
if (!hasPlayedBefore(player)) {
ItemStack book = new ItemStack(ItemUtil.getRegistryEntry("patchouli:guide_book", BuiltInRegistries.ITEM));
CompoundTag nbt = new CompoundTag();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public class BlockEntityTypes {
public static final DeferredHolder<BlockEntityType<?>, BlockEntityType<ChatBoxEntity>> CHAT_BOX = Registration.BLOCK_ENTITIES.register("chat_box", () -> new BlockEntityType<>(ChatBoxEntity::new, Sets.newHashSet(Blocks.CHAT_BOX.get()), null));
public static final DeferredHolder<BlockEntityType<?>, BlockEntityType<EnvironmentDetectorEntity>> ENVIRONMENT_DETECTOR = Registration.BLOCK_ENTITIES.register("environment_detector", () -> new BlockEntityType<>(EnvironmentDetectorEntity::new, Sets.newHashSet(Blocks.ENVIRONMENT_DETECTOR.get()), null));
public static final DeferredHolder<BlockEntityType<?>, BlockEntityType<PlayerDetectorEntity>> PLAYER_DETECTOR = Registration.BLOCK_ENTITIES.register("player_detector", () -> new BlockEntityType<>(PlayerDetectorEntity::new, Sets.newHashSet(Blocks.PLAYER_DETECTOR.get()), null));
public static final DeferredHolder<BlockEntityType<?>, BlockEntityType<MeBridgeEntity>> ME_BRIDGE = APAddons.ae2Loaded ? Registration.BLOCK_ENTITIES.register("me_bridge", () -> new BlockEntityType<>(MeBridgeEntity::new, Sets.newHashSet(Blocks.ME_BRIDGE.get()), null)) : null;
public static final DeferredHolder<BlockEntityType<?>, BlockEntityType<RsBridgeEntity>> RS_BRIDGE = APAddons.refinedStorageLoaded ? Registration.BLOCK_ENTITIES.register("rs_bridge", () -> new BlockEntityType<>(RsBridgeEntity::new, Sets.newHashSet(Blocks.RS_BRIDGE.get()), null)) : null;
public static final DeferredHolder<BlockEntityType<?>, BlockEntityType<MeBridgeEntity>> ME_BRIDGE = APAddons.ae2Loaded() ? Registration.BLOCK_ENTITIES.register("me_bridge", () -> new BlockEntityType<>(MeBridgeEntity::new, Sets.newHashSet(Blocks.ME_BRIDGE.get()), null)) : null;
public static final DeferredHolder<BlockEntityType<?>, BlockEntityType<RsBridgeEntity>> RS_BRIDGE = APAddons.refinedStorageLoaded() ? Registration.BLOCK_ENTITIES.register("rs_bridge", () -> new BlockEntityType<>(RsBridgeEntity::new, Sets.newHashSet(Blocks.RS_BRIDGE.get()), null)) : null;
public static final DeferredHolder<BlockEntityType<?>, BlockEntityType<EnergyDetectorEntity>> ENERGY_DETECTOR = Registration.BLOCK_ENTITIES.register("energy_detector", () -> new BlockEntityType<>(EnergyDetectorEntity::new, Sets.newHashSet(Blocks.ENERGY_DETECTOR.get()), null));
public static final DeferredHolder<BlockEntityType<?>, BlockEntityType<InventoryManagerEntity>> INVENTORY_MANAGER = Registration.BLOCK_ENTITIES.register("inventory_manager", () -> new BlockEntityType<>(InventoryManagerEntity::new, Sets.newHashSet(Blocks.INVENTORY_MANAGER.get()), null));
public static final DeferredHolder<BlockEntityType<?>, BlockEntityType<RedstoneIntegratorEntity>> REDSTONE_INTEGRATOR = Registration.BLOCK_ENTITIES.register("redstone_integrator", () -> new BlockEntityType<>(RedstoneIntegratorEntity::new, Sets.newHashSet(Blocks.REDSTONE_INTEGRATOR.get()), null));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public class Blocks {
public static final DeferredHolder<Block, APBlockEntityBlock<?>> ENVIRONMENT_DETECTOR = register("environment_detector", () -> new APBlockEntityBlock<>(BlockEntityTypes.ENVIRONMENT_DETECTOR, false), () -> new APBlockItem(Blocks.ENVIRONMENT_DETECTOR.get(), APConfig.PERIPHERALS_CONFIG.enableEnvironmentDetector::get));
public static final DeferredHolder<Block, APBlockEntityBlock<?>> CHAT_BOX = register("chat_box", () -> new APBlockEntityBlock<>(BlockEntityTypes.CHAT_BOX, true), () -> new APBlockItem(Blocks.CHAT_BOX.get(), APConfig.PERIPHERALS_CONFIG.enableChatBox::get));
public static final DeferredHolder<Block, APBlockEntityBlock<?>> PLAYER_DETECTOR = register("player_detector", PlayerDetectorBlock::new, () -> new APBlockItem(Blocks.PLAYER_DETECTOR.get(), APConfig.PERIPHERALS_CONFIG.enablePlayerDetector::get));
public static final DeferredHolder<Block, APBlockEntityBlock<?>> ME_BRIDGE = register("me_bridge", () -> new APBlockEntityBlock<>(APAddons.ae2Loaded ? BlockEntityTypes.ME_BRIDGE : null, APAddons.ae2Loaded), () -> new APBlockItem(Blocks.ME_BRIDGE.get(), APConfig.PERIPHERALS_CONFIG.enableMEBridge::get));
public static final DeferredHolder<Block, APBlockEntityBlock<?>> RS_BRIDGE = register("rs_bridge", () -> new APBlockEntityBlock<>(APAddons.refinedStorageLoaded ? BlockEntityTypes.RS_BRIDGE : null, false), () -> new APBlockItem(Blocks.RS_BRIDGE.get(), APConfig.PERIPHERALS_CONFIG.enableRSBridge::get));
public static final DeferredHolder<Block, APBlockEntityBlock<?>> ME_BRIDGE = register("me_bridge", () -> new APBlockEntityBlock<>(APAddons.ae2Loaded() ? BlockEntityTypes.ME_BRIDGE : null, APAddons.ae2Loaded()), () -> new APBlockItem(Blocks.ME_BRIDGE.get(), APConfig.PERIPHERALS_CONFIG.enableMEBridge::get));
public static final DeferredHolder<Block, APBlockEntityBlock<?>> RS_BRIDGE = register("rs_bridge", () -> new APBlockEntityBlock<>(APAddons.refinedStorageLoaded() ? BlockEntityTypes.RS_BRIDGE : null, false), () -> new APBlockItem(Blocks.RS_BRIDGE.get(), APConfig.PERIPHERALS_CONFIG.enableRSBridge::get));
public static final DeferredHolder<Block, APBlockEntityBlock<?>> ENERGY_DETECTOR = register("energy_detector", () -> new APBlockEntityBlock<>(BlockEntityTypes.ENERGY_DETECTOR, true), () -> new APBlockItem(Blocks.ENERGY_DETECTOR.get(), APConfig.PERIPHERALS_CONFIG.enableEnergyDetector::get));
public static final DeferredHolder<Block, BaseBlock> PERIPHERAL_CASING = register("peripheral_casing", BaseBlock::new, () -> new APBlockItem(Blocks.PERIPHERAL_CASING.get(), new Item.Properties().stacksTo(16), () -> true));
public static final DeferredHolder<Block, APBlockEntityBlock<?>> INVENTORY_MANAGER = register("inventory_manager", () -> new APBlockEntityBlock<>(BlockEntityTypes.INVENTORY_MANAGER, false), () -> new APBlockItem(Blocks.INVENTORY_MANAGER.get(), APConfig.PERIPHERALS_CONFIG.enableInventoryManager::get));
Expand Down