-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
166 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
36 changes: 36 additions & 0 deletions
36
fabric/src/main/java/github/killarexe/copper_extension/fabric/item/FabricRustableItem.java
This file contains 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,36 @@ | ||
package github.killarexe.copper_extension.fabric.item; | ||
|
||
import github.killarexe.copper_extension.fabric.registry.CEGameRules; | ||
import github.killarexe.copper_extension.fabric.registry.CEItems; | ||
import github.killarexe.copper_extension.item.RustableItem; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.level.GameRules.IntegerValue; | ||
import net.minecraft.world.level.GameRules.Key; | ||
|
||
public class FabricRustableItem extends RustableItem{ | ||
|
||
public FabricRustableItem(Item.Properties properties, ResourceLocation scrappedItemId, ResourceLocation waxedItemId, ResourceLocation rustItemId) { | ||
super(properties, scrappedItemId, waxedItemId, rustItemId); | ||
} | ||
|
||
@Override | ||
public Item getScrappedItem() { | ||
return CEItems.getItem(getScrappedItemId()); | ||
} | ||
|
||
@Override | ||
public Item getWaxedItem() { | ||
return CEItems.getItem(getWaxedItemId()); | ||
} | ||
|
||
@Override | ||
public Item getRustItem() { | ||
return CEItems.getItem(getRustItemId()); | ||
} | ||
|
||
@Override | ||
public Key<IntegerValue> getOxidationChanceGameRule() { | ||
return CEGameRules.COPPER_OXIDATION_CHANCE; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
fabric/src/main/java/github/killarexe/copper_extension/fabric/item/FabricScrapableItem.java
This file contains 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,18 @@ | ||
package github.killarexe.copper_extension.fabric.item; | ||
|
||
import github.killarexe.copper_extension.fabric.registry.CEItems; | ||
import github.killarexe.copper_extension.item.ScrapableItem; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.item.Item; | ||
|
||
public class FabricScrapableItem extends ScrapableItem { | ||
|
||
public FabricScrapableItem(Item.Properties properties, ResourceLocation scrappedItemId) { | ||
super(properties, scrappedItemId); | ||
} | ||
|
||
@Override | ||
public Item getScrappedItem() { | ||
return CEItems.getItem(getScrappedItemId()); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
fabric/src/main/java/github/killarexe/copper_extension/fabric/item/FabricWaxableItem.java
This file contains 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,23 @@ | ||
package github.killarexe.copper_extension.fabric.item; | ||
|
||
import github.killarexe.copper_extension.fabric.registry.CEItems; | ||
import github.killarexe.copper_extension.item.WaxableItem; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.item.Item; | ||
|
||
public class FabricWaxableItem extends WaxableItem { | ||
|
||
public FabricWaxableItem(Item.Properties properties, ResourceLocation scrappedItemId, ResourceLocation waxedItemId) { | ||
super(properties, scrappedItemId, waxedItemId); | ||
} | ||
|
||
@Override | ||
public Item getScrappedItem() { | ||
return CEItems.getItem(getScrappedItemId()); | ||
} | ||
|
||
@Override | ||
public Item getWaxedItem() { | ||
return CEItems.getItem(getWaxedItemId()); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
fabric/src/main/java/github/killarexe/copper_extension/fabric/registry/CEGameRules.java
This file contains 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,15 @@ | ||
package github.killarexe.copper_extension.fabric.registry; | ||
|
||
import net.fabricmc.fabric.api.gamerule.v1.GameRuleFactory; | ||
import net.fabricmc.fabric.api.gamerule.v1.GameRuleRegistry; | ||
import net.minecraft.world.level.GameRules; | ||
|
||
public class CEGameRules { | ||
public static final GameRules.Key<GameRules.IntegerValue> COPPER_OXIDATION_CHANCE = GameRuleRegistry.register( | ||
"copperOxidationChance", GameRules.Category.UPDATES, GameRuleFactory.createIntRule(1) | ||
); | ||
|
||
public static void register() { | ||
//Just to load the class... | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
fabric/src/main/java/github/killarexe/copper_extension/fabric/registry/CEItems.java
This file contains 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,58 @@ | ||
package github.killarexe.copper_extension.fabric.registry; | ||
|
||
import java.util.HashMap; | ||
|
||
import github.killarexe.copper_extension.CEMod; | ||
import github.killarexe.copper_extension.fabric.item.*; | ||
import net.fabricmc.fabric.api.item.v1.FabricItemSettings; | ||
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; | ||
import net.minecraft.core.Registry; | ||
import net.minecraft.core.registries.BuiltInRegistries; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.item.CreativeModeTabs; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.item.Items; | ||
|
||
public class CEItems { | ||
|
||
private static final HashMap<String, Item> ITEMS = new HashMap<String, Item>(); | ||
|
||
public static final FabricScrapableItem WAXED_COPPER_INGOT = createItem("waxed_copper_ingot", new FabricScrapableItem(new FabricItemSettings(), new ResourceLocation("minecraft", "copper_ingot"))); | ||
public static final FabricScrapableItem WAXED_EXPOSED_COPPER_INGOT = createItem("waxed_exposed_copper_ingot", new FabricScrapableItem(new FabricItemSettings(), CEMod.id("exposed_copper_ingot"))); | ||
public static final FabricScrapableItem WAXED_WEATHERED_COPPER_INGOT = createItem("waxed_weathered_copper_ingot", new FabricScrapableItem(new FabricItemSettings(), CEMod.id("weathered_copper_ingot"))); | ||
|
||
public static final FabricRustableItem EXPOSED_COPPER_INGOT = createItem("exposed_copper_ingot", new FabricRustableItem( | ||
new FabricItemSettings(), | ||
new ResourceLocation("minecraft", "copper_ingot"), | ||
CEMod.id("waxed_exposed_copper_ingot"), | ||
CEMod.id("weathered_copper_ingot")) | ||
); | ||
public static final FabricRustableItem WEATHERED_COPPER_INGOT = createItem("weathered_copper_ingot", new FabricRustableItem( | ||
new FabricItemSettings(), | ||
CEMod.id("exposed_copper_ingot"), | ||
CEMod.id("waxed_weathered_copper_ingot"), | ||
CEMod.id("oxidized_copper_ingot") | ||
)); | ||
public static final Item OXIDIZED_COPPER_INGOT = createItem("oxidized_copper_ingot", new FabricScrapableItem(new FabricItemSettings(), CEMod.id("weathered_copper_ingot"))); | ||
|
||
public static void register() { | ||
ITEMS.forEach((id, item) -> { | ||
Registry.register(BuiltInRegistries.ITEM, new ResourceLocation(CEMod.MOD_ID, id), item); | ||
ItemGroupEvents.modifyEntriesEvent(CreativeModeTabs.INGREDIENTS).register((group) -> { | ||
group.accept(item); | ||
}); | ||
}); | ||
} | ||
|
||
private static <T extends Item> T createItem(String id, T item) { | ||
ITEMS.put(id, item); | ||
return item; | ||
} | ||
|
||
public static Item getItem(ResourceLocation itemId) { | ||
if(BuiltInRegistries.ITEM.containsKey(itemId)) { | ||
return BuiltInRegistries.ITEM.get(itemId); | ||
} | ||
return Items.AIR; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
fabric/src/main/java/github/killarexe/copper_extension/fabric/registry/CERegistries.java
This file contains 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,13 @@ | ||
package github.killarexe.copper_extension.fabric.registry; | ||
|
||
import github.killarexe.copper_extension.fabric.CEFabric; | ||
|
||
public class CERegistries { | ||
public static void register() { | ||
CEFabric.LOGGER.debug("Initializing Copper Extension Game Rules..."); | ||
CEGameRules.register(); | ||
CEFabric.LOGGER.debug("Initializing Copper Extension Items..."); | ||
CEItems.register(); | ||
CEFabric.LOGGER.debug("Copper Extension Items Initialized!"); | ||
} | ||
} |