Skip to content

Commit

Permalink
Add new golem materials
Browse files Browse the repository at this point in the history
Also rewrite how items are registered in favor of adding support for blocks.
  • Loading branch information
IcarussOne committed Aug 22, 2024
1 parent 6ba8671 commit 7be1f14
Show file tree
Hide file tree
Showing 10 changed files with 309 additions and 48 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package mod.icarus.crimsonrevelations.block;

import mod.icarus.crimsonrevelations.init.CRBlocks;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

public class CRBlockMaterial extends Block {
public CRBlockMaterial(Material material, MapColor mapColor, float hardness, float resistance, SoundType soundType) {
super(material, mapColor);
this.setHardness(hardness);
this.setResistance(resistance);
this.setSoundType(soundType);
}

public CRBlockMaterial(Material material, MapColor mapColor, float hardness, SoundType soundType) {
super(material, mapColor);
this.setHardness(hardness);
this.setSoundType(soundType);
}

@Override
public boolean isFireSource(World world, BlockPos pos, EnumFacing side) {
return this == CRBlocks.magicTallowBlock;
}
}
31 changes: 31 additions & 0 deletions src/main/java/mod/icarus/crimsonrevelations/init/CRBlocks.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package mod.icarus.crimsonrevelations.init;

import javax.annotation.Nonnull;

import mod.icarus.crimsonrevelations.NewCrimsonRevelations;
import mod.icarus.crimsonrevelations.block.CRBlockMaterial;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.registries.IForgeRegistry;

@EventBusSubscriber(modid = NewCrimsonRevelations.MODID)
@GameRegistry.ObjectHolder(NewCrimsonRevelations.MODID)
public class CRBlocks {
@GameRegistry.ObjectHolder("magic_tallow_block")
public static Block magicTallowBlock;

@SubscribeEvent
public static void registerBlocks(@Nonnull final RegistryEvent.Register<Block> event) {
final IForgeRegistry<Block> registry = event.getRegistry();

registry.registerAll(
CRRegistry.setup(new CRBlockMaterial(Material.ROCK, MapColor.SAND, 4.0F, 15.0F, SoundType.STONE), "magic_tallow_block")
);
}
}
71 changes: 24 additions & 47 deletions src/main/java/mod/icarus/crimsonrevelations/init/CRItems.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package mod.icarus.crimsonrevelations.init;

import com.google.common.base.Preconditions;
import mod.icarus.crimsonrevelations.NewCrimsonRevelations;
import mod.icarus.crimsonrevelations.item.CRItem;
import mod.icarus.crimsonrevelations.item.CRItemArrow;
import mod.icarus.crimsonrevelations.item.CRItemSword;
import mod.icarus.crimsonrevelations.item.armor.ItemCultistArcherArmor;
import mod.icarus.crimsonrevelations.item.weapons.ItemBoneBow;
import net.minecraft.block.Block;
import net.minecraft.block.BlockDoor;
import net.minecraft.block.BlockSlab;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
Expand All @@ -19,7 +17,6 @@
import net.minecraft.item.ItemArmor.ArmorMaterial;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.common.util.EnumHelper;
Expand All @@ -31,7 +28,6 @@
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.registries.IForgeRegistry;
import net.minecraftforge.registries.IForgeRegistryEntry;

import javax.annotation.Nonnull;

Expand Down Expand Up @@ -73,63 +69,44 @@ public class CRItems {
public static ToolMaterial TOOL_CULTIST = EnumHelper.addToolMaterial("CULTIST", 3, 321, 7.5F, 2.5F, 20).setRepairItem(new ItemStack(crimsonPlate));

@SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> event) {
event.getRegistry().registerAll(
setup(new CRItem(EnumRarity.UNCOMMON), "crimson_fabric"),
setup(new CRItem(EnumRarity.UNCOMMON), "embellished_crimson_fabric"),
setup(new CRItem(EnumRarity.UNCOMMON), "crimson_plate"),
setup(new CRItemSword(TOOL_CULTIST, EnumRarity.UNCOMMON), "crimson_sword"),
public static void registerItems(@Nonnull final RegistryEvent.Register<Item> event) {
final IForgeRegistry<Item> registry = event.getRegistry();

registry.registerAll(
CRRegistry.setup(new CRItem(EnumRarity.UNCOMMON), "crimson_fabric"),
CRRegistry.setup(new CRItem(EnumRarity.UNCOMMON), "embellished_crimson_fabric"),
CRRegistry.setup(new CRItem(EnumRarity.UNCOMMON), "crimson_plate"),
CRRegistry.setup(new CRItemSword(TOOL_CULTIST, EnumRarity.UNCOMMON), "crimson_sword"),

setup(new ItemCultistArcherArmor(EntityEquipmentSlot.HEAD), "crimson_archer_helmet"),
setup(new ItemCultistArcherArmor(EntityEquipmentSlot.CHEST), "crimson_archer_chestplate"),
setup(new ItemCultistArcherArmor(EntityEquipmentSlot.LEGS), "crimson_archer_leggings"),
CRRegistry.setup(new ItemCultistArcherArmor(EntityEquipmentSlot.HEAD), "crimson_archer_helmet"),
CRRegistry.setup(new ItemCultistArcherArmor(EntityEquipmentSlot.CHEST), "crimson_archer_chestplate"),
CRRegistry.setup(new ItemCultistArcherArmor(EntityEquipmentSlot.LEGS), "crimson_archer_leggings"),

setup(new ItemBoneBow(), "bone_bow"),
setup(new CRItemArrow(EnumRarity.UNCOMMON), "aer_arrow"),
setup(new CRItemArrow(EnumRarity.UNCOMMON), "aqua_arrow"),
setup(new CRItemArrow(EnumRarity.UNCOMMON), "ignis_arrow"),
setup(new CRItemArrow(EnumRarity.UNCOMMON), "ordo_arrow"),
setup(new CRItemArrow(EnumRarity.UNCOMMON), "perditio_arrow"),
setup(new CRItemArrow(EnumRarity.UNCOMMON), "terra_arrow")
CRRegistry.setup(new ItemBoneBow(), "bone_bow"),
CRRegistry.setup(new CRItemArrow(EnumRarity.UNCOMMON), "aer_arrow"),
CRRegistry.setup(new CRItemArrow(EnumRarity.UNCOMMON), "aqua_arrow"),
CRRegistry.setup(new CRItemArrow(EnumRarity.UNCOMMON), "ignis_arrow"),
CRRegistry.setup(new CRItemArrow(EnumRarity.UNCOMMON), "ordo_arrow"),
CRRegistry.setup(new CRItemArrow(EnumRarity.UNCOMMON), "perditio_arrow"),
CRRegistry.setup(new CRItemArrow(EnumRarity.UNCOMMON), "terra_arrow")
);
}

@SubscribeEvent
public static void registerItemBlocks(RegistryEvent.Register<Item> event) {
final IForgeRegistry<Item> registry = event.getRegistry();
// Item Blocks
ForgeRegistries.BLOCKS.getValues().stream()
.filter(block -> block.getRegistryName().getNamespace().equals(NewCrimsonRevelations.MODID))
.filter(block -> !(block instanceof BlockDoor)) // Doors should not have an item block registered
.filter(block -> !(block instanceof BlockSlab)) // Slabs should not have an item block registered
.forEach(block -> registry.register(setup(new ItemBlock(block), block.getRegistryName())));
.forEach(block -> registry.register(CRRegistry.setup(new ItemBlock(block), block.getRegistryName())));
}

@SideOnly(Side.CLIENT)
@SubscribeEvent
public static void registerModels(ModelRegistryEvent event) {
for (Item item : ForgeRegistries.ITEMS.getValues()) {
public static void onRegisterModelsEvent(@Nonnull final ModelRegistryEvent event) {
// Item Models
for (final Item item : ForgeRegistries.ITEMS.getValues()) {
if (item.getRegistryName().getNamespace().equals(NewCrimsonRevelations.MODID)) {
ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), "normal"));
ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory"));
}
}
}

@Nonnull
public static <T extends IForgeRegistryEntry<T>> T setup(T entry, String name) {
return setup(entry, new ResourceLocation(NewCrimsonRevelations.MODID, name));
}

@Nonnull
public static <T extends IForgeRegistryEntry<T>> T setup(T entry, ResourceLocation registryName) {
Preconditions.checkNotNull(entry, "Entry to setup must not be null!");
Preconditions.checkNotNull(registryName, "Registry name to assign must not be null!");
entry.setRegistryName(registryName);
if (entry instanceof Block) {
((Block) entry).setTranslationKey(registryName.getNamespace() + "." + registryName.getPath()).setCreativeTab(NewCrimsonRevelations.tabCR);
}
if (entry instanceof Item) {
((Item) entry).setTranslationKey(registryName.getNamespace() + "." + registryName.getPath()).setCreativeTab(NewCrimsonRevelations.tabCR);
}
return entry;
}
}
35 changes: 35 additions & 0 deletions src/main/java/mod/icarus/crimsonrevelations/init/CRRegistry.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package mod.icarus.crimsonrevelations.init;

import javax.annotation.Nonnull;

import com.google.common.base.Preconditions;

import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.registries.IForgeRegistryEntry;

import mod.icarus.crimsonrevelations.NewCrimsonRevelations;

@SuppressWarnings("rawtypes")
@Mod.EventBusSubscriber(modid = NewCrimsonRevelations.MODID)
public class CRRegistry {
@Nonnull
public static <T extends IForgeRegistryEntry> T setup(@Nonnull final T entry, @Nonnull final String name) {
return setup(entry, new ResourceLocation(NewCrimsonRevelations.MODID, name));
}

@Nonnull
public static <T extends IForgeRegistryEntry> T setup(@Nonnull final T entry, @Nonnull final ResourceLocation registryName) {
Preconditions.checkNotNull(entry, "Entry to setup must not be null!");
Preconditions.checkNotNull(registryName, "Registry name to assign must not be null!");

entry.setRegistryName(registryName);
if (entry instanceof Block)
((Block) entry).setTranslationKey(registryName.getNamespace() + "." + registryName.getPath()).setCreativeTab(NewCrimsonRevelations.tabCR);
if (entry instanceof Item)
((Item) entry).setTranslationKey(registryName.getNamespace() + "." + registryName.getPath()).setCreativeTab(NewCrimsonRevelations.tabCR);
return entry;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@
import mod.icarus.crimsonrevelations.casters.foci.FocusEffectBlindingFlash;
import mod.icarus.crimsonrevelations.casters.foci.FocusEffectPoison;
import mod.icarus.crimsonrevelations.casters.foci.FocusEffectTaintPoison;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.Loader;
import thaumcraft.Thaumcraft;
import thaumcraft.api.ThaumcraftApi;
import thaumcraft.api.aspects.AspectList;
import thaumcraft.api.blocks.BlocksTC;
import thaumcraft.api.casters.FocusEngine;
import thaumcraft.api.golems.EnumGolemTrait;
import thaumcraft.api.golems.parts.GolemMaterial;
import thaumcraft.api.items.ItemsTC;
import thaumcraft.api.research.ResearchCategories;
import thaumcraft.api.research.ScanEntity;
import thaumcraft.api.research.ScanningManager;
Expand All @@ -20,6 +25,28 @@

public class CRResearchRegistry {
public static void init() {
// Golems
GolemMaterial.register(
new GolemMaterial("CR_CULT_PLATE", new String[]{"CR_GOLEM_MAT_CULT_PLATE"}, new ResourceLocation(NewCrimsonRevelations.MODID, "textures/entity/golem/mat_cult_plate.png"),
4342338, 22, 9, 3, // [Color, Health, Armor , Damage] - [1 = 0.5]
new ItemStack(CRItems.crimsonPlate), new ItemStack(ItemsTC.mechanismSimple), // Base Component, Base Mechanism
new EnumGolemTrait[]{EnumGolemTrait.LIGHT, EnumGolemTrait.FIREPROOF} // Starting Traits
)
);
GolemMaterial.register(
new GolemMaterial("CR_FLESH", new String[]{"CR_GOLEM_MAT_FLESH"}, new ResourceLocation(NewCrimsonRevelations.MODID, "textures/entity/golem/mat_flesh.png"),
13474967, 2, 0, 1, // [Color, Health, Armor , Damage] - [1 = 0.5]
new ItemStack(BlocksTC.fleshBlock), new ItemStack(ItemsTC.mechanismSimple), // Base Component, Base Mechanism
new EnumGolemTrait[]{EnumGolemTrait.REPAIR} // Starting Traits
)
);
GolemMaterial.register(
new GolemMaterial("CR_TALLOW", new String[]{"CR_GOLEM_MAT_TALLOW"}, new ResourceLocation(NewCrimsonRevelations.MODID, "textures/entity/golem/mat_tallow.png"),
12823156, 14, 4, 3, // [Color, Health, Armor , Damage] - [1 = 0.5]
new ItemStack(CRBlocks.magicTallowBlock), new ItemStack(ItemsTC.mechanismSimple), // Base Component, Base Mechanism
new EnumGolemTrait[]{} // Starting Traits
)
);
// Focus Effects
FocusEngine.registerElement(FocusEffectBlindingFlash.class, new ResourceLocation(NewCrimsonRevelations.MODID, "textures/foci/blinding_flash.png"), 16776421);
FocusEngine.registerElement(FocusEffectPoison.class, new ResourceLocation(NewCrimsonRevelations.MODID, "textures/foci/poison.png"), 9039872);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"forge_marker": 1,
"defaults": {
"model": "cube_column",
"textures": {
"end": "crimsonrevelations:blocks/magic_tallow_block_top",
"side": "crimsonrevelations:blocks/magic_tallow_block"
}
},
"variants": {
"normal": [
{}
],
"inventory": [
{}
]
}
}
Loading

0 comments on commit 7be1f14

Please sign in to comment.