forked from MobiusFlip/CrimsonRevelations
-
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.
Also rewrite how items are registered in favor of adding support for blocks.
- Loading branch information
1 parent
6ba8671
commit 7be1f14
Showing
10 changed files
with
309 additions
and
48 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
src/main/java/mod/icarus/crimsonrevelations/block/CRBlockMaterial.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,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
31
src/main/java/mod/icarus/crimsonrevelations/init/CRBlocks.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,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") | ||
); | ||
} | ||
} |
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
35 changes: 35 additions & 0 deletions
35
src/main/java/mod/icarus/crimsonrevelations/init/CRRegistry.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,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; | ||
} | ||
} |
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
18 changes: 18 additions & 0 deletions
18
src/main/resources/assets/crimsonrevelations/blockstates/magic_tallow_block.json
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 @@ | ||
{ | ||
"forge_marker": 1, | ||
"defaults": { | ||
"model": "cube_column", | ||
"textures": { | ||
"end": "crimsonrevelations:blocks/magic_tallow_block_top", | ||
"side": "crimsonrevelations:blocks/magic_tallow_block" | ||
} | ||
}, | ||
"variants": { | ||
"normal": [ | ||
{} | ||
], | ||
"inventory": [ | ||
{} | ||
] | ||
} | ||
} |
Oops, something went wrong.