From 276a99d7cff77c7698e8fada8e842fef344e10d1 Mon Sep 17 00:00:00 2001 From: Sollace Date: Fri, 15 Mar 2019 19:15:28 +0200 Subject: [PATCH] Added diamond doors --- .../unicopia/block/BlockDiamondDoor.java | 48 +++++++++++++ .../minelittlepony/unicopia/block/UDoor.java | 20 ++++-- .../minelittlepony/unicopia/init/UBlocks.java | 4 +- .../minelittlepony/unicopia/init/UItems.java | 7 +- .../unicopia/blockstates/diamond_door.json | 68 ++++++++++++++++++ .../resources/assets/unicopia/lang/en_US.lang | 1 + .../models/block/door/diamond_bottom.json | 7 ++ .../models/block/door/diamond_bottom_rh.json | 7 ++ .../models/block/door/diamond_top.json | 7 ++ .../models/block/door/diamond_top_rh.json | 7 ++ .../unicopia/models/item/diamond_door.json | 6 ++ .../assets/unicopia/recipes/diamond_door.json | 14 ++++ .../textures/blocks/door_diamond_lower.png | Bin 0 -> 336 bytes .../textures/blocks/door_diamond_upper.png | Bin 0 -> 397 bytes .../unicopia/textures/items/door_diamond.png | Bin 0 -> 219 bytes 15 files changed, 189 insertions(+), 7 deletions(-) create mode 100644 src/main/java/com/minelittlepony/unicopia/block/BlockDiamondDoor.java create mode 100644 src/main/resources/assets/unicopia/blockstates/diamond_door.json create mode 100644 src/main/resources/assets/unicopia/models/block/door/diamond_bottom.json create mode 100644 src/main/resources/assets/unicopia/models/block/door/diamond_bottom_rh.json create mode 100644 src/main/resources/assets/unicopia/models/block/door/diamond_top.json create mode 100644 src/main/resources/assets/unicopia/models/block/door/diamond_top_rh.json create mode 100644 src/main/resources/assets/unicopia/models/item/diamond_door.json create mode 100644 src/main/resources/assets/unicopia/recipes/diamond_door.json create mode 100644 src/main/resources/assets/unicopia/textures/blocks/door_diamond_lower.png create mode 100644 src/main/resources/assets/unicopia/textures/blocks/door_diamond_upper.png create mode 100644 src/main/resources/assets/unicopia/textures/items/door_diamond.png diff --git a/src/main/java/com/minelittlepony/unicopia/block/BlockDiamondDoor.java b/src/main/java/com/minelittlepony/unicopia/block/BlockDiamondDoor.java new file mode 100644 index 00000000..4b3c866a --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/block/BlockDiamondDoor.java @@ -0,0 +1,48 @@ +package com.minelittlepony.unicopia.block; + +import java.util.function.Supplier; + +import javax.annotation.Nullable; + +import com.minelittlepony.unicopia.Predicates; + +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.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class BlockDiamondDoor extends UDoor { + + public BlockDiamondDoor(String domain, String name, Supplier theItem) { + super(Material.IRON, domain, name, theItem); + setSoundType(SoundType.METAL); + setHardness(5.0F); + } + + @Override + @Deprecated + public MapColor getMapColor(IBlockState state, IBlockAccess worldIn, BlockPos pos) { + return MapColor.DIAMOND; + } + + @Override + protected boolean canOpen(@Nullable EntityPlayer player) { + return Predicates.MAGI.test(player); + } + + @Override + protected boolean onPowerStateChanged(World world, IBlockState state, BlockPos pos, boolean powered) { + if (state.getValue(OPEN)) { + world.setBlockState(pos, state.withProperty(OPEN, false), 2); + + return true; + } + + return false; + } +} diff --git a/src/main/java/com/minelittlepony/unicopia/block/UDoor.java b/src/main/java/com/minelittlepony/unicopia/block/UDoor.java index a35aa706..fd401999 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/UDoor.java +++ b/src/main/java/com/minelittlepony/unicopia/block/UDoor.java @@ -54,11 +54,11 @@ public abstract class UDoor extends BlockDoor { } protected WorldEvent getCloseSound() { - return material == Material.IRON ? WorldEvent.IRON_DOOR_SLAM : WorldEvent.WOODEN_DOOR_SLAM; + return isLockable() ? WorldEvent.IRON_DOOR_SLAM : WorldEvent.WOODEN_DOOR_SLAM; } protected WorldEvent getOpenSound() { - return material == Material.IRON ? WorldEvent.IRON_DOOR_OPEN : WorldEvent.WOODEN_DOOR_OPEN; + return isLockable() ? WorldEvent.IRON_DOOR_OPEN : WorldEvent.WOODEN_DOOR_OPEN; } @Override @@ -71,8 +71,20 @@ public abstract class UDoor extends BlockDoor { toggleDoor(world, pos, open, false, null); } + protected boolean isLockable() { + return material == Material.IRON; + } + + protected boolean canBePowered() { + return true; + } + + protected boolean canOpen(@Nullable EntityPlayer player) { + return player == null || material != Material.IRON; + } + protected boolean toggleDoor(World world, BlockPos pos, boolean open, boolean force, @Nullable EntityPlayer player) { - if (player != null && material == Material.IRON) { + if (!canOpen(player)) { return false; } @@ -154,7 +166,7 @@ public abstract class UDoor extends BlockDoor { if (!world.isRemote) { dropBlockAsItem(world, pos, state, 0); } - } else { + } else if (canBePowered()) { boolean powered = world.isBlockPowered(pos) || world.isBlockPowered(upper); if (sender != this && (powered || sender.getDefaultState().canProvidePower()) && powered != upperDoor.getValue(POWERED)) { diff --git a/src/main/java/com/minelittlepony/unicopia/init/UBlocks.java b/src/main/java/com/minelittlepony/unicopia/init/UBlocks.java index 4f423f7b..a381b4de 100644 --- a/src/main/java/com/minelittlepony/unicopia/init/UBlocks.java +++ b/src/main/java/com/minelittlepony/unicopia/init/UBlocks.java @@ -23,6 +23,7 @@ import com.minelittlepony.unicopia.block.UPot; import com.minelittlepony.unicopia.block.USapling; import com.minelittlepony.unicopia.item.ItemApple; import com.minelittlepony.unicopia.block.BlockCloudDoor; +import com.minelittlepony.unicopia.block.BlockDiamondDoor; import com.minelittlepony.unicopia.block.BlockCloudFarm; import com.minelittlepony.unicopia.block.BlockCloudFence; import com.minelittlepony.unicopia.block.BlockCloud; @@ -61,6 +62,7 @@ public class UBlocks { public static final Block bakery_door = new BlockDutchDoor(Material.WOOD, Unicopia.MODID, "bakery_door", () -> UItems.bakery_door) .setSoundType(SoundType.WOOD) .setHardness(3); + public static final Block diamond_door = new BlockDiamondDoor(Unicopia.MODID, "diamond_door", () -> UItems.diamond_door); public static final BlockGlowingGem enchanted_torch = new BlockGlowingGem(Unicopia.MODID, "enchanted_torch"); @@ -101,7 +103,7 @@ public class UBlocks { enchanted_cloud_slab, enchanted_cloud_slab.doubleSlab, packed_cloud_slab, packed_cloud_slab.doubleSlab, cloud_fence, cloud_banister, - mist_door, library_door, bakery_door, + mist_door, library_door, bakery_door, diamond_door, hive, chitin, chissled_chitin, cuccoon, slime_layer, anvil, cloud_farmland, sugar_block, flower_pot, diff --git a/src/main/java/com/minelittlepony/unicopia/init/UItems.java b/src/main/java/com/minelittlepony/unicopia/init/UItems.java index fbbceeea..174ca238 100644 --- a/src/main/java/com/minelittlepony/unicopia/init/UItems.java +++ b/src/main/java/com/minelittlepony/unicopia/init/UItems.java @@ -127,6 +127,9 @@ public class UItems { public static final Item bakery_door = new ItemDoor(UBlocks.bakery_door) .setTranslationKey("bakery_door") .setRegistryName(Unicopia.MODID, "bakery_door"); + public static final Item diamond_door = new ItemDoor(UBlocks.diamond_door) + .setTranslationKey("diamond_door") + .setRegistryName(Unicopia.MODID, "diamond_door"); public static final Item sugar_block = new UItemDecoration(UBlocks.sugar_block); @@ -243,7 +246,7 @@ public class UItems { cloud_stairs, cloud_slab, enchanted_cloud_slab, packed_cloud_slab, cloud_fence, cloud_banister, - cloud_farmland, mist_door, library_door, bakery_door, anvil, + cloud_farmland, mist_door, library_door, bakery_door, diamond_door, anvil, bag_of_holding, spell, curse, spellbook, mug, enchanted_torch, staff_meadow_brook, staff_remembrance, alicorn_amulet, @@ -278,7 +281,7 @@ public class UItems { cloud_stairs, cloud_slab, enchanted_cloud_slab, packed_cloud_slab, cloud_fence, cloud_banister, - cloud_farmland, mist_door, library_door, bakery_door, anvil, + cloud_farmland, mist_door, library_door, bakery_door, diamond_door, anvil, bag_of_holding, spell, curse, spellbook, mug, enchanted_torch, staff_meadow_brook, staff_remembrance, alicorn_amulet, diff --git a/src/main/resources/assets/unicopia/blockstates/diamond_door.json b/src/main/resources/assets/unicopia/blockstates/diamond_door.json new file mode 100644 index 00000000..2a69bf7f --- /dev/null +++ b/src/main/resources/assets/unicopia/blockstates/diamond_door.json @@ -0,0 +1,68 @@ +{ + "variants": { + "facing=east,half=lower,hinge=left,open=false,powered=false": { "model": "unicopia:door/diamond_bottom" }, + "facing=south,half=lower,hinge=left,open=false,powered=false": { "model": "unicopia:door/diamond_bottom", "y": 90 }, + "facing=west,half=lower,hinge=left,open=false,powered=false": { "model": "unicopia:door/diamond_bottom", "y": 180 }, + "facing=north,half=lower,hinge=left,open=false,powered=false": { "model": "unicopia:door/diamond_bottom", "y": 270 }, + "facing=east,half=lower,hinge=right,open=false,powered=false": { "model": "unicopia:door/diamond_bottom_rh" }, + "facing=south,half=lower,hinge=right,open=false,powered=false": { "model": "unicopia:door/diamond_bottom_rh", "y": 90 }, + "facing=west,half=lower,hinge=right,open=false,powered=false": { "model": "unicopia:door/diamond_bottom_rh", "y": 180 }, + "facing=north,half=lower,hinge=right,open=false,powered=false": { "model": "unicopia:door/diamond_bottom_rh", "y": 270 }, + "facing=east,half=lower,hinge=left,open=true,powered=false": { "model": "unicopia:door/diamond_bottom_rh", "y": 90 }, + "facing=south,half=lower,hinge=left,open=true,powered=false": { "model": "unicopia:door/diamond_bottom_rh", "y": 180 }, + "facing=west,half=lower,hinge=left,open=true,powered=false": { "model": "unicopia:door/diamond_bottom_rh", "y": 270 }, + "facing=north,half=lower,hinge=left,open=true,powered=false": { "model": "unicopia:door/diamond_bottom_rh" }, + "facing=east,half=lower,hinge=right,open=true,powered=false": { "model": "unicopia:door/diamond_bottom", "y": 270 }, + "facing=south,half=lower,hinge=right,open=true,powered=false": { "model": "unicopia:door/diamond_bottom" }, + "facing=west,half=lower,hinge=right,open=true,powered=false": { "model": "unicopia:door/diamond_bottom", "y": 90 }, + "facing=north,half=lower,hinge=right,open=true,powered=false": { "model": "unicopia:door/diamond_bottom", "y": 180 }, + "facing=east,half=upper,hinge=left,open=false,powered=false": { "model": "unicopia:door/diamond_top" }, + "facing=south,half=upper,hinge=left,open=false,powered=false": { "model": "unicopia:door/diamond_top", "y": 90 }, + "facing=west,half=upper,hinge=left,open=false,powered=false": { "model": "unicopia:door/diamond_top", "y": 180 }, + "facing=north,half=upper,hinge=left,open=false,powered=false": { "model": "unicopia:door/diamond_top", "y": 270 }, + "facing=east,half=upper,hinge=right,open=false,powered=false": { "model": "unicopia:door/diamond_top_rh" }, + "facing=south,half=upper,hinge=right,open=false,powered=false": { "model": "unicopia:door/diamond_top_rh", "y": 90 }, + "facing=west,half=upper,hinge=right,open=false,powered=false": { "model": "unicopia:door/diamond_top_rh", "y": 180 }, + "facing=north,half=upper,hinge=right,open=false,powered=false": { "model": "unicopia:door/diamond_top_rh", "y": 270 }, + "facing=east,half=upper,hinge=left,open=true,powered=false": { "model": "unicopia:door/diamond_top_rh", "y": 90 }, + "facing=south,half=upper,hinge=left,open=true,powered=false": { "model": "unicopia:door/diamond_top_rh", "y": 180 }, + "facing=west,half=upper,hinge=left,open=true,powered=false": { "model": "unicopia:door/diamond_top_rh", "y": 270 }, + "facing=north,half=upper,hinge=left,open=true,powered=false": { "model": "unicopia:door/diamond_top_rh" }, + "facing=east,half=upper,hinge=right,open=true,powered=false": { "model": "unicopia:door/diamond_top", "y": 270 }, + "facing=south,half=upper,hinge=right,open=true,powered=false": { "model": "unicopia:door/diamond_top" }, + "facing=west,half=upper,hinge=right,open=true,powered=false": { "model": "unicopia:door/diamond_top", "y": 90 }, + "facing=north,half=upper,hinge=right,open=true,powered=false": { "model": "unicopia:door/diamond_top", "y": 180 }, + "facing=east,half=lower,hinge=left,open=false,powered=true": { "model": "unicopia:door/diamond_bottom" }, + "facing=south,half=lower,hinge=left,open=false,powered=true": { "model": "unicopia:door/diamond_bottom", "y": 90 }, + "facing=west,half=lower,hinge=left,open=false,powered=true": { "model": "unicopia:door/diamond_bottom", "y": 180 }, + "facing=north,half=lower,hinge=left,open=false,powered=true": { "model": "unicopia:door/diamond_bottom", "y": 270 }, + "facing=east,half=lower,hinge=right,open=false,powered=true": { "model": "unicopia:door/diamond_bottom_rh" }, + "facing=south,half=lower,hinge=right,open=false,powered=true": { "model": "unicopia:door/diamond_bottom_rh", "y": 90 }, + "facing=west,half=lower,hinge=right,open=false,powered=true": { "model": "unicopia:door/diamond_bottom_rh", "y": 180 }, + "facing=north,half=lower,hinge=right,open=false,powered=true": { "model": "unicopia:door/diamond_bottom_rh", "y": 270 }, + "facing=east,half=lower,hinge=left,open=true,powered=true": { "model": "unicopia:door/diamond_bottom_rh", "y": 90 }, + "facing=south,half=lower,hinge=left,open=true,powered=true": { "model": "unicopia:door/diamond_bottom_rh", "y": 180 }, + "facing=west,half=lower,hinge=left,open=true,powered=true": { "model": "unicopia:door/diamond_bottom_rh", "y": 270 }, + "facing=north,half=lower,hinge=left,open=true,powered=true": { "model": "unicopia:door/diamond_bottom_rh" }, + "facing=east,half=lower,hinge=right,open=true,powered=true": { "model": "unicopia:door/diamond_bottom", "y": 270 }, + "facing=south,half=lower,hinge=right,open=true,powered=true": { "model": "unicopia:door/diamond_bottom" }, + "facing=west,half=lower,hinge=right,open=true,powered=true": { "model": "unicopia:door/diamond_bottom", "y": 90 }, + "facing=north,half=lower,hinge=right,open=true,powered=true": { "model": "unicopia:door/diamond_bottom", "y": 180 }, + "facing=east,half=upper,hinge=left,open=false,powered=true": { "model": "unicopia:door/diamond_top" }, + "facing=south,half=upper,hinge=left,open=false,powered=true": { "model": "unicopia:door/diamond_top", "y": 90 }, + "facing=west,half=upper,hinge=left,open=false,powered=true": { "model": "unicopia:door/diamond_top", "y": 180 }, + "facing=north,half=upper,hinge=left,open=false,powered=true": { "model": "unicopia:door/diamond_top", "y": 270 }, + "facing=east,half=upper,hinge=right,open=false,powered=true": { "model": "unicopia:door/diamond_top_rh" }, + "facing=south,half=upper,hinge=right,open=false,powered=true": { "model": "unicopia:door/diamond_top_rh", "y": 90 }, + "facing=west,half=upper,hinge=right,open=false,powered=true": { "model": "unicopia:door/diamond_top_rh", "y": 180 }, + "facing=north,half=upper,hinge=right,open=false,powered=true": { "model": "unicopia:door/diamond_top_rh", "y": 270 }, + "facing=east,half=upper,hinge=left,open=true,powered=true": { "model": "unicopia:door/diamond_top_rh", "y": 90 }, + "facing=south,half=upper,hinge=left,open=true,powered=true": { "model": "unicopia:door/diamond_top_rh", "y": 180 }, + "facing=west,half=upper,hinge=left,open=true,powered=true": { "model": "unicopia:door/diamond_top_rh", "y": 270 }, + "facing=north,half=upper,hinge=left,open=true,powered=true": { "model": "unicopia:door/diamond_top_rh" }, + "facing=east,half=upper,hinge=right,open=true,powered=true": { "model": "unicopia:door/diamond_top", "y": 270 }, + "facing=south,half=upper,hinge=right,open=true,powered=true": { "model": "unicopia:door/diamond_top" }, + "facing=west,half=upper,hinge=right,open=true,powered=true": { "model": "unicopia:door/diamond_top", "y": 90 }, + "facing=north,half=upper,hinge=right,open=true,powered=true": { "model": "unicopia:door/diamond_top", "y": 180 } + } +} diff --git a/src/main/resources/assets/unicopia/lang/en_US.lang b/src/main/resources/assets/unicopia/lang/en_US.lang index 6fa1b336..c8ef9f01 100644 --- a/src/main/resources/assets/unicopia/lang/en_US.lang +++ b/src/main/resources/assets/unicopia/lang/en_US.lang @@ -36,6 +36,7 @@ item.cloud.large.name=Wild Cloud item.mist_door.name=Cloud Door item.library_door.name=Dutch Library Door item.bakery_door.name=Dutch Bakery Door +item.diamond_door.name=Diamond Door item.dew_drop.name=Dew Drop item.cloud_anvil.name=Anvilhead Anvil item.chitin_shell.name=Chitinous Shell diff --git a/src/main/resources/assets/unicopia/models/block/door/diamond_bottom.json b/src/main/resources/assets/unicopia/models/block/door/diamond_bottom.json new file mode 100644 index 00000000..02d76d21 --- /dev/null +++ b/src/main/resources/assets/unicopia/models/block/door/diamond_bottom.json @@ -0,0 +1,7 @@ +{ + "parent": "unicopia:block/door/bottom", + "textures": { + "bottom": "unicopia:blocks/door_diamond_lower", + "top": "unicopia:blocks/door_diamond_upper" + } +} diff --git a/src/main/resources/assets/unicopia/models/block/door/diamond_bottom_rh.json b/src/main/resources/assets/unicopia/models/block/door/diamond_bottom_rh.json new file mode 100644 index 00000000..8556b6d7 --- /dev/null +++ b/src/main/resources/assets/unicopia/models/block/door/diamond_bottom_rh.json @@ -0,0 +1,7 @@ +{ + "parent": "unicopia:block/door/bottom_rh", + "textures": { + "bottom": "unicopia:blocks/door_diamond_lower", + "top": "unicopia:blocks/door_diamond_upper" + } +} diff --git a/src/main/resources/assets/unicopia/models/block/door/diamond_top.json b/src/main/resources/assets/unicopia/models/block/door/diamond_top.json new file mode 100644 index 00000000..19212184 --- /dev/null +++ b/src/main/resources/assets/unicopia/models/block/door/diamond_top.json @@ -0,0 +1,7 @@ +{ + "parent": "unicopia:block/door/top", + "textures": { + "bottom": "unicopia:blocks/door_diamond_lower", + "top": "unicopia:blocks/door_diamond_upper" + } +} diff --git a/src/main/resources/assets/unicopia/models/block/door/diamond_top_rh.json b/src/main/resources/assets/unicopia/models/block/door/diamond_top_rh.json new file mode 100644 index 00000000..ad3be532 --- /dev/null +++ b/src/main/resources/assets/unicopia/models/block/door/diamond_top_rh.json @@ -0,0 +1,7 @@ +{ + "parent": "unicopia:block/door/top_rh", + "textures": { + "bottom": "unicopia:blocks/door_diamond_lower", + "top": "unicopia:blocks/door_diamond_upper" + } +} diff --git a/src/main/resources/assets/unicopia/models/item/diamond_door.json b/src/main/resources/assets/unicopia/models/item/diamond_door.json new file mode 100644 index 00000000..6ac870bf --- /dev/null +++ b/src/main/resources/assets/unicopia/models/item/diamond_door.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "unicopia:items/door_diamond" + } +} diff --git a/src/main/resources/assets/unicopia/recipes/diamond_door.json b/src/main/resources/assets/unicopia/recipes/diamond_door.json new file mode 100644 index 00000000..4499cb13 --- /dev/null +++ b/src/main/resources/assets/unicopia/recipes/diamond_door.json @@ -0,0 +1,14 @@ +{ + "type": "minecraft:crafting_shaped", + "pattern": [ + "##", + "##", + "##" + ], + "key": { + "#": [ + { "item": "minecraft:diamond" } + ] + }, + "result": { "item": "unicopia:diamond_door", "count": 3 } +} diff --git a/src/main/resources/assets/unicopia/textures/blocks/door_diamond_lower.png b/src/main/resources/assets/unicopia/textures/blocks/door_diamond_lower.png new file mode 100644 index 0000000000000000000000000000000000000000..ad2b6b2004bdc02526f0e0e6e9f4590d175bd6a3 GIT binary patch literal 336 zcmV-W0k8gvP)e<0#G{hgiMz3&|I9=`;F@expC~C0}Tt&`TwH@F7tJEP)zQGJ!h7%E_>5a)Cu$7q%kc4PQxfSo$r}<$opcPL`G+8n@IxqmTHXUdRBufO04Ty1 zh7P3Tgdle%G=mpn>_91XRj;Zf2Y{-_v{KLj77#eB8&IxdwHf6B3$8Zo<2p_4KW|`; ze-73OGh(VQ<&a%FhINb;mQl&}YV|M9$|1X=3oLnj_1KmKEcwL#mIOXv#svRa4Vc0u zV#kx5*Mq!)lgBtWCU4?jAsyrKZiCiz5Sp(JTGJ&R-j{V8ArEsyBEACvC|=I*{(1F) iTc7mtBym_basCGPpr7x~naaih0000kf(2#i z&>+;h$;VLa+DQQQme|gB=kt9wF*9RBq#{>iySgx0uEvq=VY1ATl>z_|SdJl*l>*LO zfS8$6kt?E( zM`U|SczAF^QYiL=wZNg{q4+1y#0_DgFfy~63Z=a!w8*3wv%T~hx}zqsopewakR2E; zrnMbq`=n5{#^^$?-7!LlY_AqdwT76P^|ow++CAvCJ4V51F|DoX$B6x4Es(e&hTT&l z23kZYn6XcU*Rq6#!stRT9k3L!^?;6^?|Ap-g8s7oaNbuLjAz*@19{gIH*9=yI`jv2 r`|&IJk7FOp8&(S?`lJ#(pftguD(t%WE`x$A+BK$bnKp-V*!sKqj^^7+T zJbJJH;gs=2p@jGQ>y>Xc{P!^X-@emj!sOTXyPU+5lGx9({^ykX@bCBb|3|92TO(R4 zoxCELr)DrGaPrvN3gj{ba&lU#E?VmL=n`X)*OAqn`DsdC!ph1q@(e8b`e8aj%l80X O%i!ti=d#Wzp$Pygol{T% literal 0 HcmV?d00001