Skip to content

Commit

Permalink
Changes to config (currently broken)
Browse files Browse the repository at this point in the history
  • Loading branch information
kill05 committed Jun 11, 2024
1 parent a912553 commit 8d0e0ca
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/main/java/com/github/kill05/MixinConfigPlugin.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.kill05;

import com.github.kill05.config.ArchitectConfig;
import org.objectweb.asm.tree.ClassNode;
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
Expand All @@ -21,9 +22,9 @@ public String getRefMapperConfig() {

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

return true;
}
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/com/github/kill05/config/ArchitectConfig.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.github.kill05.config;

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

Expand Down Expand Up @@ -28,7 +27,7 @@ public final class ArchitectConfig {
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);
CONFIG = new TomlConfigHandler("architectstools", toml);

PART_ID = toml.get("IDs.Parts", Integer.class);
TOOL_ID = toml.get("IDs.Tools", Integer.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package com.github.kill05.mixins.disablevanilla;

import net.minecraft.core.block.Block;
import net.minecraft.core.data.tag.Tag;
import net.minecraft.core.entity.Entity;
import net.minecraft.core.item.Item;
import net.minecraft.core.item.ItemStack;
import net.minecraft.core.item.material.ToolMaterial;
import net.minecraft.core.item.tool.ItemTool;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import sunsetsatellite.catalyst.core.util.ICustomDescription;

@Mixin(
value = ItemTool.class,
remap = false
)
public abstract class ItemToolMixin extends Item implements ICustomDescription {

public ItemToolMixin(int id) {
super(id);
}

@SuppressWarnings("rawtypes")
@Inject(
method = "<init>",
at = @At(value = "TAIL")
)
private void getStrVsBlockInject(String name, int id, int damageDealt, ToolMaterial toolMaterial, Tag tagEffectiveAgainst, CallbackInfo ci) {
setMaxDamage(1);
}

@Override
public String getDescription(ItemStack itemStack) {
return """
§eVanilla tools are disabled by Architect's Tools.
§eIf you wish to enable vanilla tools,
§eplease open 'architectstools.cfg',
§ethen set 'DisableVanillaTools' to 'false'.""";
}

@Override
public String getTranslatedName(ItemStack itemstack) {
return super.getTranslatedName(itemstack) + " §e(DISABLED)§r";
}

@Override
public int getDamageVsEntity(Entity entity) {
return super.getDamageVsEntity(entity);
}

@Override
public float getStrVsBlock(ItemStack itemstack, Block block) {
return super.getStrVsBlock(itemstack, block);
}

@Override
public boolean canHarvestBlock(Block block) {
return super.canHarvestBlock(block);
}
}
4 changes: 3 additions & 1 deletion src/main/resources/mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
"minVersion": "0.8",
"package": "com.github.kill05.mixins",
"compatibilityLevel": "JAVA_17",
"plugin": "com.github.kill05.MixinConfigPlugin",
"mixins": [
"ItemStackMixin",
"StringTagMixin"
"StringTagMixin",
"disablevanilla.ItemToolMixin"
],
"client": [
],
Expand Down

0 comments on commit 8d0e0ca

Please sign in to comment.