Skip to content

Commit

Permalink
Added Magic Vein block
Browse files Browse the repository at this point in the history
  • Loading branch information
PiTheGuy committed Apr 9, 2022
1 parent d4bc109 commit 652690c
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/main/java/com/pitheguy/magicmod/MagicMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import com.pitheguy.magicmod.util.RegistryHandler;
import com.pitheguy.magicmod.world.gen.ModOreGen;
import net.minecraft.client.gui.ScreenManager;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.RenderTypeLookup;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
Expand Down Expand Up @@ -53,6 +55,7 @@ private void doClientStuff(final FMLClientSetupEvent event) {
ScreenManager.registerFactory(ModContainerTypes.MAGIC_INFUSER.get(), MagicInfuserScreen::new);
ScreenManager.registerFactory(ModContainerTypes.MAGIC_CRATE.get(), MagicCrateScreen::new);
ScreenManager.registerFactory(ModContainerTypes.MAGIC_PRESS.get(), MagicPressScreen::new);
RenderTypeLookup.setRenderLayer(RegistryHandler.MAGIC_VEIN.get(), RenderType.getCutout());
}

@SubscribeEvent
Expand Down
45 changes: 45 additions & 0 deletions src/main/java/com/pitheguy/magicmod/blocks/MagicVein.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.pitheguy.magicmod.blocks;

import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.common.ToolType;

import java.util.Random;

public class MagicVein extends Block {
public MagicVein() {
super(Properties.create(Material.IRON)
.hardnessAndResistance(5, 7)
.sound(SoundType.METAL)
.harvestLevel(2)
.harvestTool(ToolType.PICKAXE)
.doesNotBlockMovement()
.notSolid()
);
}

@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
return Block.makeCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 1.0D, 16.0D);
}

@Override
public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) {
return true;
}

@Override
public void tick(BlockState state, ServerWorld worldIn, BlockPos pos, Random rand) {
super.tick(state, worldIn, pos, rand);
if(worldIn.getBlockState(pos.down()).isAir()) {
worldIn.destroyBlock(pos, false);
}
}
}
2 changes: 2 additions & 0 deletions src/main/java/com/pitheguy/magicmod/util/RegistryHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ public static void init() {
public static final RegistryObject<Block> MAGIC_INFUSER = BLOCKS.register("magic_infuser", MagicInfuser::new);
public static final RegistryObject<Block> MAGIC_CRATE = BLOCKS.register("magic_crate", MagicCrate::new);
public static final RegistryObject<Block> MAGIC_PRESS = BLOCKS.register("magic_press", MagicPress::new);
public static final RegistryObject<Block> MAGIC_VEIN = BLOCKS.register("magic_vein", MagicVein::new);

//Magic Lamps
public static final RegistryObject<Block> MAGIC_LAMP_RED = BLOCKS.register("magic_lamp_red", MagicLamp::new);
Expand All @@ -153,6 +154,7 @@ public static void init() {
public static final RegistryObject<Item> MAGIC_INFUSER_ITEM = ITEMS.register("magic_infuser", () -> new BlockItemBase(MAGIC_INFUSER.get()));
public static final RegistryObject<Item> MAGIC_CRATE_ITEM = ITEMS.register("magic_crate", () -> new BlockItemBase(MAGIC_CRATE.get()));
public static final RegistryObject<Item> MAGIC_PRESS_ITEM = ITEMS.register("magic_press", () -> new BlockItemBase(MAGIC_PRESS.get()));
public static final RegistryObject<Item> MAGIC_VEIN_ITEM = ITEMS.register("magic_vein", () -> new BlockItemBase(MAGIC_VEIN.get()));

//Magic Lamps
public static final RegistryObject<Item> MAGIC_LAMP_RED_ITEM = ITEMS.register("magic_lamp_red", () -> new BlockItemBase(MAGIC_LAMP_RED.get()));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"variants": {
"": { "model": "magicmod:block/magic_vein" }
}
}
1 change: 1 addition & 0 deletions src/main/resources/assets/magicmod/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"block.magicmod.magic_infuser": "Magic Infuser",
"block.magicmod.magic_crate": "Magic Crate",
"block.magicmod.magic_press": "Magic Press",
"block.magicmod.magic_vein": "Magic Vein",
"block.magicmod.magic_lamp_red": "Magic Lamp (Red)",
"block.magicmod.magic_lamp_orange": "Magic Lamp (Orange)",
"block.magicmod.magic_lamp_yellow": "Magic Lamp (Yellow)",
Expand Down
19 changes: 19 additions & 0 deletions src/main/resources/assets/magicmod/models/block/magic_vein.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"credit": "Made with Blockbench",
"ambientocclusion": false,
"textures": {
"particle": "magicmod:blocks/magic_vein",
"vine": "magicmod:blocks/magic_vein"
},
"elements": [
{
"from": [0, 0.8, 0],
"to": [16, 0.8, 16],
"shade": false,
"faces": {
"up": {"uv": [16, 0, 0, 16], "rotation": 180, "texture": "#vine", "tintindex": 0},
"down": {"uv": [0, 0, 16, 16], "texture": "#vine", "tintindex": 0}
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "item/handheld",
"textures": {
"layer0": "magicmod:items/magic_vein"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 652690c

Please sign in to comment.