Skip to content

Commit

Permalink
Move base mod classes to common
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensworks committed Oct 6, 2024
1 parent 036db3d commit 0ca6435
Show file tree
Hide file tree
Showing 11 changed files with 110 additions and 125 deletions.
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ mod_id=colossalchests
license=MIT
github_url=https://github.com/CyclopsMC/ColossalChests
issue_tracker_url=https://github.com/CyclopsMC/ColossalChests/issues
display_url=https://www.curseforge.com/minecraft/mc-mods/colossalchests
display_url=https://www.curseforge.com/minecraft/mc-mods/colossal-chests
description=For when regular chests are too small.
fingerprint=bd0353b3e8a2810d60dd584e256e364bc3bedd44
neo_form_version=1.21-20240613.152323
Expand All @@ -29,14 +29,14 @@ fabric_forgeconfigapiport_version=21.1.0
# NeoForge
neoforge_version=21.1.2
neoforge_loader_version_range=[4,)
neoforge_update_json_url=https://raw.githubusercontent.com/CyclopsMC/Versions/master/neoforge_update/colossalchests.json
neoforge_update_json_url=https://raw.githubusercontent.com/CyclopsMC/Versions/master/neoforge_update/colossal-chests.json
# Dependencies
neoforge_commoncapabilities_version=2.9.3-147

# Forge
forge_version=52.0.3
forge_loader_version_range=[2,)
forge_update_json_url=https://raw.githubusercontent.com/CyclopsMC/Versions/master/forge_update/colossalchests.json
forge_update_json_url=https://raw.githubusercontent.com/CyclopsMC/Versions/master/forge_update/colossal-chests.json

# Gradle
org.gradle.jvmargs=-Xmx3G
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package org.cyclops.colossalchests;

import org.cyclops.cyclopscore.config.ConfigurablePropertyCommon;
import org.cyclops.cyclopscore.config.ModConfigLocation;
import org.cyclops.cyclopscore.config.extendedconfig.DummyConfigCommon;
import org.cyclops.cyclopscore.init.IModBase;

/**
* A config with general options for this mod.
* @author rubensworks
*
*/
public class GeneralConfig<M extends IModBase> extends DummyConfigCommon<M> {

@ConfigurablePropertyCommon(category = "general", comment = "If items should be ejected from the chests if one of the structure blocks are removed.", configLocation = ModConfigLocation.SERVER)
public static boolean ejectItemsOnDestroy = false;

@ConfigurablePropertyCommon(category = "general", comment = "If the higher tier metal variants (including diamond and obsidian) can be crafted.", configLocation = ModConfigLocation.SERVER)
public static boolean metalVariants = true;

@ConfigurablePropertyCommon(category = "core", comment = "Maximum buffer byte size for adaptive inventory slots fragmentation.")
public static int maxPacketBufferSize = 20000;

@ConfigurablePropertyCommon(category = "general", comment = "If the interface input overlay should always be rendered on chests.", isCommandable = true, configLocation = ModConfigLocation.CLIENT)
public static boolean alwaysShowInterfaceOverlay = true;

@ConfigurablePropertyCommon(category = "general", comment = "Always create full creative-mode chests when formed. Should not be used in survival worlds!", isCommandable = true, configLocation = ModConfigLocation.SERVER)
public static boolean creativeChests = false;

@ConfigurablePropertyCommon(category = "general", comment = "Multiplier for the number of inventory slots for this chest material.", isCommandable = true, configLocation = ModConfigLocation.SERVER)
public static double chestInventoryMaterialFactorWood = 1;
@ConfigurablePropertyCommon(category = "general", comment = "Multiplier for the number of inventory slots for this chest material.", isCommandable = true, configLocation = ModConfigLocation.SERVER)
public static double chestInventoryMaterialFactorCopper = 1.666;
@ConfigurablePropertyCommon(category = "general", comment = "Multiplier for the number of inventory slots for this chest material.", isCommandable = true, configLocation = ModConfigLocation.SERVER)
public static double chestInventoryMaterialFactorIron = 2;
@ConfigurablePropertyCommon(category = "general", comment = "Multiplier for the number of inventory slots for this chest material.", isCommandable = true, configLocation = ModConfigLocation.SERVER)
public static double chestInventoryMaterialFactorSilver = 2.666;
@ConfigurablePropertyCommon(category = "general", comment = "Multiplier for the number of inventory slots for this chest material.", isCommandable = true, configLocation = ModConfigLocation.SERVER)
public static double chestInventoryMaterialFactorGold = 3;
@ConfigurablePropertyCommon(category = "general", comment = "Multiplier for the number of inventory slots for this chest material.", isCommandable = true, configLocation = ModConfigLocation.SERVER)
public static double chestInventoryMaterialFactorDiamond = 4;
@ConfigurablePropertyCommon(category = "general", comment = "Multiplier for the number of inventory slots for this chest material.", isCommandable = true, configLocation = ModConfigLocation.SERVER)
public static double chestInventoryMaterialFactorObsidian = 4;

public GeneralConfig(M mod) {
super(mod, "general");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.cyclops.colossalchests;

/**
* Class that can hold basic static things that are better not hard-coded
* like mod details, texture paths, ID's...
* @author rubensworks
*
*/
@SuppressWarnings("javadoc")
public class Reference {

// Mod info
public static final String MOD_ID = "colossalchests";
public static final String GA_TRACKING_ID = "UA-65307010-5";

// MOD ID's
public static final String MOD_IRONCHEST = "ironchest";
public static final String MOD_COMMONCAPABILITIES = "commoncapabilities";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.cyclops.colossalchests;

import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import org.cyclops.cyclopscore.config.DeferredHolderCommon;

/**
* Referenced registry entries.
* @author rubensworks
*/
public class RegistryEntriesCommon { // TODO: rename when done

public static final DeferredHolderCommon<Item, Item> ITEM_CHEST = DeferredHolderCommon.create(Registries.ITEM, ResourceLocation.parse("minecraft:chest"));

public static final DeferredHolderCommon<Block, Block> BLOCK_UNCOLOSSAL_CHEST = DeferredHolderCommon.create(Registries.BLOCK, ResourceLocation.parse("colossalchests:uncolossal_chest"));

// TODO
// public static final DeferredHolderCommon<BlockEntityType<?>, BlockEntityType<BlockEntityColossalChest>> BLOCK_ENTITY_COLOSSAL_CHEST = DeferredHolderCommon.create(Registries.BLOCK_ENTITY_TYPE, ResourceLocation.parse("colossalchests:colossal_chest"));
// public static final DeferredHolderCommon<BlockEntityType<?>, BlockEntityType<BlockEntityInterface>> BLOCK_ENTITY_INTERFACE = DeferredHolderCommon.create(Registries.BLOCK_ENTITY_TYPE, ResourceLocation.parse("colossalchests:interface"));
// public static final DeferredHolderCommon<BlockEntityType<?>, BlockEntityType<BlockEntityUncolossalChest>> BLOCK_ENTITY_UNCOLOSSAL_CHEST = DeferredHolderCommon.create(Registries.BLOCK_ENTITY_TYPE, ResourceLocation.parse("colossalchests:uncolossal_chest"));
//
// public static final DeferredHolderCommon<MenuType<?>, MenuType<ContainerColossalChest>> CONTAINER_COLOSSAL_CHEST = DeferredHolderCommon.create(Registries.MENU, ResourceLocation.parse("colossalchests:colossal_chest"));
// public static final DeferredHolderCommon<MenuType<?>, MenuType<ContainerUncolossalChest>> CONTAINER_UNCOLOSSAL_CHEST = DeferredHolderCommon.create(Registries.MENU, ResourceLocation.parse("colossalchests:uncolossal_chest"));
//
// public static final DeferredHolderCommon<CriterionTrigger<?>, ChestFormedTrigger> TRIGGER_CHEST_FORMED = DeferredHolderCommon.create(Registries.TRIGGER_TYPE, ResourceLocation.parse("colossalchests:chest_formed"));

}
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ protected ICommonProxy constructCommonProxy() {
@Override
protected CreativeModeTab.Builder constructDefaultCreativeModeTab(CreativeModeTab.Builder builder) {
return super.constructDefaultCreativeModeTab(builder)
.icon(() -> new ItemStack(RegistryEntries.ITEM_CHEST));
.icon(() -> new ItemStack(RegistryEntriesCommon.ITEM_CHEST));
}

@Override
protected void onConfigsRegister(ConfigHandler configHandler) {
super.onConfigsRegister(configHandler);

configHandler.addConfigurable(new GeneralConfig());
configHandler.addConfigurable(new GeneralConfig<>(this));

for (ChestMaterial material : ChestMaterial.VALUES) {
configHandler.addConfigurable(new ChestWallConfig(material));
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.inventory.MenuType;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.neoforged.neoforge.registries.DeferredHolder;
import org.cyclops.colossalchests.advancement.criterion.ChestFormedTrigger;
Expand All @@ -19,11 +17,8 @@
* Referenced registry entries.
* @author rubensworks
*/
public class RegistryEntries {

public static final DeferredHolder<Item, Item> ITEM_CHEST = DeferredHolder.create(Registries.ITEM, ResourceLocation.parse("minecraft:chest"));

public static final DeferredHolder<Block, Block> BLOCK_UNCOLOSSAL_CHEST = DeferredHolder.create(Registries.BLOCK, ResourceLocation.parse("colossalchests:uncolossal_chest"));
@Deprecated
public class RegistryEntries { // TODO: rm

public static final DeferredHolder<BlockEntityType<?>, BlockEntityType<BlockEntityColossalChest>> BLOCK_ENTITY_COLOSSAL_CHEST = DeferredHolder.create(Registries.BLOCK_ENTITY_TYPE, ResourceLocation.parse("colossalchests:colossal_chest"));
public static final DeferredHolder<BlockEntityType<?>, BlockEntityType<BlockEntityInterface>> BLOCK_ENTITY_INTERFACE = DeferredHolder.create(Registries.BLOCK_ENTITY_TYPE, ResourceLocation.parse("colossalchests:interface"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import net.minecraft.world.level.block.entity.LidBlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import org.cyclops.colossalchests.RegistryEntries;
import org.cyclops.colossalchests.RegistryEntriesCommon;
import org.cyclops.colossalchests.block.UncolossalChest;
import org.cyclops.colossalchests.inventory.container.ContainerUncolossalChest;
import org.cyclops.cyclopscore.blockentity.CyclopsBlockEntity;
Expand Down Expand Up @@ -178,7 +179,7 @@ public Direction getRotation() {
}

BlockState blockState = getLevel().getBlockState(getBlockPos());
if(blockState.getBlock() != RegistryEntries.BLOCK_UNCOLOSSAL_CHEST.get()) return Direction.NORTH;
if(blockState.getBlock() != RegistryEntriesCommon.BLOCK_UNCOLOSSAL_CHEST.value()) return Direction.NORTH;
return BlockHelpers.getSafeBlockStateProperty(blockState, UncolossalChest.FACING, Direction.NORTH);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent;
import net.neoforged.neoforge.items.wrapper.InvWrapper;
import org.cyclops.colossalchests.ColossalChests;
import org.cyclops.colossalchests.RegistryEntries;
import org.cyclops.colossalchests.RegistryEntriesCommon;
import org.cyclops.colossalchests.client.render.blockentity.RenderTileEntityUncolossalChest;
import org.cyclops.cyclopscore.config.extendedconfig.BlockEntityConfig;

Expand All @@ -24,7 +24,7 @@ public BlockEntityUncolossalChestConfig() {
ColossalChests._instance,
"uncolossal_chest",
(eConfig) -> new BlockEntityType<>(BlockEntityUncolossalChest::new,
Sets.newHashSet(RegistryEntries.BLOCK_UNCOLOSSAL_CHEST.get()), null)
Sets.newHashSet(RegistryEntriesCommon.BLOCK_UNCOLOSSAL_CHEST.value()), null)
);
ColossalChests._instance.getModEventBus().addListener(this::registerCapabilities);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import net.neoforged.api.distmarker.Dist;
import net.neoforged.api.distmarker.OnlyIn;
import net.neoforged.neoforge.client.extensions.common.IClientItemExtensions;
import org.cyclops.colossalchests.RegistryEntries;
import org.cyclops.colossalchests.RegistryEntriesCommon;
import org.cyclops.colossalchests.blockentity.BlockEntityUncolossalChest;
import org.cyclops.cyclopscore.client.render.blockentity.ItemStackBlockEntityRendererBase;

Expand All @@ -16,7 +16,7 @@
public class ItemStackTileEntityUncolossalChestRender extends ItemStackBlockEntityRendererBase {

public ItemStackTileEntityUncolossalChestRender() {
super(() -> new BlockEntityUncolossalChest(BlockPos.ZERO, RegistryEntries.BLOCK_UNCOLOSSAL_CHEST.get().defaultBlockState()));
super(() -> new BlockEntityUncolossalChest(BlockPos.ZERO, RegistryEntriesCommon.BLOCK_UNCOLOSSAL_CHEST.value().defaultBlockState()));
}

public static class ClientItemExtensions implements IClientItemExtensions {
Expand Down

0 comments on commit 0ca6435

Please sign in to comment.