Skip to content

Commit

Permalink
enabled duplex tool & hammer schema cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mickelus committed Nov 10, 2019
1 parent db96de5 commit a25393b
Show file tree
Hide file tree
Showing 5 changed files with 162 additions and 186 deletions.
3 changes: 2 additions & 1 deletion src/main/java/se/mickelus/tetra/TetraMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import se.mickelus.tetra.items.ITetraItem;
import se.mickelus.tetra.items.ItemPredicateModular;
import se.mickelus.tetra.items.TetraItemGroup;
import se.mickelus.tetra.items.duplex_tool.ItemDuplexToolModular;
import se.mickelus.tetra.items.forged.ItemBeam;
import se.mickelus.tetra.items.forged.ItemBolt;
import se.mickelus.tetra.items.forged.ItemMesh;
Expand Down Expand Up @@ -147,7 +148,7 @@ public TetraMod() {
new ItemPristineEmerald(),
new ItemPristineDiamond(),
// new ItemToolbeltModular(),
// new ItemDuplexToolModular(),
new ItemDuplexToolModular(),
// new ItemCellMagmatic(),
new ItemBolt(),
new ItemBeam(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static void loadModels(ModelBakeEvent event) {

// TextureAtlasSprite particleSprite = ModelLoader.defaultTextureGetter().apply(new ResourceLocation(unbaked.resolveTextureName("particle")));
items.forEach(item -> {
ModelResourceLocation resourceLocation = new ModelResourceLocation(ItemSwordModular.instance.getRegistryName(), "inventory");
ModelResourceLocation resourceLocation = new ModelResourceLocation(item.getRegistryName(), "inventory");
SimpleBakedModel originalModel = (SimpleBakedModel) event.getModelRegistry().get(resourceLocation);
try {
IBakedModel model = loadModel(event.getModelLoader(), originalModel, resourceLocation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ public class ItemDuplexToolModular extends ItemModularHandheld {

public static BasicMajorModule handle;

// hacky, but the creative tabs are filled before init so we need to setup itemstacks and populate them with modules later
private ItemStack creativeWoodHammer;
private ItemStack creativeObsidianHammer;

@ObjectHolder(TetraMod.MOD_ID + ":" + unlocalizedName)
public static ItemDuplexToolModular instance;

Expand All @@ -87,53 +91,8 @@ public ItemDuplexToolModular() {

requiredModules = new String[] { handleKey, headLeftKey, headRightKey };

synergies = DataHandler.instance.getSynergyData("modules/duplex/synergies");

basicHammerHeadLeft = new DuplexHeadModule(headLeftKey, "basic_hammer", leftSuffix,
"duplex/improvements/basic_hammer", "duplex/improvements/shared_head_hone", "settling_improvements");
basicHammerHeadRight = new DuplexHeadModule(headRightKey, "basic_hammer", rightSuffix,
"duplex/improvements/basic_hammer", "duplex/improvements/shared_head_hone", "settling_improvements");

basicAxeLeft = new DuplexHeadModule(headLeftKey, "basic_axe", leftSuffix,
"duplex/improvements/basic_axe", "duplex/improvements/basic_axe_hone", "duplex/improvements/shared_head_hone", "settling_improvements");
basicAxeRight = new DuplexHeadModule(headRightKey, "basic_axe", rightSuffix,
"duplex/improvements/basic_axe", "duplex/improvements/basic_axe_hone", "duplex/improvements/shared_head_hone", "settling_improvements");

basicPickaxeLeft = new DuplexHeadModule(headLeftKey, "basic_pickaxe", leftSuffix,
"duplex/improvements/basic_pickaxe", "duplex/improvements/basic_pickaxe_hone", "duplex/improvements/shared_head_hone", "settling_improvements");
basicPickaxeRight = new DuplexHeadModule(headRightKey, "basic_pickaxe", rightSuffix,
"duplex/improvements/basic_pickaxe", "duplex/improvements/basic_pickaxe_hone", "duplex/improvements/shared_head_hone", "settling_improvements");

hoeLeft = new DuplexHeadModule(headLeftKey, "hoe", leftSuffix,
"duplex/improvements/hoe", "duplex/improvements/hoe_hone", "duplex/improvements/shared_head_hone", "settling_improvements");
hoeRight = new DuplexHeadModule(headRightKey, "hoe", rightSuffix,
"duplex/improvements/hoe", "duplex/improvements/hoe_hone", "duplex/improvements/shared_head_hone", "settling_improvements");

adzeLeft = new DuplexHeadModule(headLeftKey, "adze", leftSuffix,
"duplex/improvements/adze", "duplex/improvements/adze_hone", "duplex/improvements/shared_head_hone", "settling_improvements");
adzeRight = new DuplexHeadModule(headRightKey, "adze", rightSuffix,
"duplex/improvements/adze", "duplex/improvements/adze_hone", "duplex/improvements/shared_head_hone", "settling_improvements");

sickleLeft = new DuplexHeadModule(headLeftKey, "sickle", leftSuffix,
"duplex/improvements/sickle", "duplex/improvements/sickle_hone", "duplex/improvements/shared_head_hone", "settling_improvements");
sickleRight = new DuplexHeadModule(headRightKey, "sickle", rightSuffix,
"duplex/improvements/sickle", "duplex/improvements/sickle_hone", "duplex/improvements/shared_head_hone", "settling_improvements");

clawLeft = new DuplexHeadModule(headLeftKey, "claw", leftSuffix,
"duplex/improvements/claw", "duplex/improvements/claw_hone", "duplex/improvements/shared_head_hone", "settling_improvements");
clawRight = new DuplexHeadModule(headRightKey, "claw", rightSuffix,
"duplex/improvements/claw", "duplex/improvements/claw_hone", "duplex/improvements/shared_head_hone", "settling_improvements");

butt = new DuplexHeadModule(headRightKey, "butt", rightSuffix,
"duplex/improvements/butt", "duplex/improvements/butt_hone", "duplex/improvements/shared_head_hone", "settling_improvements");

handle = new BasicMajorModule(handleKey, "duplex/basic_handle",
"duplex/improvements/basic_handle", "duplex/improvements/basic_handle_hone", "duplex/improvements/shared_head_hone", "settling_improvements")
.withRenderLayer(Priority.LOWER);


new BasicModule(bindingKey, "duplex/binding", "duplex/tweaks/binding");
new BasicModule(bindingKey, "duplex/socket");
creativeWoodHammer = new ItemStack(this);
creativeObsidianHammer = new ItemStack(this);

updateConfig(ConfigHandler.honeDuplexBase, ConfigHandler.honeDuplexIntegrityMultiplier);
}
Expand All @@ -145,78 +104,132 @@ public void updateConfig(int honeBase, int honeIntegrityMultiplier) {

@Override
public void init(PacketHandler packetHandler) {
synergies = DataHandler.instance.getSynergyData("modules/duplex/synergies");

basicHammerHeadLeft = new DuplexHeadModule(headLeftKey, "basic_hammer", leftSuffix,
"duplex/improvements/basic_hammer", "duplex/improvements/shared_head_hone", "settling_improvements");
basicHammerHeadRight = new DuplexHeadModule(headRightKey, "basic_hammer", rightSuffix,
"duplex/improvements/basic_hammer", "duplex/improvements/shared_head_hone", "settling_improvements");
ItemUpgradeRegistry.instance.registerConfigSchema("duplex/basic_hammer");
ItemUpgradeRegistry.instance.registerConfigSchema("duplex/basic_hammer_hone");
new BookEnchantSchema(basicHammerHeadLeft);
new BookEnchantSchema(basicHammerHeadRight);

ItemUpgradeRegistry.instance.registerConfigSchema("duplex/basic_axe");
ItemUpgradeRegistry.instance.registerConfigSchema("duplex/basic_axe_hone");
new BookEnchantSchema(basicAxeLeft);
new BookEnchantSchema(basicAxeRight);

ItemUpgradeRegistry.instance.registerConfigSchema("duplex/basic_pickaxe");
ItemUpgradeRegistry.instance.registerConfigSchema("duplex/basic_pickaxe_hone");
new BookEnchantSchema(basicPickaxeLeft);
new BookEnchantSchema(basicPickaxeRight);

ItemUpgradeRegistry.instance.registerConfigSchema("duplex/hoe");
ItemUpgradeRegistry.instance.registerConfigSchema("duplex/hoe_hone");
new BookEnchantSchema(hoeLeft);
new BookEnchantSchema(hoeRight);

ItemUpgradeRegistry.instance.registerConfigSchema("duplex/adze");
ItemUpgradeRegistry.instance.registerConfigSchema("duplex/adze_hone");
new BookEnchantSchema(adzeLeft);
new BookEnchantSchema(adzeRight);

ItemUpgradeRegistry.instance.registerConfigSchema("duplex/sickle");
ItemUpgradeRegistry.instance.registerConfigSchema("duplex/sickle_hone");
new BookEnchantSchema(sickleLeft);
new BookEnchantSchema(sickleRight);

ItemUpgradeRegistry.instance.registerConfigSchema("duplex/claw");
ItemUpgradeRegistry.instance.registerConfigSchema("duplex/claw_hone");
new BookEnchantSchema(clawLeft);
new BookEnchantSchema(clawRight);

ItemUpgradeRegistry.instance.registerConfigSchema("duplex/butt");
ItemUpgradeRegistry.instance.registerConfigSchema("duplex/butt_hone");
new BookEnchantSchema(butt);
// basicAxeLeft = new DuplexHeadModule(headLeftKey, "basic_axe", leftSuffix,
// "duplex/improvements/basic_axe", "duplex/improvements/basic_axe_hone", "duplex/improvements/shared_head_hone",
// "settling_improvements");
// basicAxeRight = new DuplexHeadModule(headRightKey, "basic_axe", rightSuffix,
// "duplex/improvements/basic_axe", "duplex/improvements/basic_axe_hone", "duplex/improvements/shared_head_hone",
// "settling_improvements");
// ItemUpgradeRegistry.instance.registerConfigSchema("duplex/basic_axe");
// ItemUpgradeRegistry.instance.registerConfigSchema("duplex/basic_axe_hone");
// new BookEnchantSchema(basicAxeLeft);
// new BookEnchantSchema(basicAxeRight);
//
// basicPickaxeLeft = new DuplexHeadModule(headLeftKey, "basic_pickaxe", leftSuffix,
// "duplex/improvements/basic_pickaxe", "duplex/improvements/basic_pickaxe_hone", "duplex/improvements/shared_head_hone",
// "settling_improvements");
// basicPickaxeRight = new DuplexHeadModule(headRightKey, "basic_pickaxe", rightSuffix,
// "duplex/improvements/basic_pickaxe", "duplex/improvements/basic_pickaxe_hone", "duplex/improvements/shared_head_hone",
// "settling_improvements");
// ItemUpgradeRegistry.instance.registerConfigSchema("duplex/basic_pickaxe");
// ItemUpgradeRegistry.instance.registerConfigSchema("duplex/basic_pickaxe_hone");
// new BookEnchantSchema(basicPickaxeLeft);
// new BookEnchantSchema(basicPickaxeRight);
//
// hoeLeft = new DuplexHeadModule(headLeftKey, "hoe", leftSuffix,
// "duplex/improvements/hoe", "duplex/improvements/hoe_hone", "duplex/improvements/shared_head_hone",
// "settling_improvements");
// hoeRight = new DuplexHeadModule(headRightKey, "hoe", rightSuffix,
// "duplex/improvements/hoe", "duplex/improvements/hoe_hone", "duplex/improvements/shared_head_hone",
// "settling_improvements");
// ItemUpgradeRegistry.instance.registerConfigSchema("duplex/hoe");
// ItemUpgradeRegistry.instance.registerConfigSchema("duplex/hoe_hone");
// new BookEnchantSchema(hoeLeft);
// new BookEnchantSchema(hoeRight);
//
// adzeLeft = new DuplexHeadModule(headLeftKey, "adze", leftSuffix,
// "duplex/improvements/adze", "duplex/improvements/adze_hone", "duplex/improvements/shared_head_hone",
// "settling_improvements");
// adzeRight = new DuplexHeadModule(headRightKey, "adze", rightSuffix,
// "duplex/improvements/adze", "duplex/improvements/adze_hone", "duplex/improvements/shared_head_hone",
// "settling_improvements");
// ItemUpgradeRegistry.instance.registerConfigSchema("duplex/adze");
// ItemUpgradeRegistry.instance.registerConfigSchema("duplex/adze_hone");
// new BookEnchantSchema(adzeLeft);
// new BookEnchantSchema(adzeRight);
//
// sickleLeft = new DuplexHeadModule(headLeftKey, "sickle", leftSuffix,
// "duplex/improvements/sickle", "duplex/improvements/sickle_hone", "duplex/improvements/shared_head_hone",
// "settling_improvements");
// sickleRight = new DuplexHeadModule(headRightKey, "sickle", rightSuffix,
// "duplex/improvements/sickle", "duplex/improvements/sickle_hone", "duplex/improvements/shared_head_hone",
// "settling_improvements");
// ItemUpgradeRegistry.instance.registerConfigSchema("duplex/sickle");
// ItemUpgradeRegistry.instance.registerConfigSchema("duplex/sickle_hone");
// new BookEnchantSchema(sickleLeft);
// new BookEnchantSchema(sickleRight);
//
// clawLeft = new DuplexHeadModule(headLeftKey, "claw", leftSuffix,
// "duplex/improvements/claw", "duplex/improvements/claw_hone", "duplex/improvements/shared_head_hone",
// "settling_improvements");
// clawRight = new DuplexHeadModule(headRightKey, "claw", rightSuffix,
// "duplex/improvements/claw", "duplex/improvements/claw_hone", "duplex/improvements/shared_head_hone",
// "settling_improvements");
// ItemUpgradeRegistry.instance.registerConfigSchema("duplex/claw");
// ItemUpgradeRegistry.instance.registerConfigSchema("duplex/claw_hone");
// new BookEnchantSchema(clawLeft);
// new BookEnchantSchema(clawRight);
//
// butt = new DuplexHeadModule(headRightKey, "butt", rightSuffix,
// "duplex/improvements/butt", "duplex/improvements/butt_hone", "duplex/improvements/shared_head_hone",
// "settling_improvements");
// ItemUpgradeRegistry.instance.registerConfigSchema("duplex/butt");
// ItemUpgradeRegistry.instance.registerConfigSchema("duplex/butt_hone");
// new BookEnchantSchema(butt);

handle = new BasicMajorModule(handleKey, "duplex/basic_handle",
"duplex/improvements/basic_handle", "duplex/improvements/basic_handle_hone", "duplex/improvements/shared_head_hone",
"settling_improvements")
.withRenderLayer(Priority.LOWER);
ItemUpgradeRegistry.instance.registerConfigSchema("duplex/basic_handle");
ItemUpgradeRegistry.instance.registerConfigSchema("duplex/basic_handle_hone");
ItemUpgradeRegistry.instance.registerConfigSchema("duplex/basic_handle_improvements");
new BookEnchantSchema(handle);

// new BasicModule(bindingKey, "duplex/binding", "duplex/tweaks/binding");
// ItemUpgradeRegistry.instance.registerConfigSchema("duplex/binding");
//
// new BasicModule(bindingKey, "duplex/socket");
// ItemUpgradeRegistry.instance.registerConfigSchema("duplex/binding");

ItemUpgradeRegistry.instance.registerConfigSchema("duplex/shared_head_hone");

new RepairSchema(this);
RemoveSchema.registerRemoveSchemas(this);

ItemUpgradeRegistry.instance.registerReplacementDefinition("axe");
ItemUpgradeRegistry.instance.registerReplacementDefinition("pickaxe");
ItemUpgradeRegistry.instance.registerReplacementDefinition("hoe");
// ItemUpgradeRegistry.instance.registerReplacementDefinition("axe");
// ItemUpgradeRegistry.instance.registerReplacementDefinition("pickaxe");
// ItemUpgradeRegistry.instance.registerReplacementDefinition("hoe");

ItemUpgradeRegistry.instance.registerConfigSchema("duplex/binding");
ItemUpgradeRegistry.instance.registerConfigSchema("duplex/socket");

setupHammerStack(creativeWoodHammer, "log", "stick");
setupHammerStack(creativeObsidianHammer, "obsidian", "iron");
}

@Override
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> items) {
if (isInGroup(group)) {
items.add(createHammerStack("log", "stick"));
items.add(createHammerStack("obsidian", "iron"));
items.add(creativeWoodHammer);
items.add(creativeObsidianHammer);
}
}

public ItemStack createHammerStack(String headMaterial, String handleMaterial) {
ItemStack itemStack = new ItemStack(this);

private void setupHammerStack(ItemStack itemStack, String headMaterial, String handleMaterial) {
basicHammerHeadLeft.addModule(itemStack, "basic_hammer/" + headMaterial, null);
basicHammerHeadRight.addModule(itemStack, "basic_hammer/" + headMaterial, null);
handle.addModule(itemStack, "basic_handle/" + handleMaterial, null);
return itemStack;
}

@Override
Expand All @@ -225,7 +238,7 @@ public ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context)
World world = context.getWorld();
BlockPos pos = context.getPos();
Hand hand = context.getHand();
if (!player.isSneaking() && world.getBlockState(pos).getBlock().equals(Blocks.CRAFTING_TABLE)
if (player != null && !player.isSneaking() && world.getBlockState(pos).getBlock().equals(Blocks.CRAFTING_TABLE)
&& getCapabilityLevel(player.getHeldItem(hand), Capability.hammer) > 0) {
return BlockWorkbench.upgradeWorkbench(player, world, pos, hand, context.getFace());
}
Expand Down
Loading

0 comments on commit a25393b

Please sign in to comment.