Skip to content

Commit

Permalink
Moved config to ArchitectConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
kill05 committed Jun 10, 2024
1 parent 3111ffb commit a912553
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 40 deletions.
40 changes: 4 additions & 36 deletions src/main/java/com/github/kill05/ArchitectTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.github.kill05.blocks.architectstation.ArchitectTableBlock;
import com.github.kill05.blocks.architectstation.ArchitectTableTileEntity;
import com.github.kill05.config.ArchitectConfig;
import com.github.kill05.exceptions.ArchitectItemException;
import com.github.kill05.exceptions.InvalidMaterialException;
import com.github.kill05.items.part.ArchitectPart;
Expand All @@ -11,13 +12,13 @@
import com.github.kill05.materials.ArchitectMaterial;
import com.github.kill05.utils.ClassUtils;
import com.github.kill05.utils.ItemUtils;
import com.mojang.nbt.*;
import com.mojang.nbt.ListTag;
import com.mojang.nbt.StringTag;
import net.fabricmc.api.ModInitializer;
import net.minecraft.client.Minecraft;
import net.minecraft.client.render.stitcher.TextureRegistry;
import net.minecraft.core.block.Block;
import net.minecraft.core.data.DataLoader;
import net.minecraft.core.data.registry.Registries;
import net.minecraft.core.item.Item;
import net.minecraft.core.item.ItemStack;
import org.apache.commons.lang3.tuple.Pair;
Expand All @@ -31,8 +32,6 @@
import turniplabs.halplibe.helper.RecipeBuilder;
import turniplabs.halplibe.util.ClientStartEntrypoint;
import turniplabs.halplibe.util.RecipeEntrypoint;
import turniplabs.halplibe.util.TomlConfigHandler;
import turniplabs.halplibe.util.toml.Toml;

import java.io.IOException;
import java.net.URI;
Expand All @@ -50,38 +49,8 @@ public final class ArchitectTools implements ModInitializer, RecipeEntrypoint, C

public static final String MOD_ID = "architectstools";
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
public static final TomlConfigHandler CONFIG;
public static final int MAX_TOOL_PARTS = 3;

public static int PART_ID;
public static int TOOL_ID;
public static int ITEM_ID;

public static int BLOCK_ID;

static {
new Registries();
Toml toml = new Toml();

// Id
toml.addCategory("Set from which ID each category of blocks/items should start registering.", "IDs");
toml.addEntry("IDs.Parts", 23000);
toml.addEntry("IDs.Tools", 23100);
toml.addEntry("IDs.Items", 23200);
toml.addEntry("IDs.Blocks", 1500);

// Gameplay
//toml.addCategory("Change how the game and the mod are played.", "Gameplay");
//toml.addEntry("Gameplay.DisableOtherTools", "Set to true to disable vanilla tools so players can only use tools from Architect's Tools.", false);

CONFIG = new TomlConfigHandler(MOD_ID, toml);

PART_ID = toml.get("IDs.Parts", Integer.class);
TOOL_ID = toml.get("IDs.Tools", Integer.class);
ITEM_ID = toml.get("IDs.Items", Integer.class);
BLOCK_ID = toml.get("IDs.Blocks", Integer.class);
}


// Items and Blocks
public static final Item BLANK_PATTERN = item("blank_pattern", "blank_pattern");
Expand All @@ -99,10 +68,9 @@ public static <T extends Item> T item(T item, String texture) {
public static Item item(String name, String texture) {
return new ItemBuilder(MOD_ID)
.setIcon(MOD_ID + ":item/" + texture)
.build(new Item(name, ITEM_ID++));
.build(new Item(name, ArchitectConfig.ITEM_ID++));
}


// Materials
public static @Nullable ArchitectMaterial getMaterial(@Nullable String id) {
if (id == null) return null;
Expand Down
50 changes: 50 additions & 0 deletions src/main/java/com/github/kill05/MixinConfigPlugin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.github.kill05;

import org.objectweb.asm.tree.ClassNode;
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;

import java.util.List;
import java.util.Set;

public class MixinConfigPlugin implements IMixinConfigPlugin {

@Override
public void onLoad(String mixinPackage) {

}

@Override
public String getRefMapperConfig() {
return null;
}

@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
//if (mixinClassName.equals("com.github.kill05.mixins.ItemToolMixin")) {
// return ArchitectConfig.getDisableVanillaTools();
//}

return true;
}

@Override
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) {

}

@Override
public List<String> getMixins() {
return null;
}

@Override
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {

}

@Override
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {

}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.github.kill05.blocks.architectstation;

import com.github.kill05.ArchitectTools;
import com.github.kill05.blocks.architectstation.part.PartModeGui;
import com.github.kill05.config.ArchitectConfig;
import net.minecraft.client.Minecraft;
import net.minecraft.core.block.BlockTileEntity;
import net.minecraft.core.block.entity.TileEntity;
Expand All @@ -12,7 +12,7 @@
public class ArchitectTableBlock extends BlockTileEntity {

public ArchitectTableBlock() {
super("architect_table", ArchitectTools.BLOCK_ID++, Material.wood);
super("architect_table", ArchitectConfig.BLOCK_ID++, Material.wood);
}

@Override
Expand Down
47 changes: 47 additions & 0 deletions src/main/java/com/github/kill05/config/ArchitectConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.github.kill05.config;

import com.github.kill05.ArchitectTools;
import turniplabs.halplibe.util.TomlConfigHandler;
import turniplabs.halplibe.util.toml.Toml;

public final class ArchitectConfig {

public static final TomlConfigHandler CONFIG;

public static int PART_ID;
public static int TOOL_ID;
public static int ITEM_ID;

public static int BLOCK_ID;

static {
Toml toml = new Toml();

// Id
toml.addCategory("Set from which ID each category of blocks/items should start registering.", "IDs");
toml.addEntry("IDs.Parts", 23000);
toml.addEntry("IDs.Tools", 23100);
toml.addEntry("IDs.Items", 23200);
toml.addEntry("IDs.Blocks", 1500);

// Gameplay
toml.addCategory("Change how the game and the mod are played.", "Gameplay");
toml.addEntry("Gameplay.DisableVanillaTools", "Set to true to disable vanilla tools so players can only use tools from Architect's Tools.", false);

CONFIG = new TomlConfigHandler(ArchitectTools.MOD_ID, toml);

PART_ID = toml.get("IDs.Parts", Integer.class);
TOOL_ID = toml.get("IDs.Tools", Integer.class);
ITEM_ID = toml.get("IDs.Items", Integer.class);
BLOCK_ID = toml.get("IDs.Blocks", Integer.class);
}

private ArchitectConfig() {

}

public static boolean getDisableVanillaTools() {
return CONFIG.getBoolean("Gameplay.DisableVanillaTools");
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.kill05.items.part;

import com.github.kill05.ArchitectTools;
import com.github.kill05.config.ArchitectConfig;
import com.github.kill05.items.ArchitectItem;
import com.github.kill05.items.model.ArchitectPartModel;
import com.github.kill05.items.part.statistics.PartStatistic;
Expand Down Expand Up @@ -60,7 +61,7 @@ public static ArchitectPart partItem(String id, String texture) {
private final List<PartType> validTypes;

public ArchitectPart(String partId) {
super(partId + "_part", ArchitectTools.PART_ID++);
super(partId + "_part", ArchitectConfig.PART_ID++);
this.partId = partId;
this.ordinal = VALUES.size();
this.validTypes = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.kill05.items.tool;

import com.github.kill05.ArchitectTools;
import com.github.kill05.config.ArchitectConfig;
import com.github.kill05.items.ArchitectItem;
import com.github.kill05.items.model.ArchitectToolModel;
import com.github.kill05.items.part.ArchitectPart;
Expand Down Expand Up @@ -45,7 +46,7 @@ public static ArchitectTool toolItem(ArchitectTool tool) {
private final Collection<Tag<Block>> mineableTags;

public ArchitectTool(String toolId) {
super(toolId + "_tool", ArchitectTools.TOOL_ID++);
super(toolId + "_tool", ArchitectConfig.TOOL_ID++);
this.validStatistics = new LinkedHashMap<>();
this.partList = new ArrayList<>();
this.renderOrder = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,4 +210,9 @@ public boolean equals(Object o) {
public int hashCode() {
return Objects.hash(id);
}


static {
new Registries();
}
}

0 comments on commit a912553

Please sign in to comment.