generated from CleanroomMC/ForgeDevEnv
-
Notifications
You must be signed in to change notification settings - Fork 5
Add GTChisels #355
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
Closed
Closed
Add GTChisels #355
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 1 addition & 28 deletions
29
src/main/java/com/github/gtexpert/core/integration/chisel/recipes/ChiselToolsRecipe.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,46 +1,19 @@ | ||
| package com.github.gtexpert.core.integration.chisel.recipes; | ||
|
|
||
| import static gregtech.api.unification.ore.OrePrefix.*; | ||
|
|
||
| import gregtech.api.recipes.ModHandler; | ||
| import gregtech.api.unification.material.Materials; | ||
| import gregtech.api.unification.stack.UnificationEntry; | ||
| import gregtech.common.ConfigHolder; | ||
|
|
||
| import com.github.gtexpert.core.api.util.GTEUtility; | ||
| import com.github.gtexpert.core.api.util.Mods; | ||
| import com.github.gtexpert.core.integration.chisel.ChiselConfigHolder; | ||
|
|
||
| public class ChiselToolsRecipe { | ||
|
|
||
| public static void init() { | ||
| if (ConfigHolder.recipes.hardToolArmorRecipes && ChiselConfigHolder.hardToolRecipes) { | ||
| // Iron Chisel | ||
| // Remove original Chisel mod recipes - replaced by GregTech-style chisel | ||
| ModHandler.removeRecipeByName(Mods.Chisel.getResource("chisel_iron")); | ||
| ModHandler.addShapedRecipe(true, "chisel_iron", | ||
| GTEUtility.getModItem(Mods.Names.CHISEL, "chisel_iron"), | ||
| "fPP", " CP", "S h", | ||
| 'P', new UnificationEntry(plate, Materials.Iron), | ||
| 'C', new UnificationEntry(screw, Materials.Iron), | ||
| 'S', new UnificationEntry(stick, Materials.Bronze)); | ||
|
|
||
| // Diamond Chisel | ||
| ModHandler.removeRecipeByName(Mods.Chisel.getResource("chisel_diamond")); | ||
| ModHandler.addShapedRecipe(true, "chisel_diamond", | ||
| GTEUtility.getModItem(Mods.Names.CHISEL, "chisel_diamond"), | ||
| "fPP", " CP", "S h", | ||
| 'P', new UnificationEntry(plate, Materials.Diamond), | ||
| 'C', GTEUtility.getModItem(Mods.Names.CHISEL, "chisel_iron"), | ||
| 'S', new UnificationEntry(stick, Materials.RoseGold)); | ||
|
|
||
| // iChisel | ||
| ModHandler.removeRecipeByName(Mods.Chisel.getResource("chisel_hitech")); | ||
| ModHandler.addShapedRecipe(true, "chisel_hitech", | ||
| GTEUtility.getModItem(Mods.Names.CHISEL, "chisel_hitech"), | ||
| "fPP", " CP", "S h", | ||
| 'P', new UnificationEntry(plate, Materials.Diamond), | ||
| 'C', GTEUtility.getModItem(Mods.Names.CHISEL, "chisel_diamond"), | ||
| 'S', new UnificationEntry(stick, Materials.StainlessSteel)); | ||
| } | ||
| } | ||
| } |
65 changes: 65 additions & 0 deletions
65
src/main/java/com/github/gtexpert/core/integration/chisel/tools/ChiselToolItems.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| package com.github.gtexpert.core.integration.chisel.tools; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| import net.minecraft.client.Minecraft; | ||
| import net.minecraft.item.ItemStack; | ||
| import net.minecraftforge.client.model.ModelLoader; | ||
| import net.minecraftforge.fml.relauncher.Side; | ||
| import net.minecraftforge.fml.relauncher.SideOnly; | ||
|
|
||
| import gregtech.api.GTValues; | ||
| import gregtech.api.items.toolitem.IGTTool; | ||
| import gregtech.api.items.toolitem.ItemGTTool; | ||
| import gregtech.api.unification.OreDictUnifier; | ||
|
|
||
| import com.github.gtexpert.core.api.GTEValues; | ||
|
|
||
| public final class ChiselToolItems { | ||
|
|
||
| private static final List<IGTTool> TOOLS = new ArrayList<>(); | ||
|
|
||
| public static IGTTool CHISEL; | ||
|
|
||
| private ChiselToolItems() {} | ||
|
|
||
| public static List<IGTTool> getAllTools() { | ||
| return TOOLS; | ||
| } | ||
|
|
||
| public static void init() { | ||
| CHISEL = register(ItemGTTool.Builder.of(GTEValues.MODID, "chisel") | ||
| .toolStats(b -> b.cannotAttack().attackSpeed(-2.4F).durabilityMultiplier(2.0F)) | ||
| .oreDict("toolChisel") | ||
| .secondaryOreDicts("craftingToolChisel") | ||
| .toolClasses("chisel") | ||
| .build()); | ||
| } | ||
|
|
||
| public static IGTTool register(IGTTool tool) { | ||
| TOOLS.add(tool); | ||
| return tool; | ||
| } | ||
|
|
||
| @SideOnly(Side.CLIENT) | ||
| public static void registerModels() { | ||
| TOOLS.forEach(tool -> ModelLoader.setCustomModelResourceLocation(tool.get(), 0, tool.getModelLocation())); | ||
| } | ||
|
|
||
| @SideOnly(Side.CLIENT) | ||
| public static void registerColors() { | ||
| TOOLS.forEach( | ||
| tool -> Minecraft.getMinecraft().getItemColors().registerItemColorHandler(tool::getColor, tool.get())); | ||
| } | ||
|
|
||
| public static void registerOreDict() { | ||
| TOOLS.forEach(tool -> { | ||
| final ItemStack stack = new ItemStack(tool.get(), 1, GTValues.W); | ||
| if (tool.getOreDictName() != null) { | ||
| OreDictUnifier.registerOre(stack, tool.getOreDictName()); | ||
| } | ||
| tool.getSecondaryOreDicts().forEach(oreDict -> OreDictUnifier.registerOre(stack, oreDict)); | ||
| }); | ||
| } | ||
| } |
39 changes: 39 additions & 0 deletions
39
src/main/java/com/github/gtexpert/core/integration/chisel/tools/ChiselToolRecipeHandler.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| package com.github.gtexpert.core.integration.chisel.tools; | ||
|
|
||
| import static gregtech.api.unification.material.info.MaterialFlags.*; | ||
|
|
||
| import gregtech.api.recipes.ModHandler; | ||
| import gregtech.api.unification.material.Material; | ||
| import gregtech.api.unification.material.Materials; | ||
| import gregtech.api.unification.material.properties.PropertyKey; | ||
| import gregtech.api.unification.material.properties.ToolProperty; | ||
| import gregtech.api.unification.ore.OrePrefix; | ||
| import gregtech.api.unification.stack.UnificationEntry; | ||
| import gregtech.common.ConfigHolder; | ||
|
|
||
| import com.github.gtexpert.core.integration.chisel.ChiselConfigHolder; | ||
|
|
||
| public class ChiselToolRecipeHandler { | ||
|
|
||
| public static void registerRecipes() { | ||
| OrePrefix.plate.addProcessingHandler(PropertyKey.TOOL, ChiselToolRecipeHandler::processChiselRecipe); | ||
| } | ||
|
|
||
| private static void processChiselRecipe(OrePrefix prefix, Material material, ToolProperty property) { | ||
| if (!material.hasFlag(GENERATE_PLATE)) return; | ||
|
|
||
| if (ConfigHolder.recipes.hardToolArmorRecipes && ChiselConfigHolder.hardToolRecipes) { | ||
| ModHandler.addShapedRecipe(String.format("chisel_%s", material.getName()), | ||
| ChiselToolItems.CHISEL.get(material), | ||
| "fPh", " S ", | ||
| 'P', new UnificationEntry(OrePrefix.plate, material), | ||
| 'S', new UnificationEntry(OrePrefix.stick, Materials.Wood)); | ||
| } else { | ||
| ModHandler.addShapedRecipe(String.format("chisel_%s", material.getName()), | ||
| ChiselToolItems.CHISEL.get(material), | ||
| " I", "S ", | ||
| 'I', new UnificationEntry(OrePrefix.ingot, material), | ||
| 'S', new UnificationEntry(OrePrefix.stick, Materials.Wood)); | ||
| } | ||
| } | ||
| } | ||
87 changes: 87 additions & 0 deletions
87
src/main/java/com/github/gtexpert/core/mixins/chisel/ItemGTToolChiselMixin.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| package com.github.gtexpert.core.mixins.chisel; | ||
|
|
||
| import net.minecraft.block.state.IBlockState; | ||
| import net.minecraft.entity.player.EntityPlayer; | ||
| import net.minecraft.item.ItemStack; | ||
| import net.minecraft.util.EnumHand; | ||
| import net.minecraft.util.math.BlockPos; | ||
| import net.minecraft.world.World; | ||
|
|
||
| import org.spongepowered.asm.mixin.Mixin; | ||
|
|
||
| import gregtech.api.items.toolitem.ItemGTTool; | ||
| import gregtech.api.items.toolitem.ToolHelper; | ||
|
|
||
| import team.chisel.api.IChiselGuiType; | ||
| import team.chisel.api.IChiselGuiType.ChiselGuiType; | ||
| import team.chisel.api.IChiselItem; | ||
| import team.chisel.api.carving.ICarvingVariation; | ||
| import team.chisel.api.carving.IChiselMode; | ||
| import team.chisel.common.item.ChiselMode; | ||
|
|
||
| /** | ||
| * Mixin to make GregTech tools with "chisel" tool class implement Chisel mod's IChiselItem interface. | ||
| * This allows GT chisel tools to work with the Chisel mod's chiseling functionality. | ||
| */ | ||
| @Mixin(value = ItemGTTool.class, remap = false) | ||
| public abstract class ItemGTToolChiselMixin implements IChiselItem { | ||
|
|
||
| /** | ||
| * Check if this tool has the "chisel" tool class | ||
tier940 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| */ | ||
| private boolean gtexpert$isChiselTool() { | ||
| ItemGTTool tool = (ItemGTTool) (Object) this; | ||
| return tool.getToolClasses(ItemStack.EMPTY).contains("chisel"); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean canOpenGui(World world, EntityPlayer player, EnumHand hand) { | ||
| return gtexpert$isChiselTool(); | ||
| } | ||
|
|
||
| @Override | ||
| public IChiselGuiType getGuiType(World world, EntityPlayer player, EnumHand hand) { | ||
| return ChiselGuiType.NORMAL; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean onChisel(World world, EntityPlayer player, ItemStack chisel, ICarvingVariation target) { | ||
| return gtexpert$isChiselTool(); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean canChisel(World world, EntityPlayer player, ItemStack chisel, ICarvingVariation target) { | ||
| return gtexpert$isChiselTool() && !chisel.isEmpty(); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean canChiselBlock(World world, EntityPlayer player, EnumHand hand, BlockPos pos, IBlockState state) { | ||
| return gtexpert$isChiselTool(); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean supportsMode(EntityPlayer player, ItemStack chisel, IChiselMode mode) { | ||
| if (!gtexpert$isChiselTool()) return false; | ||
| // Support basic modes, exclude advanced contiguous modes | ||
| return mode != ChiselMode.CONTIGUOUS && mode != ChiselMode.CONTIGUOUS_2D; | ||
| } | ||
|
|
||
| @Override | ||
| public ItemStack craftItem(ItemStack chisel, ItemStack source, ItemStack target, EntityPlayer player) { | ||
| if (!gtexpert$isChiselTool() || chisel.isEmpty()) return ItemStack.EMPTY; | ||
|
|
||
| int toCraft = Math.min(source.getCount(), target.getMaxStackSize()); | ||
|
|
||
| // Check remaining durability | ||
| int durabilityLeft = chisel.getMaxDamage() - chisel.getItemDamage() + 1; | ||
| toCraft = Math.min(toCraft, durabilityLeft); | ||
|
|
||
| // Damage the tool using GT's damage system | ||
| ToolHelper.damageItem(chisel, player, toCraft); | ||
|
|
||
| ItemStack result = target.copy(); | ||
| source.shrink(toCraft); | ||
| result.setCount(toCraft); | ||
| return result; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| item.gt.tool.chisel.name=%s Chisel | ||
| gt.tool.class.chisel=Chisel |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| item.gt.tool.chisel.name=%sのチゼル | ||
| gt.tool.class.chisel=チゼル |
7 changes: 7 additions & 0 deletions
7
src/main/resources/assets/gtexpert/models/item/tools/chisel.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "parent": "item/handheld", | ||
| "textures": { | ||
| "layer0": "gtexpert:items/tools/chisel_base", | ||
| "layer1": "gtexpert:items/tools/chisel" | ||
| } | ||
| } |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+152 Bytes
src/main/resources/assets/gtexpert/textures/items/tools/chisel_base.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.