Skip to content

Commit

Permalink
Implement custom doors
Browse files Browse the repository at this point in the history
  • Loading branch information
IcarussOne committed Mar 4, 2024
1 parent cda2c34 commit 5bd6747
Show file tree
Hide file tree
Showing 14 changed files with 256 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@ public MoCBlockButtonStone() {
this.setSoundType(SoundType.STONE);
this.setHardness(0.5F);
this.setHarvestLevel("pickaxe", 0);
this.setResistance(0.5F);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.minecraft.block.BlockButtonWood;
import net.minecraft.block.SoundType;

// NOTE: Wooden buttons are not flammable in vanilla
public class MoCBlockButtonWood extends BlockButtonWood {
public MoCBlockButtonWood() {
super();
Expand Down
57 changes: 57 additions & 0 deletions src/main/java/drzhark/mocreatures/block/MoCBlockDoorWood.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package drzhark.mocreatures.block;

import java.util.Random;

import drzhark.mocreatures.init.MoCBlocks;
import drzhark.mocreatures.init.MoCItems;
import net.minecraft.block.BlockDoor;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

// NOTE: Wooden doors are not flammable in vanilla
public class MoCBlockDoorWood extends BlockDoor {
private final MapColor mapColor;

public MoCBlockDoorWood(MapColor mapColor) {
super(Material.WOOD);
this.setSoundType(SoundType.WOOD);
this.setHardness(3.0F);
this.setHarvestLevel("axe", 0);
this.mapColor = mapColor;
//this.enableStats = false;
}

@Override
public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state) {
return new ItemStack(getItemBlock());
}

protected Item getItemBlock() {
if (this == MoCBlocks.wyvwoodDoor) {
return MoCItems.wyvwoodDoor;
}

// If door is not listed here give an oak one instead to prevent issues
else {
return Items.OAK_DOOR;
}
}

@Override
public Item getItemDropped(IBlockState state, Random rand, int fortune) {
return state.getValue(HALF) == BlockDoor.EnumDoorHalf.UPPER ? Items.AIR : getItemBlock();
}

@Override
public MapColor getMapColor(IBlockState state, IBlockAccess world, BlockPos pos) {
return mapColor;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public MoCBlockPressurePlateStone(MapColor mapColor) {
this.setSoundType(SoundType.STONE);
this.setHardness(0.5F);
this.setHarvestLevel("pickaxe", 0);
this.setResistance(0.5F);
this.mapColor = mapColor;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;

// NOTE: Wooden pressure plates are not flammable in vanilla
public class MoCBlockPressurePlateWood extends BlockPressurePlate {
private final MapColor mapColor;

Expand Down
7 changes: 7 additions & 0 deletions src/main/java/drzhark/mocreatures/init/MoCBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import drzhark.mocreatures.block.*;
import drzhark.mocreatures.block.MoCBlockSapling.EnumWoodType;
import net.minecraft.block.Block;
import net.minecraft.block.BlockDoor;
import net.minecraft.block.material.MapColor;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.block.statemap.StateMap;
Expand Down Expand Up @@ -118,6 +119,8 @@ public class MoCBlocks {
public static Block wyvdirt;
@GameRegistry.ObjectHolder("wyvwood_button")
public static MoCBlockButtonWood wyvwoodButton;
@GameRegistry.ObjectHolder("wyvwood_door")
public static MoCBlockDoorWood wyvwoodDoor;
@GameRegistry.ObjectHolder("wyvwood_fence")
public static MoCBlockFenceWood wyvwoodFence;
@GameRegistry.ObjectHolder("wyvwood_fence_gate")
Expand Down Expand Up @@ -183,6 +186,7 @@ public static void registerBlocks(RegistryEvent.Register<Block> event) {
setup(new MoCBlockTallGrass(MapColor.LIGHT_BLUE_STAINED_HARDENED_CLAY, false), "tall_wyvgrass").setHardness(0.0F),
setup(new MoCBlockPlanks(MapColor.DIAMOND, true), "wyvwood_planks").setHardness(2.0F).setResistance(5.0F),
setup(new MoCBlockButtonWood(), "wyvwood_button"),
setup(new MoCBlockDoorWood(MapColor.DIAMOND), "wyvwood_door"),
setup(new MoCBlockFenceWood(MapColor.DIAMOND, true), "wyvwood_fence"),
setup(new MoCBlockFenceGateWood(MapColor.DIAMOND, true), "wyvwood_fence_gate"),
setup(new MoCBlockPressurePlateWood(MapColor.DIAMOND), "wyvwood_pressure_plate"),
Expand All @@ -196,6 +200,7 @@ public static void registerItemBlocks(RegistryEvent.Register<Item> event) {
final IForgeRegistry<Item> registry = event.getRegistry();
ForgeRegistries.BLOCKS.getValues().stream()
.filter(block -> block.getRegistryName().getNamespace().equals(MoCConstants.MOD_ID))
.filter(block -> !(block instanceof BlockDoor))
.forEach(block -> registry.register(setup(new ItemBlock(block), block.getRegistryName())));
}

Expand All @@ -209,6 +214,8 @@ public static void registerModels(ModelRegistryEvent event) {
}

// All doors, fence gates, slabs, and walls go here
ModelLoader.setCustomStateMapper(wyvwoodDoor, (new StateMap.Builder()).ignore(MoCBlockDoorWood.POWERED).build());

ModelLoader.setCustomStateMapper(wyvwoodFenceGate, (new StateMap.Builder()).ignore(MoCBlockFenceGateWood.POWERED).build());

ModelLoader.setCustomStateMapper(cobbledWyvstoneWall, (new StateMap.Builder()).ignore(MoCBlockWall.VARIANT).build());
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/drzhark/mocreatures/init/MoCItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ public class MoCItems {
public static final MoCItem ancientSilverNugget = new MoCItem("ancientsilvernugget");
public static final MoCItem firestoneChunk = new MoCItem("firestonechunk");
//public static final MoCItemCrabClaw brackishClaw = new MoCItemCrabClaw("brackish_claw", 768, 15, 0.0F, 1, 2.0F);
// Doors - These need to be registered alongside the blocks
public static final MoCItemDoor wyvwoodDoor = new MoCItemDoor(MoCBlocks.wyvwoodDoor, "wyvwood_door");
// Food
public static final MoCItemFood cookedTurkey = new MoCItemFood("turkeycooked", 7, 0.8F, true);
public static final MoCItemFood crabraw = (MoCItemFood) new MoCItemFood("crabraw", 2, 0.1F, true).setPotionEffect(new PotionEffect(MobEffects.HUNGER, 30 * 20, 0), 0.8F);
Expand Down Expand Up @@ -204,12 +206,12 @@ public class MoCItems {
public static final MoCItemArmor helmetSilver = new MoCItemArmor("ancient_silver_helmet", silverARMOR, 4, EntityEquipmentSlot.HEAD);
public static final MoCItemArmor legsSilver = new MoCItemArmor("ancient_silver_leggings", silverARMOR, 4, EntityEquipmentSlot.LEGS);
public static final MoCItemArmor bootsSilver = new MoCItemArmor("ancient_silver_boots", silverARMOR, 4, EntityEquipmentSlot.FEET);

@SubscribeEvent
@SideOnly(Side.CLIENT)
public static void registerRenders(final ModelRegistryEvent modelRegistryEvent) {
// All bow items go here
ModelLoader.setCustomModelResourceLocation(silverBow, 0, new ModelResourceLocation(silverBow.delegate.name(), "inventory"));
// All bow items go here
ModelLoader.setCustomModelResourceLocation(silverBow, 0, new ModelResourceLocation(silverBow.delegate.name(), "inventory"));
}

@Mod.EventBusSubscriber(modid = MoCConstants.MOD_ID)
Expand Down Expand Up @@ -301,6 +303,7 @@ public static void registerItems(final RegistryEvent.Register<Item> event) {
horsearmorcrystal,
mysticPear,
recordshuffle,
wyvwoodDoor,

animalHide,
rawTurkey,
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/drzhark/mocreatures/item/MoCItemDoor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package drzhark.mocreatures.item;

import drzhark.mocreatures.MoCConstants;
import drzhark.mocreatures.MoCreatures;
import net.minecraft.block.Block;
import net.minecraft.item.ItemDoor;

public class MoCItemDoor extends ItemDoor {
public MoCItemDoor(Block block, String name) {
super(block);
this.setCreativeTab(MoCreatures.tabMoC);
this.setRegistryName(MoCConstants.MOD_ID, name);
this.setTranslationKey(name);
}
}
149 changes: 149 additions & 0 deletions src/main/resources/assets/mocreatures/blockstates/wyvwood_door.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
{
"forge_marker": 1,
"defaults": {
"textures": {
"bottom": "mocreatures:blocks/door_wyvwood_lower",
"top": "mocreatures:blocks/door_wyvwood_upper"
}
},
"variants": {
"normal": [
{
"transform": "forge:default-item",
"model": "builtin/generated",
"textures": {
"layer0": "mocreatures:items/door_wyvwood"
}
}
],
"inventory": [
{
"transform": "forge:default-item",
"model": "builtin/generated",
"textures": {
"layer0": "mocreatures:items/door_wyvwood"
}
}
],
"facing=east,half=lower,hinge=left,open=false": {
"model": "door_bottom"
},
"facing=south,half=lower,hinge=left,open=false": {
"model": "door_bottom",
"y": 90
},
"facing=west,half=lower,hinge=left,open=false": {
"model": "door_bottom",
"y": 180
},
"facing=north,half=lower,hinge=left,open=false": {
"model": "door_bottom",
"y": 270
},
"facing=east,half=lower,hinge=right,open=false": {
"model": "door_bottom_rh"
},
"facing=south,half=lower,hinge=right,open=false": {
"model": "door_bottom_rh",
"y": 90
},
"facing=west,half=lower,hinge=right,open=false": {
"model": "door_bottom_rh",
"y": 180
},
"facing=north,half=lower,hinge=right,open=false": {
"model": "door_bottom_rh",
"y": 270
},
"facing=east,half=lower,hinge=left,open=true": {
"model": "door_bottom_rh",
"y": 90
},
"facing=south,half=lower,hinge=left,open=true": {
"model": "door_bottom_rh",
"y": 180
},
"facing=west,half=lower,hinge=left,open=true": {
"model": "door_bottom_rh",
"y": 270
},
"facing=north,half=lower,hinge=left,open=true": {
"model": "door_bottom_rh"
},
"facing=east,half=lower,hinge=right,open=true": {
"model": "door_bottom",
"y": 270
},
"facing=south,half=lower,hinge=right,open=true": {
"model": "door_bottom"
},
"facing=west,half=lower,hinge=right,open=true": {
"model": "door_bottom",
"y": 90
},
"facing=north,half=lower,hinge=right,open=true": {
"model": "door_bottom",
"y": 180
},
"facing=east,half=upper,hinge=left,open=false": {
"model": "door_top"
},
"facing=south,half=upper,hinge=left,open=false": {
"model": "door_top",
"y": 90
},
"facing=west,half=upper,hinge=left,open=false": {
"model": "door_top",
"y": 180
},
"facing=north,half=upper,hinge=left,open=false": {
"model": "door_top",
"y": 270
},
"facing=east,half=upper,hinge=right,open=false": {
"model": "door_top_rh"
},
"facing=south,half=upper,hinge=right,open=false": {
"model": "door_top_rh",
"y": 90
},
"facing=west,half=upper,hinge=right,open=false": {
"model": "door_top_rh",
"y": 180
},
"facing=north,half=upper,hinge=right,open=false": {
"model": "door_top_rh",
"y": 270
},
"facing=east,half=upper,hinge=left,open=true": {
"model": "door_top_rh",
"y": 90
},
"facing=south,half=upper,hinge=left,open=true": {
"model": "door_top_rh",
"y": 180
},
"facing=west,half=upper,hinge=left,open=true": {
"model": "door_top_rh",
"y": 270
},
"facing=north,half=upper,hinge=left,open=true": {
"model": "door_top_rh"
},
"facing=east,half=upper,hinge=right,open=true": {
"model": "door_top",
"y": 270
},
"facing=south,half=upper,hinge=right,open=true": {
"model": "door_top"
},
"facing=west,half=upper,hinge=right,open=true": {
"model": "door_top",
"y": 90
},
"facing=north,half=upper,hinge=right,open=true": {
"model": "door_top",
"y": 180
}
}
}
3 changes: 3 additions & 0 deletions src/main/resources/assets/mocreatures/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,14 @@ tile.mocreatures.wyvstone_pressure_plate.name=Wyvstone Pressure Plate
tile.mocreatures.wyvstone_stairs.name=Wyvstone Stairs
tile.mocreatures.wyvstone_wall.name=Wyvstone Wall
tile.mocreatures.wyvwood_button.name=Wyvwood Button
tile.mocreatures.wyvwood_door.name=Wyvwood Door
tile.mocreatures.wyvwood_fence.name=Wyvwood Fence
tile.mocreatures.wyvwood_fence_gate.name=Wyvwood Fence Gate
tile.mocreatures.wyvwood_planks.name=Wyvwood Planks
tile.mocreatures.wyvwood_pressure_plate.name=Wyvwood Pressure Plate
tile.mocreatures.wyvwood_sapling.name=Wyvwood Sapling
tile.mocreatures.wyvwood_stairs.name=Wyvwood Stairs
tile.mocreatures.wyvwood_trapdoor.name=Wyvwood Trapdoor [WIP]

# ITEMS
item.amuletbone.name=Bone Amulet
Expand Down Expand Up @@ -277,6 +279,7 @@ item.venisoncooked.name=Cooked Venison
item.venisonraw.name=Raw Venison
item.whip.name=Whip
item.woolball.name=Wool Ball
item.wyvwood_door.name=Wyvwood Door [WIP]

# ENTITIES
entity.mocreatures:anchovy.name=Anchovy
Expand Down
17 changes: 17 additions & 0 deletions src/main/resources/assets/mocreatures/recipes/wyvwood_door.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"type": "forge:ore_shaped",
"pattern": [
"XX",
"XX",
"XX"
],
"key": {
"X": {
"item": "mocreatures:wyvwood_planks"
}
},
"result": {
"item": "mocreatures:wyvwood_door",
"count": 3
}
}
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 5bd6747

Please sign in to comment.