From 35b1785e9c6362e6ef04b753e1b7c6e448cefadf Mon Sep 17 00:00:00 2001 From: stfwi Date: Thu, 6 Feb 2020 10:44:21 +0100 Subject: [PATCH] 1.12/1.14/1.15: Fixed Gloor Grating item jitter. 1.14/1.15: Librarizing, Factory Hopper second standard insertion run added (issue #84), Placer planting race condition circumvention added (issue #83). 1.15: JEI integration enabled (issue #85). --- 1.12/gradle.properties | 2 +- 1.12/meta/update.json | 3 +- 1.12/readme.md | 3 + .../java/wile/engineersdecor/ModContent.java | 2 +- .../blocks/BlockDecorFloorGrating.java | 54 +-- .../furniture/steel_floor_grating_model.json | 17 +- .../testing/collision_test1_diorite.json | 22 - .../testing/collision_test2_diorite.json | 22 - .../testing/collision_test3_diorite.json | 22 - 1.14/gradle.properties | 2 +- 1.14/meta/update.json | 3 +- 1.14/readme.md | 6 + .../java/wile/engineersdecor/ModContent.java | 157 +++---- .../engineersdecor/ModEngineersDecor.java | 47 +-- .../engineersdecor/blocks/BlockDecor.java | 216 +++------- .../blocks/BlockDecorBreaker.java | 12 +- .../blocks/BlockDecorChair.java | 3 +- .../blocks/BlockDecorCraftingTable.java | 16 +- .../blocks/BlockDecorDirected.java | 118 ------ .../blocks/BlockDecorDirectedHorizontal.java | 126 ------ .../blocks/BlockDecorDropper.java | 5 +- .../blocks/BlockDecorFence.java | 103 +---- .../blocks/BlockDecorFloorGrating.java | 61 ++- .../blocks/BlockDecorFluidFunnel.java | 3 +- .../blocks/BlockDecorFurnace.java | 15 +- .../blocks/BlockDecorFurnaceElectrical.java | 8 +- .../blocks/BlockDecorGlassBlock.java | 6 +- .../blocks/BlockDecorHalfSlab.java | 195 +-------- .../blocks/BlockDecorHopper.java | 17 +- .../blocks/BlockDecorHorizontalSupport.java | 17 +- .../blocks/BlockDecorLadder.java | 14 +- .../blocks/BlockDecorMilker.java | 3 +- .../blocks/BlockDecorMineralSmelter.java | 4 +- .../BlockDecorPassiveFluidAccumulator.java | 7 +- .../blocks/BlockDecorPipeValve.java | 28 +- .../blocks/BlockDecorPlacer.java | 29 +- .../engineersdecor/blocks/BlockDecorSlab.java | 152 +------ .../blocks/BlockDecorSolarPanel.java | 3 +- .../blocks/BlockDecorStairs.java | 41 +- .../blocks/BlockDecorStraightPole.java | 12 +- .../engineersdecor/blocks/BlockDecorTest.java | 19 +- .../blocks/BlockDecorTreeCutter.java | 3 +- .../engineersdecor/blocks/BlockDecorWall.java | 107 +---- .../blocks/BlockDecorWasteIncinerator.java | 9 +- .../blocks/BlockDecorWindow.java | 13 +- .../engineersdecor/blocks/IDecorBlock.java | 11 +- .../wile/engineersdecor/detail/ModConfig.java | 11 +- .../wile/engineersdecor/detail/ModTesrs.java | 3 +- .../libmc/blocks/SlabSliceBlock.java | 211 ++++++++++ .../libmc/blocks/StandardBlocks.java | 380 +++++++++++++++++ .../libmc/blocks/StandardFenceBlock.java | 114 ++++++ .../libmc/blocks/StandardStairsBlock.java | 55 +++ .../libmc/blocks/VariantSlabBlock.java | 200 +++++++++ .../libmc/blocks/VariantWallBlock.java | 129 ++++++ .../datagen/LootTableGen.java} | 21 +- .../detail/Auxiliaries.java} | 83 ++-- .../{ => libmc}/detail/Networking.java | 19 +- .../detail/OptionalRecipeCondition.java | 101 ++++- .../libmc/detail/SidedProxy.java | 58 +++ .../blockstates/small_electrical_furnace.json | 6 +- .../blockstates/small_lab_furnace.json | 6 +- .../treated_wood_crafting_table.json | 4 +- .../furniture/steel_floor_grating_model.json | 15 +- .../testing/collision_test1_diorite.json | 21 - .../testing/collision_test2_diorite.json | 21 - .../testing/collision_test3_diorite.json | 21 - 1.15/build.gradle | 6 +- 1.15/gradle.properties | 4 +- 1.15/meta/update.json | 3 +- 1.15/readme.md | 7 + .../java/wile/engineersdecor/ModContent.java | 162 ++++---- .../engineersdecor/ModEngineersDecor.java | 47 +-- .../engineersdecor/blocks/BlockDecor.java | 243 +++-------- .../blocks/BlockDecorBreaker.java | 10 +- .../blocks/BlockDecorChair.java | 2 +- .../blocks/BlockDecorCraftingTable.java | 16 +- .../blocks/BlockDecorDirected.java | 114 ------ .../blocks/BlockDecorDirectedHorizontal.java | 122 ------ .../blocks/BlockDecorDropper.java | 4 +- .../blocks/BlockDecorFence.java | 102 +---- .../blocks/BlockDecorFloorGrating.java | 59 ++- .../blocks/BlockDecorFluidFunnel.java | 2 +- .../blocks/BlockDecorFurnace.java | 12 +- .../blocks/BlockDecorFurnaceElectrical.java | 10 +- .../blocks/BlockDecorGlassBlock.java | 4 +- .../blocks/BlockDecorHalfSlab.java | 194 +-------- .../blocks/BlockDecorHopper.java | 16 +- .../blocks/BlockDecorHorizontalSupport.java | 19 +- .../blocks/BlockDecorLadder.java | 14 +- .../blocks/BlockDecorMilker.java | 2 +- .../blocks/BlockDecorMineralSmelter.java | 2 +- .../BlockDecorPassiveFluidAccumulator.java | 6 +- .../blocks/BlockDecorPipeValve.java | 26 +- .../blocks/BlockDecorPlacer.java | 26 +- .../engineersdecor/blocks/BlockDecorSlab.java | 168 +------- .../blocks/BlockDecorSolarPanel.java | 9 +- .../blocks/BlockDecorStairs.java | 41 +- .../blocks/BlockDecorStraightPole.java | 18 +- .../engineersdecor/blocks/BlockDecorTest.java | 17 +- .../blocks/BlockDecorTreeCutter.java | 2 +- .../engineersdecor/blocks/BlockDecorWall.java | 107 +---- .../blocks/BlockDecorWasteIncinerator.java | 4 - .../blocks/BlockDecorWindow.java | 11 +- .../engineersdecor/blocks/IDecorBlock.java | 21 +- .../wile/engineersdecor/detail/ModConfig.java | 7 +- .../engineersdecor/detail/ModRenderers.java | 3 +- .../engineersdecor/eapi/jei/JEIPlugin.java | 10 +- .../libmc/blocks/SlabSliceBlock.java | 210 ++++++++++ .../libmc/blocks/StandardBlocks.java | 386 ++++++++++++++++++ .../libmc/blocks/StandardFenceBlock.java | 114 ++++++ .../libmc/blocks/StandardStairsBlock.java | 53 +++ .../libmc/blocks/VariantSlabBlock.java | 182 +++++++++ .../libmc/blocks/VariantWallBlock.java | 117 ++++++ .../datagen/LootTableGen.java} | 21 +- .../detail/Auxiliaries.java} | 135 +++--- .../{ => libmc}/detail/Networking.java | 19 +- .../detail/OptionalRecipeCondition.java | 101 ++++- .../libmc/detail/SidedProxy.java | 58 +++ .../blockstates/small_electrical_furnace.json | 6 +- .../blockstates/small_lab_furnace.json | 6 +- .../treated_wood_crafting_table.json | 4 +- .../furniture/steel_floor_grating_model.json | 15 +- .../testing/collision_test1_diorite.json | 21 - .../testing/collision_test2_diorite.json | 21 - .../testing/collision_test3_diorite.json | 21 - meta/update.json | 9 +- 126 files changed, 3325 insertions(+), 3043 deletions(-) delete mode 100644 1.12/src/main/resources/assets/engineersdecor/recipes/testing/collision_test1_diorite.json delete mode 100644 1.12/src/main/resources/assets/engineersdecor/recipes/testing/collision_test2_diorite.json delete mode 100644 1.12/src/main/resources/assets/engineersdecor/recipes/testing/collision_test3_diorite.json delete mode 100644 1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorDirected.java delete mode 100644 1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorDirectedHorizontal.java create mode 100644 1.14/src/main/java/wile/engineersdecor/libmc/blocks/SlabSliceBlock.java create mode 100644 1.14/src/main/java/wile/engineersdecor/libmc/blocks/StandardBlocks.java create mode 100644 1.14/src/main/java/wile/engineersdecor/libmc/blocks/StandardFenceBlock.java create mode 100644 1.14/src/main/java/wile/engineersdecor/libmc/blocks/StandardStairsBlock.java create mode 100644 1.14/src/main/java/wile/engineersdecor/libmc/blocks/VariantSlabBlock.java create mode 100644 1.14/src/main/java/wile/engineersdecor/libmc/blocks/VariantWallBlock.java rename 1.14/src/main/java/wile/engineersdecor/{datagen/ModLootTables.java => libmc/datagen/LootTableGen.java} (80%) rename 1.14/src/main/java/wile/engineersdecor/{detail/ModAuxiliaries.java => libmc/detail/Auxiliaries.java} (77%) rename 1.14/src/main/java/wile/engineersdecor/{ => libmc}/detail/Networking.java (94%) rename 1.14/src/main/java/wile/engineersdecor/{ => libmc}/detail/OptionalRecipeCondition.java (53%) create mode 100644 1.14/src/main/java/wile/engineersdecor/libmc/detail/SidedProxy.java delete mode 100644 1.14/src/main/resources/data/engineersdecor/recipes/testing/collision_test1_diorite.json delete mode 100644 1.14/src/main/resources/data/engineersdecor/recipes/testing/collision_test2_diorite.json delete mode 100644 1.14/src/main/resources/data/engineersdecor/recipes/testing/collision_test3_diorite.json delete mode 100644 1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorDirected.java delete mode 100644 1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorDirectedHorizontal.java create mode 100644 1.15/src/main/java/wile/engineersdecor/libmc/blocks/SlabSliceBlock.java create mode 100644 1.15/src/main/java/wile/engineersdecor/libmc/blocks/StandardBlocks.java create mode 100644 1.15/src/main/java/wile/engineersdecor/libmc/blocks/StandardFenceBlock.java create mode 100644 1.15/src/main/java/wile/engineersdecor/libmc/blocks/StandardStairsBlock.java create mode 100644 1.15/src/main/java/wile/engineersdecor/libmc/blocks/VariantSlabBlock.java create mode 100644 1.15/src/main/java/wile/engineersdecor/libmc/blocks/VariantWallBlock.java rename 1.15/src/main/java/wile/engineersdecor/{datagen/ModLootTables.java => libmc/datagen/LootTableGen.java} (80%) rename 1.15/src/main/java/wile/engineersdecor/{detail/ModAuxiliaries.java => libmc/detail/Auxiliaries.java} (75%) rename 1.15/src/main/java/wile/engineersdecor/{ => libmc}/detail/Networking.java (94%) rename 1.15/src/main/java/wile/engineersdecor/{ => libmc}/detail/OptionalRecipeCondition.java (53%) create mode 100644 1.15/src/main/java/wile/engineersdecor/libmc/detail/SidedProxy.java delete mode 100644 1.15/src/main/resources/data/engineersdecor/recipes/testing/collision_test1_diorite.json delete mode 100644 1.15/src/main/resources/data/engineersdecor/recipes/testing/collision_test2_diorite.json delete mode 100644 1.15/src/main/resources/data/engineersdecor/recipes/testing/collision_test3_diorite.json diff --git a/1.12/gradle.properties b/1.12/gradle.properties index 89e1892..49b29be 100644 --- a/1.12/gradle.properties +++ b/1.12/gradle.properties @@ -4,4 +4,4 @@ org.gradle.jvmargs=-Xmx8G version_minecraft=1.12.2 version_forge=14.23.5.2768 version_jei=4.10.0.198 -version_engineersdecor=1.0.19-b1 +version_engineersdecor=1.0.19-b2 diff --git a/1.12/meta/update.json b/1.12/meta/update.json index 979d0ce..5e21f05 100644 --- a/1.12/meta/update.json +++ b/1.12/meta/update.json @@ -1,6 +1,7 @@ { "homepage": "https://www.curseforge.com/minecraft/mc-mods/engineers-decor/", "1.12.2": { + "1.0.19-b2": "[F] Fixed Floor Grating item pass-through jitters (thx Cid).\n[M] Removed obsolete recipe collision testing recipes.", "1.0.19-b1": "[F] Fixed Tree Cutter / Block Breaker not accepting small energy transfers (thx WindFox, issue #82).", "1.0.18": "[R] Release based on v1.0.18-b2. Release-to-release changes: * Tree cutter config fixes. * Treated Wood Crafting Table mouse tweaks. * Lang updates.\n[M] Lang update ru_ru (PR#77, thanks Smollet777).", "1.0.18-b2": "[A] Added Treated Wood Crafting table tweaks (ctrl-shift moves all same stacks from the inventory, mouse wheel over crafting slot increases/decreases crafting grid stacks).\n[F] EN Lang file fixed (issue #76, thx Riverstar907).\n[F] Fixed Tree Cutter not respecting power-required config (thx federsavo, issue #77).", @@ -78,6 +79,6 @@ }, "promos": { "1.12.2-recommended": "1.0.18", - "1.12.2-latest": "1.0.19-b1" + "1.12.2-latest": "1.0.19-b2" } } \ No newline at end of file diff --git a/1.12/readme.md b/1.12/readme.md index a057ce1..6c24eef 100644 --- a/1.12/readme.md +++ b/1.12/readme.md @@ -10,6 +10,9 @@ Mod sources for Minecraft version 1.12.2. ---- ## Version history + - v1.0.19-b2 [F] Fixed Floor Grating item pass-through jitters (thx Cid). + [M] Removed obsolete recipe collision testing recipes. + - v1.0.19-b1 [F] Fixed Tree Cutter / Block Breaker not accepting small energy transfers (thx WindFox, issue #82). ------------------------------------------------------------------- diff --git a/1.12/src/main/java/wile/engineersdecor/ModContent.java b/1.12/src/main/java/wile/engineersdecor/ModContent.java index da2e8f2..e0448db 100644 --- a/1.12/src/main/java/wile/engineersdecor/ModContent.java +++ b/1.12/src/main/java/wile/engineersdecor/ModContent.java @@ -338,7 +338,7 @@ public class ModContent "steel_floor_grating", BlockDecor.CFG_CUTOUT, Material.IRON, 1.0f, 15f, SoundType.METAL, - ModAuxiliaries.getPixeledAABB(0,14,0, 16,16,16) + ModAuxiliaries.getPixeledAABB(0,14,0, 16,15.9,16) ); //-------------------------------------------------------------------------------------------------------------------- diff --git a/1.12/src/main/java/wile/engineersdecor/blocks/BlockDecorFloorGrating.java b/1.12/src/main/java/wile/engineersdecor/blocks/BlockDecorFloorGrating.java index af3a5f1..3ef7321 100644 --- a/1.12/src/main/java/wile/engineersdecor/blocks/BlockDecorFloorGrating.java +++ b/1.12/src/main/java/wile/engineersdecor/blocks/BlockDecorFloorGrating.java @@ -17,12 +17,12 @@ import net.minecraft.entity.item.EntityItem; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import java.util.List; public class BlockDecorFloorGrating extends BlockDecor { @@ -45,45 +45,27 @@ public class BlockDecorFloorGrating extends BlockDecor public BlockFaceShape getBlockFaceShape(IBlockAccess world, IBlockState state, BlockPos pos, EnumFacing face) { return BlockFaceShape.UNDEFINED; } - @Override - public void addCollisionBoxToList(IBlockState state, World world, BlockPos pos, AxisAlignedBB entityBox, List collidingBoxes, @Nullable Entity entity, boolean isActualState) - { if(!(entity instanceof EntityItem)) super.addCollisionBoxToList(state, world, pos, entityBox, collidingBoxes, entity, isActualState); } - - @Override - public void onFallenUpon(World world, BlockPos pos, Entity entity, float fallDistance) - { - if(!(entity instanceof EntityItem)) { - entity.fall(fallDistance, 1.0F); - } else { - entity.motionX = 0; - entity.motionY = -0.1; - entity.motionZ = 0; - entity.setPositionAndUpdate(pos.getX()+0.5, entity.posY-0.3, pos.getZ()+0.5); - } - } - - @Override - public void onLanded(World world, Entity entity) - { - if(!(entity instanceof EntityItem)) { - super.onLanded(world, entity); - } else { - entity.motionX = 0; - entity.motionY = -0.1; - entity.motionZ = 0; - entity.setPositionAndUpdate(entity.posX, entity.posY-0.3, entity.posZ); - } - } - @Override public void onEntityCollision(World world, BlockPos pos, IBlockState state, Entity entity) { if(!(entity instanceof EntityItem)) return; - entity.motionX = 0; - entity.motionZ = 0; - if((entity.posY-pos.getY()) > 0.7) { - if(entity.motionY > -0.2) entity.motionY = -0.2; - entity.setPositionAndUpdate(pos.getX()+0.5, entity.posY-0.3, pos.getZ()+0.5); + final boolean colliding = ((entity.posY-pos.getY()) > 0.7); + if(colliding || (entity.motionY > 0)) { + double x = pos.getX() + 0.5; + double y = MathHelper.clamp(entity.posY-0.3, pos.getY(), pos.getY()+0.6); + double z = pos.getZ() + 0.5; + if(colliding) { + entity.motionX = 0; + entity.motionZ = 0; + entity.motionY = -0.3; + if((entity.posY-pos.getY()) > 0.8) y = pos.getY() + 0.6; + entity.prevPosX = x+0.1; + entity.prevPosY = y+0.1; + entity.prevPosZ = z+0.1; + } + entity.motionY = MathHelper.clamp(entity.motionY, -0.3, 0); + entity.fallDistance = 0; + entity.setPositionAndUpdate(x,y,z); } } } diff --git a/1.12/src/main/resources/assets/engineersdecor/models/block/furniture/steel_floor_grating_model.json b/1.12/src/main/resources/assets/engineersdecor/models/block/furniture/steel_floor_grating_model.json index 88383fd..5553a6d 100644 --- a/1.12/src/main/resources/assets/engineersdecor/models/block/furniture/steel_floor_grating_model.json +++ b/1.12/src/main/resources/assets/engineersdecor/models/block/furniture/steel_floor_grating_model.json @@ -1,8 +1,8 @@ { "parent": "block/cube", "textures": { - "s": "engineersdecor:blocks/furniture/steel_table_side_texture", "particle": "engineersdecor:blocks/furniture/steel_table_side_texture", + "s": "engineersdecor:blocks/furniture/steel_table_side_texture", "t": "engineersdecor:blocks/furniture/steel_table_top_texture" }, "elements": [ @@ -173,15 +173,28 @@ } ], "display": { + "thirdperson_righthand": { + "rotation": [66, 0, 0], + "translation": [0.25, 0, -2.75], + "scale": [0.3, 0.3, 0.3] + }, + "firstperson_righthand": { + "rotation": [-4, -1, 58], + "translation": [2.5, 0.25, 1.75], + "scale": [0.3, 0.3, 0.3] + }, "ground": { - "translation": [0, 1.75, 0], + "translation": [0, 1.75, 0], "scale": [0.2, 0.2, 0.2] }, "gui": { "rotation": [30, 225, 0], + "translation": [0, -2, 0], "scale": [0.625, 0.625, 0.625] }, "fixed": { + "rotation": [-90, 0, 1], + "translation": [0, 0.25, 3.25], "scale": [0.5, 0.5, 0.5] } } diff --git a/1.12/src/main/resources/assets/engineersdecor/recipes/testing/collision_test1_diorite.json b/1.12/src/main/resources/assets/engineersdecor/recipes/testing/collision_test1_diorite.json deleted file mode 100644 index 2597836..0000000 --- a/1.12/src/main/resources/assets/engineersdecor/recipes/testing/collision_test1_diorite.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "conditions": [ - { - "type": "engineersdecor:grc", - "experimental": true - } - ], - "type": "minecraft:crafting_shaped", - "pattern": [ - "DDD", - " D ", - " D " - ], - "key": { - "D": { "item": "minecraft:stone", "data":3 } - }, - "result": { - "item": "minecraft:stone", - "data": 0, - "count": 1 - } -} diff --git a/1.12/src/main/resources/assets/engineersdecor/recipes/testing/collision_test2_diorite.json b/1.12/src/main/resources/assets/engineersdecor/recipes/testing/collision_test2_diorite.json deleted file mode 100644 index 8eaa485..0000000 --- a/1.12/src/main/resources/assets/engineersdecor/recipes/testing/collision_test2_diorite.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "conditions": [ - { - "type": "engineersdecor:grc", - "experimental": true - } - ], - "type": "minecraft:crafting_shaped", - "pattern": [ - "DDD", - " D ", - " D " - ], - "key": { - "D": { "item": "minecraft:stone", "data":3 } - }, - "result": { - "item": "minecraft:stone", - "data": 1, - "count": 1 - } -} diff --git a/1.12/src/main/resources/assets/engineersdecor/recipes/testing/collision_test3_diorite.json b/1.12/src/main/resources/assets/engineersdecor/recipes/testing/collision_test3_diorite.json deleted file mode 100644 index a700163..0000000 --- a/1.12/src/main/resources/assets/engineersdecor/recipes/testing/collision_test3_diorite.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "conditions": [ - { - "type": "engineersdecor:grc", - "experimental": true - } - ], - "type": "minecraft:crafting_shaped", - "pattern": [ - "DDD", - " D ", - " D " - ], - "key": { - "D": { "item": "minecraft:stone", "data":3 } - }, - "result": { - "item": "minecraft:stone", - "data": 5, - "count": 1 - } -} diff --git a/1.14/gradle.properties b/1.14/gradle.properties index 130b3e0..ffa62c2 100644 --- a/1.14/gradle.properties +++ b/1.14/gradle.properties @@ -5,4 +5,4 @@ version_minecraft=1.14.4 version_forge_minecraft=1.14.4-28.1.116 version_fml_mappings=20190719-1.14.3 version_jei=1.14.4:6.0.0.10 -version_engineersdecor=1.0.19-b1 +version_engineersdecor=1.0.19-b2 diff --git a/1.14/meta/update.json b/1.14/meta/update.json index ebddf0e..8d572f5 100644 --- a/1.14/meta/update.json +++ b/1.14/meta/update.json @@ -1,6 +1,7 @@ { "homepage": "https://www.curseforge.com/minecraft/mc-mods/engineers-decor/", "1.14.4": { + "1.0.19-b2": "[F] Fixed Floor Grating item pass-through jitters (thx Cid).\n[M] Removed obsolete recipe collision testing recipes.\n[F] Fixed missing Block Breaker dynamic block drops.\n[F] Block Placer planting race condition issue fixed (issue #83, thx jcardii).\n[F] Factory Hopper: Added second standard insertion after smart-insert to circumcent compat issues (issue #84, thx NillerMedDild).", "1.0.19-b1": "[F] Fixed Tree Cutter / Block Breaker not accepting small energy transfers (thx WindFox, issue #82).", "1.0.18-b4": "[M] Lang update ru_ru (PR#77, thanks Smollet777).\n[F] Fixed Milking machine cow path issue, added milking delay cow tracking.\n[F] Slab / Slab Slice placement adapted to vanilla standard.", "1.0.18-b3": "[A] Added Treated Wood Crafting table tweaks (ctrl-shift moves all same stacks from the inventory, mouse wheel over crafting slot increases/decreases crafting grid stacks).\n[F] EN Lang file fixed (issue #76, thx Riverstar907).\n[F] Fixed Tree Cutter not respecting power-required config (thx federsavo, issue #77).\n[F] Fixed Small Solar Panel not exposing energy capability (thx MatthiasMann, issue #78).", @@ -45,6 +46,6 @@ }, "promos": { "1.14.4-recommended": "", - "1.14.4-latest": "1.0.19-b1" + "1.14.4-latest": "1.0.19-b2" } } \ No newline at end of file diff --git a/1.14/readme.md b/1.14/readme.md index 8a76feb..05b80e8 100644 --- a/1.14/readme.md +++ b/1.14/readme.md @@ -11,6 +11,12 @@ Mod sources for Minecraft version 1.14.4. ## Version history + - v1.0.19-b2 [F] Fixed Floor Grating item pass-through jitters (thx Cid). + [M] Removed obsolete recipe collision testing recipes. + [F] Fixed missing Block Breaker dynamic block drops. + [F] Block Placer planting race condition issue fixed (issue #83, thx jcardii). + [F] Factory Hopper: Added second standard insertion after smart-insert to circumcent compat issues (issue #84, thx NillerMedDild). + - v1.0.19-b1 [F] Fixed Tree Cutter / Block Breaker not accepting small energy transfers (thx WindFox, issue #82). - v1.0.18-b4 [M] Lang update ru_ru (PR#77, thanks Smollet777). diff --git a/1.14/src/main/java/wile/engineersdecor/ModContent.java b/1.14/src/main/java/wile/engineersdecor/ModContent.java index 5323bf6..e201422 100644 --- a/1.14/src/main/java/wile/engineersdecor/ModContent.java +++ b/1.14/src/main/java/wile/engineersdecor/ModContent.java @@ -14,7 +14,7 @@ package wile.engineersdecor; import wile.engineersdecor.blocks.*; -import wile.engineersdecor.detail.ModAuxiliaries; +import wile.engineersdecor.libmc.detail.Auxiliaries; import net.minecraft.client.gui.ScreenManager; import net.minecraft.inventory.container.ContainerType; import net.minecraft.entity.Entity; @@ -216,55 +216,55 @@ public class ModContent public static final BlockDecor.WaterLoggable TREATED_WOOD_TABLE = (BlockDecor.WaterLoggable)(new BlockDecor.WaterLoggable( BlockDecor.CFG_CUTOUT, Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(2f, 15f).sound(SoundType.WOOD), - ModAuxiliaries.getPixeledAABB(1,0,1, 15,15.9,15) + Auxiliaries.getPixeledAABB(1,0,1, 15,15.9,15) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "treated_wood_table")); public static final BlockDecorChair TREATED_WOOD_STOOL = (BlockDecorChair)(new BlockDecorChair( BlockDecor.CFG_CUTOUT|BlockDecor.CFG_HORIZIONTAL|BlockDecor.CFG_LOOK_PLACEMENT, Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(2f, 15f).sound(SoundType.WOOD), - ModAuxiliaries.getPixeledAABB(4.1,0,4.1, 11.8,8.8,11.8) + Auxiliaries.getPixeledAABB(4.1,0,4.1, 11.8,8.8,11.8) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "treated_wood_stool")); public static final BlockDecor.WaterLoggable TREATED_WOOD_SIDE_TABLE = (BlockDecor.WaterLoggable)(new BlockDecor.WaterLoggable( BlockDecor.CFG_CUTOUT|BlockDecor.CFG_HORIZIONTAL|BlockDecor.CFG_LOOK_PLACEMENT, Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(2f, 15f).sound(SoundType.WOOD), - ModAuxiliaries.getPixeledAABB(2,0,2, 14,15.9,14) + Auxiliaries.getPixeledAABB(2,0,2, 14,15.9,14) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "treated_wood_side_table")); - public static final BlockDecorDirected.WaterLoggable TREATED_WOOD_WINDOWSILL = (BlockDecorDirected.WaterLoggable)(new BlockDecorDirected.WaterLoggable( + public static final BlockDecor.DirectedWaterLoggable TREATED_WOOD_WINDOWSILL = (BlockDecor.DirectedWaterLoggable)(new BlockDecor.DirectedWaterLoggable( BlockDecor.CFG_CUTOUT|BlockDecor.CFG_HORIZIONTAL|BlockDecor.CFG_FACING_PLACEMENT, Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(2f, 15f).sound(SoundType.WOOD), - ModAuxiliaries.getPixeledAABB(0.5,15,10.5, 15.5,16,16) + Auxiliaries.getPixeledAABB(0.5,15,10.5, 15.5,16,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "treated_wood_windowsill")); - public static final BlockDecorDirected.WaterLoggable TREATED_WOOD_BROAD_WINDOWSILL = (BlockDecorDirected.WaterLoggable)(new BlockDecorDirected.WaterLoggable( + public static final BlockDecor.DirectedWaterLoggable TREATED_WOOD_BROAD_WINDOWSILL = (BlockDecor.DirectedWaterLoggable)(new BlockDecor.DirectedWaterLoggable( BlockDecor.CFG_CUTOUT|BlockDecor.CFG_HORIZIONTAL|BlockDecor.CFG_FACING_PLACEMENT, Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(2f, 15f).sound(SoundType.WOOD), - ModAuxiliaries.getPixeledAABB(0,14.5,4, 16,16,16) + Auxiliaries.getPixeledAABB(0,14.5,4, 16,16,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "treated_wood_broad_windowsill")); - public static final BlockDecorDirected.WaterLoggable INSET_LIGHT_IRON = (BlockDecorDirected.WaterLoggable)(new BlockDecorDirected.WaterLoggable( - BlockDecor.CFG_CUTOUT|BlockDecor.CFG_OPPOSITE_PLACEMENT, + public static final BlockDecor.DirectedWaterLoggable INSET_LIGHT_IRON = (BlockDecor.DirectedWaterLoggable)(new BlockDecor.DirectedWaterLoggable( + BlockDecor.CFG_CUTOUT|BlockDecor.CFG_FACING_PLACEMENT|BlockDecor.CFG_OPPOSITE_PLACEMENT, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).lightValue(15), - ModAuxiliaries.getPixeledAABB(5.2,5.2,15.7, 10.8,10.8,16.0) + Auxiliaries.getPixeledAABB(5.2,5.2,0, 10.8,10.8,0.3) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "iron_inset_light")); - public static final BlockDecorDirected.WaterLoggable FLOOR_EDGE_LIGHT_IRON = (BlockDecorDirected.WaterLoggable)(new BlockDecorDirected.WaterLoggable( + public static final BlockDecor.DirectedWaterLoggable FLOOR_EDGE_LIGHT_IRON = (BlockDecor.DirectedWaterLoggable)(new BlockDecor.DirectedWaterLoggable( BlockDecor.CFG_CUTOUT|BlockDecor.CFG_LOOK_PLACEMENT|BlockDecor.CFG_HORIZIONTAL, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).lightValue(15), - ModAuxiliaries.getPixeledAABB(5,0,0, 11,2,1) + Auxiliaries.getPixeledAABB(5,0,0, 11,2,0.5) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "iron_floor_edge_light")); public static final BlockDecor.WaterLoggable STEEL_TABLE = (BlockDecor.WaterLoggable)(new BlockDecor.WaterLoggable( - BlockDecor.CFG_CUTOUT|BlockDecor.CFG_HORIZIONTAL|BlockDecor.CFG_LOOK_PLACEMENT, + BlockDecor.CFG_CUTOUT, Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(2f, 15f).sound(SoundType.WOOD), - ModAuxiliaries.getPixeledAABB(0,0,0, 16,16,16) + Auxiliaries.getPixeledAABB(0,0,0, 16,16,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "steel_table")); - public static final BlockDecor STEEL_FLOOR_GRATING = (BlockDecorFloorGrating)(new BlockDecorFloorGrating( + public static final BlockDecorFloorGrating STEEL_FLOOR_GRATING = (BlockDecorFloorGrating)(new BlockDecorFloorGrating( BlockDecor.CFG_CUTOUT, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL), - ModAuxiliaries.getPixeledAABB(0,14,0, 16,16,16) + Auxiliaries.getPixeledAABB(0,14,0, 16,15.9,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "steel_floor_grating")); // ------------------------------------------------------------------------------------------------------------------- @@ -272,13 +272,13 @@ public class ModContent public static final BlockDecorWindow TREATED_WOOD_WINDOW = (BlockDecorWindow)(new BlockDecorWindow( BlockDecor.CFG_LOOK_PLACEMENT, Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(2f, 15f).sound(SoundType.GLASS), - ModAuxiliaries.getPixeledAABB(0,0,7, 16,16,9) + Auxiliaries.getPixeledAABB(0,0,7, 16,16,9) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "treated_wood_window")); public static final BlockDecorWindow STEEL_FRAMED_WINDOW = (BlockDecorWindow)(new BlockDecorWindow( BlockDecor.CFG_LOOK_PLACEMENT, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.GLASS), - ModAuxiliaries.getPixeledAABB(0,0,7.5, 16,16,8.5) + Auxiliaries.getPixeledAABB(0,0,7.5, 16,16,8.5) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "steel_framed_window")); // ------------------------------------------------------------------------------------------------------------------- @@ -286,87 +286,87 @@ public class ModContent public static final BlockDecorStraightPole TREATED_WOOD_POLE = (BlockDecorStraightPole)(new BlockDecorStraightPole( BlockDecor.CFG_CUTOUT|BlockDecor.CFG_FACING_PLACEMENT|BlockDecor.CFG_FLIP_PLACEMENT_IF_SAME, Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(2f, 15f).sound(SoundType.WOOD), - ModAuxiliaries.getPixeledAABB(5.8,5.8,0, 10.2,10.2,16) + Auxiliaries.getPixeledAABB(5.8,5.8,0, 10.2,10.2,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "treated_wood_pole")); public static final BlockDecorStraightPole TREATED_WOOD_POLE_HEAD = (BlockDecorStraightPole)(new BlockDecorStraightPole( BlockDecor.CFG_CUTOUT|BlockDecor.CFG_FACING_PLACEMENT|BlockDecor.CFG_FLIP_PLACEMENT_IF_SAME, Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(2f, 15f).sound(SoundType.WOOD), - ModAuxiliaries.getPixeledAABB(5.8,5.8,0, 10.2,10.2,16) + Auxiliaries.getPixeledAABB(5.8,5.8,0, 10.2,10.2,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "treated_wood_pole_head")); public static final BlockDecorStraightPole TREATED_WOOD_POLE_SUPPORT = (BlockDecorStraightPole)(new BlockDecorStraightPole( BlockDecor.CFG_CUTOUT|BlockDecor.CFG_FACING_PLACEMENT|BlockDecor.CFG_FLIP_PLACEMENT_IF_SAME, Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(2f, 15f).sound(SoundType.WOOD), - ModAuxiliaries.getPixeledAABB(5.8,5.8,0, 10.2,10.2,16) + Auxiliaries.getPixeledAABB(5.8,5.8,0, 10.2,10.2,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "treated_wood_pole_support")); public static final BlockDecorStraightPole THIN_STEEL_POLE = (BlockDecorStraightPole)(new BlockDecorStraightPole( BlockDecor.CFG_CUTOUT|BlockDecor.CFG_FACING_PLACEMENT, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL), - ModAuxiliaries.getPixeledAABB(6,6,0, 10,10,16) + Auxiliaries.getPixeledAABB(6,6,0, 10,10,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "thin_steel_pole")); public static final BlockDecorStraightPole THIN_STEEL_POLE_HEAD = (BlockDecorStraightPole)(new BlockDecorStraightPole( BlockDecor.CFG_CUTOUT|BlockDecor.CFG_FACING_PLACEMENT|BlockDecor.CFG_FLIP_PLACEMENT_IF_SAME, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL), - ModAuxiliaries.getPixeledAABB(6,6,0, 10,10,16) + Auxiliaries.getPixeledAABB(6,6,0, 10,10,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "thin_steel_pole_head")); public static final BlockDecorStraightPole THICK_STEEL_POLE = (BlockDecorStraightPole)(new BlockDecorStraightPole( BlockDecor.CFG_CUTOUT|BlockDecor.CFG_FACING_PLACEMENT, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL), - ModAuxiliaries.getPixeledAABB(5,5,0, 11,11,16) + Auxiliaries.getPixeledAABB(5,5,0, 11,11,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "thick_steel_pole")); public static final BlockDecorStraightPole THICK_STEEL_POLE_HEAD = (BlockDecorStraightPole)(new BlockDecorStraightPole( BlockDecor.CFG_CUTOUT|BlockDecor.CFG_FACING_PLACEMENT|BlockDecor.CFG_FLIP_PLACEMENT_IF_SAME, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL), - ModAuxiliaries.getPixeledAABB(5,5,0, 11,11,16) + Auxiliaries.getPixeledAABB(5,5,0, 11,11,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "thick_steel_pole_head")); public static final BlockDecorHorizontalSupport STEEL_DOUBLE_T_SUPPORT = (BlockDecorHorizontalSupport)(new BlockDecorHorizontalSupport( BlockDecor.CFG_CUTOUT|BlockDecor.CFG_HORIZIONTAL|BlockDecor.CFG_LOOK_PLACEMENT, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL), - ModAuxiliaries.getPixeledAABB(5,11,0, 11,16,16) + Auxiliaries.getPixeledAABB(5,11,0, 11,16,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "steel_double_t_support")); // ------------------------------------------------------------------------------------------------------------------- - public static final BlockDecorDirected.WaterLoggable SIGN_MODLOGO = (BlockDecorDirected.WaterLoggable)(new BlockDecorDirected.WaterLoggable( + public static final BlockDecor.DirectedWaterLoggable SIGN_MODLOGO = (BlockDecor.DirectedWaterLoggable)(new BlockDecor.DirectedWaterLoggable( BlockDecor.CFG_CUTOUT|BlockDecor.CFG_FACING_PLACEMENT|BlockDecor.CFG_HORIZIONTAL, Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(1f, 1000f).sound(SoundType.WOOD).lightValue(1), - ModAuxiliaries.getPixeledAABB(0,0,15.6, 16,16,16.0) + Auxiliaries.getPixeledAABB(0,0,15.6, 16,16,16.0) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "sign_decor")); - public static final BlockDecorDirected.WaterLoggable SIGN_HOTWIRE = (BlockDecorDirected.WaterLoggable)(new BlockDecorDirected.WaterLoggable( + public static final BlockDecor.DirectedWaterLoggable SIGN_HOTWIRE = (BlockDecor.DirectedWaterLoggable)(new BlockDecor.DirectedWaterLoggable( BlockDecor.CFG_CUTOUT|BlockDecor.CFG_FACING_PLACEMENT|BlockDecor.CFG_HORIZIONTAL, Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(1f, 1f).sound(SoundType.WOOD), - ModAuxiliaries.getPixeledAABB(2,2,15.6, 14,14,16) + Auxiliaries.getPixeledAABB(2,2,15.6, 14,14,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "sign_hotwire")); - public static final BlockDecorDirected.WaterLoggable SIGN_DANGER = (BlockDecorDirected.WaterLoggable)(new BlockDecorDirected.WaterLoggable( + public static final BlockDecor.DirectedWaterLoggable SIGN_DANGER = (BlockDecor.DirectedWaterLoggable)(new BlockDecor.DirectedWaterLoggable( BlockDecor.CFG_CUTOUT|BlockDecor.CFG_FACING_PLACEMENT|BlockDecor.CFG_HORIZIONTAL, Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(1f, 1f).sound(SoundType.WOOD), - ModAuxiliaries.getPixeledAABB(2,2,15.6, 14,14,16) + Auxiliaries.getPixeledAABB(2,2,15.6, 14,14,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "sign_danger")); - public static final BlockDecorDirected.WaterLoggable SIGN_DEFENSE = (BlockDecorDirected.WaterLoggable)(new BlockDecorDirected.WaterLoggable( + public static final BlockDecor.DirectedWaterLoggable SIGN_DEFENSE = (BlockDecor.DirectedWaterLoggable)(new BlockDecor.DirectedWaterLoggable( BlockDecor.CFG_CUTOUT|BlockDecor.CFG_FACING_PLACEMENT|BlockDecor.CFG_HORIZIONTAL, Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(1f, 1f).sound(SoundType.WOOD), - ModAuxiliaries.getPixeledAABB(2,2,15.6, 14,14,16) + Auxiliaries.getPixeledAABB(2,2,15.6, 14,14,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "sign_defense")); - public static final BlockDecorDirected.WaterLoggable SIGN_FACTORY_AREA = (BlockDecorDirected.WaterLoggable)(new BlockDecorDirected.WaterLoggable( + public static final BlockDecor.DirectedWaterLoggable SIGN_FACTORY_AREA = (BlockDecor.DirectedWaterLoggable)(new BlockDecor.DirectedWaterLoggable( BlockDecor.CFG_CUTOUT|BlockDecor.CFG_FACING_PLACEMENT|BlockDecor.CFG_HORIZIONTAL, Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(1f, 1f).sound(SoundType.WOOD), - ModAuxiliaries.getPixeledAABB(2,2,15.6, 14,14,16) + Auxiliaries.getPixeledAABB(2,2,15.6, 14,14,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "sign_factoryarea")); - public static final BlockDecorDirected.WaterLoggable SIGN_EXIT = (BlockDecorDirected.WaterLoggable)(new BlockDecorDirected.WaterLoggable( + public static final BlockDecor.DirectedWaterLoggable SIGN_EXIT = (BlockDecor.DirectedWaterLoggable)(new BlockDecor.DirectedWaterLoggable( BlockDecor.CFG_CUTOUT|BlockDecor.CFG_FACING_PLACEMENT|BlockDecor.CFG_HORIZIONTAL, Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(1f, 1f).sound(SoundType.WOOD), - ModAuxiliaries.getPixeledAABB(3,7,15.6, 13,13,16) + Auxiliaries.getPixeledAABB(3,7,15.6, 13,13,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "sign_exit")); // ------------------------------------------------------------------------------------------------------------------- @@ -374,103 +374,106 @@ public class ModContent public static final BlockDecorCraftingTable.CraftingTableBlock TREATED_WOOD_CRAFTING_TABLE = (BlockDecorCraftingTable.CraftingTableBlock)(new BlockDecorCraftingTable.CraftingTableBlock( BlockDecor.CFG_CUTOUT|BlockDecor.CFG_HORIZIONTAL|BlockDecor.CFG_LOOK_PLACEMENT|BlockDecor.CFG_OPPOSITE_PLACEMENT, Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(1f, 15f).sound(SoundType.WOOD), - ModAuxiliaries.getPixeledAABB(1,0,1, 15,15.9,15) + Auxiliaries.getPixeledAABB(1,0,1, 15,15.9,15) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "treated_wood_crafting_table")); public static final BlockDecorFurnace SMALL_LAB_FURNACE = (BlockDecorFurnace)(new BlockDecorFurnace( - BlockDecor.CFG_CUTOUT|BlockDecor.CFG_HORIZIONTAL|BlockDecor.CFG_LOOK_PLACEMENT, + BlockDecor.CFG_CUTOUT|BlockDecor.CFG_HORIZIONTAL|BlockDecor.CFG_LOOK_PLACEMENT|BlockDecor.CFG_OPPOSITE_PLACEMENT, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(1f, 15f).sound(SoundType.METAL), - ModAuxiliaries.getPixeledAABB(1,0,1, 15,15,16.0) + Auxiliaries.getPixeledAABB(1,0,1, 15,15,16.0) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "small_lab_furnace")); public static final BlockDecorFurnaceElectrical SMALL_ELECTRICAL_FURNACE = (BlockDecorFurnaceElectrical)(new BlockDecorFurnaceElectrical( - BlockDecor.CFG_CUTOUT|BlockDecor.CFG_HORIZIONTAL|BlockDecor.CFG_LOOK_PLACEMENT|BlockDecor.CFG_ELECTRICAL, + BlockDecor.CFG_CUTOUT|BlockDecor.CFG_HORIZIONTAL|BlockDecor.CFG_LOOK_PLACEMENT|BlockDecor.CFG_OPPOSITE_PLACEMENT, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL), - ModAuxiliaries.getPixeledAABB(0,0,0, 16,16,16) + Auxiliaries.getPixeledAABB(0,0,0, 16,16,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "small_electrical_furnace")); public static final BlockDecorDropper FACTORY_DROPPER = (BlockDecorDropper)(new BlockDecorDropper( - BlockDecor.CFG_LOOK_PLACEMENT|BlockDecor.CFG_OPPOSITE_PLACEMENT|BlockDecor.CFG_REDSTONE_CONTROLLED, + BlockDecor.CFG_LOOK_PLACEMENT|BlockDecor.CFG_OPPOSITE_PLACEMENT, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL), - ModAuxiliaries.getPixeledAABB(0,0,0, 16,16,15) + Auxiliaries.getPixeledAABB(0,0,1, 16,16,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "factory_dropper")); public static final BlockDecorPlacer FACTORY_PLACER = (BlockDecorPlacer)(new BlockDecorPlacer( - BlockDecor.CFG_LOOK_PLACEMENT|BlockDecor.CFG_FLIP_PLACEMENT_SHIFTCLICK|BlockDecor.CFG_OPPOSITE_PLACEMENT|BlockDecor.CFG_REDSTONE_CONTROLLED, + BlockDecor.CFG_LOOK_PLACEMENT|BlockDecor.CFG_FLIP_PLACEMENT_SHIFTCLICK|BlockDecor.CFG_OPPOSITE_PLACEMENT, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL), - ModAuxiliaries.getPixeledAABB(2,2,2, 14,14,14) + Auxiliaries.getPixeledAABB(2,2,2, 14,14,14) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "factory_placer")); public static final BlockDecorBreaker SMALL_BLOCK_BREAKER = (BlockDecorBreaker)(new BlockDecorBreaker( BlockDecor.CFG_HORIZIONTAL|BlockDecor.CFG_LOOK_PLACEMENT|BlockDecor.CFG_OPPOSITE_PLACEMENT|BlockDecor.CFG_FLIP_PLACEMENT_SHIFTCLICK, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL), - ModAuxiliaries.getPixeledAABB(0,0,0, 16,12,16) + Auxiliaries.getPixeledAABB(0,0,0, 16,12,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "small_block_breaker")); public static final BlockDecorHopper FACTORY_HOPPER = (BlockDecorHopper)(new BlockDecorHopper( - BlockDecor.CFG_CUTOUT|BlockDecor.CFG_FACING_PLACEMENT|BlockDecor.CFG_OPPOSITE_PLACEMENT|BlockDecor.CFG_REDSTONE_CONTROLLED, + BlockDecor.CFG_CUTOUT|BlockDecor.CFG_FACING_PLACEMENT|BlockDecor.CFG_OPPOSITE_PLACEMENT, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL), - ModAuxiliaries.getPixeledAABB(0,0,0, 16,16,16) + Auxiliaries.getPixeledAABB(0,0,0, 16,16,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "factory_hopper")); public static final BlockDecorWasteIncinerator SMALL_WASTE_INCINERATOR = (BlockDecorWasteIncinerator)(new BlockDecorWasteIncinerator( - BlockDecor.CFG_DEFAULT|BlockDecor.CFG_ELECTRICAL, + BlockDecor.CFG_DEFAULT, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL), - ModAuxiliaries.getPixeledAABB(0,0,0, 16,16,16) + Auxiliaries.getPixeledAABB(0,0,0, 16,16,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "small_waste_incinerator")); public static final BlockDecorMineralSmelter SMALL_MINERAL_SMELTER = (BlockDecorMineralSmelter)(new BlockDecorMineralSmelter( - BlockDecor.CFG_CUTOUT|BlockDecor.CFG_HORIZIONTAL|BlockDecor.CFG_LOOK_PLACEMENT|BlockDecor.CFG_ELECTRICAL, + BlockDecor.CFG_CUTOUT|BlockDecor.CFG_HORIZIONTAL|BlockDecor.CFG_LOOK_PLACEMENT, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL), - ModAuxiliaries.getPixeledAABB(1.1,0,1.1, 14.9,16,14.9) + Auxiliaries.getPixeledAABB(1.1,0,1.1, 14.9,16,14.9) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "small_mineral_smelter")); public static final BlockDecorSolarPanel SMALL_SOLAR_PANEL = (BlockDecorSolarPanel)(new BlockDecorSolarPanel( - BlockDecor.CFG_CUTOUT|BlockDecor.CFG_HORIZIONTAL|BlockDecor.CFG_LOOK_PLACEMENT|BlockDecor.CFG_ELECTRICAL, + BlockDecor.CFG_CUTOUT, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL), - ModAuxiliaries.getPixeledAABB(0,0,0, 16,11.5,16) + Auxiliaries.getPixeledAABB(0,0,0, 16,11.5,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "small_solar_panel")); public static final BlockDecorMilker SMALL_MILKING_MACHINE = (BlockDecorMilker)(new BlockDecorMilker( - BlockDecor.CFG_LOOK_PLACEMENT|BlockDecor.CFG_HORIZIONTAL|BlockDecor.CFG_CUTOUT|BlockDecor.CFG_ELECTRICAL, + BlockDecor.CFG_CUTOUT|BlockDecor.CFG_HORIZIONTAL|BlockDecor.CFG_LOOK_PLACEMENT, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL), - ModAuxiliaries.getPixeledAABB(0,0,0, 16,16,13) + Auxiliaries.getPixeledAABB(0,0,0, 16,16,13) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "small_milking_machine")); public static final BlockDecorTreeCutter SMALL_TREE_CUTTER = (BlockDecorTreeCutter)(new BlockDecorTreeCutter( BlockDecor.CFG_CUTOUT|BlockDecor.CFG_HORIZIONTAL|BlockDecor.CFG_LOOK_PLACEMENT|BlockDecor.CFG_FLIP_PLACEMENT_SHIFTCLICK, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL), - ModAuxiliaries.getPixeledAABB(0,0,0, 16,8,16) + Auxiliaries.getPixeledAABB(0,0,0, 16,8,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "small_tree_cutter")); public static final BlockDecorPipeValve STRAIGHT_CHECK_VALVE = (BlockDecorPipeValve)(new BlockDecorPipeValve( - BlockDecor.CFG_FACING_PLACEMENT|BlockDecor.CFG_OPPOSITE_PLACEMENT|BlockDecor.CFG_FLIP_PLACEMENT_SHIFTCLICK|BlockDecor.CFG_CUTOUT, + BlockDecor.CFG_CUTOUT|BlockDecor.CFG_FACING_PLACEMENT|BlockDecor.CFG_OPPOSITE_PLACEMENT|BlockDecor.CFG_FLIP_PLACEMENT_SHIFTCLICK, + BlockDecorPipeValve.CFG_CHECK_VALVE, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL), - ModAuxiliaries.getPixeledAABB(4,4,0, 12,12,16) + Auxiliaries.getPixeledAABB(4,4,0, 12,12,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "straight_pipe_valve")); public static final BlockDecorPipeValve STRAIGHT_REDSTONE_VALVE = (BlockDecorPipeValve)(new BlockDecorPipeValve( - BlockDecor.CFG_FACING_PLACEMENT|BlockDecor.CFG_OPPOSITE_PLACEMENT|BlockDecor.CFG_FLIP_PLACEMENT_SHIFTCLICK|BlockDecor.CFG_CUTOUT|BlockDecor.CFG_REDSTONE_CONTROLLED, + BlockDecor.CFG_CUTOUT|BlockDecor.CFG_FACING_PLACEMENT|BlockDecor.CFG_OPPOSITE_PLACEMENT|BlockDecor.CFG_FLIP_PLACEMENT_SHIFTCLICK, + BlockDecorPipeValve.CFG_REDSTONE_CONTROLLED_VALVE, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL), - ModAuxiliaries.getPixeledAABB(4,4,0, 12,12,16) + Auxiliaries.getPixeledAABB(4,4,0, 12,12,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "straight_pipe_valve_redstone")); public static final BlockDecorPipeValve STRAIGHT_REDSTONE_ANALOG_VALVE = (BlockDecorPipeValve)(new BlockDecorPipeValve( - BlockDecor.CFG_FACING_PLACEMENT|BlockDecor.CFG_OPPOSITE_PLACEMENT|BlockDecor.CFG_FLIP_PLACEMENT_SHIFTCLICK|BlockDecor.CFG_CUTOUT|BlockDecor.CFG_REDSTONE_CONTROLLED|BlockDecor.CFG_ANALOG, + BlockDecor.CFG_CUTOUT|BlockDecor.CFG_FACING_PLACEMENT|BlockDecor.CFG_OPPOSITE_PLACEMENT|BlockDecor.CFG_FLIP_PLACEMENT_SHIFTCLICK, + BlockDecorPipeValve.CFG_REDSTONE_CONTROLLED_VALVE|BlockDecorPipeValve.CFG_ANALOG_VALVE, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL), - ModAuxiliaries.getPixeledAABB(4,4,0, 12,12,16) + Auxiliaries.getPixeledAABB(4,4,0, 12,12,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "straight_pipe_valve_redstone_analog")); public static final BlockDecorPassiveFluidAccumulator PASSIVE_FLUID_ACCUMULATOR = (BlockDecorPassiveFluidAccumulator)(new BlockDecorPassiveFluidAccumulator( - BlockDecor.CFG_FACING_PLACEMENT|BlockDecor.CFG_OPPOSITE_PLACEMENT|BlockDecor.CFG_FLIP_PLACEMENT_SHIFTCLICK|BlockDecor.CFG_CUTOUT, + BlockDecor.CFG_CUTOUT|BlockDecor.CFG_FACING_PLACEMENT|BlockDecor.CFG_OPPOSITE_PLACEMENT|BlockDecor.CFG_FLIP_PLACEMENT_SHIFTCLICK, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL), - ModAuxiliaries.getPixeledAABB(0,0,0, 16,16,16) + Auxiliaries.getPixeledAABB(0,0,0, 16,16,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "passive_fluid_accumulator")); public static final BlockDecorFluidFunnel SMALL_FLUID_FUNNEL = (BlockDecorFluidFunnel)(new BlockDecorFluidFunnel( - BlockDecor.CFG_CUTOUT|BlockDecor.CFG_REDSTONE_CONTROLLED, + BlockDecor.CFG_CUTOUT, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL), - ModAuxiliaries.getPixeledAABB(0,0,0, 16,16,16) + Auxiliaries.getPixeledAABB(0,0,0, 16,16,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "small_fluid_funnel")); // ------------------------------------------------------------------------------------------------------------------- @@ -525,9 +528,9 @@ public class ModContent // ------------------------------------------------------------------------------------------------------------------- public static final BlockDecorTest TEST_BLOCK = (BlockDecorTest)(new BlockDecorTest( - BlockDecor.CFG_LOOK_PLACEMENT|BlockDecor.CFG_FLIP_PLACEMENT_SHIFTCLICK|BlockDecor.CFG_ELECTRICAL|BlockDecor.CFG_REDSTONE_CONTROLLED, + BlockDecor.CFG_LOOK_PLACEMENT|BlockDecor.CFG_FLIP_PLACEMENT_SHIFTCLICK, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(0f, 32000f).sound(SoundType.METAL), - ModAuxiliaries.getPixeledAABB(0,0,0, 16,16,16) + Auxiliaries.getPixeledAABB(0,0,0, 16,16,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "test_block")); // ------------------------------------------------------------------------------------------------------------------- @@ -802,10 +805,10 @@ public class ModContent public static final void registerBlocks(final RegistryEvent.Register event) { - if(ModAuxiliaries.isModLoaded("immersiveengineering")) ModAuxiliaries.logInfo("Immersive Engineering also installed ..."); + if(Auxiliaries.isModLoaded("immersiveengineering")) Auxiliaries.logInfo("Immersive Engineering also installed ..."); registeredBlocks.addAll(allBlocks()); for(Block e:registeredBlocks) event.getRegistry().register(e); - ModAuxiliaries.logInfo("Registered " + Integer.toString(registeredBlocks.size()) + " blocks."); + Auxiliaries.logInfo("Registered " + Integer.toString(registeredBlocks.size()) + " blocks."); } public static final void registerBlockItems(final RegistryEvent.Register event) @@ -826,7 +829,7 @@ public class ModContent event.getRegistry().register(e); ++n_registered; } - ModAuxiliaries.logInfo("Registered " + Integer.toString(n_registered) + " tile entities."); + Auxiliaries.logInfo("Registered " + Integer.toString(n_registered) + " tile entities."); } public static final void registerEntities(final RegistryEvent.Register> event) @@ -837,7 +840,7 @@ public class ModContent event.getRegistry().register(e); ++n_registered; } - ModAuxiliaries.logInfo("Registered " + Integer.toString(n_registered) + " entities bound to blocks."); + Auxiliaries.logInfo("Registered " + Integer.toString(n_registered) + " entities bound to blocks."); } public static final void registerContainers(final RegistryEvent.Register> event) @@ -847,7 +850,7 @@ public class ModContent event.getRegistry().register(e); ++n_registered; } - ModAuxiliaries.logInfo("Registered " + Integer.toString(n_registered) + " containers bound to tile entities."); + Auxiliaries.logInfo("Registered " + Integer.toString(n_registered) + " containers bound to tile entities."); } @OnlyIn(Dist.CLIENT) diff --git a/1.14/src/main/java/wile/engineersdecor/ModEngineersDecor.java b/1.14/src/main/java/wile/engineersdecor/ModEngineersDecor.java index 3eb4c66..2edd3de 100644 --- a/1.14/src/main/java/wile/engineersdecor/ModEngineersDecor.java +++ b/1.14/src/main/java/wile/engineersdecor/ModEngineersDecor.java @@ -1,20 +1,15 @@ package wile.engineersdecor; -import net.minecraft.client.util.InputMappings; -import org.lwjgl.glfw.GLFW; -import wile.engineersdecor.detail.ModAuxiliaries; +import wile.engineersdecor.libmc.detail.Auxiliaries; import wile.engineersdecor.detail.ModConfig; -import wile.engineersdecor.detail.Networking; import wile.engineersdecor.blocks.*; -import wile.engineersdecor.detail.OptionalRecipeCondition.Serializer; -import wile.engineersdecor.datagen.ModLootTables; -import net.minecraft.client.Minecraft; +import wile.engineersdecor.libmc.detail.OptionalRecipeCondition; +import wile.engineersdecor.libmc.detail.Networking; import net.minecraft.entity.EntityType; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.inventory.container.ContainerType; import net.minecraft.item.ItemGroup; import net.minecraft.tileentity.TileEntityType; -import net.minecraft.world.World; import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -23,7 +18,6 @@ import net.minecraftforge.event.entity.living.LivingEvent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.ModLoadingContext; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.*; @@ -34,10 +28,6 @@ import net.minecraftforge.api.distmarker.OnlyIn; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import javax.annotation.Nullable; -import java.util.Optional; - - @Mod("engineersdecor") public class ModEngineersDecor { @@ -49,7 +39,9 @@ public class ModEngineersDecor public ModEngineersDecor() { - ModAuxiliaries.logGitVersion(MODNAME); + Auxiliaries.init(MODID, LOGGER, ModConfig::getServerConfig); + Auxiliaries.logGitVersion(MODNAME); + OptionalRecipeCondition.init(MODID, LOGGER); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onSetup); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onSendImc); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onRecvImc); @@ -68,8 +60,8 @@ public class ModEngineersDecor private void onSetup(final FMLCommonSetupEvent event) { LOGGER.info("Registering recipe condition processor ..."); - CraftingHelper.register(Serializer.INSTANCE); - Networking.init(); + CraftingHelper.register(OptionalRecipeCondition.Serializer.INSTANCE); + Networking.init(MODID); if(config_loaded) { try { logger().info("Applying loaded config file."); @@ -136,31 +128,10 @@ public class ModEngineersDecor @SubscribeEvent public static void onDataGeneration(GatherDataEvent event) { - event.getGenerator().addProvider(new ModLootTables(event.getGenerator())); + event.getGenerator().addProvider(new wile.engineersdecor.libmc.datagen.LootTableGen(event.getGenerator(), ModContent::allBlocks)); } } - // - // Sided proxy functionality (skel) - // - public static ISidedProxy proxy = DistExecutor.runForDist(()->ClientProxy::new, ()->ServerProxy::new); - public interface ISidedProxy - { - default @Nullable PlayerEntity getPlayerClientSide() { return null; } - default @Nullable World getWorldClientSide() { return null; } - default @Nullable Minecraft mc() { return null; } - default Optional isCtrlDown() { return Optional.empty(); } - } - public static final class ClientProxy implements ISidedProxy - { - public @Nullable PlayerEntity getPlayerClientSide() { return Minecraft.getInstance().player; } - public @Nullable World getWorldClientSide() { return Minecraft.getInstance().world; } - public @Nullable Minecraft mc() { return Minecraft.getInstance(); } - public Optional isCtrlDown() { return Optional.of(ModAuxiliaries.isCtrlDown()); } - } - public static final class ServerProxy implements ISidedProxy - {} - // // Item group / creative tab // diff --git a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecor.java b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecor.java index 9aa37bb..fc6635b 100644 --- a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecor.java +++ b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecor.java @@ -12,195 +12,73 @@ */ package wile.engineersdecor.blocks; +import wile.engineersdecor.libmc.blocks.StandardBlocks; +import wile.engineersdecor.libmc.blocks.StandardBlocks.IStandardBlock; +import wile.engineersdecor.libmc.detail.Auxiliaries; import net.minecraft.block.IWaterLoggable; -import net.minecraft.state.StateContainer; -import wile.engineersdecor.detail.ModAuxiliaries; -import net.minecraft.state.BooleanProperty; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.fluid.IFluidState; -import net.minecraft.fluid.Fluids; -import net.minecraft.world.IWorld; -import net.minecraft.world.Explosion; -import net.minecraft.world.World; import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.shapes.VoxelShapes; import net.minecraft.block.Block; -import net.minecraft.block.material.PushReaction; -import net.minecraft.block.BlockState; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.item.ItemStack; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.storage.loot.LootContext; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.util.*; -import net.minecraft.util.text.ITextComponent; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import wile.engineersdecor.detail.ModConfig; - -import javax.annotation.Nullable; -import java.util.Collections; -import java.util.List; -public class BlockDecor extends Block implements IDecorBlock +public class BlockDecor extends StandardBlocks.BaseBlock implements IDecorBlock { - public static final long CFG_DEFAULT = 0x0000000000000000L; // no special config - public static final long CFG_CUTOUT = 0x0000000000000001L; // cutout rendering - public static final long CFG_HORIZIONTAL = 0x0000000000000002L; // horizontal block, affects bounding box calculation at construction time and placement - public static final long CFG_LOOK_PLACEMENT = 0x0000000000000004L; // placed in direction the player is looking when placing. - public static final long CFG_FACING_PLACEMENT = 0x0000000000000008L; // placed on the facing the player has clicked. - public static final long CFG_OPPOSITE_PLACEMENT = 0x0000000000000010L; // placed placed in the opposite direction of the face the player clicked. - public static final long CFG_FLIP_PLACEMENT_IF_SAME = 0x0000000000000020L; // placement direction flipped if an instance of the same class was clicked - public static final long CFG_FLIP_PLACEMENT_SHIFTCLICK = 0x0000000000000040L; // placement direction flipped if player is sneaking - public static final long CFG_TRANSLUCENT = 0x0000000000000080L; // indicates a block/pane is glass like (transparent, etc) - public static final long CFG_ELECTRICAL = 0x0000000000010000L; // Denotes if a component is mainly flux driven. - public static final long CFG_REDSTONE_CONTROLLED = 0x0000000000020000L; // Denotes if a component has somehow a redstone control input - public static final long CFG_ANALOG = 0x0000000000040000L; // Denotes if a component has analog behaviour - public static final long CFG_HARD_IE_DEPENDENT = 0x8000000000000000L; // The block is implicitly opt'ed out if IE is not installed - public static final long CFG_WATERLOGGABLE = 0x4000000000000000L; // The derived block extends IWaterLoggable - - public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; - public final long config; - public final VoxelShape vshape; + public static final long CFG_DEFAULT = StandardBlocks.CFG_DEFAULT; + public static final long CFG_CUTOUT = StandardBlocks.CFG_CUTOUT; + public static final long CFG_MIPPED = StandardBlocks.CFG_MIPPED; + public static final long CFG_TRANSLUCENT = StandardBlocks.CFG_TRANSLUCENT; + public static final long CFG_WATERLOGGABLE = StandardBlocks.CFG_WATERLOGGABLE; + public static final long CFG_HORIZIONTAL = StandardBlocks.CFG_HORIZIONTAL; + public static final long CFG_LOOK_PLACEMENT = StandardBlocks.CFG_LOOK_PLACEMENT; + public static final long CFG_FACING_PLACEMENT = StandardBlocks.CFG_FACING_PLACEMENT; + public static final long CFG_OPPOSITE_PLACEMENT = StandardBlocks.CFG_OPPOSITE_PLACEMENT; + public static final long CFG_FLIP_PLACEMENT_IF_SAME = StandardBlocks.CFG_FLIP_PLACEMENT_IF_SAME; + public static final long CFG_FLIP_PLACEMENT_SHIFTCLICK = StandardBlocks.CFG_FLIP_PLACEMENT_SHIFTCLICK; + public static final long CFG_STRICT_CONNECTIONS = StandardBlocks.CFG_STRICT_CONNECTIONS; + public static final long CFG_HARD_IE_DEPENDENT = 0x8000000000000000L; public BlockDecor(long conf, Block.Properties properties) - { this(conf, properties, ModAuxiliaries.getPixeledAABB(0, 0, 0, 16, 16,16 )); } + { super(conf, properties, Auxiliaries.getPixeledAABB(0, 0, 0, 16, 16,16 )); } public BlockDecor(long conf, Block.Properties properties, AxisAlignedBB aabb) - { super(properties); config = conf; vshape = VoxelShapes.create(aabb); } + { super(conf, properties, aabb);} public BlockDecor(long conf, Block.Properties properties, VoxelShape voxel_shape) - { super(properties); config = conf; vshape = voxel_shape; } + { super(conf, properties, voxel_shape); } - @Override - @OnlyIn(Dist.CLIENT) - public void addInformation(ItemStack stack, @Nullable IBlockReader world, List tooltip, ITooltipFlag flag) - { ModAuxiliaries.Tooltip.addInformation(stack, world, tooltip, flag, true); } - - @Override - @OnlyIn(Dist.CLIENT) - public BlockRenderLayer getRenderLayer() - { return ((config & CFG_CUTOUT)!=0) ? BlockRenderLayer.CUTOUT : BlockRenderLayer.SOLID; } - - @Override - @SuppressWarnings("deprecation") - public VoxelShape getShape(BlockState state, IBlockReader source, BlockPos pos, ISelectionContext selectionContext) - { return vshape; } - - @Override - @SuppressWarnings("deprecation") - public VoxelShape getCollisionShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext selectionContext) - { return vshape; } - - @Override - @Nullable - public BlockState getStateForPlacement(BlockItemUseContext context) - { - BlockState state = super.getStateForPlacement(context); - if((config & CFG_WATERLOGGABLE)!=0) { - IFluidState fs = context.getWorld().getFluidState(context.getPos()); - state = state.with(WATERLOGGED,fs.getFluid()==Fluids.WATER); - } - return state; - } - - @Override - public boolean canSpawnInBlock() - { return false; } - - @Override - @SuppressWarnings("deprecation") - public PushReaction getPushReaction(BlockState state) - { return PushReaction.NORMAL; } - - @Override - @SuppressWarnings("deprecation") - public void onReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean isMoving) - { - if(state.hasTileEntity() && (state.getBlock() != newState.getBlock())) { - world.removeTileEntity(pos); - world.updateComparatorOutputLevel(pos, this); - } - } - - public static boolean dropBlock(BlockState state, World world, BlockPos pos, @Nullable PlayerEntity player) - { - if(!(state.getBlock() instanceof IDecorBlock)) { world.removeBlock(pos, false); return true; } - if(!world.isRemote()) { - if((ModConfig.with_creative_mode_device_drops) || (player==null) || (!player.isCreative())) { - ((IDecorBlock)state.getBlock()).dropList(state, world, pos, player==null).forEach(stack->world.addEntity(new ItemEntity(world, pos.getX()+0.5, pos.getY()+0.5, pos.getZ()+0.5, stack))); - } - } - if(state.getBlock().hasTileEntity(state)) world.removeTileEntity(pos); - world.removeBlock(pos, false); - return true; - } - - @Override - public boolean removedByPlayer(BlockState state, World world, BlockPos pos, PlayerEntity player, boolean willHarvest, IFluidState fluid) - { return hasDynamicDropList() ? dropBlock(state, world, pos, player) : super.removedByPlayer(state, world,pos , player, willHarvest, fluid); } - - @Override - public void onExplosionDestroy(World world, BlockPos pos, Explosion explosion) - { if(hasDynamicDropList()) dropBlock(world.getBlockState(pos), world, pos, null); } - - @Override - @SuppressWarnings("deprecation") - public List getDrops(BlockState state, LootContext.Builder builder) - { return hasDynamicDropList() ? Collections.singletonList(ItemStack.EMPTY) : super.getDrops(state, builder); } - - @Override - public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) - { - if((config & CFG_WATERLOGGABLE)!=0) { - if(state.get(WATERLOGGED)) return false; - } - return super.propagatesSkylightDown(state, reader, pos); - } - - @Override - @SuppressWarnings("deprecation") - public IFluidState getFluidState(BlockState state) - { - if((config & CFG_WATERLOGGABLE)!=0) { - return state.get(WATERLOGGED) ? Fluids.WATER.getStillFluidState(false) : super.getFluidState(state); - } - return super.getFluidState(state); - } - - @Override - @SuppressWarnings("deprecation") - public BlockState updatePostPlacement(BlockState state, Direction facing, BlockState facingState, IWorld world, BlockPos pos, BlockPos facingPos) - { - if((config & CFG_WATERLOGGABLE)!=0) { - if(state.get(WATERLOGGED)) world.getPendingFluidTicks().scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); - } - return state; - } - - /** - * Water loggable version of the basic block. - */ - public static class WaterLoggable extends BlockDecor implements IWaterLoggable + public static class WaterLoggable extends StandardBlocks.WaterLoggable implements IStandardBlock, IWaterLoggable { public WaterLoggable(long config, Block.Properties properties) - { super(config|CFG_WATERLOGGABLE, properties); } + { super(config, properties); } public WaterLoggable(long config, Block.Properties properties, AxisAlignedBB aabb) - { super(config|CFG_WATERLOGGABLE, properties, aabb); } + { super(config, properties, aabb); } public WaterLoggable(long config, Block.Properties properties, VoxelShape voxel_shape) - { super(config|CFG_WATERLOGGABLE, properties, voxel_shape); } - - @Override - protected void fillStateContainer(StateContainer.Builder builder) - { super.fillStateContainer(builder); builder.add(WATERLOGGED); } + { super(config, properties, voxel_shape); } } + static public class Directed extends StandardBlocks.Directed implements IDecorBlock + { + public Directed(long config, Block.Properties builder, final AxisAlignedBB unrotatedAABB) + { super(config, builder, unrotatedAABB); } + } + + public static class DirectedWaterLoggable extends StandardBlocks.DirectedWaterLoggable implements IDecorBlock,IWaterLoggable + { + public DirectedWaterLoggable(long config, Block.Properties properties, AxisAlignedBB aabb) + { super(config, properties, aabb); } + } + + public static class Horizontal extends StandardBlocks.Horizontal implements IDecorBlock + { + public Horizontal(long config, Block.Properties builder, final AxisAlignedBB unrotatedAABB) + { super(config, builder, unrotatedAABB); } + } + + public static class HorizontalWaterLoggable extends StandardBlocks.HorizontalWaterLoggable implements IWaterLoggable + { + public HorizontalWaterLoggable(long config, Block.Properties properties, AxisAlignedBB aabb) + { super(config, properties, aabb); } + } } diff --git a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorBreaker.java b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorBreaker.java index 1919384..8f8a939 100644 --- a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorBreaker.java +++ b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorBreaker.java @@ -34,13 +34,15 @@ import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.energy.CapabilityEnergy; import net.minecraftforge.energy.IEnergyStorage; +import wile.engineersdecor.libmc.blocks.StandardBlocks; + import javax.annotation.Nullable; import java.util.HashSet; import java.util.List; import java.util.Random; -public class BlockDecorBreaker extends BlockDecorDirectedHorizontal +public class BlockDecorBreaker extends StandardBlocks.HorizontalWaterLoggable implements IDecorBlock { public static final BooleanProperty ACTIVE = BooleanProperty.create("active"); @@ -221,7 +223,13 @@ public class BlockDecorBreaker extends BlockDecorDirectedHorizontal private boolean breakBlock(BlockState state, BlockPos pos, World world) { if(world.isRemote || (!(world instanceof ServerWorld)) || world.restoringBlockSnapshots) return false; // retry next cycle - List drops = Block.getDrops(state, (ServerWorld)world, pos, world.getTileEntity(pos)); + List drops; + final Block block = state.getBlock(); + if((!(block instanceof IDecorBlock)) || (!((IDecorBlock)block).hasDynamicDropList())) { + drops = Block.getDrops(state, (ServerWorld)world, pos, world.getTileEntity(pos)); + } else { + drops = ((IDecorBlock)block).dropList(state, world, pos, false); + } world.removeBlock(pos, false); for(ItemStack drop:drops) spawnAsEntity(world, pos, drop); SoundType stype = state.getBlock().getSoundType(state, world, pos, null); diff --git a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorChair.java b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorChair.java index 597cdd1..82bfb41 100644 --- a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorChair.java +++ b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorChair.java @@ -10,6 +10,7 @@ package wile.engineersdecor.blocks; import wile.engineersdecor.ModContent; import wile.engineersdecor.ModEngineersDecor; +import wile.engineersdecor.libmc.blocks.StandardBlocks; import net.minecraft.entity.*; import net.minecraft.entity.monster.*; import net.minecraft.nbt.CompoundNBT; @@ -28,7 +29,7 @@ import java.util.List; import java.util.Random; -public class BlockDecorChair extends BlockDecorDirected.WaterLoggable +public class BlockDecorChair extends StandardBlocks.HorizontalWaterLoggable { private static boolean sitting_enabled = true; private static double sitting_probability = 0.1; diff --git a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorCraftingTable.java b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorCraftingTable.java index dd9c0a0..b1179a1 100644 --- a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorCraftingTable.java +++ b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorCraftingTable.java @@ -15,10 +15,12 @@ */ package wile.engineersdecor.blocks; +import net.minecraft.block.IWaterLoggable; import wile.engineersdecor.ModContent; import wile.engineersdecor.ModEngineersDecor; -import wile.engineersdecor.detail.ModAuxiliaries; -import wile.engineersdecor.detail.Networking; +import wile.engineersdecor.libmc.blocks.StandardBlocks; +import wile.engineersdecor.libmc.detail.Auxiliaries; +import wile.engineersdecor.libmc.detail.Networking; import net.minecraft.inventory.container.*; import net.minecraft.network.play.server.SSetSlotPacket; import net.minecraft.network.NetworkManager; @@ -86,10 +88,10 @@ public class BlockDecorCraftingTable // Block //-------------------------------------------------------------------------------------------------------------------- - public static final class CraftingTableBlock extends BlockDecorDirected.WaterLoggable + public static final class CraftingTableBlock extends StandardBlocks.HorizontalWaterLoggable implements IDecorBlock { public CraftingTableBlock(long config, Block.Properties builder, final AxisAlignedBB unrotatedAABB) - { super(config|CFG_WATERLOGGABLE, builder, unrotatedAABB); } + { super(config, builder, unrotatedAABB); } @Override public boolean hasTileEntity(BlockState state) @@ -1363,10 +1365,10 @@ public class BlockDecorCraftingTable // Explicit grid placement. CompoundNBT nbt = new CompoundNBT(); nbt.putInt("containerslot", slotId); - if(ModAuxiliaries.isCtrlDown()) nbt.putBoolean("move-all", true); + if(Auxiliaries.isCtrlDown()) nbt.putBoolean("move-all", true); action(ACTION_PLACE_SHIFTCLICKED_STACK, nbt); return; - } else if(ModAuxiliaries.isCtrlDown()) { + } else if(Auxiliaries.isCtrlDown()) { // Move all same items from the inventory of the clicked slot // (or the crafting grid) to the corresponding target inventory. CompoundNBT nbt = new CompoundNBT(); @@ -1391,7 +1393,7 @@ public class BlockDecorCraftingTable }).isPresent(); } int count = resultSlot.getStack().getCount(); - int limit = (ModAuxiliaries.isShiftDown() ? 2 : 1) * (ModAuxiliaries.isCtrlDown() ? 4 : 1); + int limit = (Auxiliaries.isShiftDown() ? 2 : 1) * (Auxiliaries.isCtrlDown() ? 4 : 1); if(wheel_inc > 0.1) { if(count > 0) { if((count < resultSlot.getStack().getMaxStackSize()) && (count < resultSlot.getSlotStackLimit())) { diff --git a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorDirected.java b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorDirected.java deleted file mode 100644 index e9083c9..0000000 --- a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorDirected.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * @file BlockDecorDirected.java - * @author Stefan Wilhelm (wile) - * @copyright (C) 2019 Stefan Wilhelm - * @license MIT (see https://opensource.org/licenses/MIT) - * - * Smaller (cutout) block with a defined facing. - */ -package wile.engineersdecor.blocks; - -import net.minecraft.block.IWaterLoggable; -import wile.engineersdecor.detail.ModAuxiliaries; -import net.minecraft.entity.EntityType; -import net.minecraft.state.StateContainer; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShapes; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.state.DirectionProperty; -import net.minecraft.block.Block; -import net.minecraft.block.DirectionalBlock; -import net.minecraft.block.BlockState; -import net.minecraft.world.IBlockReader; -import net.minecraft.util.BlockRenderLayer; -import net.minecraft.util.Direction; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import javax.annotation.Nullable; -import java.util.ArrayList; -import java.util.Arrays; - - -public class BlockDecorDirected extends BlockDecor -{ - public static final DirectionProperty FACING = DirectionalBlock.FACING; - protected final ArrayList AABBs; - - public BlockDecorDirected(long config, Block.Properties builder, final AxisAlignedBB unrotatedAABB) - { - super(config, builder); - setDefaultState(stateContainer.getBaseState().with(FACING, Direction.UP)); - final boolean is_horizontal = ((config & BlockDecor.CFG_HORIZIONTAL)!=0); - AABBs = new ArrayList(Arrays.asList( - VoxelShapes.create(ModAuxiliaries.getRotatedAABB(unrotatedAABB, Direction.DOWN, is_horizontal)), - VoxelShapes.create(ModAuxiliaries.getRotatedAABB(unrotatedAABB, Direction.UP, is_horizontal)), - VoxelShapes.create(ModAuxiliaries.getRotatedAABB(unrotatedAABB, Direction.NORTH, is_horizontal)), - VoxelShapes.create(ModAuxiliaries.getRotatedAABB(unrotatedAABB, Direction.SOUTH, is_horizontal)), - VoxelShapes.create(ModAuxiliaries.getRotatedAABB(unrotatedAABB, Direction.WEST, is_horizontal)), - VoxelShapes.create(ModAuxiliaries.getRotatedAABB(unrotatedAABB, Direction.EAST, is_horizontal)), - VoxelShapes.create(unrotatedAABB), - VoxelShapes.create(unrotatedAABB) - )); - } - - @Override - @OnlyIn(Dist.CLIENT) - public BlockRenderLayer getRenderLayer() - { return ((config & CFG_CUTOUT)!=0) ? BlockRenderLayer.CUTOUT : BlockRenderLayer.SOLID; } - - @Override - public boolean canSpawnInBlock() - { return false; } - - @Override - @SuppressWarnings("deprecation") - public boolean canEntitySpawn(BlockState state, IBlockReader world, BlockPos pos, EntityType entityType) - { return false; } - - @Override - public VoxelShape getShape(BlockState state, IBlockReader source, BlockPos pos, ISelectionContext selectionContext) - { return AABBs.get((state.get(FACING)).getIndex() & 0x7); } - - @Override - public VoxelShape getCollisionShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext selectionContext) - { return getShape(state, world, pos, selectionContext); } - - @Override - protected void fillStateContainer(StateContainer.Builder builder) - { super.fillStateContainer(builder); builder.add(FACING); } - - @Override - @Nullable - public BlockState getStateForPlacement(BlockItemUseContext context) - { - Direction facing = context.getFace(); - if((config & (CFG_HORIZIONTAL|CFG_LOOK_PLACEMENT)) == (CFG_HORIZIONTAL|CFG_LOOK_PLACEMENT)) { - // horizontal placement in direction the player is looking - facing = context.getPlacementHorizontalFacing(); - } else if((config & (CFG_HORIZIONTAL|CFG_LOOK_PLACEMENT)) == (CFG_HORIZIONTAL)) { - // horizontal placement on a face - if(((facing==Direction.UP)||(facing==Direction.DOWN))) return null; - } else if((config & CFG_LOOK_PLACEMENT)!=0) { - // placement in direction the player is looking, with up and down - facing = context.getNearestLookingDirection(); - } else { - // default: placement on the face the player clicking - } - if((config & CFG_OPPOSITE_PLACEMENT)!=0) facing = facing.getOpposite(); - if(((config & CFG_FLIP_PLACEMENT_SHIFTCLICK) != 0) && (context.getPlayer().isSneaking())) facing = facing.getOpposite(); - return super.getStateForPlacement(context).with(FACING, facing); - } - - /** - * Water loggable version of directed blocks. - */ - public static class WaterLoggable extends BlockDecorDirected implements IWaterLoggable - { - public WaterLoggable(long config, Block.Properties properties, AxisAlignedBB aabb) - { super(config|CFG_WATERLOGGABLE, properties, aabb); } - - @Override - protected void fillStateContainer(StateContainer.Builder builder) - { super.fillStateContainer(builder); builder.add(WATERLOGGED); } - } - -} diff --git a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorDirectedHorizontal.java b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorDirectedHorizontal.java deleted file mode 100644 index 4f4f98c..0000000 --- a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorDirectedHorizontal.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * @file BlockDecorDirectedHorizontal.java - * @author Stefan Wilhelm (wile) - * @copyright (C) 2019 Stefan Wilhelm - * @license MIT (see https://opensource.org/licenses/MIT) - * - * Smaller directed block with direction set narrowed - * to horizontal directions. - */ -package wile.engineersdecor.blocks; - -import net.minecraft.block.HorizontalBlock; -import net.minecraft.block.IWaterLoggable; -import net.minecraft.util.Mirror; -import net.minecraft.util.Rotation; -import net.minecraft.entity.EntityType; -import net.minecraft.state.StateContainer; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.state.DirectionProperty; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.shapes.VoxelShapes; -import net.minecraft.world.IBlockReader; -import net.minecraft.util.BlockRenderLayer; -import net.minecraft.util.Direction; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import wile.engineersdecor.detail.ModAuxiliaries; - -import javax.annotation.Nullable; -import java.util.ArrayList; -import java.util.Arrays; - - -public class BlockDecorDirectedHorizontal extends BlockDecor -{ - public static final DirectionProperty HORIZONTAL_FACING = HorizontalBlock.HORIZONTAL_FACING; - protected final ArrayList AABBs; - - public BlockDecorDirectedHorizontal(long config, Block.Properties builder, final AxisAlignedBB unrotatedAABB) - { - super(config|CFG_HORIZIONTAL, builder, unrotatedAABB); - setDefaultState(stateContainer.getBaseState().with(HORIZONTAL_FACING, Direction.NORTH)); - AABBs = new ArrayList(Arrays.asList( - VoxelShapes.create(ModAuxiliaries.getRotatedAABB(unrotatedAABB, Direction.DOWN, true)), - VoxelShapes.create(ModAuxiliaries.getRotatedAABB(unrotatedAABB, Direction.UP, true)), - VoxelShapes.create(ModAuxiliaries.getRotatedAABB(unrotatedAABB, Direction.NORTH, true)), - VoxelShapes.create(ModAuxiliaries.getRotatedAABB(unrotatedAABB, Direction.SOUTH, true)), - VoxelShapes.create(ModAuxiliaries.getRotatedAABB(unrotatedAABB, Direction.WEST, true)), - VoxelShapes.create(ModAuxiliaries.getRotatedAABB(unrotatedAABB, Direction.EAST, true)), - VoxelShapes.create(unrotatedAABB), - VoxelShapes.create(unrotatedAABB) - )); - } - - @Override - @OnlyIn(Dist.CLIENT) - public BlockRenderLayer getRenderLayer() - { return ((config & CFG_CUTOUT)!=0) ? BlockRenderLayer.CUTOUT : BlockRenderLayer.SOLID; } - - @Override - public boolean canSpawnInBlock() - { return false; } - - @Override - @SuppressWarnings("deprecation") - public boolean canEntitySpawn(BlockState state, IBlockReader world, BlockPos pos, EntityType entityType) - { return false; } - - @Override - public VoxelShape getShape(BlockState state, IBlockReader source, BlockPos pos, ISelectionContext selectionContext) - { return AABBs.get((state.get(HORIZONTAL_FACING)).getIndex() & 0x7); } - - @Override - public VoxelShape getCollisionShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext selectionContext) - { return getShape(state, world, pos, selectionContext); } - - @Override - protected void fillStateContainer(StateContainer.Builder builder) - { super.fillStateContainer(builder); builder.add(HORIZONTAL_FACING); } - - @Override - @Nullable - public BlockState getStateForPlacement(BlockItemUseContext context) - { - Direction facing = context.getFace(); - if((config & CFG_LOOK_PLACEMENT) != 0) { - // horizontal placement in direction the player is looking - facing = context.getPlacementHorizontalFacing(); - } else { - // horizontal placement on a face - facing = ((facing==Direction.UP)||(facing==Direction.DOWN)) ? (context.getPlacementHorizontalFacing()) : facing; - } - if((config & CFG_OPPOSITE_PLACEMENT)!=0) facing = facing.getOpposite(); - if(((config & CFG_FLIP_PLACEMENT_SHIFTCLICK) != 0) && (context.getPlayer().isSneaking())) facing = facing.getOpposite(); - return super.getStateForPlacement(context).with(HORIZONTAL_FACING, facing); - } - - @Override - @SuppressWarnings("deprecation") - public BlockState rotate(BlockState state, Rotation rot) - { return state.with(HORIZONTAL_FACING, rot.rotate(state.get(HORIZONTAL_FACING))); } - - @Override - @SuppressWarnings("deprecation") - public BlockState mirror(BlockState state, Mirror mirrorIn) - { return state.rotate(mirrorIn.toRotation(state.get(HORIZONTAL_FACING))); } - - /** - * Water loggable version of directed blocks. - */ - public static class WaterLoggable extends BlockDecorDirectedHorizontal implements IWaterLoggable - { - public WaterLoggable(long config, Block.Properties properties, AxisAlignedBB aabb) - { super(config|CFG_WATERLOGGABLE, properties, aabb); } - - @Override - protected void fillStateContainer(StateContainer.Builder builder) - { super.fillStateContainer(builder); builder.add(WATERLOGGED); } - } - -} diff --git a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorDropper.java b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorDropper.java index 8f2a1f3..7f8acb4 100644 --- a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorDropper.java +++ b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorDropper.java @@ -10,7 +10,8 @@ package wile.engineersdecor.blocks; import wile.engineersdecor.ModContent; import wile.engineersdecor.ModEngineersDecor; -import wile.engineersdecor.detail.Networking; +import wile.engineersdecor.libmc.blocks.StandardBlocks; +import wile.engineersdecor.libmc.detail.Networking; import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.inventory.container.INamedContainerProvider; import net.minecraft.block.DoorBlock; @@ -55,7 +56,7 @@ import java.util.ArrayList; import java.util.List; -public class BlockDecorDropper extends BlockDecorDirected +public class BlockDecorDropper extends StandardBlocks.Directed implements IDecorBlock { public static final BooleanProperty OPEN = DoorBlock.OPEN; diff --git a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorFence.java b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorFence.java index 2e8ccb1..d1dc07c 100644 --- a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorFence.java +++ b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorFence.java @@ -8,108 +8,11 @@ */ package wile.engineersdecor.blocks; -import wile.engineersdecor.detail.ModAuxiliaries; -import net.minecraft.world.*; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.fluid.IFluidState; -import net.minecraft.entity.EntityType; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.state.StateContainer; +import wile.engineersdecor.libmc.blocks.StandardFenceBlock; import net.minecraft.block.*; -import net.minecraft.block.material.PushReaction; -import net.minecraft.block.BlockState; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.fluid.Fluids; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.text.ITextComponent; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import javax.annotation.Nullable; -import java.util.List; - -public class BlockDecorFence extends WallBlock implements IDecorBlock +public class BlockDecorFence extends StandardFenceBlock implements IDecorBlock { - private final VoxelShape[] shape_voxels; - private final VoxelShape[] collision_shape_voxels; - public BlockDecorFence(long config, Block.Properties builder) - { - super(builder); - this.shape_voxels = buildWallShapes(1.5f, 1.5f, 16f, 0f, 16f); - this.collision_shape_voxels = buildWallShapes(1.5f, 1.5f, 24f, 0f, 24f); - } - - @Override - @OnlyIn(Dist.CLIENT) - public void addInformation(ItemStack stack, @Nullable IBlockReader world, List tooltip, ITooltipFlag flag) - { ModAuxiliaries.Tooltip.addInformation(stack, world, tooltip, flag, true); } - - protected VoxelShape[] buildWallShapes(float pole_width_x, float pole_width_z, float pole_height, float side_min_y, float side_max_y) - { return super.makeShapes(pole_width_x, pole_width_z, pole_height, side_min_y, side_max_y); } - - @Override - public VoxelShape getShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext selectionContext) - { return shape_voxels[this.getIndex(state)]; } - - @Override - public VoxelShape getCollisionShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext selectionContext) - { return collision_shape_voxels[this.getIndex(state)]; } - - @Override - protected void fillStateContainer(StateContainer.Builder builder) - { super.fillStateContainer(builder); } - - private boolean attachesTo(BlockState facingState, IWorldReader world, BlockPos facingPos, Direction side) - { - final Block block = facingState.getBlock(); - if((block instanceof FenceGateBlock) || (block instanceof BlockDecorFence) || (block instanceof BlockDecorWall)) return true; - final BlockState oppositeState = world.getBlockState(facingPos.offset(side, 2)); - if(!(oppositeState.getBlock() instanceof BlockDecorFence)) return false; - return facingState.isNormalCube(world, facingPos) && hasSolidSide(facingState, world, facingPos, side); - } - - public BlockState getStateForPlacement(BlockItemUseContext context) - { - IWorldReader world = context.getWorld(); - BlockPos pos = context.getPos(); - IFluidState fs = context.getWorld().getFluidState(context.getPos()); - boolean n = attachesTo(world.getBlockState(pos.north()), world, pos.north(), Direction.SOUTH); - boolean e = attachesTo(world.getBlockState(pos.east()), world, pos.east(), Direction.WEST); - boolean s = attachesTo(world.getBlockState(pos.south()), world, pos.south(), Direction.NORTH); - boolean w = attachesTo(world.getBlockState(pos.west()), world, pos.west(), Direction.EAST); - boolean not_straight = (!n || !s || e || w) && (n || s || !e || !w); - return getDefaultState().with(UP, not_straight).with(NORTH, n).with(EAST, e).with(SOUTH, s).with(WEST, w).with(WATERLOGGED, fs.getFluid() == Fluids.WATER); - } - - @Override - public BlockState updatePostPlacement(BlockState state, Direction side, BlockState facingState, IWorld world, BlockPos currentPos, BlockPos facingPos) - { - if(state.get(WATERLOGGED)) world.getPendingFluidTicks().scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickRate(world)); - if(side == Direction.DOWN) return super.updatePostPlacement(state, side, facingState, world, currentPos, facingPos); - boolean n = (side==Direction.NORTH) ? attachesTo(facingState, world, facingPos, side) : state.get(NORTH); - boolean e = (side==Direction.EAST) ? attachesTo(facingState, world, facingPos, side) : state.get(EAST); - boolean s = (side==Direction.SOUTH) ? attachesTo(facingState, world, facingPos, side) : state.get(SOUTH); - boolean w = (side==Direction.WEST) ? attachesTo(facingState, world, facingPos, side) : state.get(WEST); - boolean not_straight = (!n || !s || e || w) && (n || s || !e || !w); - return state.with(UP, not_straight).with(NORTH, n).with(EAST, e).with(SOUTH, s).with(WEST, w); - } - - @Override - @SuppressWarnings("deprecation") - public boolean canEntitySpawn(BlockState state, IBlockReader world, BlockPos pos, EntityType entityType) - { return false; } - - @Override - public boolean canSpawnInBlock() - { return false; } - - @Override - @SuppressWarnings("deprecation") - public PushReaction getPushReaction(BlockState state) - { return PushReaction.NORMAL; } + { super(config, builder); } } diff --git a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorFloorGrating.java b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorFloorGrating.java index 7b6db1f..f6b1623 100644 --- a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorFloorGrating.java +++ b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorFloorGrating.java @@ -8,6 +8,7 @@ */ package wile.engineersdecor.blocks; +import wile.engineersdecor.libmc.blocks.StandardBlocks; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.entity.Entity; @@ -15,56 +16,50 @@ import net.minecraft.entity.item.ItemEntity; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.shapes.VoxelShapes; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; -public class BlockDecorFloorGrating extends BlockDecor.WaterLoggable +public class BlockDecorFloorGrating extends StandardBlocks.WaterLoggable implements IDecorBlock { public BlockDecorFloorGrating(long config, Block.Properties builder, final AxisAlignedBB unrotatedAABB) - { super(config|CFG_WATERLOGGABLE, builder); } + { super(config, builder, unrotatedAABB); } @Override public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) { return true; } @Override - public void onLanded(IBlockReader world, Entity entity) - { - if(!(entity instanceof ItemEntity)) { - super.onLanded(world, entity); - } else { - entity.setMotion(0, -0.1,0); - entity.setPositionAndUpdate(entity.posX, entity.posY-0.3, entity.posZ); - } - } - - @Override - public void onFallenUpon(World world, BlockPos pos, Entity entity, float fallDistance) - { - if(!(entity instanceof ItemEntity)) { - super.onFallenUpon(world, pos, entity, fallDistance); - } else { - entity.setMotion(0, -0.1,0); - entity.setPositionAndUpdate(entity.posX, entity.posY-0.3, entity.posZ); - } - } + @SuppressWarnings("deprecation") + public boolean isNormalCube(BlockState state, IBlockReader worldIn, BlockPos pos) + { return false; } @Override @SuppressWarnings("deprecation") public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) { if(!(entity instanceof ItemEntity)) return; - if((entity.posY-pos.getY()) < 0.7) return; - double vy = MathHelper.clamp(entity.getMotion().y, -1.2, -0.2); - entity.setMotion(0, vy, 0); - entity.setPositionAndUpdate(pos.getX()+0.5, entity.posY-0.3, pos.getZ()+0.5); + final boolean colliding = ((entity.posY-pos.getY()) > 0.7); + if(colliding || (entity.getMotion().getY() > 0)) { + double x = pos.getX() + 0.5; + double y = MathHelper.clamp(entity.posY-0.3, pos.getY(), pos.getY()+0.6); + double z = pos.getZ() + 0.5; + double vx = entity.getMotion().getX(); + double vy = entity.getMotion().getY(); + double vz = entity.getMotion().getZ(); + if(colliding) { + vx = 0; + vy = -0.3; + vz = 0; + if((entity.posY-pos.getY()) > 0.8) y = pos.getY() + 0.6; + entity.prevPosX = x+0.1; + entity.prevPosY = y+0.1; + entity.prevPosZ = z+0.1; + } + vy = MathHelper.clamp(vy, -0.3, 0); + entity.setMotion(vx, vy, vz); + entity.fallDistance = 0; + entity.setPositionAndUpdate(x,y,z); + } } - - @Override - public VoxelShape getCollisionShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext context) - { return (context.getEntity() instanceof ItemEntity) ? VoxelShapes.empty() : super.getCollisionShape(state, world, pos, context); } } diff --git a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorFluidFunnel.java b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorFluidFunnel.java index a232a13..c1ae3ab 100644 --- a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorFluidFunnel.java +++ b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorFluidFunnel.java @@ -36,13 +36,14 @@ import net.minecraftforge.fluids.*; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction; +import wile.engineersdecor.libmc.blocks.StandardBlocks; import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.util.*; -public class BlockDecorFluidFunnel extends BlockDecor +public class BlockDecorFluidFunnel extends StandardBlocks.BaseBlock implements IDecorBlock { public static final int FILL_LEVEL_MAX = 3; public static final IntegerProperty FILL_LEVEL = IntegerProperty.create("level", 0, FILL_LEVEL_MAX); diff --git a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorFurnace.java b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorFurnace.java index 786075c..d9d4991 100644 --- a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorFurnace.java +++ b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorFurnace.java @@ -8,11 +8,11 @@ */ package wile.engineersdecor.blocks; -import net.minecraftforge.common.ForgeHooks; import wile.engineersdecor.ModContent; import wile.engineersdecor.ModEngineersDecor; import wile.engineersdecor.detail.ExtItems; -import wile.engineersdecor.detail.Networking; +import wile.engineersdecor.libmc.blocks.StandardBlocks; +import wile.engineersdecor.libmc.detail.Networking; import net.minecraft.tileentity.*; import net.minecraft.inventory.container.*; import net.minecraft.item.crafting.AbstractCookingRecipe; @@ -52,6 +52,7 @@ import net.minecraftforge.fml.hooks.BasicEventHooks; import net.minecraftforge.fml.network.NetworkHooks; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.energy.IEnergyStorage; import net.minecraftforge.items.CapabilityItemHandler; @@ -63,14 +64,14 @@ import javax.annotation.Nullable; import java.util.*; -public class BlockDecorFurnace extends BlockDecorDirected +public class BlockDecorFurnace extends StandardBlocks.Horizontal { public static final BooleanProperty LIT = RedstoneTorchBlock.LIT; public BlockDecorFurnace(long config, Block.Properties builder, final AxisAlignedBB unrotatedAABB) { super(config, builder, unrotatedAABB); - setDefaultState(stateContainer.getBaseState().with(FACING, Direction.NORTH).with(LIT, false)); + setDefaultState(super.getDefaultState().with(LIT, false)); } @Override @@ -85,7 +86,7 @@ public class BlockDecorFurnace extends BlockDecorDirected @Override @Nullable public BlockState getStateForPlacement(BlockItemUseContext context) - { return super.getStateForPlacement(context).with(FACING, context.getPlacementHorizontalFacing().getOpposite()).with(LIT, false); } + { return super.getStateForPlacement(context).with(LIT, false); } @Override @SuppressWarnings("deprecation") @@ -171,7 +172,7 @@ public class BlockDecorFurnace extends BlockDecorDirected final double x=0.5+pos.getX(), y=0.5+pos.getY(), z=0.5+pos.getZ(); final double xc=0.52, xr=rnd.nextDouble()*0.4-0.2, yr=(y-0.3+rnd.nextDouble()*0.2); if(rv < 0.1d) world.playSound(x, y, z, SoundEvents.BLOCK_FURNACE_FIRE_CRACKLE, SoundCategory.BLOCKS, 0.4f, 0.5f, false); - switch(state.get(FACING)) { + switch(state.get(HORIZONTAL_FACING)) { case WEST: world.addParticle(ParticleTypes.SMOKE, x-xc, yr, z+xr, 0.0, 0.0, 0.0); break; case EAST: world.addParticle(ParticleTypes.SMOKE, x+xc, yr, z+xr, 0.0, 0.0, 0.0); break; case NORTH: world.addParticle(ParticleTypes.SMOKE, x+xr, yr, z-xc, 0.0, 0.0, 0.0); break; @@ -451,7 +452,7 @@ public class BlockDecorFurnace extends BlockDecorDirected @Override public boolean canInsertItem(int index, ItemStack itemStackIn, Direction direction) - { return isItemValidForSlot(index, itemStackIn); } + { return ((index==FIFO_INPUT_1_SLOT_NO) || (index==FIFO_INPUT_0_SLOT_NO) || (index==FIFO_FUEL_1_SLOT_NO) || (index==FIFO_FUEL_0_SLOT_NO)) && isItemValidForSlot(index, itemStackIn); } @Override public boolean canExtractItem(int index, ItemStack stack, Direction direction) diff --git a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorFurnaceElectrical.java b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorFurnaceElectrical.java index 2b00709..d1fbd67 100644 --- a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorFurnaceElectrical.java +++ b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorFurnaceElectrical.java @@ -10,7 +10,7 @@ package wile.engineersdecor.blocks; import wile.engineersdecor.ModContent; import wile.engineersdecor.ModEngineersDecor; -import wile.engineersdecor.detail.Networking; +import wile.engineersdecor.libmc.detail.Networking; import net.minecraft.inventory.container.*; import net.minecraft.item.crafting.AbstractCookingRecipe; import net.minecraft.item.crafting.FurnaceRecipe; @@ -274,7 +274,7 @@ public class BlockDecorFurnaceElectrical extends BlockDecorFurnace @Override public boolean canInsertItem(int index, ItemStack itemStackIn, Direction direction) - { return isItemValidForSlot(index, itemStackIn); } + { return ((index==FIFO_INPUT_0_SLOT_NO) || (index==FIFO_INPUT_1_SLOT_NO)) && isItemValidForSlot(index, itemStackIn); } @Override public boolean canExtractItem(int index, ItemStack stack, Direction direction) @@ -538,7 +538,7 @@ public class BlockDecorFurnaceElectrical extends BlockDecorFurnace if(energy_stored_ < transfer_energy_consumption_) return false; final BlockState state = world.getBlockState(pos); if(!(state.getBlock() instanceof BlockDecorFurnaceElectrical)) return false; - final Direction out_facing = state.get(FACING); + final Direction out_facing = state.get(HORIZONTAL_FACING); if(out && (!stacks_.get(FIFO_OUTPUT_1_SLOT_NO).isEmpty())) { TileEntity te = world.getTileEntity(pos.offset(out_facing)); if(te!=null) { @@ -552,7 +552,7 @@ public class BlockDecorFurnaceElectrical extends BlockDecorFurnace } } if(with_automatic_inventory_pulling_) { - final Direction inp_facing = state.get(FACING).getOpposite(); + final Direction inp_facing = state.get(HORIZONTAL_FACING).getOpposite(); if(inp && (stacks_.get(FIFO_INPUT_1_SLOT_NO).isEmpty())) { TileEntity te = world.getTileEntity(pos.offset(inp_facing)); if(te!=null) { diff --git a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorGlassBlock.java b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorGlassBlock.java index 7d0d0d7..ae3942b 100644 --- a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorGlassBlock.java +++ b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorGlassBlock.java @@ -9,7 +9,7 @@ */ package wile.engineersdecor.blocks; -import wile.engineersdecor.detail.ModAuxiliaries; +import wile.engineersdecor.libmc.detail.Auxiliaries; import net.minecraft.world.IBlockReader; import net.minecraft.block.Block; import net.minecraft.block.BlockState; @@ -25,7 +25,7 @@ import javax.annotation.Nullable; import java.util.List; -public class BlockDecorGlassBlock extends StainedGlassBlock +public class BlockDecorGlassBlock extends StainedGlassBlock implements IDecorBlock { public BlockDecorGlassBlock(long config, Block.Properties properties) { super(DyeColor.BLACK, properties); } @@ -33,7 +33,7 @@ public class BlockDecorGlassBlock extends StainedGlassBlock @Override @OnlyIn(Dist.CLIENT) public void addInformation(ItemStack stack, @Nullable IBlockReader world, List tooltip, ITooltipFlag flag) - { ModAuxiliaries.Tooltip.addInformation(stack, world, tooltip, flag, true); } + { Auxiliaries.Tooltip.addInformation(stack, world, tooltip, flag, true); } @Override @OnlyIn(Dist.CLIENT) diff --git a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorHalfSlab.java b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorHalfSlab.java index ceadb7e..a9f5818 100644 --- a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorHalfSlab.java +++ b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorHalfSlab.java @@ -9,200 +9,11 @@ */ package wile.engineersdecor.blocks; -import net.minecraft.fluid.Fluid; -import net.minecraft.fluid.IFluidState; -import net.minecraft.world.IWorld; -import wile.engineersdecor.detail.ModAuxiliaries; +import wile.engineersdecor.libmc.blocks.SlabSliceBlock; import net.minecraft.block.*; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.state.IntegerProperty; -import net.minecraft.util.*; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.Vec3d; -import net.minecraft.util.math.shapes.VoxelShapes; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.world.World; -import net.minecraft.entity.EntityType; -import net.minecraft.state.StateContainer; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.block.BlockState; -import net.minecraft.world.IBlockReader; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import wile.engineersdecor.detail.ModConfig; -import javax.annotation.Nullable; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - - -public class BlockDecorHalfSlab extends BlockDecor.WaterLoggable +public class BlockDecorHalfSlab extends SlabSliceBlock implements IDecorBlock { - public static final IntegerProperty PARTS = IntegerProperty.create("parts", 0, 14); - - protected static final VoxelShape AABBs[] = { - VoxelShapes.create(new AxisAlignedBB(0, 0./16, 0, 1, 2./16, 1)), - VoxelShapes.create(new AxisAlignedBB(0, 0./16, 0, 1, 4./16, 1)), - VoxelShapes.create(new AxisAlignedBB(0, 0./16, 0, 1, 6./16, 1)), - VoxelShapes.create(new AxisAlignedBB(0, 0./16, 0, 1, 8./16, 1)), - VoxelShapes.create(new AxisAlignedBB(0, 0./16, 0, 1, 10./16, 1)), - VoxelShapes.create(new AxisAlignedBB(0, 0./16, 0, 1, 12./16, 1)), - VoxelShapes.create(new AxisAlignedBB(0, 0./16, 0, 1, 14./16, 1)), - VoxelShapes.create(new AxisAlignedBB(0, 0./16, 0, 1, 16./16, 1)), - VoxelShapes.create(new AxisAlignedBB(0, 2./16, 0, 1, 16./16, 1)), - VoxelShapes.create(new AxisAlignedBB(0, 4./16, 0, 1, 16./16, 1)), - VoxelShapes.create(new AxisAlignedBB(0, 6./16, 0, 1, 16./16, 1)), - VoxelShapes.create(new AxisAlignedBB(0, 8./16, 0, 1, 16./16, 1)), - VoxelShapes.create(new AxisAlignedBB(0, 10./16, 0, 1, 16./16, 1)), - VoxelShapes.create(new AxisAlignedBB(0, 12./16, 0, 1, 16./16, 1)), - VoxelShapes.create(new AxisAlignedBB(0, 14./16, 0, 1, 16./16, 1)), - VoxelShapes.create(new AxisAlignedBB(0,0,0,1,1,1)) // <- with 4bit fill - }; - - protected static final int num_slabs_contained_in_parts_[] = { 1,2,3,4,5,6,7,8,7,6,5,4,3,2,1 ,0x1 }; // <- with 4bit fill - public BlockDecorHalfSlab(long config, Block.Properties builder) - { super(config|CFG_WATERLOGGABLE, builder); } - - protected boolean is_cube(BlockState state) - { return state.get(PARTS) == 0x07; } - - @Override - @OnlyIn(Dist.CLIENT) - public void addInformation(ItemStack stack, @Nullable IBlockReader world, List tooltip, ITooltipFlag flag) - { - if(!ModAuxiliaries.Tooltip.addInformation(stack, world, tooltip, flag, true)) return; - if(!ModConfig.without_direct_slab_pickup) ModAuxiliaries.Tooltip.addInformation("engineersdecor.tooltip.slabpickup", "engineersdecor.tooltip.slabpickup", tooltip, flag, true); - } - - @Override - @OnlyIn(Dist.CLIENT) - public BlockRenderLayer getRenderLayer() - { return (((config & CFG_TRANSLUCENT)!=0) ? (BlockRenderLayer.TRANSLUCENT) : (BlockRenderLayer.CUTOUT)); } - - @Override - public boolean canSpawnInBlock() - { return false; } - - @Override - @SuppressWarnings("deprecation") - public boolean canEntitySpawn(BlockState state, IBlockReader world, BlockPos pos, EntityType entityType) - { return false; } - - @Override - public VoxelShape getShape(BlockState state, IBlockReader source, BlockPos pos, ISelectionContext selectionContext) - { return AABBs[state.get(PARTS) & 0xf]; } - - @Override - public VoxelShape getCollisionShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext selectionContext) - { return getShape(state, world, pos, selectionContext); } - - @Override - protected void fillStateContainer(StateContainer.Builder builder) - { super.fillStateContainer(builder); builder.add(PARTS); } - - @Override - @Nullable - public BlockState getStateForPlacement(BlockItemUseContext context) - { - final Direction facing = context.getFace(); - double y = context.getHitVec().getY(); - return super.getStateForPlacement(context).with(PARTS, ((facing==Direction.UP) || ((facing!=Direction.DOWN) && (y < 0.6))) ? 0 : 14); - } - - @Override - @SuppressWarnings("deprecation") - public BlockState rotate(BlockState state, Rotation rot) - { return state; } - - @Override - @SuppressWarnings("deprecation") - public BlockState mirror(BlockState state, Mirror mirrorIn) - { return state; } - - @Override - public boolean hasDynamicDropList() - { return true; } - - @Override - public List dropList(BlockState state, World world, BlockPos pos, boolean explosion) - { return new ArrayList(Collections.singletonList(new ItemStack(this.asItem(), num_slabs_contained_in_parts_[state.get(PARTS) & 0xf]))); } - - @Override - @SuppressWarnings("deprecation") - public boolean onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult rayTraceResult) - { - Direction face = rayTraceResult.getFace(); - final ItemStack stack = player.getHeldItem(hand); - if(stack.isEmpty() || (Block.getBlockFromItem(stack.getItem()) != this)) return false; - if((face != Direction.UP) && (face != Direction.DOWN)) return false; - int parts = state.get(PARTS); - if((face != Direction.UP) && (parts > 7)) { - world.setBlockState(pos, state.with(PARTS, parts-1), 3); - } else if((face != Direction.DOWN) && (parts < 7)) { - world.setBlockState(pos, state.with(PARTS, parts+1), 3); - } else { - return (parts != 7); - } - if(world.isRemote) return true; - if(!player.isCreative()) { - stack.shrink(1); - if(player.inventory != null) player.inventory.markDirty(); - } - SoundType st = this.getSoundType(state, world, pos, null); - world.playSound(null, pos, st.getPlaceSound(), SoundCategory.BLOCKS, (st.getVolume()+1f)/2.5f, 0.9f*st.getPitch()); - return true; - } - - @Override - @SuppressWarnings("deprecation") - public void onBlockClicked(BlockState state, World world, BlockPos pos, PlayerEntity player) - { - if((world.isRemote) || (ModConfig.without_direct_slab_pickup)) return; - final ItemStack stack = player.getHeldItemMainhand(); - if(stack.isEmpty() || (Block.getBlockFromItem(stack.getItem()) != this)) return; - if(stack.getCount() >= stack.getMaxStackSize()) return; - Vec3d lv = player.getLookVec(); - Direction facing = Direction.getFacingFromVector((float)lv.x, (float)lv.y, (float)lv.z); - if((facing != Direction.UP) && (facing != Direction.DOWN)) return; - if(state.getBlock() != this) return; - int parts = state.get(PARTS); - if((facing == Direction.DOWN) && (parts <= 7)) { - if(parts > 0) { - world.setBlockState(pos, state.with(PARTS, parts-1), 3); - } else { - world.removeBlock(pos, false); - } - } else if((facing == Direction.UP) && (parts >= 7)) { - if(parts < 14) { - world.setBlockState(pos, state.with(PARTS, parts + 1), 3); - } else { - world.removeBlock(pos, false); - } - } else { - return; - } - if(!player.isCreative()) { - stack.grow(1); - if(player.inventory != null) player.inventory.markDirty(); // @todo: check if inventory can actually be null - } - SoundType st = this.getSoundType(state, world, pos, null); - world.playSound(player, pos, st.getPlaceSound(), SoundCategory.BLOCKS, (st.getVolume()+1f)/2.5f, 0.9f*st.getPitch()); - } - - @Override - public boolean receiveFluid(IWorld world, BlockPos pos, BlockState state, IFluidState fluidState) - { return (state.get(PARTS)==14) ? false : super.receiveFluid(world, pos, state, fluidState); } - - @Override - public boolean canContainFluid(IBlockReader world, BlockPos pos, BlockState state, Fluid fluid) - { return (state.get(PARTS)==14) ? false : super.canContainFluid(world, pos, state, fluid); } - + { super(config, builder); } } diff --git a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorHopper.java b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorHopper.java index f746190..4e0c019 100644 --- a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorHopper.java +++ b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorHopper.java @@ -10,7 +10,8 @@ package wile.engineersdecor.blocks; import wile.engineersdecor.ModContent; import wile.engineersdecor.ModEngineersDecor; -import wile.engineersdecor.detail.Networking; +import wile.engineersdecor.libmc.blocks.StandardBlocks; +import wile.engineersdecor.libmc.detail.Networking; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import net.minecraft.block.Block; @@ -50,7 +51,7 @@ import java.util.ArrayList; import java.util.List; -public class BlockDecorHopper extends BlockDecorDirected +public class BlockDecorHopper extends StandardBlocks.Directed implements IDecorBlock { public BlockDecorHopper(long config, Block.Properties builder, final AxisAlignedBB unrotatedAABB) { super(config, builder, unrotatedAABB); } @@ -486,18 +487,20 @@ public class BlockDecorHopper extends BlockDecorDirected ItemStack insert_stack = current_stack.copy(); if(insert_stack.getCount() > transfer_count_) insert_stack.setCount(transfer_count_); final int initial_insert_stack_size = insert_stack.getCount(); - int first_empty_slot_index = -1; if((ih == null) || ih.getSlots() <= 0) return false; + // First stack comletion insert run. for(int i=0; i= 0) && (!insert_stack.isEmpty())) { - insert_stack = ih.insertItem(first_empty_slot_index, insert_stack.copy(), false); + // First-available insert run. + if(!insert_stack.isEmpty()) { + for(int i=0; i 0) { diff --git a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorHorizontalSupport.java b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorHorizontalSupport.java index c940c1b..beeac59 100644 --- a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorHorizontalSupport.java +++ b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorHorizontalSupport.java @@ -11,7 +11,8 @@ package wile.engineersdecor.blocks; import net.minecraft.block.IWaterLoggable; import wile.engineersdecor.ModContent; -import wile.engineersdecor.detail.ModAuxiliaries; +import wile.engineersdecor.libmc.blocks.StandardBlocks; +import wile.engineersdecor.libmc.detail.Auxiliaries; import net.minecraft.entity.EntityType; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.block.Block; @@ -36,7 +37,7 @@ import java.util.ArrayList; import java.util.Arrays; -public class BlockDecorHorizontalSupport extends BlockDecor implements IWaterLoggable +public class BlockDecorHorizontalSupport extends StandardBlocks.WaterLoggable implements IWaterLoggable { public static final BooleanProperty EASTWEST = BooleanProperty.create("eastwest"); public static final BooleanProperty LEFTBEAM = BooleanProperty.create("leftbeam"); @@ -46,14 +47,14 @@ public class BlockDecorHorizontalSupport extends BlockDecor implements IWaterLog public BlockDecorHorizontalSupport(long config, Block.Properties builder, final AxisAlignedBB unrotatedAABB) { - super(config|CFG_HORIZIONTAL|CFG_WATERLOGGABLE, builder); + super(config|StandardBlocks.CFG_HORIZIONTAL, builder); AABBs = new ArrayList(Arrays.asList( // Effective bounding box - VoxelShapes.create(ModAuxiliaries.getRotatedAABB(unrotatedAABB.grow(2.0/16, 0, 0), Direction.NORTH, true)), - VoxelShapes.create(ModAuxiliaries.getRotatedAABB(unrotatedAABB.grow(2.0/16, 0, 0), Direction.WEST, true)), + VoxelShapes.create(Auxiliaries.getRotatedAABB(unrotatedAABB.grow(2.0/16, 0, 0), Direction.NORTH, true)), + VoxelShapes.create(Auxiliaries.getRotatedAABB(unrotatedAABB.grow(2.0/16, 0, 0), Direction.WEST, true)), // Displayed bounding box - VoxelShapes.create(ModAuxiliaries.getRotatedAABB(unrotatedAABB, Direction.NORTH, true)), - VoxelShapes.create(ModAuxiliaries.getRotatedAABB(unrotatedAABB, Direction.WEST, true)) + VoxelShapes.create(Auxiliaries.getRotatedAABB(unrotatedAABB, Direction.NORTH, true)), + VoxelShapes.create(Auxiliaries.getRotatedAABB(unrotatedAABB, Direction.WEST, true)) )); } @@ -81,7 +82,7 @@ public class BlockDecorHorizontalSupport extends BlockDecor implements IWaterLog @Override protected void fillStateContainer(StateContainer.Builder builder) - { super.fillStateContainer(builder); builder.add(EASTWEST, RIGHTBEAM, LEFTBEAM, DOWNCONNECT, WATERLOGGED); } + { super.fillStateContainer(builder); builder.add(EASTWEST, RIGHTBEAM, LEFTBEAM, DOWNCONNECT); } @Override @Nullable diff --git a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorLadder.java b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorLadder.java index c84f603..314ef73 100644 --- a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorLadder.java +++ b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorLadder.java @@ -12,7 +12,7 @@ */ package wile.engineersdecor.blocks; -import wile.engineersdecor.detail.ModAuxiliaries; +import wile.engineersdecor.libmc.detail.Auxiliaries; import net.minecraft.fluid.IFluidState; import net.minecraft.world.Explosion; import net.minecraft.world.World; @@ -40,11 +40,11 @@ import java.util.List; public class BlockDecorLadder extends LadderBlock implements IDecorBlock { - protected static final AxisAlignedBB EDLADDER_UNROTATED_AABB = ModAuxiliaries.getPixeledAABB(3, 0, 0, 13, 16, 3); - protected static final VoxelShape EDLADDER_SOUTH_AABB = VoxelShapes.create(ModAuxiliaries.getRotatedAABB(EDLADDER_UNROTATED_AABB, Direction.SOUTH, false)); - protected static final VoxelShape EDLADDER_EAST_AABB = VoxelShapes.create(ModAuxiliaries.getRotatedAABB(EDLADDER_UNROTATED_AABB, Direction.EAST, false)); - protected static final VoxelShape EDLADDER_WEST_AABB = VoxelShapes.create(ModAuxiliaries.getRotatedAABB(EDLADDER_UNROTATED_AABB, Direction.WEST, false)); - protected static final VoxelShape EDLADDER_NORTH_AABB = VoxelShapes.create(ModAuxiliaries.getRotatedAABB(EDLADDER_UNROTATED_AABB, Direction.NORTH, false)); + protected static final AxisAlignedBB EDLADDER_UNROTATED_AABB = Auxiliaries.getPixeledAABB(3, 0, 0, 13, 16, 3); + protected static final VoxelShape EDLADDER_SOUTH_AABB = VoxelShapes.create(Auxiliaries.getRotatedAABB(EDLADDER_UNROTATED_AABB, Direction.SOUTH, false)); + protected static final VoxelShape EDLADDER_EAST_AABB = VoxelShapes.create(Auxiliaries.getRotatedAABB(EDLADDER_UNROTATED_AABB, Direction.EAST, false)); + protected static final VoxelShape EDLADDER_WEST_AABB = VoxelShapes.create(Auxiliaries.getRotatedAABB(EDLADDER_UNROTATED_AABB, Direction.WEST, false)); + protected static final VoxelShape EDLADDER_NORTH_AABB = VoxelShapes.create(Auxiliaries.getRotatedAABB(EDLADDER_UNROTATED_AABB, Direction.NORTH, false)); private static boolean without_speed_boost_ = false; public static void on_config(boolean without_speed_boost) @@ -56,7 +56,7 @@ public class BlockDecorLadder extends LadderBlock implements IDecorBlock @Override @OnlyIn(Dist.CLIENT) public void addInformation(ItemStack stack, @Nullable IBlockReader world, List tooltip, ITooltipFlag flag) - { ModAuxiliaries.Tooltip.addInformation(stack, world, tooltip, flag, true); } + { Auxiliaries.Tooltip.addInformation(stack, world, tooltip, flag, true); } public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos) { diff --git a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorMilker.java b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorMilker.java index 1ed72c6..583b9fa 100644 --- a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorMilker.java +++ b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorMilker.java @@ -45,6 +45,7 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction; +import wile.engineersdecor.libmc.blocks.StandardBlocks; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -53,7 +54,7 @@ import java.util.Map.Entry; import java.util.stream.Collectors; -public class BlockDecorMilker extends BlockDecorDirectedHorizontal +public class BlockDecorMilker extends StandardBlocks.Horizontal implements IDecorBlock { public static final BooleanProperty FILLED = BooleanProperty.create("filled"); public static final BooleanProperty ACTIVE = BooleanProperty.create("active"); diff --git a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorMineralSmelter.java b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorMineralSmelter.java index aba9759..3fbcd61 100644 --- a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorMineralSmelter.java +++ b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorMineralSmelter.java @@ -50,12 +50,14 @@ import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import wile.engineersdecor.libmc.blocks.StandardBlocks; + import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.util.*; -public class BlockDecorMineralSmelter extends BlockDecorDirectedHorizontal +public class BlockDecorMineralSmelter extends StandardBlocks.Horizontal implements IDecorBlock { public static final int PHASE_MAX = 3; public static final IntegerProperty PHASE = IntegerProperty.create("phase", 0, PHASE_MAX); diff --git a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorPassiveFluidAccumulator.java b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorPassiveFluidAccumulator.java index f9e0dc6..a4ccadf 100644 --- a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorPassiveFluidAccumulator.java +++ b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorPassiveFluidAccumulator.java @@ -14,7 +14,8 @@ package wile.engineersdecor.blocks; import wile.engineersdecor.ModContent; -import wile.engineersdecor.detail.ModAuxiliaries; +import wile.engineersdecor.libmc.blocks.StandardBlocks; +import wile.engineersdecor.libmc.detail.Auxiliaries; import net.minecraft.world.World; import net.minecraft.world.IBlockReader; import net.minecraft.block.Block; @@ -40,7 +41,7 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -public class BlockDecorPassiveFluidAccumulator extends BlockDecorDirected +public class BlockDecorPassiveFluidAccumulator extends StandardBlocks.Directed implements IDecorBlock { public BlockDecorPassiveFluidAccumulator(long config, Block.Properties builder, final AxisAlignedBB unrotatedAABB) { super(config, builder, unrotatedAABB); } @@ -94,7 +95,7 @@ public class BlockDecorPassiveFluidAccumulator extends BlockDecorDirected public void send_device_stats(PlayerEntity player) { int t_vol = tank_.getAmount(); - ModAuxiliaries.playerChatMessage(player,"" + t_vol + "mB"); + Auxiliaries.playerChatMessage(player,"" + t_vol + "mB"); } public void block_changed() diff --git a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorPipeValve.java b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorPipeValve.java index dd61474..25f9233 100644 --- a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorPipeValve.java +++ b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorPipeValve.java @@ -11,6 +11,7 @@ package wile.engineersdecor.blocks; import wile.engineersdecor.ModContent; import wile.engineersdecor.ModEngineersDecor; +import wile.engineersdecor.libmc.blocks.StandardBlocks; import net.minecraft.world.IWorld; import net.minecraft.world.World; import net.minecraft.world.IBlockReader; @@ -18,7 +19,6 @@ import net.minecraft.state.BooleanProperty; import net.minecraft.state.StateContainer; import net.minecraft.block.Block; import net.minecraft.block.BlockState; -import net.minecraft.block.IWaterLoggable; import net.minecraft.tileentity.TileEntityType; import net.minecraft.tileentity.TileEntity; import net.minecraft.item.BlockItemUseContext; @@ -37,11 +37,12 @@ import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler; + import javax.annotation.Nonnull; import javax.annotation.Nullable; -public class BlockDecorPipeValve extends BlockDecorDirected implements IWaterLoggable +public class BlockDecorPipeValve extends StandardBlocks.DirectedWaterLoggable implements IDecorBlock { public static final BooleanProperty RS_CN_N = BooleanProperty.create("rs_n"); public static final BooleanProperty RS_CN_S = BooleanProperty.create("rs_s"); @@ -50,6 +51,11 @@ public class BlockDecorPipeValve extends BlockDecorDirected implements IWaterLog public static final BooleanProperty RS_CN_U = BooleanProperty.create("rs_u"); public static final BooleanProperty RS_CN_D = BooleanProperty.create("rs_d"); + public static final int CFG_CHECK_VALVE = 0x0; + public static final int CFG_ANALOG_VALVE = 0x1; + public static final int CFG_REDSTONE_CONTROLLED_VALVE = 0x2; + public final int valve_config; + public static void on_config(int container_size_decl, int redstone_slope) { BTileEntity.fluid_maxflow_mb = MathHelper.clamp(container_size_decl, 1, 10000); @@ -57,12 +63,12 @@ public class BlockDecorPipeValve extends BlockDecorDirected implements IWaterLog ModEngineersDecor.logger().info("Config pipe valve: maxflow:" + BTileEntity.fluid_maxflow_mb + "mb, redstone amp:" + BTileEntity.redstone_flow_slope_mb + "mb/sig"); } - public BlockDecorPipeValve(long config, Block.Properties builder, final AxisAlignedBB unrotatedAABB) - { super(config|CFG_WATERLOGGABLE, builder, unrotatedAABB); } + public BlockDecorPipeValve(long config, int valve_config, Block.Properties builder, final AxisAlignedBB unrotatedAABB) + { super(config, builder, unrotatedAABB); this.valve_config = valve_config; } private BlockState get_rsconnector_state(BlockState state, IWorld world, BlockPos pos, @Nullable BlockPos fromPos) { - if((config & (CFG_REDSTONE_CONTROLLED))==0) return state; + if((valve_config & (CFG_REDSTONE_CONTROLLED_VALVE))==0) return state; Direction.Axis bfa = state.get(FACING).getAxis(); int bfi = state.get(FACING).getIndex(); for(Direction f:Direction.values()) { @@ -88,7 +94,7 @@ public class BlockDecorPipeValve extends BlockDecorDirected implements IWaterLog private void update_te(IWorld world, BlockState state, BlockPos pos) { TileEntity te = world.getTileEntity(pos); - if(te instanceof BlockDecorPipeValve.BTileEntity) ((BlockDecorPipeValve.BTileEntity)te).block_reconfigure(state.get(FACING), config); + if(te instanceof BlockDecorPipeValve.BTileEntity) ((BlockDecorPipeValve.BTileEntity)te).block_reconfigure(state.get(FACING), config, valve_config); } @Override @@ -97,7 +103,7 @@ public class BlockDecorPipeValve extends BlockDecorDirected implements IWaterLog @Override protected void fillStateContainer(StateContainer.Builder builder) - { super.fillStateContainer(builder); builder.add(RS_CN_N, RS_CN_S, RS_CN_E, RS_CN_W, RS_CN_U, RS_CN_D, WATERLOGGED); } + { super.fillStateContainer(builder); builder.add(RS_CN_N, RS_CN_S, RS_CN_E, RS_CN_W, RS_CN_U, RS_CN_D); } @Override @Nullable @@ -147,6 +153,7 @@ public class BlockDecorPipeValve extends BlockDecorDirected implements IWaterLog private boolean filling_ = false; private boolean getlocked_ = false; private long block_config_ = 0; + private long valve_config_ = 0; public BTileEntity() { this(ModContent.TET_STRAIGHT_PIPE_VALVE); } @@ -154,10 +161,11 @@ public class BlockDecorPipeValve extends BlockDecorDirected implements IWaterLog public BTileEntity(TileEntityType te_type) { super(te_type); } - public void block_reconfigure(Direction facing, long block_config) + public void block_reconfigure(Direction facing, long block_config, int valve_config) { block_facing_ = facing; block_config_ = block_config; + valve_config_ = valve_config; } private Direction block_facing() @@ -234,10 +242,10 @@ public class BlockDecorPipeValve extends BlockDecorDirected implements IWaterLog if(te.filling_) return 0; final IFluidHandler fh = te.forward_fluid_handler(); if(fh==null) return 0; - if((te.block_config_ & CFG_REDSTONE_CONTROLLED) != 0) { + if((te.valve_config_ & CFG_REDSTONE_CONTROLLED_VALVE) != 0) { int rs = te.world.getRedstonePowerFromNeighbors(te.pos); if(rs <= 0) return 0; - if(((te.block_config_ & CFG_ANALOG) != 0) && (rs < 15)) resource.setAmount(MathHelper.clamp(rs * redstone_flow_slope_mb, 1, resource.getAmount())); + if(((te.valve_config_ & CFG_ANALOG_VALVE) != 0) && (rs < 15)) resource.setAmount(MathHelper.clamp(rs * redstone_flow_slope_mb, 1, resource.getAmount())); } FluidStack res = resource.copy(); if(res.getAmount() > fluid_maxflow_mb) res.setAmount(fluid_maxflow_mb); diff --git a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorPlacer.java b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorPlacer.java index 9aaf274..997bb53 100644 --- a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorPlacer.java +++ b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorPlacer.java @@ -10,9 +10,9 @@ package wile.engineersdecor.blocks; import wile.engineersdecor.ModContent; import wile.engineersdecor.ModEngineersDecor; -import wile.engineersdecor.detail.Networking; +import wile.engineersdecor.libmc.blocks.StandardBlocks; +import wile.engineersdecor.libmc.detail.Networking; import net.minecraft.block.*; -import net.minecraft.state.StateContainer; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; @@ -54,29 +54,15 @@ import java.util.ArrayList; import java.util.List; -public class BlockDecorPlacer extends BlockDecorDirected +public class BlockDecorPlacer extends StandardBlocks.Directed { public BlockDecorPlacer(long config, Block.Properties builder, final AxisAlignedBB unrotatedAABB) { super(config, builder, unrotatedAABB); } - @Override - @OnlyIn(Dist.CLIENT) - public BlockRenderLayer getRenderLayer() - { return BlockRenderLayer.SOLID; } - @Override public VoxelShape getCollisionShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext selectionContext) { return VoxelShapes.fullCube(); } - @Override - protected void fillStateContainer(StateContainer.Builder builder) - { super.fillStateContainer(builder); } - - @Override - @Nullable - public BlockState getStateForPlacement(BlockItemUseContext context) - { return super.getStateForPlacement(context); } - @Override @SuppressWarnings("deprecation") public boolean hasComparatorInputOverride(BlockState state) @@ -456,7 +442,7 @@ public class BlockDecorPlacer extends BlockDecorDirected if(current_stack.isEmpty()) { current_slot_index_ = 0; return false; } boolean no_space = false; final Item item = current_stack.getItem(); - Block block = (item instanceof IPlantable) ? (((IPlantable)item).getPlant(world, pos).getBlock()) : Block.getBlockFromItem(item); + Block block = Block.getBlockFromItem(item); if(block == Blocks.AIR) { if(item != null) { return spit_out(facing); // Item not accepted @@ -511,10 +497,15 @@ public class BlockDecorPlacer extends BlockDecorDirected final BlockState placement_state = (use_context==null) ? (block.getDefaultState()) : (block.getStateForPlacement(use_context)); if(placement_state == null) { return spit_out(facing); - } else if(item instanceof BlockItem) { + } else if((use_context!=null) && (item instanceof BlockItem)) { if(((BlockItem)item).tryPlace(use_context) == ActionResultType.SUCCESS) { SoundType stype = block.getSoundType(placement_state, world, pos, null); if(stype != null) world.playSound(null, placement_pos, stype.getPlaceSound(), SoundCategory.BLOCKS, stype.getVolume()*0.6f, stype.getPitch()); + } else if(block instanceof IPlantable) { + if(world.setBlockState(placement_pos, placement_state, 1|2|8)) { + SoundType stype = block.getSoundType(placement_state, world, pos, null); + if(stype != null) world.playSound(null, placement_pos, stype.getPlaceSound(), SoundCategory.BLOCKS, stype.getVolume()*0.6f, stype.getPitch()); + } } else { return spit_out(facing); } diff --git a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorSlab.java b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorSlab.java index 8b845ab..53827da 100644 --- a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorSlab.java +++ b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorSlab.java @@ -12,7 +12,8 @@ import net.minecraft.fluid.Fluid; import net.minecraft.fluid.IFluidState; import net.minecraft.util.math.*; import net.minecraft.world.IWorld; -import wile.engineersdecor.detail.ModAuxiliaries; +import wile.engineersdecor.libmc.blocks.VariantSlabBlock; +import wile.engineersdecor.libmc.detail.Auxiliaries; import net.minecraft.block.*; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.player.PlayerEntity; @@ -39,153 +40,8 @@ import java.util.Collections; import java.util.List; -public class BlockDecorSlab extends BlockDecor.WaterLoggable +public class BlockDecorSlab extends VariantSlabBlock { - public static final IntegerProperty PARTS = IntegerProperty.create("parts", 0, 2); - public static final IntegerProperty TEXTURE_VARIANT = IntegerProperty.create("tvariant", 0, 3); - - protected static final VoxelShape AABBs[] = { - VoxelShapes.create(new AxisAlignedBB(0, 0./16, 0, 1, 8./16, 1)), // bottom slab - VoxelShapes.create(new AxisAlignedBB(0, 8./16, 0, 1, 16./16, 1)), // top slab - VoxelShapes.create(new AxisAlignedBB(0, 0./16, 0, 1, 16./16, 1)), // both slabs - VoxelShapes.create(new AxisAlignedBB(0, 0./16, 0, 1, 16./16, 1)) // << 2bit fill - }; - protected static final int num_slabs_contained_in_parts_[] = { 1,1,2,2 }; - - protected boolean is_cube(BlockState state) - { return state.get(PARTS) >= 2; } - public BlockDecorSlab(long config, Block.Properties builder) - { super(config|CFG_WATERLOGGABLE, builder); } - - @Override - @OnlyIn(Dist.CLIENT) - public BlockRenderLayer getRenderLayer() - { return (((config & CFG_TRANSLUCENT)!=0) ? (BlockRenderLayer.TRANSLUCENT) : (BlockRenderLayer.CUTOUT)); } - - @Override - @OnlyIn(Dist.CLIENT) - public void addInformation(ItemStack stack, @Nullable IBlockReader world, List tooltip, ITooltipFlag flag) - { - if(!ModAuxiliaries.Tooltip.addInformation(stack, world, tooltip, flag, true)) return; - if(!ModConfig.without_direct_slab_pickup) ModAuxiliaries.Tooltip.addInformation("engineersdecor.tooltip.slabpickup", "engineersdecor.tooltip.slabpickup", tooltip, flag, true); - } - - @Override - @OnlyIn(Dist.CLIENT) - @SuppressWarnings("deprecation") - public boolean isSideInvisible(BlockState state, BlockState adjacentBlockState, Direction side) - { return (adjacentBlockState==state) ? true : super.isSideInvisible(state, adjacentBlockState, side); } - - @Override - public boolean canSpawnInBlock() - { return false; } - - @Override - @SuppressWarnings("deprecation") - public boolean canEntitySpawn(BlockState state, IBlockReader world, BlockPos pos, EntityType entityType) - { return false; } - - @Override - public VoxelShape getShape(BlockState state, IBlockReader source, BlockPos pos, ISelectionContext selectionContext) - { return AABBs[state.get(PARTS) & 0x3]; } - - @Override - public VoxelShape getCollisionShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext selectionContext) - { return getShape(state, world, pos, selectionContext); } - - @Override - protected void fillStateContainer(StateContainer.Builder builder) - { super.fillStateContainer(builder); builder.add(PARTS, TEXTURE_VARIANT); } - - @Override - @Nullable - public BlockState getStateForPlacement(BlockItemUseContext context) - { - BlockPos pos = context.getPos(); - if(context.getWorld().getBlockState(pos).getBlock() == this) return context.getWorld().getBlockState(pos).with(PARTS, 2).with(WATERLOGGED, false); - final int rnd = MathHelper.clamp((int)(MathHelper.getPositionRandom(context.getPos()) & 0x3), 0, 3); - final Direction face = context.getFace(); - final BlockState placement_state = super.getStateForPlacement(context).with(TEXTURE_VARIANT, rnd); // fluid state - if(face == Direction.UP) return placement_state.with(PARTS, 0); - if(face == Direction.DOWN) return placement_state.with(PARTS, 1); - if(!face.getAxis().isHorizontal()) return placement_state; - final boolean isupper = ((context.getHitVec().getY() - context.getPos().getY()) > 0.5); - return placement_state.with(PARTS, isupper ? 1 : 0); - } - - @Override - @SuppressWarnings("deprecation") - public boolean isReplaceable(BlockState state, BlockItemUseContext context) - { - if(context.getItem().getItem() != this.asItem()) return false; - if(!context.replacingClickedOnBlock()) return true; - final Direction face = context.getFace(); - final int parts = state.get(PARTS); - if((face == Direction.UP) && (parts==0)) return true; - if((face == Direction.DOWN) && (parts==1)) return true; - if(!face.getAxis().isHorizontal()) return false; - final boolean isupper = ((context.getHitVec().getY() - context.getPos().getY()) > 0.5); - return isupper ? (parts==0) : (parts==1); - } - - @Override - @SuppressWarnings("deprecation") - public BlockState rotate(BlockState state, Rotation rot) - { return state; } - - @Override - @SuppressWarnings("deprecation") - public BlockState mirror(BlockState state, Mirror mirrorIn) - { return state; } - - @Override - public boolean hasDynamicDropList() - { return true; } - - @Override - public List dropList(BlockState state, World world, BlockPos pos, boolean explosion) - { return new ArrayList(Collections.singletonList(new ItemStack(this.asItem(), num_slabs_contained_in_parts_[state.get(PARTS) & 0x3]))); } - - @Override - @SuppressWarnings("deprecation") - public void onBlockClicked(BlockState state, World world, BlockPos pos, PlayerEntity player) - { - if((world.isRemote) || (ModConfig.without_direct_slab_pickup)) return; - final ItemStack stack = player.getHeldItemMainhand(); - if(stack.isEmpty() || (Block.getBlockFromItem(stack.getItem()) != this)) return; - if(stack.getCount() >= stack.getMaxStackSize()) return; - Vec3d lv = player.getLookVec(); - Direction facing = Direction.getFacingFromVector((float)lv.x, (float)lv.y, (float)lv.z); - if((facing != Direction.UP) && (facing != Direction.DOWN)) return; - if(state.getBlock() != this) return; - int parts = state.get(PARTS); - if(facing == Direction.DOWN) { - if(parts == 2) { - world.setBlockState(pos, state.with(PARTS, 0), 3); - } else { - world.removeBlock(pos, false); - } - } else if(facing == Direction.UP) { - if(parts == 2) { - world.setBlockState(pos, state.with(PARTS, 1), 3); - } else { - world.removeBlock(pos, false); - } - } - if(!player.isCreative()) { - stack.grow(1); - if(player.inventory != null) player.inventory.markDirty(); - } - SoundType st = this.getSoundType(state, world, pos, null); - world.playSound(player, pos, st.getPlaceSound(), SoundCategory.BLOCKS, (st.getVolume()+1f)/2.5f, 0.9f*st.getPitch()); - } - - @Override - public boolean receiveFluid(IWorld world, BlockPos pos, BlockState state, IFluidState fluidState) - { return (state.get(PARTS)==2) ? false : super.receiveFluid(world, pos, state, fluidState); } - - public boolean canContainFluid(IBlockReader world, BlockPos pos, BlockState state, Fluid fluid) - { return (state.get(PARTS)==2) ? false : super.canContainFluid(world, pos, state, fluid); } - + { super(config, builder); } } diff --git a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorSolarPanel.java b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorSolarPanel.java index 372f571..c2e0f77 100644 --- a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorSolarPanel.java +++ b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorSolarPanel.java @@ -27,11 +27,12 @@ import net.minecraftforge.energy.CapabilityEnergy; import net.minecraftforge.energy.IEnergyStorage; import net.minecraftforge.common.capabilities.ICapabilityProvider; import net.minecraftforge.common.util.LazyOptional; +import wile.engineersdecor.libmc.blocks.StandardBlocks; import javax.annotation.Nullable; -public class BlockDecorSolarPanel extends BlockDecor +public class BlockDecorSolarPanel extends StandardBlocks.BaseBlock { public static final IntegerProperty EXPOSITION = IntegerProperty.create("exposition", 0, 4); diff --git a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorStairs.java b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorStairs.java index 7080d07..ed3358d 100644 --- a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorStairs.java +++ b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorStairs.java @@ -8,48 +8,15 @@ */ package wile.engineersdecor.blocks; -import wile.engineersdecor.detail.ModAuxiliaries; -import net.minecraft.entity.EntityType; -import net.minecraft.util.math.BlockPos; +import wile.engineersdecor.libmc.blocks.StandardStairsBlock; import net.minecraft.block.*; -import net.minecraft.block.material.PushReaction; import net.minecraft.block.BlockState; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.item.ItemStack; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.world.IBlockReader; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import javax.annotation.Nullable; -import java.util.List; - - -public class BlockDecorStairs extends StairsBlock implements IDecorBlock +public class BlockDecorStairs extends StandardStairsBlock implements IDecorBlock { public BlockDecorStairs(long config, BlockState state, Block.Properties properties) - { super(()->state, properties); } + { super(config, state, properties); } public BlockDecorStairs(long config, java.util.function.Supplier state, Block.Properties properties) - { super(state, properties); } - - @Override - @OnlyIn(Dist.CLIENT) - public void addInformation(ItemStack stack, @Nullable IBlockReader world, List tooltip, ITooltipFlag flag) - { ModAuxiliaries.Tooltip.addInformation(stack, world, tooltip, flag, true); } - - @Override - public boolean canSpawnInBlock() - { return false; } - - @Override - @SuppressWarnings("deprecation") - public boolean canEntitySpawn(BlockState state, IBlockReader world, BlockPos pos, EntityType entityType) - { return false; } - - @Override - @SuppressWarnings("deprecation") - public PushReaction getPushReaction(BlockState state) - { return PushReaction.NORMAL; } - + { super(config, state, properties); } } diff --git a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorStraightPole.java b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorStraightPole.java index 1e70a64..5b9ef8b 100644 --- a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorStraightPole.java +++ b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorStraightPole.java @@ -18,17 +18,15 @@ import net.minecraft.world.World; import net.minecraft.util.Direction; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; +import wile.engineersdecor.libmc.blocks.StandardBlocks; + import javax.annotation.Nullable; -public class BlockDecorStraightPole extends BlockDecorDirected implements IWaterLoggable +public class BlockDecorStraightPole extends StandardBlocks.DirectedWaterLoggable implements IDecorBlock,IWaterLoggable { public BlockDecorStraightPole(long config, Block.Properties builder, final AxisAlignedBB unrotatedAABB) - { super(config|CFG_WATERLOGGABLE, builder, unrotatedAABB); } - - @Override - protected void fillStateContainer(StateContainer.Builder builder) - { super.fillStateContainer(builder); builder.add(WATERLOGGED); } + { super(config, builder, unrotatedAABB); } @Override @Nullable @@ -37,7 +35,7 @@ public class BlockDecorStraightPole extends BlockDecorDirected implements IWater Direction facing = context.getFace(); final boolean waterlogged = context.getWorld().getFluidState(context.getPos()).getFluid()==Fluids.WATER; BlockState state = super.getStateForPlacement(context).with(FACING, facing).with(WATERLOGGED, waterlogged); - if((config & CFG_FLIP_PLACEMENT_IF_SAME) != 0) { + if((config & StandardBlocks.CFG_FLIP_PLACEMENT_IF_SAME) != 0) { World world = context.getWorld(); BlockPos pos = context.getPos(); if(world.getBlockState(pos.offset(facing.getOpposite())).getBlock() instanceof BlockDecorStraightPole) { diff --git a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorTest.java b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorTest.java index 8911eb0..9e489fd 100644 --- a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorTest.java +++ b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorTest.java @@ -9,8 +9,9 @@ package wile.engineersdecor.blocks; import wile.engineersdecor.ModContent; -import wile.engineersdecor.detail.ModAuxiliaries; -import wile.engineersdecor.detail.ModAuxiliaries.IExperimentalFeature; +import wile.engineersdecor.libmc.blocks.StandardBlocks; +import wile.engineersdecor.libmc.detail.Auxiliaries; +import wile.engineersdecor.libmc.detail.Auxiliaries.IExperimentalFeature; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; @@ -44,7 +45,7 @@ import java.util.ArrayList; import java.util.List; -public class BlockDecorTest extends BlockDecorDirected implements IExperimentalFeature +public class BlockDecorTest extends StandardBlocks.Directed implements IExperimentalFeature { public BlockDecorTest(long config, Block.Properties builder, final AxisAlignedBB unrotatedAABB) { super(config, builder, unrotatedAABB); } @@ -151,7 +152,7 @@ public class BlockDecorTest extends BlockDecorDirected implements IExperimentalF if(message.isEmpty()) { message = "No fluid, energy, or item interactions done yet."; } - ModAuxiliaries.playerChatMessage(player, message); + Auxiliaries.playerChatMessage(player, message); return; } } @@ -166,23 +167,23 @@ public class BlockDecorTest extends BlockDecorDirected implements IExperimentalF if(!fs.isEmpty()) { if(active_fill_fluidstack_.isEmpty()) { active_fill_fluidstack_ = fs.copy(); - ModAuxiliaries.playerChatMessage(player, "Fluid insertion fluid set: " + dump_fluid_stack(active_fill_fluidstack_)); + Auxiliaries.playerChatMessage(player, "Fluid insertion fluid set: " + dump_fluid_stack(active_fill_fluidstack_)); } else if(fs.isFluidEqual(active_fill_fluidstack_)) { active_fill_fluidstack_.grow(fs.getAmount()); - ModAuxiliaries.playerChatMessage(player, "Fluid insertion flowrate increased: " + dump_fluid_stack(active_fill_fluidstack_)); + Auxiliaries.playerChatMessage(player, "Fluid insertion flowrate increased: " + dump_fluid_stack(active_fill_fluidstack_)); } else { int amount = active_fill_fluidstack_.getAmount(); active_fill_fluidstack_ = fs.copy(); active_fill_fluidstack_.setAmount(amount); - ModAuxiliaries.playerChatMessage(player, "Fluid insertion fluid changed: " + dump_fluid_stack(active_fill_fluidstack_)); + Auxiliaries.playerChatMessage(player, "Fluid insertion fluid changed: " + dump_fluid_stack(active_fill_fluidstack_)); } } else { if(!active_fill_fluidstack_.isEmpty()) { active_fill_fluidstack_.shrink(1000); if(active_fill_fluidstack_.isEmpty()) active_fill_fluidstack_ = FluidStack.EMPTY; - ModAuxiliaries.playerChatMessage(player, "Fluid insertion flowrate decreased: " + dump_fluid_stack(active_fill_fluidstack_)); + Auxiliaries.playerChatMessage(player, "Fluid insertion flowrate decreased: " + dump_fluid_stack(active_fill_fluidstack_)); } else { - ModAuxiliaries.playerChatMessage(player, "Fluid insertion disabled."); + Auxiliaries.playerChatMessage(player, "Fluid insertion disabled."); } } passive_drain_fluidstack_ = active_fill_fluidstack_.copy(); // currently no difference diff --git a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorTreeCutter.java b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorTreeCutter.java index 1db5fc3..b9a29bb 100644 --- a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorTreeCutter.java +++ b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorTreeCutter.java @@ -31,12 +31,13 @@ import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.energy.CapabilityEnergy; import net.minecraftforge.energy.IEnergyStorage; import wile.engineersdecor.detail.TreeCutting; +import wile.engineersdecor.libmc.blocks.StandardBlocks; import javax.annotation.Nullable; import java.util.Random; -public class BlockDecorTreeCutter extends BlockDecorDirectedHorizontal +public class BlockDecorTreeCutter extends StandardBlocks.Horizontal { public static final BooleanProperty ACTIVE = BooleanProperty.create("active"); diff --git a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorWall.java b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorWall.java index d462812..563f4e1 100644 --- a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorWall.java +++ b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorWall.java @@ -8,112 +8,11 @@ */ package wile.engineersdecor.blocks; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.world.*; -import wile.engineersdecor.detail.ModAuxiliaries; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.fluid.IFluidState; -import net.minecraft.entity.EntityType; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.state.StateContainer; -import net.minecraft.util.math.MathHelper; +import wile.engineersdecor.libmc.blocks.VariantWallBlock; import net.minecraft.block.*; -import net.minecraft.block.material.PushReaction; -import net.minecraft.block.BlockState; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.fluid.Fluids; -import net.minecraft.item.ItemStack; -import net.minecraft.state.IntegerProperty; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.text.ITextComponent; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import javax.annotation.Nullable; -import java.util.List; - -public class BlockDecorWall extends WallBlock implements IDecorBlock +public class BlockDecorWall extends VariantWallBlock implements IDecorBlock { - private final VoxelShape[] shape_voxels; - private final VoxelShape[] collision_shape_voxels; - public static final IntegerProperty TEXTURE_VARIANT = IntegerProperty.create("tvariant", 0, 7); - public BlockDecorWall(long config, Block.Properties builder) - { - super(builder); - this.shape_voxels = buildWallShapes(4.0F, 4.0F, 16.0F, 0.0F, 16.0F); - this.collision_shape_voxels = buildWallShapes(4.0F, 4.0F, 24.0F, 0.0F, 24.0F); - } - - @Override - @OnlyIn(Dist.CLIENT) - public void addInformation(ItemStack stack, @Nullable IBlockReader world, List tooltip, ITooltipFlag flag) - { ModAuxiliaries.Tooltip.addInformation(stack, world, tooltip, flag, true); } - - protected VoxelShape[] buildWallShapes(float pole_width_x, float pole_width_z, float pole_height, float side_min_y, float side_max_y) - { return super.makeShapes(pole_width_x, pole_width_z, pole_height, side_min_y, side_max_y); } - - @Override - public VoxelShape getShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext selectionContext) - { return shape_voxels[this.getIndex(state)]; } - - @Override - public VoxelShape getCollisionShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext selectionContext) - { return collision_shape_voxels[this.getIndex(state)]; } - - @Override - protected void fillStateContainer(StateContainer.Builder builder) - { super.fillStateContainer(builder); builder.add(TEXTURE_VARIANT); } - - private boolean attachesTo(BlockState facingState, IWorldReader world, BlockPos facingPos, Direction side) - { - final Block block = facingState.getBlock(); - if((block instanceof FenceGateBlock) || (block instanceof WallBlock)) return true; - final BlockState oppositeState = world.getBlockState(facingPos.offset(side, 2)); - if(!(oppositeState.getBlock() instanceof BlockDecorWall)) return false; - return facingState.isNormalCube(world, facingPos) && hasSolidSide(facingState, world, facingPos, side); - } - - public BlockState getStateForPlacement(BlockItemUseContext context) - { - IWorldReader world = context.getWorld(); - BlockPos pos = context.getPos(); - IFluidState fs = context.getWorld().getFluidState(context.getPos()); - boolean n = attachesTo(world.getBlockState(pos.north()), world, pos.north(), Direction.SOUTH); - boolean e = attachesTo(world.getBlockState(pos.east()), world, pos.east(), Direction.WEST); - boolean s = attachesTo(world.getBlockState(pos.south()), world, pos.south(), Direction.NORTH); - boolean w = attachesTo(world.getBlockState(pos.west()), world, pos.west(), Direction.EAST); - boolean not_straight = (!n || !s || e || w) && (n || s || !e || !w); - return getDefaultState().with(UP, not_straight).with(NORTH, n).with(EAST, e).with(SOUTH, s).with(WEST, w).with(WATERLOGGED, fs.getFluid() == Fluids.WATER); - } - - @Override - public BlockState updatePostPlacement(BlockState state, Direction side, BlockState facingState, IWorld world, BlockPos currentPos, BlockPos facingPos) - { - if(state.get(WATERLOGGED)) world.getPendingFluidTicks().scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickRate(world)); - if(side == Direction.DOWN) return super.updatePostPlacement(state, side, facingState, world, currentPos, facingPos); - boolean n = (side==Direction.NORTH) ? this.attachesTo(facingState, world, facingPos, side) : state.get(NORTH); - boolean e = (side==Direction.EAST) ? this.attachesTo(facingState, world, facingPos, side) : state.get(EAST); - boolean s = (side==Direction.SOUTH) ? this.attachesTo(facingState, world, facingPos, side) : state.get(SOUTH); - boolean w = (side==Direction.WEST) ? this.attachesTo(facingState, world, facingPos, side) : state.get(WEST); - boolean not_straight = (!n || !s || e || w) && (n || s || !e || !w); - return state.with(UP, not_straight).with(NORTH, n).with(EAST, e).with(SOUTH, s).with(WEST, w).with(TEXTURE_VARIANT, ((int)MathHelper.getPositionRandom(currentPos)) & 0x7); - } - - @Override - @SuppressWarnings("deprecation") - public boolean canEntitySpawn(BlockState state, IBlockReader world, BlockPos pos, EntityType entityType) - { return false; } - - @Override - public boolean canSpawnInBlock() - { return false; } - - @Override - @SuppressWarnings("deprecation") - public PushReaction getPushReaction(BlockState state) - { return PushReaction.NORMAL; } - + { super(config, builder); } } diff --git a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorWasteIncinerator.java b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorWasteIncinerator.java index 62be7ee..b148c99 100644 --- a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorWasteIncinerator.java +++ b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorWasteIncinerator.java @@ -50,6 +50,8 @@ import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.ItemHandlerHelper; import com.mojang.blaze3d.platform.GlStateManager; +import wile.engineersdecor.libmc.blocks.StandardBlocks; + import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.util.ArrayList; @@ -57,18 +59,13 @@ import java.util.List; import java.util.Random; -public class BlockDecorWasteIncinerator extends BlockDecor +public class BlockDecorWasteIncinerator extends StandardBlocks.BaseBlock { public static final BooleanProperty LIT = BlockDecorFurnace.LIT; public BlockDecorWasteIncinerator(long config, Block.Properties builder, final AxisAlignedBB unrotatedAABB) { super(config, builder, unrotatedAABB); } - @Override - @OnlyIn(Dist.CLIENT) - public BlockRenderLayer getRenderLayer() - { return BlockRenderLayer.SOLID; } - @Override protected void fillStateContainer(StateContainer.Builder builder) { super.fillStateContainer(builder); builder.add(LIT); } diff --git a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorWindow.java b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorWindow.java index a796be4..e9994bd 100644 --- a/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorWindow.java +++ b/1.14/src/main/java/wile/engineersdecor/blocks/BlockDecorWindow.java @@ -8,23 +8,22 @@ */ package wile.engineersdecor.blocks; +import wile.engineersdecor.libmc.blocks.StandardBlocks; import net.minecraft.block.Block; import net.minecraft.block.BlockState; -import net.minecraft.block.IWaterLoggable; import net.minecraft.item.BlockItemUseContext; -import net.minecraft.state.StateContainer; import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.Direction; import net.minecraft.util.math.AxisAlignedBB; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; - import javax.annotation.Nullable; -public class BlockDecorWindow extends BlockDecorDirected implements IWaterLoggable + +public class BlockDecorWindow extends StandardBlocks.DirectedWaterLoggable implements IDecorBlock { public BlockDecorWindow(long config, Block.Properties builder, final AxisAlignedBB unrotatedAABB) - { super(config|CFG_WATERLOGGABLE, builder, unrotatedAABB); } + { super(config, builder, unrotatedAABB); } @Override @OnlyIn(Dist.CLIENT) @@ -36,10 +35,6 @@ public class BlockDecorWindow extends BlockDecorDirected implements IWaterLoggab public boolean canRenderInLayer(BlockState state, BlockRenderLayer layer) { return (layer==BlockRenderLayer.CUTOUT) || (layer==BlockRenderLayer.TRANSLUCENT); } - @Override - protected void fillStateContainer(StateContainer.Builder builder) - { super.fillStateContainer(builder); builder.add(WATERLOGGED); } - @Override @Nullable public BlockState getStateForPlacement(BlockItemUseContext context) diff --git a/1.14/src/main/java/wile/engineersdecor/blocks/IDecorBlock.java b/1.14/src/main/java/wile/engineersdecor/blocks/IDecorBlock.java index a84c2ce..bb88a29 100644 --- a/1.14/src/main/java/wile/engineersdecor/blocks/IDecorBlock.java +++ b/1.14/src/main/java/wile/engineersdecor/blocks/IDecorBlock.java @@ -12,17 +12,12 @@ import net.minecraft.block.BlockState; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import wile.engineersdecor.libmc.blocks.StandardBlocks; + import java.util.Collections; import java.util.List; -public interface IDecorBlock +public interface IDecorBlock extends StandardBlocks.IStandardBlock { - - default boolean hasDynamicDropList() - { return false; } - - default List dropList(BlockState state, World world, BlockPos pos, boolean explosion) - { return Collections.singletonList((!world.isRemote()) ? (new ItemStack(state.getBlock().asItem())) : (ItemStack.EMPTY)); } - } diff --git a/1.14/src/main/java/wile/engineersdecor/detail/ModConfig.java b/1.14/src/main/java/wile/engineersdecor/detail/ModConfig.java index 3966f75..3b6a946 100644 --- a/1.14/src/main/java/wile/engineersdecor/detail/ModConfig.java +++ b/1.14/src/main/java/wile/engineersdecor/detail/ModConfig.java @@ -12,6 +12,8 @@ package wile.engineersdecor.detail; import wile.engineersdecor.ModContent; import wile.engineersdecor.ModEngineersDecor; import wile.engineersdecor.blocks.*; +import wile.engineersdecor.libmc.detail.Auxiliaries; +import wile.engineersdecor.libmc.detail.OptionalRecipeCondition; import net.minecraft.nbt.CompoundNBT; import net.minecraft.block.Block; import net.minecraft.item.Item; @@ -500,7 +502,7 @@ public class ModConfig if(COMMON == null) return false; try { if(!COMMON.with_experimental.get()) { - if(block instanceof ModAuxiliaries.IExperimentalFeature) return true; + if(block instanceof Auxiliaries.IExperimentalFeature) return true; if(ModContent.isExperimentalBlock(block)) return true; } final String rn = block.getRegistryName().getPath(); @@ -595,7 +597,6 @@ public class ModConfig private static final CompoundNBT server_config_ = new CompoundNBT(); public static boolean without_crafting_table = false; public static boolean immersiveengineering_installed = false; - public static boolean without_direct_slab_pickup = false; public static boolean with_creative_mode_device_drops = false; private static boolean with_experimental_features_ = false; private static boolean without_recipes_ = false; @@ -605,6 +606,7 @@ public class ModConfig public static final void apply() { + OptionalRecipeCondition.on_config(with_experimental_features_, without_recipes_, (block)->isOptedOut(block), (item)->isOptedOut(item)); BlockDecorFurnace.BTileEntity.on_config(COMMON.furnace_smelting_speed_percent.get(), COMMON.furnace_fuel_efficiency_percent.get(), COMMON.furnace_boost_energy_consumption.get()); BlockDecorChair.on_config(COMMON.without_chair_sitting.get(), COMMON.without_mob_chair_sitting.get(), COMMON.chair_mob_sitting_probability_percent.get(), COMMON.chair_mob_standup_probability_percent.get()); BlockDecorLadder.on_config(COMMON.without_ladder_speed_boost.get()); @@ -615,11 +617,12 @@ public class ModConfig BlockDecorBreaker.BTileEntity.on_config(COMMON.block_breaker_power_consumption.get(), COMMON.block_breaker_reluctance.get(), COMMON.block_breaker_min_breaking_time.get(), COMMON.block_breaker_requires_power.get()); BlockDecorTreeCutter.BTileEntity.on_config(COMMON.tree_cuttter_energy_consumption.get(), COMMON.tree_cuttter_cutting_time_needed.get(), COMMON.tree_cuttter_requires_power.get()); BlockDecorMilker.BTileEntity.on_config(COMMON.milking_machine_energy_consumption.get(), COMMON.milking_machine_milking_delay.get()); + BlockDecorSlab.on_config(!COMMON.without_direct_slab_pickup.get()); + BlockDecorHalfSlab.on_config(!COMMON.without_direct_slab_pickup.get()); without_crafting_table = isOptedOut(ModContent.TREATED_WOOD_CRAFTING_TABLE); - immersiveengineering_installed = ModAuxiliaries.isModLoaded("immersiveengineering"); + immersiveengineering_installed = Auxiliaries.isModLoaded("immersiveengineering"); with_experimental_features_ = COMMON.with_experimental.get(); without_recipes_ = COMMON.without_recipes.get(); - without_direct_slab_pickup = COMMON.without_direct_slab_pickup.get(); if(with_experimental_features_) { ModEngineersDecor.logger().info("Config: EXPERIMENTAL FEATURES ENABLED."); } diff --git a/1.14/src/main/java/wile/engineersdecor/detail/ModTesrs.java b/1.14/src/main/java/wile/engineersdecor/detail/ModTesrs.java index 7169435..a78a3ab 100644 --- a/1.14/src/main/java/wile/engineersdecor/detail/ModTesrs.java +++ b/1.14/src/main/java/wile/engineersdecor/detail/ModTesrs.java @@ -19,6 +19,7 @@ import net.minecraft.util.math.MathHelper; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import com.mojang.blaze3d.platform.GlStateManager; +import wile.engineersdecor.blocks.BlockDecorCraftingTable.CraftingTableBlock; public class ModTesrs @@ -47,7 +48,7 @@ public class ModTesrs { if(tesr_error_counter<=0) return; try { - int di = MathHelper.clamp(te.getWorld().getBlockState(te.getPos()).get(BlockDecorCraftingTable.CraftingTableBlock.FACING).getHorizontalIndex(), 0, 3); + int di = MathHelper.clamp(te.getWorld().getBlockState(te.getPos()).get(CraftingTableBlock.HORIZONTAL_FACING).getHorizontalIndex(), 0, 3); long posrnd = te.getPos().toLong(); posrnd = (posrnd>>16)^(posrnd<<1); for(int i=0; i<9; ++i) { diff --git a/1.14/src/main/java/wile/engineersdecor/libmc/blocks/SlabSliceBlock.java b/1.14/src/main/java/wile/engineersdecor/libmc/blocks/SlabSliceBlock.java new file mode 100644 index 0000000..b5fb628 --- /dev/null +++ b/1.14/src/main/java/wile/engineersdecor/libmc/blocks/SlabSliceBlock.java @@ -0,0 +1,211 @@ +/* + * @file BlockDecorHalfSlab.java + * @author Stefan Wilhelm (wile) + * @copyright (C) 2019 Stefan Wilhelm + * @license MIT (see https://opensource.org/licenses/MIT) + * + * Half slab ("slab slices") characteristics class. Actually + * it's now a quater slab, but who cares. + */ +package wile.engineersdecor.libmc.blocks; + +import wile.engineersdecor.libmc.detail.Auxiliaries; +import net.minecraft.fluid.Fluid; +import net.minecraft.fluid.IFluidState; +import net.minecraft.world.IWorld; +import net.minecraft.block.*; +import net.minecraft.client.util.ITooltipFlag; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.state.IntegerProperty; +import net.minecraft.util.*; +import net.minecraft.util.math.BlockRayTraceResult; +import net.minecraft.util.math.Vec3d; +import net.minecraft.util.math.shapes.VoxelShapes; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.world.World; +import net.minecraft.entity.EntityType; +import net.minecraft.state.StateContainer; +import net.minecraft.util.math.shapes.ISelectionContext; +import net.minecraft.item.BlockItemUseContext; +import net.minecraft.block.BlockState; +import net.minecraft.world.IBlockReader; +import net.minecraft.util.math.shapes.VoxelShape; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; + +import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + + +public class SlabSliceBlock extends StandardBlocks.WaterLoggable implements StandardBlocks.IStandardBlock +{ + public static final IntegerProperty PARTS = IntegerProperty.create("parts", 0, 14); + + protected static final VoxelShape AABBs[] = { + VoxelShapes.create(new AxisAlignedBB(0, 0./16, 0, 1, 2./16, 1)), + VoxelShapes.create(new AxisAlignedBB(0, 0./16, 0, 1, 4./16, 1)), + VoxelShapes.create(new AxisAlignedBB(0, 0./16, 0, 1, 6./16, 1)), + VoxelShapes.create(new AxisAlignedBB(0, 0./16, 0, 1, 8./16, 1)), + VoxelShapes.create(new AxisAlignedBB(0, 0./16, 0, 1, 10./16, 1)), + VoxelShapes.create(new AxisAlignedBB(0, 0./16, 0, 1, 12./16, 1)), + VoxelShapes.create(new AxisAlignedBB(0, 0./16, 0, 1, 14./16, 1)), + VoxelShapes.create(new AxisAlignedBB(0, 0./16, 0, 1, 16./16, 1)), + VoxelShapes.create(new AxisAlignedBB(0, 2./16, 0, 1, 16./16, 1)), + VoxelShapes.create(new AxisAlignedBB(0, 4./16, 0, 1, 16./16, 1)), + VoxelShapes.create(new AxisAlignedBB(0, 6./16, 0, 1, 16./16, 1)), + VoxelShapes.create(new AxisAlignedBB(0, 8./16, 0, 1, 16./16, 1)), + VoxelShapes.create(new AxisAlignedBB(0, 10./16, 0, 1, 16./16, 1)), + VoxelShapes.create(new AxisAlignedBB(0, 12./16, 0, 1, 16./16, 1)), + VoxelShapes.create(new AxisAlignedBB(0, 14./16, 0, 1, 16./16, 1)), + VoxelShapes.create(new AxisAlignedBB(0,0,0,1,1,1)) // <- with 4bit fill + }; + + protected static final int num_slabs_contained_in_parts_[] = { 1,2,3,4,5,6,7,8,7,6,5,4,3,2,1 ,0x1 }; // <- with 4bit fill + private static boolean with_pickup = false; + + public static void on_config(boolean direct_slab_pickup) + { with_pickup = direct_slab_pickup; } + + public SlabSliceBlock(long config, Block.Properties builder) + { super(config, builder); } + + protected boolean is_cube(BlockState state) + { return state.get(PARTS) == 0x07; } + + @Override + @OnlyIn(Dist.CLIENT) + public void addInformation(ItemStack stack, @Nullable IBlockReader world, List tooltip, ITooltipFlag flag) + { + if(!Auxiliaries.Tooltip.addInformation(stack, world, tooltip, flag, true)) return; + if(with_pickup) Auxiliaries.Tooltip.addInformation("engineersdecor.tooltip.slabpickup", "engineersdecor.tooltip.slabpickup", tooltip, flag, true); + } + + @Override + @OnlyIn(Dist.CLIENT) + public BlockRenderLayer getRenderLayer() + { return (((config & StandardBlocks.CFG_TRANSLUCENT)!=0) ? (BlockRenderLayer.TRANSLUCENT) : (BlockRenderLayer.CUTOUT)); } + + @Override + public boolean canSpawnInBlock() + { return false; } + + @Override + @SuppressWarnings("deprecation") + public boolean canEntitySpawn(BlockState state, IBlockReader world, BlockPos pos, EntityType entityType) + { return false; } + + @Override + public VoxelShape getShape(BlockState state, IBlockReader source, BlockPos pos, ISelectionContext selectionContext) + { return AABBs[state.get(PARTS) & 0xf]; } + + @Override + public VoxelShape getCollisionShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext selectionContext) + { return getShape(state, world, pos, selectionContext); } + + @Override + protected void fillStateContainer(StateContainer.Builder builder) + { super.fillStateContainer(builder); builder.add(PARTS); } + + @Override + @Nullable + public BlockState getStateForPlacement(BlockItemUseContext context) + { + final Direction facing = context.getFace(); + double y = context.getHitVec().getY(); + return super.getStateForPlacement(context).with(PARTS, ((facing==Direction.UP) || ((facing!=Direction.DOWN) && (y < 0.6))) ? 0 : 14); + } + + @Override + @SuppressWarnings("deprecation") + public BlockState rotate(BlockState state, Rotation rot) + { return state; } + + @Override + @SuppressWarnings("deprecation") + public BlockState mirror(BlockState state, Mirror mirrorIn) + { return state; } + + @Override + public boolean hasDynamicDropList() + { return true; } + + @Override + public List dropList(BlockState state, World world, BlockPos pos, boolean explosion) + { return new ArrayList(Collections.singletonList(new ItemStack(this.asItem(), num_slabs_contained_in_parts_[state.get(PARTS) & 0xf]))); } + + @Override + @SuppressWarnings("deprecation") + public boolean onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult rayTraceResult) + { + Direction face = rayTraceResult.getFace(); + final ItemStack stack = player.getHeldItem(hand); + if(stack.isEmpty() || (Block.getBlockFromItem(stack.getItem()) != this)) return false; + if((face != Direction.UP) && (face != Direction.DOWN)) return false; + int parts = state.get(PARTS); + if((face != Direction.UP) && (parts > 7)) { + world.setBlockState(pos, state.with(PARTS, parts-1), 3); + } else if((face != Direction.DOWN) && (parts < 7)) { + world.setBlockState(pos, state.with(PARTS, parts+1), 3); + } else { + return (parts != 7); + } + if(world.isRemote) return true; + if(!player.isCreative()) { + stack.shrink(1); + if(player.inventory != null) player.inventory.markDirty(); + } + SoundType st = this.getSoundType(state, world, pos, null); + world.playSound(null, pos, st.getPlaceSound(), SoundCategory.BLOCKS, (st.getVolume()+1f)/2.5f, 0.9f*st.getPitch()); + return true; + } + + @Override + @SuppressWarnings("deprecation") + public void onBlockClicked(BlockState state, World world, BlockPos pos, PlayerEntity player) + { + if((world.isRemote) || (!with_pickup)) return; + final ItemStack stack = player.getHeldItemMainhand(); + if(stack.isEmpty() || (Block.getBlockFromItem(stack.getItem()) != this)) return; + if(stack.getCount() >= stack.getMaxStackSize()) return; + Vec3d lv = player.getLookVec(); + Direction facing = Direction.getFacingFromVector((float)lv.x, (float)lv.y, (float)lv.z); + if((facing != Direction.UP) && (facing != Direction.DOWN)) return; + if(state.getBlock() != this) return; + int parts = state.get(PARTS); + if((facing == Direction.DOWN) && (parts <= 7)) { + if(parts > 0) { + world.setBlockState(pos, state.with(PARTS, parts-1), 3); + } else { + world.removeBlock(pos, false); + } + } else if((facing == Direction.UP) && (parts >= 7)) { + if(parts < 14) { + world.setBlockState(pos, state.with(PARTS, parts + 1), 3); + } else { + world.removeBlock(pos, false); + } + } else { + return; + } + if(!player.isCreative()) { + stack.grow(1); + if(player.inventory != null) player.inventory.markDirty(); // @todo: check if inventory can actually be null + } + SoundType st = this.getSoundType(state, world, pos, null); + world.playSound(player, pos, st.getPlaceSound(), SoundCategory.BLOCKS, (st.getVolume()+1f)/2.5f, 0.9f*st.getPitch()); + } + + @Override + public boolean receiveFluid(IWorld world, BlockPos pos, BlockState state, IFluidState fluidState) + { return (state.get(PARTS)==14) ? false : super.receiveFluid(world, pos, state, fluidState); } + + @Override + public boolean canContainFluid(IBlockReader world, BlockPos pos, BlockState state, Fluid fluid) + { return (state.get(PARTS)==14) ? false : super.canContainFluid(world, pos, state, fluid); } + +} diff --git a/1.14/src/main/java/wile/engineersdecor/libmc/blocks/StandardBlocks.java b/1.14/src/main/java/wile/engineersdecor/libmc/blocks/StandardBlocks.java new file mode 100644 index 0000000..af62857 --- /dev/null +++ b/1.14/src/main/java/wile/engineersdecor/libmc/blocks/StandardBlocks.java @@ -0,0 +1,380 @@ +/* + * @file BlockDecorFull.java + * @author Stefan Wilhelm (wile) + * @copyright (C) 2019 Stefan Wilhelm + * @license MIT (see https://opensource.org/licenses/MIT) + * + * Common functionality class for decor blocks. + * Mainly needed for: + * - MC block defaults. + * - Tooltip functionality + * - Model initialisation + */ +package wile.engineersdecor.libmc.blocks; + +import wile.engineersdecor.libmc.detail.Auxiliaries; +import net.minecraft.block.*; +import net.minecraft.entity.EntityType; +import net.minecraft.state.DirectionProperty; +import net.minecraft.state.StateContainer; +import net.minecraft.state.BooleanProperty; +import net.minecraft.state.properties.BlockStateProperties; +import net.minecraft.entity.item.ItemEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.fluid.IFluidState; +import net.minecraft.fluid.Fluids; +import net.minecraft.world.IWorld; +import net.minecraft.world.Explosion; +import net.minecraft.world.World; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.shapes.ISelectionContext; +import net.minecraft.util.math.shapes.VoxelShape; +import net.minecraft.util.math.shapes.VoxelShapes; +import net.minecraft.block.material.PushReaction; +import net.minecraft.item.BlockItemUseContext; +import net.minecraft.item.ItemStack; +import net.minecraft.world.IBlockReader; +import net.minecraft.world.storage.loot.LootContext; +import net.minecraft.client.util.ITooltipFlag; +import net.minecraft.util.*; +import net.minecraft.util.text.ITextComponent; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; + +import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + + +public class StandardBlocks +{ + public static final long CFG_DEFAULT = 0x0000000000000000L; // no special config + public static final long CFG_CUTOUT = 0x0000000000000001L; // cutout rendering + public static final long CFG_MIPPED = 0x0000000000000002L; // cutout mipped rendering + public static final long CFG_TRANSLUCENT = 0x0000000000000004L; // indicates a block/pane is glass like (transparent, etc) + public static final long CFG_WATERLOGGABLE = 0x0000000000000008L; // The derived block extends IWaterLoggable + public static final long CFG_HORIZIONTAL = 0x0000000000000010L; // horizontal block, affects bounding box calculation at construction time and placement + public static final long CFG_LOOK_PLACEMENT = 0x0000000000000020L; // placed in direction the player is looking when placing. + public static final long CFG_FACING_PLACEMENT = 0x0000000000000040L; // placed on the facing the player has clicked. + public static final long CFG_OPPOSITE_PLACEMENT = 0x0000000000000080L; // placed placed in the opposite direction of the face the player clicked. + public static final long CFG_FLIP_PLACEMENT_IF_SAME = 0x0000000000000100L; // placement direction flipped if an instance of the same class was clicked + public static final long CFG_FLIP_PLACEMENT_SHIFTCLICK = 0x0000000000000200L; // placement direction flipped if player is sneaking + public static final long CFG_STRICT_CONNECTIONS = 0x0000000000000400L; // blocks do not connect to similar blocks around (implementation details may vary a bit) + + public interface IStandardBlock + { + default boolean hasDynamicDropList() + { return false; } + + default List dropList(BlockState state, World world, BlockPos pos, boolean explosion) + { return Collections.singletonList((!world.isRemote()) ? (new ItemStack(state.getBlock().asItem())) : (ItemStack.EMPTY)); } + } + + public static class BaseBlock extends Block implements IStandardBlock + { + public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; + public final long config; + public final VoxelShape vshape; + + public BaseBlock(long conf, Block.Properties properties) + { this(conf, properties, Auxiliaries.getPixeledAABB(0, 0, 0, 16, 16,16 )); } + + public BaseBlock(long conf, Block.Properties properties, AxisAlignedBB aabb) + { super(properties); config = conf; vshape = VoxelShapes.create(aabb); } + + public BaseBlock(long conf, Block.Properties properties, VoxelShape voxel_shape) + { super(properties); config = conf; vshape = voxel_shape; } + + @Override + @OnlyIn(Dist.CLIENT) + public void addInformation(ItemStack stack, @Nullable IBlockReader world, List tooltip, ITooltipFlag flag) + { Auxiliaries.Tooltip.addInformation(stack, world, tooltip, flag, true); } + + @Override + @OnlyIn(Dist.CLIENT) + public BlockRenderLayer getRenderLayer() + { return ((config & CFG_CUTOUT)!=0) ? BlockRenderLayer.CUTOUT : BlockRenderLayer.SOLID; } + + @Override + @SuppressWarnings("deprecation") + public VoxelShape getShape(BlockState state, IBlockReader source, BlockPos pos, ISelectionContext selectionContext) + { return vshape; } + + @Override + @SuppressWarnings("deprecation") + public VoxelShape getCollisionShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext selectionContext) + { return vshape; } + + @Override + @Nullable + public BlockState getStateForPlacement(BlockItemUseContext context) + { + BlockState state = super.getStateForPlacement(context); + if((config & CFG_WATERLOGGABLE)!=0) { + IFluidState fs = context.getWorld().getFluidState(context.getPos()); + state = state.with(WATERLOGGED,fs.getFluid()==Fluids.WATER); + } + return state; + } + + @Override + public boolean canSpawnInBlock() + { return false; } + + @Override + @SuppressWarnings("deprecation") + public PushReaction getPushReaction(BlockState state) + { return PushReaction.NORMAL; } + + @Override + @SuppressWarnings("deprecation") + public void onReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean isMoving) + { + if(state.hasTileEntity() && (state.getBlock() != newState.getBlock())) { + world.removeTileEntity(pos); + world.updateComparatorOutputLevel(pos, this); + } + } + + public static boolean dropBlock(BlockState state, World world, BlockPos pos, @Nullable PlayerEntity player) + { + if(!(state.getBlock() instanceof IStandardBlock)) { world.removeBlock(pos, false); return true; } + if(!world.isRemote()) { + if((player==null) || (!player.isCreative())) { + ((IStandardBlock)state.getBlock()).dropList(state, world, pos, player==null).forEach(stack->world.addEntity(new ItemEntity(world, pos.getX()+0.5, pos.getY()+0.5, pos.getZ()+0.5, stack))); + } + } + if(state.getBlock().hasTileEntity(state)) world.removeTileEntity(pos); + world.removeBlock(pos, false); + return true; + } + + @Override + public boolean removedByPlayer(BlockState state, World world, BlockPos pos, PlayerEntity player, boolean willHarvest, IFluidState fluid) + { return hasDynamicDropList() ? dropBlock(state, world, pos, player) : super.removedByPlayer(state, world,pos , player, willHarvest, fluid); } + + @Override + public void onExplosionDestroy(World world, BlockPos pos, Explosion explosion) + { if(hasDynamicDropList()) dropBlock(world.getBlockState(pos), world, pos, null); } + + @Override + @SuppressWarnings("deprecation") + public List getDrops(BlockState state, LootContext.Builder builder) + { return hasDynamicDropList() ? Collections.singletonList(ItemStack.EMPTY) : super.getDrops(state, builder); } + + @Override + public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) + { + if((config & CFG_WATERLOGGABLE)!=0) { + if(state.get(WATERLOGGED)) return false; + } + return super.propagatesSkylightDown(state, reader, pos); + } + + @Override + @SuppressWarnings("deprecation") + public IFluidState getFluidState(BlockState state) + { + if((config & CFG_WATERLOGGABLE)!=0) { + return state.get(WATERLOGGED) ? Fluids.WATER.getStillFluidState(false) : super.getFluidState(state); + } + return super.getFluidState(state); + } + + @Override + @SuppressWarnings("deprecation") + public BlockState updatePostPlacement(BlockState state, Direction facing, BlockState facingState, IWorld world, BlockPos pos, BlockPos facingPos) + { + if((config & CFG_WATERLOGGABLE)!=0) { + if(state.get(WATERLOGGED)) world.getPendingFluidTicks().scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); + } + return state; + } + } + + public static class WaterLoggable extends BaseBlock implements IWaterLoggable, IStandardBlock + { + public WaterLoggable(long config, Block.Properties properties) + { super(config|CFG_WATERLOGGABLE, properties); } + + public WaterLoggable(long config, Block.Properties properties, AxisAlignedBB aabb) + { super(config|CFG_WATERLOGGABLE, properties, aabb); } + + public WaterLoggable(long config, Block.Properties properties, VoxelShape voxel_shape) + { super(config|CFG_WATERLOGGABLE, properties, voxel_shape); } + + @Override + protected void fillStateContainer(StateContainer.Builder builder) + { super.fillStateContainer(builder); builder.add(WATERLOGGED); } + } + + public static class Directed extends BaseBlock implements IStandardBlock + { + public static final DirectionProperty FACING = DirectionalBlock.FACING; + protected final ArrayList AABBs; + + public Directed(long config, Block.Properties builder, final AxisAlignedBB unrotatedAABB) + { + super(config, builder); + setDefaultState(stateContainer.getBaseState().with(FACING, Direction.UP)); + final boolean is_horizontal = ((config & CFG_HORIZIONTAL)!=0); + AABBs = new ArrayList(Arrays.asList( + VoxelShapes.create(Auxiliaries.getRotatedAABB(unrotatedAABB, Direction.DOWN, is_horizontal)), + VoxelShapes.create(Auxiliaries.getRotatedAABB(unrotatedAABB, Direction.UP, is_horizontal)), + VoxelShapes.create(Auxiliaries.getRotatedAABB(unrotatedAABB, Direction.NORTH, is_horizontal)), + VoxelShapes.create(Auxiliaries.getRotatedAABB(unrotatedAABB, Direction.SOUTH, is_horizontal)), + VoxelShapes.create(Auxiliaries.getRotatedAABB(unrotatedAABB, Direction.WEST, is_horizontal)), + VoxelShapes.create(Auxiliaries.getRotatedAABB(unrotatedAABB, Direction.EAST, is_horizontal)), + VoxelShapes.create(unrotatedAABB), + VoxelShapes.create(unrotatedAABB) + )); + } + + @Override + @OnlyIn(Dist.CLIENT) + public BlockRenderLayer getRenderLayer() + { return ((config & CFG_CUTOUT)!=0) ? BlockRenderLayer.CUTOUT : BlockRenderLayer.SOLID; } + + @Override + public boolean canSpawnInBlock() + { return false; } + + @Override + @SuppressWarnings("deprecation") + public boolean canEntitySpawn(BlockState state, IBlockReader world, BlockPos pos, EntityType entityType) + { return false; } + + @Override + public VoxelShape getShape(BlockState state, IBlockReader source, BlockPos pos, ISelectionContext selectionContext) + { return AABBs.get((state.get(FACING)).getIndex() & 0x7); } + + @Override + public VoxelShape getCollisionShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext selectionContext) + { return getShape(state, world, pos, selectionContext); } + + @Override + protected void fillStateContainer(StateContainer.Builder builder) + { super.fillStateContainer(builder); builder.add(FACING); } + + @Override + @Nullable + public BlockState getStateForPlacement(BlockItemUseContext context) + { + Direction facing = context.getFace(); + if((config & (CFG_HORIZIONTAL|CFG_LOOK_PLACEMENT)) == (CFG_HORIZIONTAL|CFG_LOOK_PLACEMENT)) { + // horizontal placement in direction the player is looking + facing = context.getPlacementHorizontalFacing(); + } else if((config & (CFG_HORIZIONTAL|CFG_LOOK_PLACEMENT)) == (CFG_HORIZIONTAL)) { + // horizontal placement on a face + if(((facing==Direction.UP)||(facing==Direction.DOWN))) return null; + } else if((config & CFG_LOOK_PLACEMENT)!=0) { + // placement in direction the player is looking, with up and down + facing = context.getNearestLookingDirection(); + } else { + // default: placement on the face the player clicking + } + if((config & CFG_OPPOSITE_PLACEMENT)!=0) facing = facing.getOpposite(); + if(((config & CFG_FLIP_PLACEMENT_SHIFTCLICK) != 0) && (context.getPlayer().isSneaking())) facing = facing.getOpposite(); + return super.getStateForPlacement(context).with(FACING, facing); + } + } + + public static class Horizontal extends BaseBlock implements IStandardBlock + { + public static final DirectionProperty HORIZONTAL_FACING = HorizontalBlock.HORIZONTAL_FACING; + protected final ArrayList AABBs; + + public Horizontal(long config, Block.Properties builder, final AxisAlignedBB unrotatedAABB) + { + super(config|CFG_HORIZIONTAL, builder, unrotatedAABB); + setDefaultState(stateContainer.getBaseState().with(HORIZONTAL_FACING, Direction.NORTH)); + AABBs = new ArrayList(Arrays.asList( + VoxelShapes.create(Auxiliaries.getRotatedAABB(unrotatedAABB, Direction.DOWN, true)), + VoxelShapes.create(Auxiliaries.getRotatedAABB(unrotatedAABB, Direction.UP, true)), + VoxelShapes.create(Auxiliaries.getRotatedAABB(unrotatedAABB, Direction.NORTH, true)), + VoxelShapes.create(Auxiliaries.getRotatedAABB(unrotatedAABB, Direction.SOUTH, true)), + VoxelShapes.create(Auxiliaries.getRotatedAABB(unrotatedAABB, Direction.WEST, true)), + VoxelShapes.create(Auxiliaries.getRotatedAABB(unrotatedAABB, Direction.EAST, true)), + VoxelShapes.create(unrotatedAABB), + VoxelShapes.create(unrotatedAABB) + )); + } + + @Override + @OnlyIn(Dist.CLIENT) + public BlockRenderLayer getRenderLayer() + { return ((config & CFG_CUTOUT)!=0) ? BlockRenderLayer.CUTOUT : BlockRenderLayer.SOLID; } + + @Override + public boolean canSpawnInBlock() + { return false; } + + @Override + @SuppressWarnings("deprecation") + public boolean canEntitySpawn(BlockState state, IBlockReader world, BlockPos pos, EntityType entityType) + { return false; } + + @Override + public VoxelShape getShape(BlockState state, IBlockReader source, BlockPos pos, ISelectionContext selectionContext) + { return AABBs.get((state.get(HORIZONTAL_FACING)).getIndex() & 0x7); } + + @Override + public VoxelShape getCollisionShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext selectionContext) + { return getShape(state, world, pos, selectionContext); } + + @Override + protected void fillStateContainer(StateContainer.Builder builder) + { super.fillStateContainer(builder); builder.add(HORIZONTAL_FACING); } + + @Override + @Nullable + public BlockState getStateForPlacement(BlockItemUseContext context) + { + Direction facing = context.getFace(); + if((config & CFG_LOOK_PLACEMENT) != 0) { + // horizontal placement in direction the player is looking + facing = context.getPlacementHorizontalFacing(); + } else { + // horizontal placement on a face + facing = ((facing==Direction.UP)||(facing==Direction.DOWN)) ? (context.getPlacementHorizontalFacing()) : facing; + } + if((config & CFG_OPPOSITE_PLACEMENT)!=0) facing = facing.getOpposite(); + if(((config & CFG_FLIP_PLACEMENT_SHIFTCLICK) != 0) && (context.getPlayer().isSneaking())) facing = facing.getOpposite(); + return super.getStateForPlacement(context).with(HORIZONTAL_FACING, facing); + } + + @Override + @SuppressWarnings("deprecation") + public BlockState rotate(BlockState state, Rotation rot) + { return state.with(HORIZONTAL_FACING, rot.rotate(state.get(HORIZONTAL_FACING))); } + + @Override + @SuppressWarnings("deprecation") + public BlockState mirror(BlockState state, Mirror mirrorIn) + { return state.rotate(mirrorIn.toRotation(state.get(HORIZONTAL_FACING))); } + } + + public static class DirectedWaterLoggable extends Directed implements IWaterLoggable, IStandardBlock + { + public DirectedWaterLoggable(long config, Block.Properties properties, AxisAlignedBB aabb) + { super(config|CFG_WATERLOGGABLE, properties, aabb); } + + @Override + protected void fillStateContainer(StateContainer.Builder builder) + { super.fillStateContainer(builder); builder.add(WATERLOGGED); } + } + + public static class HorizontalWaterLoggable extends Horizontal implements IWaterLoggable, IStandardBlock + { + public HorizontalWaterLoggable(long config, Block.Properties properties, AxisAlignedBB aabb) + { super(config|CFG_WATERLOGGABLE|CFG_HORIZIONTAL, properties, aabb); } + + @Override + protected void fillStateContainer(StateContainer.Builder builder) + { super.fillStateContainer(builder); builder.add(WATERLOGGED); } + } + +} diff --git a/1.14/src/main/java/wile/engineersdecor/libmc/blocks/StandardFenceBlock.java b/1.14/src/main/java/wile/engineersdecor/libmc/blocks/StandardFenceBlock.java new file mode 100644 index 0000000..44c273e --- /dev/null +++ b/1.14/src/main/java/wile/engineersdecor/libmc/blocks/StandardFenceBlock.java @@ -0,0 +1,114 @@ +/* + * @file BlockDecorWall.java + * @author Stefan Wilhelm (wile) + * @copyright (C) 2019 Stefan Wilhelm + * @license MIT (see https://opensource.org/licenses/MIT) + * + * Wall blocks. + */ +package wile.engineersdecor.libmc.blocks; + +import wile.engineersdecor.libmc.detail.Auxiliaries; +import net.minecraft.world.*; +import net.minecraft.fluid.IFluidState; +import net.minecraft.entity.EntityType; +import net.minecraft.util.math.shapes.ISelectionContext; +import net.minecraft.state.StateContainer; +import net.minecraft.block.*; +import net.minecraft.block.material.PushReaction; +import net.minecraft.block.BlockState; +import net.minecraft.client.util.ITooltipFlag; +import net.minecraft.fluid.Fluids; +import net.minecraft.item.BlockItemUseContext; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Direction; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.shapes.VoxelShape; +import net.minecraft.util.text.ITextComponent; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import javax.annotation.Nullable; +import java.util.List; + + +public class StandardFenceBlock extends WallBlock implements StandardBlocks.IStandardBlock +{ + private final VoxelShape[] shape_voxels; + private final VoxelShape[] collision_shape_voxels; + + public StandardFenceBlock(long config, Block.Properties builder) + { + super(builder); + this.shape_voxels = buildWallShapes(1.5f, 1.5f, 16f, 0f, 16f); + this.collision_shape_voxels = buildWallShapes(1.5f, 1.5f, 24f, 0f, 24f); + } + + @Override + @OnlyIn(Dist.CLIENT) + public void addInformation(ItemStack stack, @Nullable IBlockReader world, List tooltip, ITooltipFlag flag) + { Auxiliaries.Tooltip.addInformation(stack, world, tooltip, flag, true); } + + protected VoxelShape[] buildWallShapes(float pole_width_x, float pole_width_z, float pole_height, float side_min_y, float side_max_y) + { return super.makeShapes(pole_width_x, pole_width_z, pole_height, side_min_y, side_max_y); } + + @Override + public VoxelShape getShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext selectionContext) + { return shape_voxels[this.getIndex(state)]; } + + @Override + public VoxelShape getCollisionShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext selectionContext) + { return collision_shape_voxels[this.getIndex(state)]; } + + @Override + protected void fillStateContainer(StateContainer.Builder builder) + { super.fillStateContainer(builder); } + + private boolean attachesTo(BlockState facingState, IWorldReader world, BlockPos facingPos, Direction side) + { + final Block block = facingState.getBlock(); + if((block instanceof FenceGateBlock) || (block instanceof StandardFenceBlock) || (block instanceof VariantWallBlock)) return true; + final BlockState oppositeState = world.getBlockState(facingPos.offset(side, 2)); + if(!(oppositeState.getBlock() instanceof StandardFenceBlock)) return false; + return facingState.isNormalCube(world, facingPos) && hasSolidSide(facingState, world, facingPos, side); + } + + public BlockState getStateForPlacement(BlockItemUseContext context) + { + IWorldReader world = context.getWorld(); + BlockPos pos = context.getPos(); + IFluidState fs = context.getWorld().getFluidState(context.getPos()); + boolean n = attachesTo(world.getBlockState(pos.north()), world, pos.north(), Direction.SOUTH); + boolean e = attachesTo(world.getBlockState(pos.east()), world, pos.east(), Direction.WEST); + boolean s = attachesTo(world.getBlockState(pos.south()), world, pos.south(), Direction.NORTH); + boolean w = attachesTo(world.getBlockState(pos.west()), world, pos.west(), Direction.EAST); + boolean not_straight = (!n || !s || e || w) && (n || s || !e || !w); + return getDefaultState().with(UP, not_straight).with(NORTH, n).with(EAST, e).with(SOUTH, s).with(WEST, w).with(WATERLOGGED, fs.getFluid() == Fluids.WATER); + } + + @Override + public BlockState updatePostPlacement(BlockState state, Direction side, BlockState facingState, IWorld world, BlockPos currentPos, BlockPos facingPos) + { + if(state.get(WATERLOGGED)) world.getPendingFluidTicks().scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickRate(world)); + if(side == Direction.DOWN) return super.updatePostPlacement(state, side, facingState, world, currentPos, facingPos); + boolean n = (side==Direction.NORTH) ? attachesTo(facingState, world, facingPos, side) : state.get(NORTH); + boolean e = (side==Direction.EAST) ? attachesTo(facingState, world, facingPos, side) : state.get(EAST); + boolean s = (side==Direction.SOUTH) ? attachesTo(facingState, world, facingPos, side) : state.get(SOUTH); + boolean w = (side==Direction.WEST) ? attachesTo(facingState, world, facingPos, side) : state.get(WEST); + boolean not_straight = (!n || !s || e || w) && (n || s || !e || !w); + return state.with(UP, not_straight).with(NORTH, n).with(EAST, e).with(SOUTH, s).with(WEST, w); + } + + @Override + @SuppressWarnings("deprecation") + public boolean canEntitySpawn(BlockState state, IBlockReader world, BlockPos pos, EntityType entityType) + { return false; } + + @Override + public boolean canSpawnInBlock() + { return false; } + + @Override + @SuppressWarnings("deprecation") + public PushReaction getPushReaction(BlockState state) + { return PushReaction.NORMAL; } +} diff --git a/1.14/src/main/java/wile/engineersdecor/libmc/blocks/StandardStairsBlock.java b/1.14/src/main/java/wile/engineersdecor/libmc/blocks/StandardStairsBlock.java new file mode 100644 index 0000000..19c46a6 --- /dev/null +++ b/1.14/src/main/java/wile/engineersdecor/libmc/blocks/StandardStairsBlock.java @@ -0,0 +1,55 @@ +/* + * @file StandardStairsBlock.java + * @author Stefan Wilhelm (wile) + * @copyright (C) 2019 Stefan Wilhelm + * @license MIT (see https://opensource.org/licenses/MIT) + * + * Stairs and roof blocks, almost entirely based on vanilla stairs. + */ +package wile.engineersdecor.libmc.blocks; + +import wile.engineersdecor.libmc.detail.Auxiliaries; +import net.minecraft.entity.EntityType; +import net.minecraft.util.math.BlockPos; +import net.minecraft.block.*; +import net.minecraft.block.material.PushReaction; +import net.minecraft.block.BlockState; +import net.minecraft.client.util.ITooltipFlag; +import net.minecraft.item.ItemStack; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.world.IBlockReader; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; + +import javax.annotation.Nullable; +import java.util.List; + + +public class StandardStairsBlock extends StairsBlock implements StandardBlocks.IStandardBlock +{ + public StandardStairsBlock(long config, BlockState state, Block.Properties properties) + { super(()->state, properties); } + + public StandardStairsBlock(long config, java.util.function.Supplier state, Block.Properties properties) + { super(state, properties); } + + @Override + @OnlyIn(Dist.CLIENT) + public void addInformation(ItemStack stack, @Nullable IBlockReader world, List tooltip, ITooltipFlag flag) + { Auxiliaries.Tooltip.addInformation(stack, world, tooltip, flag, true); } + + @Override + public boolean canSpawnInBlock() + { return false; } + + @Override + @SuppressWarnings("deprecation") + public boolean canEntitySpawn(BlockState state, IBlockReader world, BlockPos pos, EntityType entityType) + { return false; } + + @Override + @SuppressWarnings("deprecation") + public PushReaction getPushReaction(BlockState state) + { return PushReaction.NORMAL; } + +} diff --git a/1.14/src/main/java/wile/engineersdecor/libmc/blocks/VariantSlabBlock.java b/1.14/src/main/java/wile/engineersdecor/libmc/blocks/VariantSlabBlock.java new file mode 100644 index 0000000..dd8c678 --- /dev/null +++ b/1.14/src/main/java/wile/engineersdecor/libmc/blocks/VariantSlabBlock.java @@ -0,0 +1,200 @@ +/* + * @file VariantSlabBlock.java + * @author Stefan Wilhelm (wile) + * @copyright (C) 2019 Stefan Wilhelm + * @license MIT (see https://opensource.org/licenses/MIT) + * + * Standard half block horizontal slab characteristics class. + */ +package wile.engineersdecor.libmc.blocks; + +import wile.engineersdecor.libmc.detail.Auxiliaries; +import net.minecraft.world.IWorld; +import net.minecraft.world.World; +import net.minecraft.world.IBlockReader; +import net.minecraft.state.StateContainer; +import net.minecraft.block.*; +import net.minecraft.block.BlockState; +import net.minecraft.item.ItemStack; +import net.minecraft.item.BlockItemUseContext; +import net.minecraft.state.IntegerProperty; +import net.minecraft.util.*; +import net.minecraft.util.math.*; +import net.minecraft.util.math.shapes.VoxelShapes; +import net.minecraft.util.math.shapes.ISelectionContext; +import net.minecraft.util.math.shapes.VoxelShape; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.fluid.Fluid; +import net.minecraft.fluid.IFluidState; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.client.util.ITooltipFlag; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; + +import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + + +public class VariantSlabBlock extends StandardBlocks.WaterLoggable implements StandardBlocks.IStandardBlock +{ + private static boolean with_pickup = false; + + public static final IntegerProperty PARTS = IntegerProperty.create("parts", 0, 2); + public static final IntegerProperty TEXTURE_VARIANT = IntegerProperty.create("tvariant", 0, 3); + + protected static final VoxelShape AABBs[] = { + VoxelShapes.create(new AxisAlignedBB(0, 0./16, 0, 1, 8./16, 1)), // bottom slab + VoxelShapes.create(new AxisAlignedBB(0, 8./16, 0, 1, 16./16, 1)), // top slab + VoxelShapes.create(new AxisAlignedBB(0, 0./16, 0, 1, 16./16, 1)), // both slabs + VoxelShapes.create(new AxisAlignedBB(0, 0./16, 0, 1, 16./16, 1)) // << 2bit fill + }; + protected static final int num_slabs_contained_in_parts_[] = { 1,1,2,2 }; + + public static void on_config(boolean with_quick_pickup) + { + with_pickup = with_quick_pickup; + } + + protected boolean is_cube(BlockState state) + { return state.get(PARTS) >= 2; } + + public VariantSlabBlock(long config, Block.Properties builder) + { super(config, builder); } + + @Override + @OnlyIn(Dist.CLIENT) + public BlockRenderLayer getRenderLayer() + { return (((config & StandardBlocks.CFG_TRANSLUCENT)!=0) ? (BlockRenderLayer.TRANSLUCENT) : (BlockRenderLayer.CUTOUT)); } + + @Override + @OnlyIn(Dist.CLIENT) + public void addInformation(ItemStack stack, @Nullable IBlockReader world, List tooltip, ITooltipFlag flag) + { + if(!Auxiliaries.Tooltip.addInformation(stack, world, tooltip, flag, true)) return; + if(with_pickup) { + String tr_key = Auxiliaries.modid() + ".tooltip.slabpickup"; + if(Auxiliaries.hasTranslation(tr_key)) Auxiliaries.Tooltip.addInformation(tr_key, tr_key, tooltip, flag, true); + } + } + + @Override + @OnlyIn(Dist.CLIENT) + @SuppressWarnings("deprecation") + public boolean isSideInvisible(BlockState state, BlockState adjacentBlockState, Direction side) + { return (adjacentBlockState==state) ? true : super.isSideInvisible(state, adjacentBlockState, side); } + + @Override + public boolean canSpawnInBlock() + { return false; } + + @Override + @SuppressWarnings("deprecation") + public boolean canEntitySpawn(BlockState state, IBlockReader world, BlockPos pos, EntityType entityType) + { return false; } + + @Override + public VoxelShape getShape(BlockState state, IBlockReader source, BlockPos pos, ISelectionContext selectionContext) + { return AABBs[state.get(PARTS) & 0x3]; } + + @Override + public VoxelShape getCollisionShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext selectionContext) + { return getShape(state, world, pos, selectionContext); } + + @Override + protected void fillStateContainer(StateContainer.Builder builder) + { super.fillStateContainer(builder); builder.add(PARTS, TEXTURE_VARIANT); } + + @Override + @Nullable + public BlockState getStateForPlacement(BlockItemUseContext context) + { + BlockPos pos = context.getPos(); + if(context.getWorld().getBlockState(pos).getBlock() == this) return context.getWorld().getBlockState(pos).with(PARTS, 2).with(WATERLOGGED, false); + final int rnd = MathHelper.clamp((int)(MathHelper.getPositionRandom(context.getPos()) & 0x3), 0, 3); + final Direction face = context.getFace(); + final BlockState placement_state = super.getStateForPlacement(context).with(TEXTURE_VARIANT, rnd); // fluid state + if(face == Direction.UP) return placement_state.with(PARTS, 0); + if(face == Direction.DOWN) return placement_state.with(PARTS, 1); + if(!face.getAxis().isHorizontal()) return placement_state; + final boolean isupper = ((context.getHitVec().getY() - context.getPos().getY()) > 0.5); + return placement_state.with(PARTS, isupper ? 1 : 0); + } + + @Override + @SuppressWarnings("deprecation") + public boolean isReplaceable(BlockState state, BlockItemUseContext context) + { + if(context.getItem().getItem() != this.asItem()) return false; + if(!context.replacingClickedOnBlock()) return true; + final Direction face = context.getFace(); + final int parts = state.get(PARTS); + if((face == Direction.UP) && (parts==0)) return true; + if((face == Direction.DOWN) && (parts==1)) return true; + if(!face.getAxis().isHorizontal()) return false; + final boolean isupper = ((context.getHitVec().getY() - context.getPos().getY()) > 0.5); + return isupper ? (parts==0) : (parts==1); + } + + @Override + @SuppressWarnings("deprecation") + public BlockState rotate(BlockState state, Rotation rot) + { return state; } + + @Override + @SuppressWarnings("deprecation") + public BlockState mirror(BlockState state, Mirror mirrorIn) + { return state; } + + @Override + public boolean hasDynamicDropList() + { return true; } + + @Override + public List dropList(BlockState state, World world, BlockPos pos, boolean explosion) + { return new ArrayList(Collections.singletonList(new ItemStack(this.asItem(), num_slabs_contained_in_parts_[state.get(PARTS) & 0x3]))); } + + @Override + @SuppressWarnings("deprecation") + public void onBlockClicked(BlockState state, World world, BlockPos pos, PlayerEntity player) + { + if((world.isRemote) || (!with_pickup)) return; + final ItemStack stack = player.getHeldItemMainhand(); + if(stack.isEmpty() || (Block.getBlockFromItem(stack.getItem()) != this)) return; + if(stack.getCount() >= stack.getMaxStackSize()) return; + Vec3d lv = player.getLookVec(); + Direction facing = Direction.getFacingFromVector((float)lv.x, (float)lv.y, (float)lv.z); + if((facing != Direction.UP) && (facing != Direction.DOWN)) return; + if(state.getBlock() != this) return; + int parts = state.get(PARTS); + if(facing == Direction.DOWN) { + if(parts == 2) { + world.setBlockState(pos, state.with(PARTS, 0), 3); + } else { + world.removeBlock(pos, false); + } + } else if(facing == Direction.UP) { + if(parts == 2) { + world.setBlockState(pos, state.with(PARTS, 1), 3); + } else { + world.removeBlock(pos, false); + } + } + if(!player.isCreative()) { + stack.grow(1); + if(player.inventory != null) player.inventory.markDirty(); + } + SoundType st = this.getSoundType(state, world, pos, null); + world.playSound(player, pos, st.getPlaceSound(), SoundCategory.BLOCKS, (st.getVolume()+1f)/2.5f, 0.9f*st.getPitch()); + } + + @Override + public boolean receiveFluid(IWorld world, BlockPos pos, BlockState state, IFluidState fluidState) + { return (state.get(PARTS)==2) ? false : super.receiveFluid(world, pos, state, fluidState); } + + public boolean canContainFluid(IBlockReader world, BlockPos pos, BlockState state, Fluid fluid) + { return (state.get(PARTS)==2) ? false : super.canContainFluid(world, pos, state, fluid); } + +} diff --git a/1.14/src/main/java/wile/engineersdecor/libmc/blocks/VariantWallBlock.java b/1.14/src/main/java/wile/engineersdecor/libmc/blocks/VariantWallBlock.java new file mode 100644 index 0000000..66f012b --- /dev/null +++ b/1.14/src/main/java/wile/engineersdecor/libmc/blocks/VariantWallBlock.java @@ -0,0 +1,129 @@ +/* + * @file VariantWallBlock.java + * @author Stefan Wilhelm (wile) + * @copyright (C) 2019 Stefan Wilhelm + * @license MIT (see https://opensource.org/licenses/MIT) + * + * Wall blocks. + */ +package wile.engineersdecor.libmc.blocks; + +import wile.engineersdecor.libmc.detail.Auxiliaries; +import net.minecraft.item.BlockItemUseContext; +import net.minecraft.world.*; +import net.minecraft.fluid.IFluidState; +import net.minecraft.entity.EntityType; +import net.minecraft.util.math.shapes.ISelectionContext; +import net.minecraft.state.StateContainer; +import net.minecraft.util.math.MathHelper; +import net.minecraft.block.*; +import net.minecraft.block.material.PushReaction; +import net.minecraft.block.BlockState; +import net.minecraft.client.util.ITooltipFlag; +import net.minecraft.fluid.Fluids; +import net.minecraft.item.ItemStack; +import net.minecraft.state.IntegerProperty; +import net.minecraft.util.Direction; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.shapes.VoxelShape; +import net.minecraft.util.text.ITextComponent; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import javax.annotation.Nullable; +import java.util.List; + + +public class VariantWallBlock extends WallBlock implements StandardBlocks.IStandardBlock +{ + private final VoxelShape[] shape_voxels_with_pole; + private final VoxelShape[] shape_voxels_without_pole; + private final VoxelShape[] collision_shape_voxels; + public static final IntegerProperty TEXTURE_VARIANT = IntegerProperty.create("tvariant", 0, 3); + + public VariantWallBlock(long config, Block.Properties builder) + { this(config, builder, 4, 16, 3, 0, 14); } + + public VariantWallBlock(long config, Block.Properties builder, float pole_width, float pole_max_y, float side_width, float side_min_y, float side_max_y) + { + super(builder); + pole_width = MathHelper.clamp(pole_width, 2, 8); + pole_max_y = MathHelper.clamp(pole_max_y, 2, 16); + side_width = MathHelper.clamp(side_width, 2, 8); + side_min_y = MathHelper.clamp(side_min_y, 0, 16); + side_max_y = MathHelper.clamp(side_max_y, 1, 16); + if(side_max_y <= side_min_y) { side_min_y = 0; side_max_y = 16; } + shape_voxels_with_pole = buildWallShapes(pole_width, side_width, pole_max_y, side_min_y, side_max_y); + shape_voxels_without_pole = buildWallShapes(side_width, side_width, side_max_y, side_min_y, side_max_y); + collision_shape_voxels = buildWallShapes(pole_width, side_width, 24, side_min_y, 24); + } + + @Override + @OnlyIn(Dist.CLIENT) + public void addInformation(ItemStack stack, @Nullable IBlockReader world, List tooltip, ITooltipFlag flag) + { Auxiliaries.Tooltip.addInformation(stack, world, tooltip, flag, true); } + + protected VoxelShape[] buildWallShapes(float pole_width, float side_width, float pole_height, float side_min_y, float side_max_y) + { return super.makeShapes(pole_width, side_width, pole_height, side_min_y, side_max_y); } + + @Override + public VoxelShape getShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext selectionContext) + { return state.get(UP) ? shape_voxels_with_pole[this.getIndex(state)] : shape_voxels_without_pole[this.getIndex(state)]; } + + @Override + public VoxelShape getCollisionShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext selectionContext) + { return collision_shape_voxels[this.getIndex(state)]; } + + @Override + protected void fillStateContainer(StateContainer.Builder builder) + { super.fillStateContainer(builder); builder.add(TEXTURE_VARIANT); } + + private boolean attachesTo(BlockState facingState, IWorldReader world, BlockPos facingPos, Direction side) + { + final Block block = facingState.getBlock(); + if((block instanceof FenceGateBlock) || (block instanceof WallBlock)) return true; + final BlockState oppositeState = world.getBlockState(facingPos.offset(side, 2)); + if(!(oppositeState.getBlock() instanceof VariantWallBlock)) return false; + return facingState.isNormalCube(world, facingPos) && hasSolidSide(facingState, world, facingPos, side); + } + + public BlockState getStateForPlacement(BlockItemUseContext context) + { + IWorldReader world = context.getWorld(); + BlockPos pos = context.getPos(); + IFluidState fs = context.getWorld().getFluidState(context.getPos()); + boolean n = attachesTo(world.getBlockState(pos.north()), world, pos.north(), Direction.SOUTH); + boolean e = attachesTo(world.getBlockState(pos.east()), world, pos.east(), Direction.WEST); + boolean s = attachesTo(world.getBlockState(pos.south()), world, pos.south(), Direction.NORTH); + boolean w = attachesTo(world.getBlockState(pos.west()), world, pos.west(), Direction.EAST); + boolean not_straight = (!n || !s || e || w) && (n || s || !e || !w); + return getDefaultState().with(UP, not_straight).with(NORTH, n).with(EAST, e).with(SOUTH, s).with(WEST, w).with(WATERLOGGED, fs.getFluid() == Fluids.WATER); + } + + @Override + public BlockState updatePostPlacement(BlockState state, Direction side, BlockState facingState, IWorld world, BlockPos currentPos, BlockPos facingPos) + { + if(state.get(WATERLOGGED)) world.getPendingFluidTicks().scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickRate(world)); + if(side == Direction.DOWN) return super.updatePostPlacement(state, side, facingState, world, currentPos, facingPos); + boolean n = (side==Direction.NORTH) ? this.attachesTo(facingState, world, facingPos, side) : state.get(NORTH); + boolean e = (side==Direction.EAST) ? this.attachesTo(facingState, world, facingPos, side) : state.get(EAST); + boolean s = (side==Direction.SOUTH) ? this.attachesTo(facingState, world, facingPos, side) : state.get(SOUTH); + boolean w = (side==Direction.WEST) ? this.attachesTo(facingState, world, facingPos, side) : state.get(WEST); + boolean not_straight = (!n || !s || e || w) && (n || s || !e || !w); + return state.with(UP, not_straight).with(NORTH, n).with(EAST, e).with(SOUTH, s).with(WEST, w).with(TEXTURE_VARIANT, ((int)MathHelper.getPositionRandom(currentPos)) & 0x3); + } + + @Override + @SuppressWarnings("deprecation") + public boolean canEntitySpawn(BlockState state, IBlockReader world, BlockPos pos, EntityType entityType) + { return false; } + + @Override + public boolean canSpawnInBlock() + { return false; } + + @Override + @SuppressWarnings("deprecation") + public PushReaction getPushReaction(BlockState state) + { return PushReaction.NORMAL; } + +} diff --git a/1.14/src/main/java/wile/engineersdecor/datagen/ModLootTables.java b/1.14/src/main/java/wile/engineersdecor/libmc/datagen/LootTableGen.java similarity index 80% rename from 1.14/src/main/java/wile/engineersdecor/datagen/ModLootTables.java rename to 1.14/src/main/java/wile/engineersdecor/libmc/datagen/LootTableGen.java index 724d294..d25e21e 100644 --- a/1.14/src/main/java/wile/engineersdecor/datagen/ModLootTables.java +++ b/1.14/src/main/java/wile/engineersdecor/libmc/datagen/LootTableGen.java @@ -6,11 +6,10 @@ * * Loot table generator. */ -package wile.engineersdecor.datagen; +package wile.engineersdecor.libmc.datagen; -import wile.engineersdecor.ModContent; -import wile.engineersdecor.blocks.IDecorBlock; -import wile.engineersdecor.detail.ModAuxiliaries; +import wile.engineersdecor.libmc.blocks.StandardBlocks; +import wile.engineersdecor.libmc.detail.Auxiliaries; import net.minecraft.block.Block; import net.minecraft.data.*; import net.minecraft.util.ResourceLocation; @@ -26,24 +25,26 @@ import java.nio.file.Path; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.function.Supplier; -public class ModLootTables extends LootTableProvider +public class LootTableGen extends LootTableProvider { private static final Logger LOGGER = LogManager.getLogger(); private static final Gson GSON = (new GsonBuilder()).setPrettyPrinting().disableHtmlEscaping().create(); private final DataGenerator generator; + private final Supplier> block_listing; //-------------------------------------------------------------------------------------------------------------------- - public ModLootTables(DataGenerator gen) - { super(gen); generator=gen; } + public LootTableGen(DataGenerator gen, Supplier> block_list_supplier) + { super(gen); generator=gen; block_listing = block_list_supplier; } //-- LootTableProvider ----------------------------------------------------------------------------------------------- @Override public String getName() - { return ModAuxiliaries.MODID + " Loot Tables"; } + { return Auxiliaries.modid() + " Loot Tables"; } @Override public void act(DirectoryCache cache) @@ -54,9 +55,9 @@ public class ModLootTables extends LootTableProvider private Map generate() { final HashMap tables = new HashMap(); - final List blocks = ModContent.allBlocks(); + final List blocks = block_listing.get(); blocks.forEach((block)->{ - if((!(block instanceof IDecorBlock)) || (!(((IDecorBlock)block).hasDynamicDropList()))) { + if((!(block instanceof StandardBlocks.IStandardBlock)) || (!(((StandardBlocks.IStandardBlock)block).hasDynamicDropList()))) { tables.put( block.getLootTable(), defaultBlockDrops(block.getRegistryName().getPath() + "_dlt", block) diff --git a/1.14/src/main/java/wile/engineersdecor/detail/ModAuxiliaries.java b/1.14/src/main/java/wile/engineersdecor/libmc/detail/Auxiliaries.java similarity index 77% rename from 1.14/src/main/java/wile/engineersdecor/detail/ModAuxiliaries.java rename to 1.14/src/main/java/wile/engineersdecor/libmc/detail/Auxiliaries.java index ac5fe32..8113f33 100644 --- a/1.14/src/main/java/wile/engineersdecor/detail/ModAuxiliaries.java +++ b/1.14/src/main/java/wile/engineersdecor/libmc/detail/Auxiliaries.java @@ -1,16 +1,16 @@ /* - * @file ModAuxiliaries.java + * @file Auxiliaries.java * @author Stefan Wilhelm (wile) * @copyright (C) 2018 Stefan Wilhelm * @license MIT (see https://opensource.org/licenses/MIT) * * General commonly used functionality. */ -package wile.engineersdecor.detail; +package wile.engineersdecor.libmc.detail; -import wile.engineersdecor.ModEngineersDecor; import net.minecraft.client.util.InputMappings; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.Direction; import net.minecraft.util.SharedConstants; import net.minecraft.util.text.ITextComponent; @@ -32,15 +32,34 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; import java.util.List; +import java.util.function.Supplier; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; -public class ModAuxiliaries + +public class Auxiliaries { - public static final String MODID = ModEngineersDecor.MODID; - public static final Logger LOGGER = ModEngineersDecor.logger(); - public static final ModEngineersDecor.ISidedProxy PROXY = ModEngineersDecor.proxy; + private static String modid; + private static Logger logger; + private static Supplier server_config_supplier = ()->new CompoundNBT(); + + public static void init(String modid, Logger logger, Supplier server_config_supplier) + { + Auxiliaries.modid = modid; + Auxiliaries.logger = logger; + Auxiliaries.server_config_supplier = server_config_supplier; + } + + // ------------------------------------------------------------------------------------------------------------------- + // Mod specific exports + // ------------------------------------------------------------------------------------------------------------------- + + public static String modid() + { return modid; } + + public static Logger logger() + { return logger; } // ------------------------------------------------------------------------------------------------------------------- // Sideness, system/environment, tagging interfaces @@ -57,15 +76,15 @@ public class ModAuxiliaries @OnlyIn(Dist.CLIENT) public static final boolean isShiftDown() { - return (InputMappings.isKeyDown(PROXY.mc().mainWindow.getHandle(), GLFW.GLFW_KEY_LEFT_SHIFT) || - InputMappings.isKeyDown(PROXY.mc().mainWindow.getHandle(), GLFW.GLFW_KEY_RIGHT_SHIFT)); + return (InputMappings.isKeyDown(SidedProxy.mc().mainWindow.getHandle(), GLFW.GLFW_KEY_LEFT_SHIFT) || + InputMappings.isKeyDown(SidedProxy.mc().mainWindow.getHandle(), GLFW.GLFW_KEY_RIGHT_SHIFT)); } @OnlyIn(Dist.CLIENT) public static final boolean isCtrlDown() { - return (InputMappings.isKeyDown(PROXY.mc().mainWindow.getHandle(), GLFW.GLFW_KEY_LEFT_CONTROL) || - InputMappings.isKeyDown(PROXY.mc().mainWindow.getHandle(), GLFW.GLFW_KEY_RIGHT_CONTROL)); + return (InputMappings.isKeyDown(SidedProxy.mc().mainWindow.getHandle(), GLFW.GLFW_KEY_LEFT_CONTROL) || + InputMappings.isKeyDown(SidedProxy.mc().mainWindow.getHandle(), GLFW.GLFW_KEY_RIGHT_CONTROL)); } // ------------------------------------------------------------------------------------------------------------------- @@ -73,13 +92,13 @@ public class ModAuxiliaries // ------------------------------------------------------------------------------------------------------------------- public static final void logInfo(final String msg) - { LOGGER.info(msg); } + { logger.info(msg); } public static final void logWarn(final String msg) - { LOGGER.warn(msg); } + { logger.warn(msg); } public static final void logError(final String msg) - { LOGGER.error(msg); } + { logger.error(msg); } // ------------------------------------------------------------------------------------------------------------------- // Localization, text formatting @@ -91,7 +110,7 @@ public class ModAuxiliaries */ public static TranslationTextComponent localizable(String modtrkey, @Nullable TextFormatting color, Object... args) { - TranslationTextComponent tr = new TranslationTextComponent(MODID+"."+modtrkey, args); + TranslationTextComponent tr = new TranslationTextComponent(modid+"."+modtrkey, args); if(color!=null) tr.getStyle().setColor(color); return tr; } @@ -100,7 +119,7 @@ public class ModAuxiliaries { return localizable(modtrkey, null); } public static TranslationTextComponent localizable_block_key(String blocksubkey) - { return new TranslationTextComponent("block."+MODID+"."+blocksubkey); } + { return new TranslationTextComponent("block."+modid+"."+blocksubkey); } @OnlyIn(Dist.CLIENT) public static String localize(String translationKey, Object... args) @@ -121,10 +140,10 @@ public class ModAuxiliaries boolean not = key.startsWith("!"); if(not) key = key.replaceFirst("!", ""); m = kv[1].trim(); - if(!ModConfig.getServerConfig().contains(key)) { + if(!server_config_supplier.get().contains(key)) { m = ""; } else { - boolean r = ModConfig.getServerConfig().getBoolean(key); + boolean r = server_config_supplier.get().getBoolean(key); if(not) r = !r; if(!r) m = ""; } @@ -165,8 +184,8 @@ public class ModAuxiliaries { // Note: intentionally not using keybinding here, this must be `control` or `shift`. MC uses lwjgl Keyboard, // so using this also here should be ok. - final boolean help_available = (helpTranslationKey != null) && ModAuxiliaries.hasTranslation(helpTranslationKey + ".help"); - final boolean tip_available = (advancedTooltipTranslationKey != null) && ModAuxiliaries.hasTranslation(helpTranslationKey + ".tip"); + final boolean help_available = (helpTranslationKey != null) && Auxiliaries.hasTranslation(helpTranslationKey + ".help"); + final boolean tip_available = (advancedTooltipTranslationKey != null) && Auxiliaries.hasTranslation(helpTranslationKey + ".tip"); if((!help_available) && (!tip_available)) return false; if(helpCondition()) { if(!help_available) return false; @@ -182,8 +201,8 @@ public class ModAuxiliaries return true; } else if(addAdvancedTooltipHints) { String s = ""; - if(tip_available) s += localize(MODID + ".tooltip.hint.extended") + (help_available ? " " : ""); - if(help_available) s += localize(MODID + ".tooltip.hint.help"); + if(tip_available) s += localize(modid + ".tooltip.hint.extended") + (help_available ? " " : ""); + if(help_available) s += localize(modid + ".tooltip.hint.help"); tooltip.add(new StringTextComponent(s)); } return false; @@ -210,12 +229,12 @@ public class ModAuxiliaries { if(!horizontal_rotation) { switch(new_facing.getIndex()) { - case 0: return new AxisAlignedBB(1-bb.maxX, 1-bb.maxZ, 1-bb.maxY, 1-bb.minX, 1-bb.minZ, 1-bb.minY); // D - case 1: return new AxisAlignedBB(1-bb.maxX, bb.minZ, bb.minY, 1-bb.minX, bb.maxZ, bb.maxY); // U - case 2: return new AxisAlignedBB(1-bb.maxX, bb.minY, 1-bb.maxZ, 1-bb.minX, bb.maxY, 1-bb.minZ); // N - case 3: return new AxisAlignedBB( bb.minX, bb.minY, bb.minZ, bb.maxX, bb.maxY, bb.maxZ); // S --> bb - case 4: return new AxisAlignedBB(1-bb.maxZ, bb.minY, bb.minX, 1-bb.minZ, bb.maxY, bb.maxX); // W - case 5: return new AxisAlignedBB( bb.minZ, bb.minY, 1-bb.maxX, bb.maxZ, bb.maxY, 1-bb.minX); // E + case 0: return new AxisAlignedBB(1-bb.maxX, bb.minZ, bb.minY, 1-bb.minX, bb.maxZ, bb.maxY); // D + case 1: return new AxisAlignedBB(1-bb.maxX, 1-bb.maxZ, 1-bb.maxY, 1-bb.minX, 1-bb.minZ, 1-bb.minY); // U + case 2: return new AxisAlignedBB( bb.minX, bb.minY, bb.minZ, bb.maxX, bb.maxY, bb.maxZ); // N --> bb + case 3: return new AxisAlignedBB(1-bb.maxX, bb.minY, 1-bb.maxZ, 1-bb.minX, bb.maxY, 1-bb.minZ); // S + case 4: return new AxisAlignedBB( bb.minZ, bb.minY, 1-bb.maxX, bb.maxZ, bb.maxY, 1-bb.minX); // W + case 5: return new AxisAlignedBB(1-bb.maxZ, bb.minY, bb.minX, 1-bb.minZ, bb.maxY, bb.maxX); // E } } else { switch(new_facing.getIndex()) { @@ -241,10 +260,9 @@ public class ModAuxiliaries // JAR resource related // ------------------------------------------------------------------------------------------------------------------- - public static String loadResourceText(String path) + public static String loadResourceText(InputStream is) { try { - InputStream is = ModAuxiliaries.class.getResourceAsStream(path); if(is==null) return ""; BufferedReader br = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8)); return br.lines().collect(Collectors.joining("\n")); @@ -253,11 +271,14 @@ public class ModAuxiliaries } } + public static String loadResourceText(String path) + { return loadResourceText(Auxiliaries.class.getResourceAsStream(path)); } + public static void logGitVersion(String mod_name) { try { // Done during construction to have an exact version in case of a crash while registering. - String version = ModAuxiliaries.loadResourceText("/.gitversion-" + MODID).trim(); + String version = Auxiliaries.loadResourceText("/.gitversion-" + modid).trim(); logInfo(mod_name+((version.isEmpty())?(" (dev build)"):(" GIT id #"+version)) + "."); } catch(Throwable e) { // (void)e; well, then not. Priority is not to get unneeded crashes because of version logging. diff --git a/1.14/src/main/java/wile/engineersdecor/detail/Networking.java b/1.14/src/main/java/wile/engineersdecor/libmc/detail/Networking.java similarity index 94% rename from 1.14/src/main/java/wile/engineersdecor/detail/Networking.java rename to 1.14/src/main/java/wile/engineersdecor/libmc/detail/Networking.java index 6e465d2..1744cee 100644 --- a/1.14/src/main/java/wile/engineersdecor/detail/Networking.java +++ b/1.14/src/main/java/wile/engineersdecor/libmc/detail/Networking.java @@ -6,9 +6,8 @@ * * Main client/server message handling. */ -package wile.engineersdecor.detail; +package wile.engineersdecor.libmc.detail; -import wile.engineersdecor.ModEngineersDecor; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.fml.network.NetworkEvent; @@ -29,14 +28,14 @@ import java.util.function.Supplier; public class Networking { private static final String PROTOCOL = "1"; + private static SimpleChannel DEFAULT_CHANNEL; - private static final SimpleChannel DEFAULT_CHANNEL = NetworkRegistry.ChannelBuilder - .named(new ResourceLocation(ModEngineersDecor.MODID, "default_ch")) - .clientAcceptedVersions(PROTOCOL::equals).serverAcceptedVersions(PROTOCOL::equals).networkProtocolVersion(() -> PROTOCOL) - .simpleChannel(); - - public static void init() + public static void init(String modid) { + DEFAULT_CHANNEL = NetworkRegistry.ChannelBuilder + .named(new ResourceLocation(modid, "default_ch")) + .clientAcceptedVersions(PROTOCOL::equals).serverAcceptedVersions(PROTOCOL::equals).networkProtocolVersion(() -> PROTOCOL) + .simpleChannel(); int discr = -1; DEFAULT_CHANNEL.registerMessage(++discr, PacketTileNotifyClientToServer.class, PacketTileNotifyClientToServer::compose, PacketTileNotifyClientToServer::parse, PacketTileNotifyClientToServer.Handler::handle); DEFAULT_CHANNEL.registerMessage(++discr, PacketTileNotifyServerToClient.class, PacketTileNotifyServerToClient::compose, PacketTileNotifyServerToClient::parse, PacketTileNotifyServerToClient.Handler::handle); @@ -128,7 +127,7 @@ public class Networking public static void handle(final PacketTileNotifyServerToClient pkt, final Supplier ctx) { ctx.get().enqueueWork(() -> { - World world = ModEngineersDecor.proxy.getWorldClientSide(); + World world = SidedProxy.getWorldClientSide(); if(world == null) return; final TileEntity te = world.getTileEntity(pkt.pos); if(!(te instanceof IPacketTileNotifyReceiver)) return; @@ -230,7 +229,7 @@ public class Networking public static void handle(final PacketContainerSyncServerToClient pkt, final Supplier ctx) { ctx.get().enqueueWork(() -> { - PlayerEntity player = ModEngineersDecor.proxy.getPlayerClientSide(); + PlayerEntity player = SidedProxy.getPlayerClientSide(); if(!(player.openContainer instanceof INetworkSynchronisableContainer)) return; if(player.openContainer.windowId != pkt.id) return; ((INetworkSynchronisableContainer)player.openContainer).onServerPacketReceived(pkt.id,pkt.nbt); diff --git a/1.14/src/main/java/wile/engineersdecor/detail/OptionalRecipeCondition.java b/1.14/src/main/java/wile/engineersdecor/libmc/detail/OptionalRecipeCondition.java similarity index 53% rename from 1.14/src/main/java/wile/engineersdecor/detail/OptionalRecipeCondition.java rename to 1.14/src/main/java/wile/engineersdecor/libmc/detail/OptionalRecipeCondition.java index 66ec968..b69791b 100644 --- a/1.14/src/main/java/wile/engineersdecor/detail/OptionalRecipeCondition.java +++ b/1.14/src/main/java/wile/engineersdecor/libmc/detail/OptionalRecipeCondition.java @@ -6,11 +6,11 @@ * * Recipe condition to enable opt'ing out JSON based recipes. */ -package wile.engineersdecor.detail; +package wile.engineersdecor.libmc.detail; -import wile.engineersdecor.ModEngineersDecor; import net.minecraft.block.Block; import net.minecraft.item.Item; +import net.minecraft.tags.ItemTags; import net.minecraft.util.ResourceLocation; import net.minecraft.util.JSONUtils; import net.minecraftforge.common.crafting.conditions.ICondition; @@ -20,22 +20,58 @@ import net.minecraftforge.registries.ForgeRegistries; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; +import org.apache.logging.log4j.Logger; + import javax.annotation.Nullable; import java.util.ArrayList; import java.util.List; +import java.util.function.Predicate; public class OptionalRecipeCondition implements ICondition { - private static final ResourceLocation NAME = new ResourceLocation(ModEngineersDecor.MODID, "optional"); + private static ResourceLocation NAME; + private static Logger LOGGER; private final List all_required; private final List any_missing; + private final List all_required_tags; + private final List any_missing_tags; private final @Nullable ResourceLocation result; private final boolean experimental; - public OptionalRecipeCondition(ResourceLocation result, List required, List missing, boolean isexperimental) - { all_required = required; any_missing = missing; this.result = result; experimental=isexperimental; } + private static boolean with_experimental = false; + private static boolean without_recipes = false; + private static Predicate block_optouts = (block)->false; + private static Predicate item_optouts = (item)->false; + + + public static void init(String modid, Logger logger) + { + NAME = new ResourceLocation(modid, "optional"); + LOGGER = logger; + } + + public static void on_config(boolean enable_experimental, boolean disable_all_recipes, + Predicate block_optout_provider, + Predicate item_optout_provider) + { + with_experimental = enable_experimental; + without_recipes = disable_all_recipes; + block_optouts = block_optout_provider; + item_optouts = item_optout_provider; + } + + + public OptionalRecipeCondition(ResourceLocation result, List required, List missing, List required_tags, List missing_tags, boolean isexperimental) + { + all_required = required; + any_missing = missing; + all_required_tags = required_tags; + any_missing_tags = missing_tags; + this.result = result; + experimental=isexperimental; + } @Override public ResourceLocation getID() @@ -47,8 +83,10 @@ public class OptionalRecipeCondition implements ICondition StringBuilder sb = new StringBuilder(); sb.append("Optional recipe, all-required: ["); for(ResourceLocation e:all_required) sb.append(e.toString()).append(","); + for(ResourceLocation e:all_required_tags) sb.append("#").append(e.toString()).append(","); sb.delete(sb.length()-1, sb.length()).append("], any-missing: ["); for(ResourceLocation e:any_missing) sb.append(e.toString()).append(","); + for(ResourceLocation e:any_missing_tags) sb.append("#").append(e.toString()).append(","); sb.delete(sb.length()-1, sb.length()).append("]"); if(experimental) sb.append(" EXPERIMENTAL"); return sb.toString(); @@ -57,34 +95,41 @@ public class OptionalRecipeCondition implements ICondition @Override public boolean test() { - if(ModConfig.withoutRecipes()) return false; - if((experimental) && (!ModConfig.withExperimental())) return false; - final IForgeRegistry block_registry = ForgeRegistries.BLOCKS; + if(without_recipes) return false; + if((experimental) && (!with_experimental)) return false; final IForgeRegistry item_registry = ForgeRegistries.ITEMS; if(result != null) { boolean item_registered = item_registry.containsKey(result); - boolean block_registered = block_registry.containsKey(result); - if((!block_registered) && (!item_registered)) return false; // required result not registered - if(item_registered && ModConfig.isOptedOut(item_registry.getValue(result))) return false; - if(block_registered && ModConfig.isOptedOut(block_registry.getValue(result))) return false; + if(!item_registered) return false; // required result not registered + if(item_registered && item_optouts.test(item_registry.getValue(result))) return false; + if(ForgeRegistries.BLOCKS.containsKey(result) && block_optouts.test(ForgeRegistries.BLOCKS.getValue(result))) return false; } if(!all_required.isEmpty()) { for(ResourceLocation rl:all_required) { - if((!block_registry.containsKey(rl)) && (!item_registry.containsKey(rl))) return false; + if(!item_registry.containsKey(rl)) return false; + } + } + if(!all_required_tags.isEmpty()) { + for(ResourceLocation rl:all_required_tags) { + if(!ItemTags.getCollection().getTagMap().containsKey(rl)) return false; } } if(!any_missing.isEmpty()) { for(ResourceLocation rl:any_missing) { - // At least one item missing, enable this recipe as alternative recipe for another one that check the missing item as required item. - // --> e.g. if IE not installed there is no slag. One recipe requires slag, and another one (for the same result) is used if there - // is no slag. - if((!block_registry.containsKey(rl)) && (!item_registry.containsKey(rl))) return true; + if(!item_registry.containsKey(rl)) return true; + } + return false; + } + if(!any_missing_tags.isEmpty()) { + for(ResourceLocation rl:any_missing_tags) { + if(!ItemTags.getCollection().getTagMap().containsKey(rl)) return true; } return false; } return true; } + public static class Serializer implements IConditionSerializer { public static final Serializer INSTANCE = new Serializer(); @@ -110,17 +155,33 @@ public class OptionalRecipeCondition implements ICondition { List required = new ArrayList<>(); List missing = new ArrayList<>(); + List required_tags = new ArrayList<>(); + List missing_tags = new ArrayList<>(); ResourceLocation result = null; boolean experimental = false; if(json.has("result")) result = new ResourceLocation(json.get("result").getAsString()); if(json.has("required")) { - for(JsonElement e:JSONUtils.getJsonArray(json, "required")) required.add(new ResourceLocation(e.getAsString())); + for(JsonElement e:JSONUtils.getJsonArray(json, "required")) { + String s = e.getAsString(); + if(s.startsWith("#")) { + required_tags.add(new ResourceLocation(s.substring(1))); + } else { + required.add(new ResourceLocation(s)); + } + } } if(json.has("missing")) { - for(JsonElement e:JSONUtils.getJsonArray(json, "missing")) missing.add(new ResourceLocation(e.getAsString())); + for(JsonElement e:JSONUtils.getJsonArray(json, "missing")) { + String s = e.getAsString(); + if(s.startsWith("#")) { + missing_tags.add(new ResourceLocation(s.substring(1))); + } else { + missing.add(new ResourceLocation(s)); + } + } } if(json.has("experimental")) experimental = json.get("experimental").getAsBoolean(); - return new OptionalRecipeCondition(result, required, missing, experimental); + return new OptionalRecipeCondition(result, required, missing, required_tags, missing_tags, experimental); } } } diff --git a/1.14/src/main/java/wile/engineersdecor/libmc/detail/SidedProxy.java b/1.14/src/main/java/wile/engineersdecor/libmc/detail/SidedProxy.java new file mode 100644 index 0000000..cc99a9c --- /dev/null +++ b/1.14/src/main/java/wile/engineersdecor/libmc/detail/SidedProxy.java @@ -0,0 +1,58 @@ +package wile.engineersdecor.libmc.detail; + +import net.minecraft.client.Minecraft; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.World; +import net.minecraftforge.fml.DistExecutor; +import javax.annotation.Nullable; +import java.util.Optional; + +public class SidedProxy +{ + @Nullable + public static PlayerEntity getPlayerClientSide() + { return proxy.getPlayerClientSide(); } + + @Nullable + public static World getWorldClientSide() + { return proxy.getWorldClientSide(); } + + @Nullable + public static Minecraft mc() + { return proxy.mc(); } + + @Nullable + public static Optional isCtrlDown() + { return proxy.isCtrlDown(); } + + @Nullable + public static Optional isShiftDown() + { return proxy.isShiftDown(); } + + // -------------------------------------------------------------------------------------------------------- + + private static ISidedProxy proxy = DistExecutor.runForDist(()->ClientProxy::new, ()->ServerProxy::new); + + private interface ISidedProxy + { + default @Nullable PlayerEntity getPlayerClientSide() { return null; } + default @Nullable World getWorldClientSide() { return null; } + default @Nullable Minecraft mc() { return null; } + default Optional isCtrlDown() { return Optional.empty(); } + default Optional isShiftDown() { return Optional.empty(); } + } + + private static final class ClientProxy implements ISidedProxy + { + public @Nullable PlayerEntity getPlayerClientSide() { return Minecraft.getInstance().player; } + public @Nullable World getWorldClientSide() { return Minecraft.getInstance().world; } + public @Nullable Minecraft mc() { return Minecraft.getInstance(); } + public Optional isCtrlDown() { return Optional.of(Auxiliaries.isCtrlDown()); } + public Optional isShiftDown() { return Optional.of(Auxiliaries.isShiftDown()); } + } + + private static final class ServerProxy implements ISidedProxy + { + } + +} \ No newline at end of file diff --git a/1.14/src/main/resources/assets/engineersdecor/blockstates/small_electrical_furnace.json b/1.14/src/main/resources/assets/engineersdecor/blockstates/small_electrical_furnace.json index 5759f7b..8286de3 100644 --- a/1.14/src/main/resources/assets/engineersdecor/blockstates/small_electrical_furnace.json +++ b/1.14/src/main/resources/assets/engineersdecor/blockstates/small_electrical_furnace.json @@ -4,13 +4,9 @@ "facing=south,lit=false": { "model": "engineersdecor:block/furnace/small_electrical_furnace_model", "y": 180 }, "facing=west,lit=false": { "model": "engineersdecor:block/furnace/small_electrical_furnace_model", "y": 270 }, "facing=east,lit=false": { "model": "engineersdecor:block/furnace/small_electrical_furnace_model", "y": 90 }, - "facing=up,lit=false": { "model": "engineersdecor:block/furnace/small_electrical_furnace_model", "y": 0 }, - "facing=down,lit=false": { "model": "engineersdecor:block/furnace/small_electrical_furnace_model", "y": 0 }, "facing=north,lit=true": { "model": "engineersdecor:block/furnace/small_electrical_furnace_model_lit", "y": 0 }, "facing=south,lit=true": { "model": "engineersdecor:block/furnace/small_electrical_furnace_model_lit", "y": 180 }, "facing=west,lit=true": { "model": "engineersdecor:block/furnace/small_electrical_furnace_model_lit", "y": 270 }, - "facing=east,lit=true": { "model": "engineersdecor:block/furnace/small_electrical_furnace_model_lit", "y": 90 }, - "facing=up,lit=true": { "model": "engineersdecor:block/furnace/small_electrical_furnace_model_lit", "y": 0 }, - "facing=down,lit=true": { "model": "engineersdecor:block/furnace/small_electrical_furnace_model_lit", "y": 0 } + "facing=east,lit=true": { "model": "engineersdecor:block/furnace/small_electrical_furnace_model_lit", "y": 90 } } } diff --git a/1.14/src/main/resources/assets/engineersdecor/blockstates/small_lab_furnace.json b/1.14/src/main/resources/assets/engineersdecor/blockstates/small_lab_furnace.json index b330c50..9eaa12d 100644 --- a/1.14/src/main/resources/assets/engineersdecor/blockstates/small_lab_furnace.json +++ b/1.14/src/main/resources/assets/engineersdecor/blockstates/small_lab_furnace.json @@ -4,13 +4,9 @@ "facing=south,lit=false": { "model": "engineersdecor:block/furnace/small_lab_furnace_model", "y": 180 }, "facing=west,lit=false": { "model": "engineersdecor:block/furnace/small_lab_furnace_model", "y": 270 }, "facing=east,lit=false": { "model": "engineersdecor:block/furnace/small_lab_furnace_model", "y": 90 }, - "facing=up,lit=false": { "model": "engineersdecor:block/furnace/small_lab_furnace_model", "y": 0 }, - "facing=down,lit=false": { "model": "engineersdecor:block/furnace/small_lab_furnace_model", "y": 0 }, "facing=north,lit=true": { "model": "engineersdecor:block/furnace/small_lab_furnace_model_lit", "y": 0 }, "facing=south,lit=true": { "model": "engineersdecor:block/furnace/small_lab_furnace_model_lit", "y": 180 }, "facing=west,lit=true": { "model": "engineersdecor:block/furnace/small_lab_furnace_model_lit", "y": 270 }, - "facing=east,lit=true": { "model": "engineersdecor:block/furnace/small_lab_furnace_model_lit", "y": 90 }, - "facing=up,lit=true": { "model": "engineersdecor:block/furnace/small_lab_furnace_model", "y": 0 }, - "facing=down,lit=true": { "model": "engineersdecor:block/furnace/small_lab_furnace_model", "y": 0 } + "facing=east,lit=true": { "model": "engineersdecor:block/furnace/small_lab_furnace_model_lit", "y": 90 } } } diff --git a/1.14/src/main/resources/assets/engineersdecor/blockstates/treated_wood_crafting_table.json b/1.14/src/main/resources/assets/engineersdecor/blockstates/treated_wood_crafting_table.json index d6f3f9c..82a14e4 100644 --- a/1.14/src/main/resources/assets/engineersdecor/blockstates/treated_wood_crafting_table.json +++ b/1.14/src/main/resources/assets/engineersdecor/blockstates/treated_wood_crafting_table.json @@ -3,8 +3,6 @@ "facing=north": { "model": "engineersdecor:block/crafting_table/treated_wood_crafting_table_model" }, "facing=south": { "model": "engineersdecor:block/crafting_table/treated_wood_crafting_table_model", "y":180 }, "facing=west": { "model": "engineersdecor:block/crafting_table/treated_wood_crafting_table_model", "y":270 }, - "facing=east": { "model": "engineersdecor:block/crafting_table/treated_wood_crafting_table_model", "y":90 }, - "facing=up": { "model": "engineersdecor:block/crafting_table/treated_wood_crafting_table_model" }, - "facing=down": { "model": "engineersdecor:block/crafting_table/treated_wood_crafting_table_model" } + "facing=east": { "model": "engineersdecor:block/crafting_table/treated_wood_crafting_table_model", "y":90 } } } \ No newline at end of file diff --git a/1.14/src/main/resources/assets/engineersdecor/models/block/furniture/steel_floor_grating_model.json b/1.14/src/main/resources/assets/engineersdecor/models/block/furniture/steel_floor_grating_model.json index d6d598d..c0dec34 100644 --- a/1.14/src/main/resources/assets/engineersdecor/models/block/furniture/steel_floor_grating_model.json +++ b/1.14/src/main/resources/assets/engineersdecor/models/block/furniture/steel_floor_grating_model.json @@ -173,15 +173,28 @@ } ], "display": { + "thirdperson_righthand": { + "rotation": [66, 0, 0], + "translation": [0.25, 0, -2.75], + "scale": [0.3, 0.3, 0.3] + }, + "firstperson_righthand": { + "rotation": [-4, -1, 58], + "translation": [2.5, 0.25, 1.75], + "scale": [0.3, 0.3, 0.3] + }, "ground": { - "translation": [0, 1.75, 0], + "translation": [0, 1.75, 0], "scale": [0.2, 0.2, 0.2] }, "gui": { "rotation": [30, 225, 0], + "translation": [0, -2, 0], "scale": [0.625, 0.625, 0.625] }, "fixed": { + "rotation": [-90, 0, 1], + "translation": [0, 0.25, 3.25], "scale": [0.5, 0.5, 0.5] } } diff --git a/1.14/src/main/resources/data/engineersdecor/recipes/testing/collision_test1_diorite.json b/1.14/src/main/resources/data/engineersdecor/recipes/testing/collision_test1_diorite.json deleted file mode 100644 index 138ffb8..0000000 --- a/1.14/src/main/resources/data/engineersdecor/recipes/testing/collision_test1_diorite.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "conditions": [ - { - "type": "engineersdecor:optional", - "experimental": true - } - ], - "type": "minecraft:crafting_shaped", - "pattern": [ - "DDD", - " D ", - " D " - ], - "key": { - "D": { "item": "minecraft:diorite" } - }, - "result": { - "item": "minecraft:stone", - "count": 1 - } -} diff --git a/1.14/src/main/resources/data/engineersdecor/recipes/testing/collision_test2_diorite.json b/1.14/src/main/resources/data/engineersdecor/recipes/testing/collision_test2_diorite.json deleted file mode 100644 index a2ba7c7..0000000 --- a/1.14/src/main/resources/data/engineersdecor/recipes/testing/collision_test2_diorite.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "conditions": [ - { - "type": "engineersdecor:optional", - "experimental": true - } - ], - "type": "minecraft:crafting_shaped", - "pattern": [ - "DDD", - " D ", - " D " - ], - "key": { - "D": { "item": "minecraft:diorite" } - }, - "result": { - "item": "minecraft:granite", - "count": 1 - } -} diff --git a/1.14/src/main/resources/data/engineersdecor/recipes/testing/collision_test3_diorite.json b/1.14/src/main/resources/data/engineersdecor/recipes/testing/collision_test3_diorite.json deleted file mode 100644 index a8cc4b3..0000000 --- a/1.14/src/main/resources/data/engineersdecor/recipes/testing/collision_test3_diorite.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "conditions": [ - { - "type": "engineersdecor:optional", - "experimental": true - } - ], - "type": "minecraft:crafting_shaped", - "pattern": [ - "DDD", - " D ", - " D " - ], - "key": { - "D": { "item": "minecraft:diorite" } - }, - "result": { - "item": "minecraft:andesite", - "count": 1 - } -} diff --git a/1.15/build.gradle b/1.15/build.gradle index d9c8403..dead599 100644 --- a/1.15/build.gradle +++ b/1.15/build.gradle @@ -21,7 +21,7 @@ archivesBaseName = "engineersdecor-${version_minecraft}" repositories { maven { name = "Progwml6 maven"; url = "https://dvs1.progwml6.com/files/maven/" } // JEI files - maven { name = "ModMaven"; url = "modmaven.k-4u.nl" } // JEI files, fallback + maven { name = "ModMaven"; url = "https://modmaven.k-4u.nl" } // JEI files, fallback } minecraft { @@ -64,8 +64,8 @@ minecraft { dependencies { minecraft "net.minecraftforge:forge:${version_forge_minecraft}" - //compileOnly fg.deobf("mezz.jei:jei-${version_jei}:api") - //runtimeOnly fg.deobf("mezz.jei:jei-${version_jei}") + compileOnly fg.deobf("mezz.jei:jei-${version_jei}:api") + runtimeOnly fg.deobf("mezz.jei:jei-${version_jei}") } processResources { diff --git a/1.15/gradle.properties b/1.15/gradle.properties index 10b6484..928bd9b 100644 --- a/1.15/gradle.properties +++ b/1.15/gradle.properties @@ -4,5 +4,5 @@ org.gradle.jvmargs=-Xmx8G version_minecraft=1.15.2 version_forge_minecraft=1.15.2-31.0.1 version_fml_mappings=20191105-1.14.3 -version_jei=1.15.2-6.0.0.2 -version_engineersdecor=1.0.19-b1 +version_jei=1.15.2:6.0.0.2 +version_engineersdecor=1.0.19-b2 diff --git a/1.15/meta/update.json b/1.15/meta/update.json index 34ecaf7..06215e8 100644 --- a/1.15/meta/update.json +++ b/1.15/meta/update.json @@ -1,6 +1,7 @@ { "homepage": "https://www.curseforge.com/minecraft/mc-mods/engineers-decor/", "1.15.2": { + "1.0.19-b2": "[F] Fixed Floor Grating item pass-through jitters (thx Cid).\n[M] Removed obsolete recipe collision testing recipes.\n[F] Fixed missing Block Breaker dynamic block drops.\n[F] Block Placer planting race condition issue fixed (issue #83, thx jcardii).\n[F] Factory Hopper: Added second standard insertion run after smart-insert to circumcent compat issues (issue #84, thx NillerMedDild).\n[A] Enabled JEI plugin (issue #85, thx ProsperCraft/Goshen).", "1.0.19-b1": "[U] Update to 1.15.2.\n[F] Fixed Tree Cutter / Block Breaker not accepting small energy transfers (thx WindFox, issue #82).", "1.0.18-b4": "[A] Ported Treated Wood Crafting Table item rendering.\n[F] Fixed Milking machine cow path issue, added milking delay cow tracking.\n[F] Slab / Slab Slice placement adapted to vanilla standard.\n[M] Lang update ru_ru (PR#77, thanks Smollet777).", "1.0.18-b3": "[A] Added Treated Wood Crafting Table tweaks (ctrl-shift moves all same stacks from the inventory, mouse wheel over crafting slot increases/decreases crafting grid stacks).\n[F] EN Lang file fixed (issue #76, thx Riverstar907).\n[F] Fixed Tree Cutter not respecting power-required config (thx federsavo, issue #77).\n[F] Fixed Small Solar Panel not exposing energy capability (thx MatthiasMann, issue #78).", @@ -10,6 +11,6 @@ }, "promos": { "1.15.2-recommended": "", - "1.15.2-latest": "1.0.19-b1" + "1.15.2-latest": "1.0.19-b2" } } \ No newline at end of file diff --git a/1.15/readme.md b/1.15/readme.md index baad1ac..3f5877d 100644 --- a/1.15/readme.md +++ b/1.15/readme.md @@ -11,6 +11,13 @@ Mod sources for Minecraft version 1.15.1. ## Version history + - v1.0.19-b2 [F] Fixed Floor Grating item pass-through jitters (thx Cid). + [M] Removed obsolete recipe collision testing recipes. + [F] Fixed missing Block Breaker dynamic block drops. + [F] Block Placer planting race condition issue fixed (issue #83, thx jcardii). + [F] Factory Hopper: Added second standard insertion run after smart-insert to circumcent compat issues (issue #84, thx NillerMedDild). + [A] Enabled JEI plugin (issue #85, thx ProsperCraft/Goshen). + - v1.0.19-b1 [U] Update to 1.15.2. [F] Fixed Tree Cutter / Block Breaker not accepting small energy transfers (thx WindFox, issue #82). diff --git a/1.15/src/main/java/wile/engineersdecor/ModContent.java b/1.15/src/main/java/wile/engineersdecor/ModContent.java index 1b97bfb..664d2ce 100644 --- a/1.15/src/main/java/wile/engineersdecor/ModContent.java +++ b/1.15/src/main/java/wile/engineersdecor/ModContent.java @@ -14,7 +14,8 @@ package wile.engineersdecor; import wile.engineersdecor.blocks.*; -import wile.engineersdecor.detail.ModAuxiliaries; +import wile.engineersdecor.libmc.blocks.StandardBlocks.IStandardBlock; +import wile.engineersdecor.libmc.detail.Auxiliaries; import net.minecraft.block.material.MaterialColor; import net.minecraft.block.Block; import net.minecraft.block.SoundType; @@ -219,55 +220,55 @@ public class ModContent public static final BlockDecor.WaterLoggable TREATED_WOOD_TABLE = (BlockDecor.WaterLoggable)(new BlockDecor.WaterLoggable( BlockDecor.CFG_CUTOUT, Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(2f, 15f).sound(SoundType.WOOD), - ModAuxiliaries.getPixeledAABB(1,0,1, 15,15.9,15) + Auxiliaries.getPixeledAABB(1,0,1, 15,15.9,15) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "treated_wood_table")); public static final BlockDecorChair TREATED_WOOD_STOOL = (BlockDecorChair)(new BlockDecorChair( BlockDecor.CFG_CUTOUT|BlockDecor.CFG_HORIZIONTAL|BlockDecor.CFG_LOOK_PLACEMENT, Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(2f, 15f).sound(SoundType.WOOD), - ModAuxiliaries.getPixeledAABB(4.1,0,4.1, 11.8,8.8,11.8) + Auxiliaries.getPixeledAABB(4.1,0,4.1, 11.8,8.8,11.8) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "treated_wood_stool")); public static final BlockDecor.WaterLoggable TREATED_WOOD_SIDE_TABLE = (BlockDecor.WaterLoggable)(new BlockDecor.WaterLoggable( BlockDecor.CFG_CUTOUT|BlockDecor.CFG_HORIZIONTAL|BlockDecor.CFG_LOOK_PLACEMENT, Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(2f, 15f).sound(SoundType.WOOD), - ModAuxiliaries.getPixeledAABB(2,0,2, 14,15.9,14) + Auxiliaries.getPixeledAABB(2,0,2, 14,15.9,14) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "treated_wood_side_table")); - public static final BlockDecorDirected.WaterLoggable TREATED_WOOD_WINDOWSILL = (BlockDecorDirected.WaterLoggable)(new BlockDecorDirected.WaterLoggable( + public static final BlockDecor.DirectedWaterLoggable TREATED_WOOD_WINDOWSILL = (BlockDecor.DirectedWaterLoggable)(new BlockDecor.DirectedWaterLoggable( BlockDecor.CFG_CUTOUT|BlockDecor.CFG_HORIZIONTAL|BlockDecor.CFG_FACING_PLACEMENT, Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(2f, 15f).sound(SoundType.WOOD), - ModAuxiliaries.getPixeledAABB(0.5,15,10.5, 15.5,16,16) + Auxiliaries.getPixeledAABB(0.5,15,10.5, 15.5,16,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "treated_wood_windowsill")); - public static final BlockDecorDirected.WaterLoggable TREATED_WOOD_BROAD_WINDOWSILL = (BlockDecorDirected.WaterLoggable)(new BlockDecorDirected.WaterLoggable( + public static final BlockDecor.DirectedWaterLoggable TREATED_WOOD_BROAD_WINDOWSILL = (BlockDecor.DirectedWaterLoggable)(new BlockDecor.DirectedWaterLoggable( BlockDecor.CFG_CUTOUT|BlockDecor.CFG_HORIZIONTAL|BlockDecor.CFG_FACING_PLACEMENT, Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(2f, 15f).sound(SoundType.WOOD), - ModAuxiliaries.getPixeledAABB(0,14.5,4, 16,16,16) + Auxiliaries.getPixeledAABB(0,14.5,4, 16,16,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "treated_wood_broad_windowsill")); - public static final BlockDecorDirected.WaterLoggable INSET_LIGHT_IRON = (BlockDecorDirected.WaterLoggable)(new BlockDecorDirected.WaterLoggable( - BlockDecor.CFG_CUTOUT|BlockDecor.CFG_OPPOSITE_PLACEMENT, + public static final BlockDecor.DirectedWaterLoggable INSET_LIGHT_IRON = (BlockDecor.DirectedWaterLoggable)(new BlockDecor.DirectedWaterLoggable( + BlockDecor.CFG_CUTOUT|BlockDecor.CFG_FACING_PLACEMENT|BlockDecor.CFG_OPPOSITE_PLACEMENT, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).lightValue(15), - ModAuxiliaries.getPixeledAABB(5.2,5.2,15.7, 10.8,10.8,16.0) + Auxiliaries.getPixeledAABB(5.2,5.2,0, 10.8,10.8,0.3) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "iron_inset_light")); - public static final BlockDecorDirected.WaterLoggable FLOOR_EDGE_LIGHT_IRON = (BlockDecorDirected.WaterLoggable)(new BlockDecorDirected.WaterLoggable( + public static final BlockDecor.DirectedWaterLoggable FLOOR_EDGE_LIGHT_IRON = (BlockDecor.DirectedWaterLoggable)(new BlockDecor.DirectedWaterLoggable( BlockDecor.CFG_CUTOUT|BlockDecor.CFG_LOOK_PLACEMENT|BlockDecor.CFG_HORIZIONTAL, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).lightValue(15), - ModAuxiliaries.getPixeledAABB(5,0,0, 11,2,1) + Auxiliaries.getPixeledAABB(5,0,0, 11,2,0.5) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "iron_floor_edge_light")); public static final BlockDecor.WaterLoggable STEEL_TABLE = (BlockDecor.WaterLoggable)(new BlockDecor.WaterLoggable( - BlockDecor.CFG_CUTOUT|BlockDecor.CFG_HORIZIONTAL|BlockDecor.CFG_LOOK_PLACEMENT, + BlockDecor.CFG_CUTOUT, Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(2f, 15f).sound(SoundType.WOOD), - ModAuxiliaries.getPixeledAABB(0,0,0, 16,16,16) + Auxiliaries.getPixeledAABB(0,0,0, 16,16,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "steel_table")); - public static final BlockDecor STEEL_FLOOR_GRATING = (BlockDecorFloorGrating)(new BlockDecorFloorGrating( + public static final BlockDecorFloorGrating STEEL_FLOOR_GRATING = (BlockDecorFloorGrating)(new BlockDecorFloorGrating( BlockDecor.CFG_CUTOUT, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).func_226896_b_(), - ModAuxiliaries.getPixeledAABB(0,14,0, 16,16,16) + Auxiliaries.getPixeledAABB(0,14,0, 16,15.9,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "steel_floor_grating")); // ------------------------------------------------------------------------------------------------------------------- @@ -275,13 +276,13 @@ public class ModContent public static final BlockDecorWindow TREATED_WOOD_WINDOW = (BlockDecorWindow)(new BlockDecorWindow( BlockDecor.CFG_LOOK_PLACEMENT, Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(2f, 15f).sound(SoundType.GLASS), - ModAuxiliaries.getPixeledAABB(0,0,7, 16,16,9) + Auxiliaries.getPixeledAABB(0,0,7, 16,16,9) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "treated_wood_window")); public static final BlockDecorWindow STEEL_FRAMED_WINDOW = (BlockDecorWindow)(new BlockDecorWindow( BlockDecor.CFG_LOOK_PLACEMENT, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.GLASS), - ModAuxiliaries.getPixeledAABB(0,0,7.5, 16,16,8.5) + Auxiliaries.getPixeledAABB(0,0,7.5, 16,16,8.5) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "steel_framed_window")); // ------------------------------------------------------------------------------------------------------------------- @@ -289,87 +290,87 @@ public class ModContent public static final BlockDecorStraightPole TREATED_WOOD_POLE = (BlockDecorStraightPole)(new BlockDecorStraightPole( BlockDecor.CFG_CUTOUT|BlockDecor.CFG_FACING_PLACEMENT|BlockDecor.CFG_FLIP_PLACEMENT_IF_SAME, Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(2f, 15f).sound(SoundType.WOOD), - ModAuxiliaries.getPixeledAABB(5.8,5.8,0, 10.2,10.2,16) + Auxiliaries.getPixeledAABB(5.8,5.8,0, 10.2,10.2,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "treated_wood_pole")); public static final BlockDecorStraightPole TREATED_WOOD_POLE_HEAD = (BlockDecorStraightPole)(new BlockDecorStraightPole( BlockDecor.CFG_CUTOUT|BlockDecor.CFG_FACING_PLACEMENT|BlockDecor.CFG_FLIP_PLACEMENT_IF_SAME, Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(2f, 15f).sound(SoundType.WOOD), - ModAuxiliaries.getPixeledAABB(5.8,5.8,0, 10.2,10.2,16) + Auxiliaries.getPixeledAABB(5.8,5.8,0, 10.2,10.2,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "treated_wood_pole_head")); public static final BlockDecorStraightPole TREATED_WOOD_POLE_SUPPORT = (BlockDecorStraightPole)(new BlockDecorStraightPole( BlockDecor.CFG_CUTOUT|BlockDecor.CFG_FACING_PLACEMENT|BlockDecor.CFG_FLIP_PLACEMENT_IF_SAME, Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(2f, 15f).sound(SoundType.WOOD), - ModAuxiliaries.getPixeledAABB(5.8,5.8,0, 10.2,10.2,16) + Auxiliaries.getPixeledAABB(5.8,5.8,0, 10.2,10.2,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "treated_wood_pole_support")); public static final BlockDecorStraightPole THIN_STEEL_POLE = (BlockDecorStraightPole)(new BlockDecorStraightPole( BlockDecor.CFG_CUTOUT|BlockDecor.CFG_FACING_PLACEMENT, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL), - ModAuxiliaries.getPixeledAABB(6,6,0, 10,10,16) + Auxiliaries.getPixeledAABB(6,6,0, 10,10,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "thin_steel_pole")); public static final BlockDecorStraightPole THIN_STEEL_POLE_HEAD = (BlockDecorStraightPole)(new BlockDecorStraightPole( BlockDecor.CFG_CUTOUT|BlockDecor.CFG_FACING_PLACEMENT|BlockDecor.CFG_FLIP_PLACEMENT_IF_SAME, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).func_226896_b_(), - ModAuxiliaries.getPixeledAABB(6,6,0, 10,10,16) + Auxiliaries.getPixeledAABB(6,6,0, 10,10,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "thin_steel_pole_head")); public static final BlockDecorStraightPole THICK_STEEL_POLE = (BlockDecorStraightPole)(new BlockDecorStraightPole( BlockDecor.CFG_CUTOUT|BlockDecor.CFG_FACING_PLACEMENT, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL), - ModAuxiliaries.getPixeledAABB(5,5,0, 11,11,16) + Auxiliaries.getPixeledAABB(5,5,0, 11,11,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "thick_steel_pole")); public static final BlockDecorStraightPole THICK_STEEL_POLE_HEAD = (BlockDecorStraightPole)(new BlockDecorStraightPole( BlockDecor.CFG_CUTOUT|BlockDecor.CFG_FACING_PLACEMENT|BlockDecor.CFG_FLIP_PLACEMENT_IF_SAME, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).func_226896_b_(), - ModAuxiliaries.getPixeledAABB(5,5,0, 11,11,16) + Auxiliaries.getPixeledAABB(5,5,0, 11,11,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "thick_steel_pole_head")); public static final BlockDecorHorizontalSupport STEEL_DOUBLE_T_SUPPORT = (BlockDecorHorizontalSupport)(new BlockDecorHorizontalSupport( BlockDecor.CFG_CUTOUT|BlockDecor.CFG_HORIZIONTAL|BlockDecor.CFG_LOOK_PLACEMENT, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL), - ModAuxiliaries.getPixeledAABB(5,11,0, 11,16,16) + Auxiliaries.getPixeledAABB(5,11,0, 11,16,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "steel_double_t_support")); // ------------------------------------------------------------------------------------------------------------------- - public static final BlockDecorDirected.WaterLoggable SIGN_MODLOGO = (BlockDecorDirected.WaterLoggable)(new BlockDecorDirected.WaterLoggable( + public static final BlockDecor.DirectedWaterLoggable SIGN_MODLOGO = (BlockDecor.DirectedWaterLoggable)(new BlockDecor.DirectedWaterLoggable( BlockDecor.CFG_CUTOUT|BlockDecor.CFG_FACING_PLACEMENT|BlockDecor.CFG_HORIZIONTAL, Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(1f, 1000f).sound(SoundType.WOOD).lightValue(1), - ModAuxiliaries.getPixeledAABB(0,0,15.6, 16,16,16.0) + Auxiliaries.getPixeledAABB(0,0,15.6, 16,16,16.0) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "sign_decor")); - public static final BlockDecorDirected.WaterLoggable SIGN_HOTWIRE = (BlockDecorDirected.WaterLoggable)(new BlockDecorDirected.WaterLoggable( + public static final BlockDecor.DirectedWaterLoggable SIGN_HOTWIRE = (BlockDecor.DirectedWaterLoggable)(new BlockDecor.DirectedWaterLoggable( BlockDecor.CFG_CUTOUT|BlockDecor.CFG_FACING_PLACEMENT|BlockDecor.CFG_HORIZIONTAL, Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(1f, 1f).sound(SoundType.WOOD), - ModAuxiliaries.getPixeledAABB(2,2,15.6, 14,14,16) + Auxiliaries.getPixeledAABB(2,2,15.6, 14,14,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "sign_hotwire")); - public static final BlockDecorDirected.WaterLoggable SIGN_DANGER = (BlockDecorDirected.WaterLoggable)(new BlockDecorDirected.WaterLoggable( + public static final BlockDecor.DirectedWaterLoggable SIGN_DANGER = (BlockDecor.DirectedWaterLoggable)(new BlockDecor.DirectedWaterLoggable( BlockDecor.CFG_CUTOUT|BlockDecor.CFG_FACING_PLACEMENT|BlockDecor.CFG_HORIZIONTAL, Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(1f, 1f).sound(SoundType.WOOD), - ModAuxiliaries.getPixeledAABB(2,2,15.6, 14,14,16) + Auxiliaries.getPixeledAABB(2,2,15.6, 14,14,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "sign_danger")); - public static final BlockDecorDirected.WaterLoggable SIGN_DEFENSE = (BlockDecorDirected.WaterLoggable)(new BlockDecorDirected.WaterLoggable( + public static final BlockDecor.DirectedWaterLoggable SIGN_DEFENSE = (BlockDecor.DirectedWaterLoggable)(new BlockDecor.DirectedWaterLoggable( BlockDecor.CFG_CUTOUT|BlockDecor.CFG_FACING_PLACEMENT|BlockDecor.CFG_HORIZIONTAL, Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(1f, 1f).sound(SoundType.WOOD), - ModAuxiliaries.getPixeledAABB(2,2,15.6, 14,14,16) + Auxiliaries.getPixeledAABB(2,2,15.6, 14,14,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "sign_defense")); - public static final BlockDecorDirected.WaterLoggable SIGN_FACTORY_AREA = (BlockDecorDirected.WaterLoggable)(new BlockDecorDirected.WaterLoggable( + public static final BlockDecor.DirectedWaterLoggable SIGN_FACTORY_AREA = (BlockDecor.DirectedWaterLoggable)(new BlockDecor.DirectedWaterLoggable( BlockDecor.CFG_CUTOUT|BlockDecor.CFG_FACING_PLACEMENT|BlockDecor.CFG_HORIZIONTAL, Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(1f, 1f).sound(SoundType.WOOD), - ModAuxiliaries.getPixeledAABB(2,2,15.6, 14,14,16) + Auxiliaries.getPixeledAABB(2,2,15.6, 14,14,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "sign_factoryarea")); - public static final BlockDecorDirected.WaterLoggable SIGN_EXIT = (BlockDecorDirected.WaterLoggable)(new BlockDecorDirected.WaterLoggable( + public static final BlockDecor.DirectedWaterLoggable SIGN_EXIT = (BlockDecor.DirectedWaterLoggable)(new BlockDecor.DirectedWaterLoggable( BlockDecor.CFG_CUTOUT|BlockDecor.CFG_FACING_PLACEMENT|BlockDecor.CFG_HORIZIONTAL, Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(1f, 1f).sound(SoundType.WOOD), - ModAuxiliaries.getPixeledAABB(3,7,15.6, 13,13,16) + Auxiliaries.getPixeledAABB(3,7,15.6, 13,13,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "sign_exit")); // ------------------------------------------------------------------------------------------------------------------- @@ -377,103 +378,106 @@ public class ModContent public static final BlockDecorCraftingTable.CraftingTableBlock TREATED_WOOD_CRAFTING_TABLE = (BlockDecorCraftingTable.CraftingTableBlock)(new BlockDecorCraftingTable.CraftingTableBlock( BlockDecor.CFG_CUTOUT|BlockDecor.CFG_HORIZIONTAL|BlockDecor.CFG_LOOK_PLACEMENT|BlockDecor.CFG_OPPOSITE_PLACEMENT, Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(1f, 15f).sound(SoundType.WOOD), - ModAuxiliaries.getPixeledAABB(1,0,1, 15,15.9,15) + Auxiliaries.getPixeledAABB(1,0,1, 15,15.9,15) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "treated_wood_crafting_table")); public static final BlockDecorFurnace SMALL_LAB_FURNACE = (BlockDecorFurnace)(new BlockDecorFurnace( - BlockDecor.CFG_CUTOUT|BlockDecor.CFG_HORIZIONTAL|BlockDecor.CFG_LOOK_PLACEMENT, + BlockDecor.CFG_CUTOUT|BlockDecor.CFG_HORIZIONTAL|BlockDecor.CFG_LOOK_PLACEMENT|BlockDecor.CFG_OPPOSITE_PLACEMENT, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(1f, 15f).sound(SoundType.METAL).func_226896_b_(), - ModAuxiliaries.getPixeledAABB(1,0,1, 15,15,16.0) + Auxiliaries.getPixeledAABB(1,0,1, 15,15,16.0) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "small_lab_furnace")); public static final BlockDecorFurnaceElectrical SMALL_ELECTRICAL_FURNACE = (BlockDecorFurnaceElectrical)(new BlockDecorFurnaceElectrical( - BlockDecor.CFG_CUTOUT|BlockDecor.CFG_HORIZIONTAL|BlockDecor.CFG_LOOK_PLACEMENT|BlockDecor.CFG_ELECTRICAL, + BlockDecor.CFG_CUTOUT|BlockDecor.CFG_HORIZIONTAL|BlockDecor.CFG_LOOK_PLACEMENT|BlockDecor.CFG_OPPOSITE_PLACEMENT, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).func_226896_b_(), - ModAuxiliaries.getPixeledAABB(0,0,0, 16,16,16) + Auxiliaries.getPixeledAABB(0,0,0, 16,16,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "small_electrical_furnace")); public static final BlockDecorDropper FACTORY_DROPPER = (BlockDecorDropper)(new BlockDecorDropper( - BlockDecor.CFG_LOOK_PLACEMENT|BlockDecor.CFG_OPPOSITE_PLACEMENT|BlockDecor.CFG_REDSTONE_CONTROLLED, + BlockDecor.CFG_LOOK_PLACEMENT|BlockDecor.CFG_OPPOSITE_PLACEMENT, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).func_226896_b_(), - ModAuxiliaries.getPixeledAABB(0,0,0, 16,16,15) + Auxiliaries.getPixeledAABB(0,0,1, 16,16,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "factory_dropper")); public static final BlockDecorPlacer FACTORY_PLACER = (BlockDecorPlacer)(new BlockDecorPlacer( - BlockDecor.CFG_LOOK_PLACEMENT|BlockDecor.CFG_FLIP_PLACEMENT_SHIFTCLICK|BlockDecor.CFG_OPPOSITE_PLACEMENT|BlockDecor.CFG_REDSTONE_CONTROLLED, + BlockDecor.CFG_LOOK_PLACEMENT|BlockDecor.CFG_FLIP_PLACEMENT_SHIFTCLICK|BlockDecor.CFG_OPPOSITE_PLACEMENT, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).func_226896_b_(), - ModAuxiliaries.getPixeledAABB(2,2,2, 14,14,14) + Auxiliaries.getPixeledAABB(2,2,2, 14,14,14) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "factory_placer")); public static final BlockDecorBreaker SMALL_BLOCK_BREAKER = (BlockDecorBreaker)(new BlockDecorBreaker( BlockDecor.CFG_HORIZIONTAL|BlockDecor.CFG_LOOK_PLACEMENT|BlockDecor.CFG_OPPOSITE_PLACEMENT|BlockDecor.CFG_FLIP_PLACEMENT_SHIFTCLICK, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).func_226896_b_(), - ModAuxiliaries.getPixeledAABB(0,0,0, 16,12,16) + Auxiliaries.getPixeledAABB(0,0,0, 16,12,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "small_block_breaker")); public static final BlockDecorHopper FACTORY_HOPPER = (BlockDecorHopper)(new BlockDecorHopper( - BlockDecor.CFG_CUTOUT|BlockDecor.CFG_FACING_PLACEMENT|BlockDecor.CFG_OPPOSITE_PLACEMENT|BlockDecor.CFG_REDSTONE_CONTROLLED, + BlockDecor.CFG_CUTOUT|BlockDecor.CFG_FACING_PLACEMENT|BlockDecor.CFG_OPPOSITE_PLACEMENT, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).func_226896_b_(), - ModAuxiliaries.getPixeledAABB(0,0,0, 16,16,16) + Auxiliaries.getPixeledAABB(0,0,0, 16,16,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "factory_hopper")); public static final BlockDecorWasteIncinerator SMALL_WASTE_INCINERATOR = (BlockDecorWasteIncinerator)(new BlockDecorWasteIncinerator( - BlockDecor.CFG_DEFAULT|BlockDecor.CFG_ELECTRICAL, + BlockDecor.CFG_DEFAULT, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL), - ModAuxiliaries.getPixeledAABB(0,0,0, 16,16,16) + Auxiliaries.getPixeledAABB(0,0,0, 16,16,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "small_waste_incinerator")); public static final BlockDecorMineralSmelter SMALL_MINERAL_SMELTER = (BlockDecorMineralSmelter)(new BlockDecorMineralSmelter( - BlockDecor.CFG_CUTOUT|BlockDecor.CFG_HORIZIONTAL|BlockDecor.CFG_LOOK_PLACEMENT|BlockDecor.CFG_ELECTRICAL, + BlockDecor.CFG_CUTOUT|BlockDecor.CFG_HORIZIONTAL|BlockDecor.CFG_LOOK_PLACEMENT, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).func_226896_b_(), - ModAuxiliaries.getPixeledAABB(1.1,0,1.1, 14.9,16,14.9) + Auxiliaries.getPixeledAABB(1.1,0,1.1, 14.9,16,14.9) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "small_mineral_smelter")); public static final BlockDecorSolarPanel SMALL_SOLAR_PANEL = (BlockDecorSolarPanel)(new BlockDecorSolarPanel( - BlockDecor.CFG_CUTOUT|BlockDecor.CFG_HORIZIONTAL|BlockDecor.CFG_LOOK_PLACEMENT|BlockDecor.CFG_ELECTRICAL, + BlockDecor.CFG_CUTOUT, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).func_226896_b_(), - ModAuxiliaries.getPixeledAABB(0,0,0, 16,11.5,16) + Auxiliaries.getPixeledAABB(0,0,0, 16,11.5,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "small_solar_panel")); public static final BlockDecorMilker SMALL_MILKING_MACHINE = (BlockDecorMilker)(new BlockDecorMilker( - BlockDecor.CFG_LOOK_PLACEMENT|BlockDecor.CFG_HORIZIONTAL|BlockDecor.CFG_CUTOUT|BlockDecor.CFG_ELECTRICAL, + BlockDecor.CFG_CUTOUT|BlockDecor.CFG_HORIZIONTAL|BlockDecor.CFG_LOOK_PLACEMENT, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).func_226896_b_(), - ModAuxiliaries.getPixeledAABB(0,0,0, 16,16,13) + Auxiliaries.getPixeledAABB(0,0,0, 16,16,13) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "small_milking_machine")); public static final BlockDecorTreeCutter SMALL_TREE_CUTTER = (BlockDecorTreeCutter)(new BlockDecorTreeCutter( BlockDecor.CFG_CUTOUT|BlockDecor.CFG_HORIZIONTAL|BlockDecor.CFG_LOOK_PLACEMENT|BlockDecor.CFG_FLIP_PLACEMENT_SHIFTCLICK, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).func_226896_b_(), - ModAuxiliaries.getPixeledAABB(0,0,0, 16,8,16) + Auxiliaries.getPixeledAABB(0,0,0, 16,8,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "small_tree_cutter")); public static final BlockDecorPipeValve STRAIGHT_CHECK_VALVE = (BlockDecorPipeValve)(new BlockDecorPipeValve( - BlockDecor.CFG_FACING_PLACEMENT|BlockDecor.CFG_OPPOSITE_PLACEMENT|BlockDecor.CFG_FLIP_PLACEMENT_SHIFTCLICK|BlockDecor.CFG_CUTOUT, + BlockDecor.CFG_CUTOUT|BlockDecor.CFG_FACING_PLACEMENT|BlockDecor.CFG_OPPOSITE_PLACEMENT|BlockDecor.CFG_FLIP_PLACEMENT_SHIFTCLICK, + BlockDecorPipeValve.CFG_CHECK_VALVE, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).func_226896_b_(), - ModAuxiliaries.getPixeledAABB(4,4,0, 12,12,16) + Auxiliaries.getPixeledAABB(4,4,0, 12,12,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "straight_pipe_valve")); public static final BlockDecorPipeValve STRAIGHT_REDSTONE_VALVE = (BlockDecorPipeValve)(new BlockDecorPipeValve( - BlockDecor.CFG_FACING_PLACEMENT|BlockDecor.CFG_OPPOSITE_PLACEMENT|BlockDecor.CFG_FLIP_PLACEMENT_SHIFTCLICK|BlockDecor.CFG_CUTOUT|BlockDecor.CFG_REDSTONE_CONTROLLED, + BlockDecor.CFG_CUTOUT|BlockDecor.CFG_FACING_PLACEMENT|BlockDecor.CFG_OPPOSITE_PLACEMENT|BlockDecor.CFG_FLIP_PLACEMENT_SHIFTCLICK, + BlockDecorPipeValve.CFG_REDSTONE_CONTROLLED_VALVE, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).func_226896_b_(), - ModAuxiliaries.getPixeledAABB(4,4,0, 12,12,16) + Auxiliaries.getPixeledAABB(4,4,0, 12,12,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "straight_pipe_valve_redstone")); public static final BlockDecorPipeValve STRAIGHT_REDSTONE_ANALOG_VALVE = (BlockDecorPipeValve)(new BlockDecorPipeValve( - BlockDecor.CFG_FACING_PLACEMENT|BlockDecor.CFG_OPPOSITE_PLACEMENT|BlockDecor.CFG_FLIP_PLACEMENT_SHIFTCLICK|BlockDecor.CFG_CUTOUT|BlockDecor.CFG_REDSTONE_CONTROLLED|BlockDecor.CFG_ANALOG, + BlockDecor.CFG_CUTOUT|BlockDecor.CFG_FACING_PLACEMENT|BlockDecor.CFG_OPPOSITE_PLACEMENT|BlockDecor.CFG_FLIP_PLACEMENT_SHIFTCLICK, + BlockDecorPipeValve.CFG_REDSTONE_CONTROLLED_VALVE|BlockDecorPipeValve.CFG_ANALOG_VALVE, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).func_226896_b_(), - ModAuxiliaries.getPixeledAABB(4,4,0, 12,12,16) + Auxiliaries.getPixeledAABB(4,4,0, 12,12,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "straight_pipe_valve_redstone_analog")); public static final BlockDecorPassiveFluidAccumulator PASSIVE_FLUID_ACCUMULATOR = (BlockDecorPassiveFluidAccumulator)(new BlockDecorPassiveFluidAccumulator( - BlockDecor.CFG_FACING_PLACEMENT|BlockDecor.CFG_OPPOSITE_PLACEMENT|BlockDecor.CFG_FLIP_PLACEMENT_SHIFTCLICK|BlockDecor.CFG_CUTOUT, + BlockDecor.CFG_CUTOUT|BlockDecor.CFG_FACING_PLACEMENT|BlockDecor.CFG_OPPOSITE_PLACEMENT|BlockDecor.CFG_FLIP_PLACEMENT_SHIFTCLICK, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).func_226896_b_(), - ModAuxiliaries.getPixeledAABB(0,0,0, 16,16,16) + Auxiliaries.getPixeledAABB(0,0,0, 16,16,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "passive_fluid_accumulator")); public static final BlockDecorFluidFunnel SMALL_FLUID_FUNNEL = (BlockDecorFluidFunnel)(new BlockDecorFluidFunnel( - BlockDecor.CFG_CUTOUT|BlockDecor.CFG_REDSTONE_CONTROLLED, + BlockDecor.CFG_CUTOUT, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).func_226896_b_(), - ModAuxiliaries.getPixeledAABB(0,0,0, 16,16,16) + Auxiliaries.getPixeledAABB(0,0,0, 16,16,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "small_fluid_funnel")); // ------------------------------------------------------------------------------------------------------------------- @@ -528,9 +532,9 @@ public class ModContent // ------------------------------------------------------------------------------------------------------------------- public static final BlockDecorTest TEST_BLOCK = (BlockDecorTest)(new BlockDecorTest( - BlockDecor.CFG_LOOK_PLACEMENT|BlockDecor.CFG_FLIP_PLACEMENT_SHIFTCLICK|BlockDecor.CFG_ELECTRICAL|BlockDecor.CFG_REDSTONE_CONTROLLED, + BlockDecor.CFG_LOOK_PLACEMENT|BlockDecor.CFG_FLIP_PLACEMENT_SHIFTCLICK, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(0f, 32000f).sound(SoundType.METAL), - ModAuxiliaries.getPixeledAABB(0,0,0, 16,16,16) + Auxiliaries.getPixeledAABB(0,0,0, 16,16,16) )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "test_block")); // ------------------------------------------------------------------------------------------------------------------- @@ -807,10 +811,10 @@ public class ModContent public static final void registerBlocks(final RegistryEvent.Register event) { - if(ModAuxiliaries.isModLoaded("immersiveengineering")) ModAuxiliaries.logInfo("Immersive Engineering also installed ..."); + if(Auxiliaries.isModLoaded("immersiveengineering")) Auxiliaries.logInfo("Immersive Engineering also installed ..."); registeredBlocks.addAll(allBlocks()); for(Block e:registeredBlocks) event.getRegistry().register(e); - ModAuxiliaries.logInfo("Registered " + Integer.toString(registeredBlocks.size()) + " blocks."); + Auxiliaries.logInfo("Registered " + Integer.toString(registeredBlocks.size()) + " blocks."); } public static final void registerBlockItems(final RegistryEvent.Register event) @@ -831,7 +835,7 @@ public class ModContent event.getRegistry().register(e); ++n_registered; } - ModAuxiliaries.logInfo("Registered " + Integer.toString(n_registered) + " tile entities."); + Auxiliaries.logInfo("Registered " + Integer.toString(n_registered) + " tile entities."); } public static final void registerEntities(final RegistryEvent.Register> event) @@ -842,7 +846,7 @@ public class ModContent event.getRegistry().register(e); ++n_registered; } - ModAuxiliaries.logInfo("Registered " + Integer.toString(n_registered) + " entities bound to blocks."); + Auxiliaries.logInfo("Registered " + Integer.toString(n_registered) + " entities bound to blocks."); } public static final void registerContainers(final RegistryEvent.Register> event) @@ -852,7 +856,7 @@ public class ModContent event.getRegistry().register(e); ++n_registered; } - ModAuxiliaries.logInfo("Registered " + Integer.toString(n_registered) + " containers bound to tile entities."); + Auxiliaries.logInfo("Registered " + Integer.toString(n_registered) + " containers bound to tile entities."); } @OnlyIn(Dist.CLIENT) @@ -882,8 +886,8 @@ public class ModContent { // Block renderer selection for(Block block: getRegisteredBlocks()) { - if(block instanceof IDecorBlock) { - switch(((IDecorBlock)block).getRenderTypeHint()) { + if(block instanceof IStandardBlock) { + switch(((IStandardBlock)block).getRenderTypeHint()) { case CUTOUT: RenderTypeLookup.setRenderLayer(block, RenderType.func_228643_e_()/*cutout*/); break; diff --git a/1.15/src/main/java/wile/engineersdecor/ModEngineersDecor.java b/1.15/src/main/java/wile/engineersdecor/ModEngineersDecor.java index c2678fe..3b67b8e 100644 --- a/1.15/src/main/java/wile/engineersdecor/ModEngineersDecor.java +++ b/1.15/src/main/java/wile/engineersdecor/ModEngineersDecor.java @@ -1,18 +1,15 @@ package wile.engineersdecor; -import wile.engineersdecor.detail.ModAuxiliaries; -import wile.engineersdecor.detail.ModConfig; -import wile.engineersdecor.detail.Networking; import wile.engineersdecor.blocks.*; -import wile.engineersdecor.detail.OptionalRecipeCondition.Serializer; -import wile.engineersdecor.datagen.ModLootTables; -import net.minecraft.client.Minecraft; +import wile.engineersdecor.detail.ModConfig; +import wile.engineersdecor.libmc.detail.Auxiliaries; +import wile.engineersdecor.libmc.detail.OptionalRecipeCondition; +import wile.engineersdecor.libmc.detail.Networking; import net.minecraft.entity.EntityType; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.inventory.container.ContainerType; import net.minecraft.item.ItemGroup; import net.minecraft.tileentity.TileEntityType; -import net.minecraft.world.World; import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -21,7 +18,6 @@ import net.minecraftforge.event.entity.living.LivingEvent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.ModLoadingContext; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.*; @@ -32,8 +28,6 @@ import net.minecraftforge.api.distmarker.OnlyIn; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import javax.annotation.Nullable; - @Mod("engineersdecor") public class ModEngineersDecor @@ -46,7 +40,9 @@ public class ModEngineersDecor public ModEngineersDecor() { - ModAuxiliaries.logGitVersion(MODNAME); + Auxiliaries.init(MODID, LOGGER, ModConfig::getServerConfig); + Auxiliaries.logGitVersion(MODNAME); + OptionalRecipeCondition.init(MODID, LOGGER); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onSetup); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onSendImc); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onRecvImc); @@ -65,8 +61,8 @@ public class ModEngineersDecor private void onSetup(final FMLCommonSetupEvent event) { LOGGER.info("Registering recipe condition processor ..."); - CraftingHelper.register(Serializer.INSTANCE); - Networking.init(); + CraftingHelper.register(OptionalRecipeCondition.Serializer.INSTANCE); + Networking.init(MODID); if(config_loaded) { try { logger().info("Applying loaded config file."); @@ -137,33 +133,10 @@ public class ModEngineersDecor @SubscribeEvent public static void onDataGeneration(GatherDataEvent event) { - event.getGenerator().addProvider(new ModLootTables(event.getGenerator())); + event.getGenerator().addProvider(new wile.engineersdecor.libmc.datagen.LootTableGen(event.getGenerator(), ModContent::allBlocks)); } } - // - // Sided proxy functionality (skel) - // - public static ISidedProxy proxy = DistExecutor.runForDist(()->ClientProxy::new, ()->ServerProxy::new); - public interface ISidedProxy - { - default @Nullable PlayerEntity getPlayerClientSide() { return null; } - default @Nullable World getWorldClientSide() { return null; } - default @Nullable Minecraft mc() { return null; } - } - public static final class ClientProxy implements ISidedProxy - { - public @Nullable PlayerEntity getPlayerClientSide() { return Minecraft.getInstance().player; } - public @Nullable World getWorldClientSide() { return Minecraft.getInstance().world; } - public @Nullable Minecraft mc() { return Minecraft.getInstance(); } - } - public static final class ServerProxy implements ISidedProxy - { - public @Nullable PlayerEntity getPlayerClientSide() { return null; } - public @Nullable World getWorldClientSide() { return null; } - public @Nullable Minecraft mc() { return null; } - } - // // Item group / creative tab // diff --git a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecor.java b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecor.java index 3c8dd4d..223295e 100644 --- a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecor.java +++ b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecor.java @@ -12,222 +12,73 @@ */ package wile.engineersdecor.blocks; +import wile.engineersdecor.libmc.blocks.StandardBlocks; +import wile.engineersdecor.libmc.blocks.StandardBlocks.IStandardBlock; +import wile.engineersdecor.libmc.detail.Auxiliaries; import net.minecraft.block.IWaterLoggable; -import net.minecraft.state.StateContainer; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.world.server.ServerWorld; -import wile.engineersdecor.detail.ModAuxiliaries; -import net.minecraft.state.BooleanProperty; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.fluid.IFluidState; -import net.minecraft.fluid.Fluids; -import net.minecraft.world.IWorld; -import net.minecraft.world.Explosion; -import net.minecraft.world.World; import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.shapes.VoxelShapes; import net.minecraft.block.Block; -import net.minecraft.block.material.PushReaction; -import net.minecraft.block.BlockState; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.item.ItemStack; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.storage.loot.LootContext; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.util.*; -import net.minecraft.util.text.ITextComponent; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import wile.engineersdecor.detail.ModConfig; - -import javax.annotation.Nullable; -import java.util.Collections; -import java.util.List; -import java.util.Random; -public class BlockDecor extends Block implements IDecorBlock +public class BlockDecor extends StandardBlocks.BaseBlock implements IDecorBlock { - public static final long CFG_DEFAULT = 0x0000000000000000L; // no special config - public static final long CFG_CUTOUT = 0x0000000000000001L; // cutout rendering - public static final long CFG_HORIZIONTAL = 0x0000000000000002L; // horizontal block, affects bounding box calculation at construction time and placement - public static final long CFG_LOOK_PLACEMENT = 0x0000000000000004L; // placed in direction the player is looking when placing. - public static final long CFG_FACING_PLACEMENT = 0x0000000000000008L; // placed on the facing the player has clicked. - public static final long CFG_OPPOSITE_PLACEMENT = 0x0000000000000010L; // placed placed in the opposite direction of the face the player clicked. - public static final long CFG_FLIP_PLACEMENT_IF_SAME = 0x0000000000000020L; // placement direction flipped if an instance of the same class was clicked - public static final long CFG_FLIP_PLACEMENT_SHIFTCLICK = 0x0000000000000040L; // placement direction flipped if player is sneaking - public static final long CFG_TRANSLUCENT = 0x0000000000000080L; // indicates a block/pane is glass like (transparent, etc) - public static final long CFG_ELECTRICAL = 0x0000000000010000L; // Denotes if a component is mainly flux driven. - public static final long CFG_REDSTONE_CONTROLLED = 0x0000000000020000L; // Denotes if a component has somehow a redstone control input - public static final long CFG_ANALOG = 0x0000000000040000L; // Denotes if a component has analog behaviour - public static final long CFG_HARD_IE_DEPENDENT = 0x8000000000000000L; // The block is implicitly opt'ed out if IE is not installed - public static final long CFG_WATERLOGGABLE = 0x4000000000000000L; // The derived block extends IWaterLoggable - - public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; - public final long config; - public final VoxelShape vshape; + public static final long CFG_DEFAULT = StandardBlocks.CFG_DEFAULT; + public static final long CFG_CUTOUT = StandardBlocks.CFG_CUTOUT; + public static final long CFG_MIPPED = StandardBlocks.CFG_MIPPED; + public static final long CFG_TRANSLUCENT = StandardBlocks.CFG_TRANSLUCENT; + public static final long CFG_WATERLOGGABLE = StandardBlocks.CFG_WATERLOGGABLE; + public static final long CFG_HORIZIONTAL = StandardBlocks.CFG_HORIZIONTAL; + public static final long CFG_LOOK_PLACEMENT = StandardBlocks.CFG_LOOK_PLACEMENT; + public static final long CFG_FACING_PLACEMENT = StandardBlocks.CFG_FACING_PLACEMENT; + public static final long CFG_OPPOSITE_PLACEMENT = StandardBlocks.CFG_OPPOSITE_PLACEMENT; + public static final long CFG_FLIP_PLACEMENT_IF_SAME = StandardBlocks.CFG_FLIP_PLACEMENT_IF_SAME; + public static final long CFG_FLIP_PLACEMENT_SHIFTCLICK = StandardBlocks.CFG_FLIP_PLACEMENT_SHIFTCLICK; + public static final long CFG_STRICT_CONNECTIONS = StandardBlocks.CFG_STRICT_CONNECTIONS; + public static final long CFG_HARD_IE_DEPENDENT = 0x8000000000000000L; public BlockDecor(long conf, Block.Properties properties) - { this(conf, properties, ModAuxiliaries.getPixeledAABB(0, 0, 0, 16, 16,16 )); } + { super(conf, properties, Auxiliaries.getPixeledAABB(0, 0, 0, 16, 16,16 )); } public BlockDecor(long conf, Block.Properties properties, AxisAlignedBB aabb) - { super(properties); config = conf; vshape = VoxelShapes.create(aabb); } + { super(conf, properties, aabb);} public BlockDecor(long conf, Block.Properties properties, VoxelShape voxel_shape) - { super(properties); config = conf; vshape = voxel_shape; } + { super(conf, properties, voxel_shape); } - ///////////// -------------------------------------------------------------------------------------------------------- - // 1.15 transition - - public boolean onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) - { return false; } - - @Deprecated - public ActionResultType func_225533_a_(BlockState p_225533_1_, World p_225533_2_, BlockPos p_225533_3_, PlayerEntity p_225533_4_, Hand p_225533_5_, BlockRayTraceResult p_225533_6_) - { - return onBlockActivated(p_225533_1_,p_225533_2_,p_225533_3_,p_225533_4_,p_225533_5_,p_225533_6_) ? ActionResultType.SUCCESS : ActionResultType.PASS; - } - - @Deprecated - public void func_225534_a_(BlockState p_225534_1_, ServerWorld p_225534_2_, BlockPos p_225534_3_, Random p_225534_4_) - { tick(p_225534_1_,p_225534_2_,p_225534_3_,p_225534_4_); } - - public void tick(BlockState state, World world, BlockPos pos, Random rnd) - {} - - // 1.15 /transition - ///////////// -------------------------------------------------------------------------------------------------------- - - @Override - @OnlyIn(Dist.CLIENT) - public void addInformation(ItemStack stack, @Nullable IBlockReader world, List tooltip, ITooltipFlag flag) - { ModAuxiliaries.Tooltip.addInformation(stack, world, tooltip, flag, true); } - - @Override - public RenderTypeHint getRenderTypeHint() - { return ((config & CFG_CUTOUT)!=0) ? RenderTypeHint.CUTOUT : RenderTypeHint.SOLID; } - - @Override - @SuppressWarnings("deprecation") - public VoxelShape getShape(BlockState state, IBlockReader source, BlockPos pos, ISelectionContext selectionContext) - { return vshape; } - - @Override - @SuppressWarnings("deprecation") - public VoxelShape getCollisionShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext selectionContext) - { return vshape; } - - @Override - @Nullable - public BlockState getStateForPlacement(BlockItemUseContext context) - { - BlockState state = super.getStateForPlacement(context); - if((config & CFG_WATERLOGGABLE)!=0) { - IFluidState fs = context.getWorld().getFluidState(context.getPos()); - state = state.with(WATERLOGGED,fs.getFluid()==Fluids.WATER); - } - return state; - } - - @Override - public boolean canSpawnInBlock() - { return false; } - - @Override - @SuppressWarnings("deprecation") - public PushReaction getPushReaction(BlockState state) - { return PushReaction.NORMAL; } - - @Override - @SuppressWarnings("deprecation") - public void onReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean isMoving) - { - if(state.hasTileEntity() && (state.getBlock() != newState.getBlock())) { - world.removeTileEntity(pos); - world.updateComparatorOutputLevel(pos, this); - } - } - - public static boolean dropBlock(BlockState state, World world, BlockPos pos, @Nullable PlayerEntity player) - { - if(!(state.getBlock() instanceof IDecorBlock)) { world.removeBlock(pos, false); return true; } - if(!world.isRemote()) { - if((ModConfig.with_creative_mode_device_drops) || (player==null) || (!player.isCreative())) { - ((IDecorBlock)state.getBlock()).dropList(state, world, pos, player==null).forEach(stack->world.addEntity(new ItemEntity(world, pos.getX()+0.5, pos.getY()+0.5, pos.getZ()+0.5, stack))); - } - } - if(state.getBlock().hasTileEntity(state)) world.removeTileEntity(pos); - world.removeBlock(pos, false); - return true; - } - - @Override - public boolean removedByPlayer(BlockState state, World world, BlockPos pos, PlayerEntity player, boolean willHarvest, IFluidState fluid) - { return hasDynamicDropList() ? dropBlock(state, world, pos, player) : super.removedByPlayer(state, world,pos , player, willHarvest, fluid); } - - @Override - public void onExplosionDestroy(World world, BlockPos pos, Explosion explosion) - { if(hasDynamicDropList()) dropBlock(world.getBlockState(pos), world, pos, null); } - - @Override - @SuppressWarnings("deprecation") - public List getDrops(BlockState state, LootContext.Builder builder) - { return hasDynamicDropList() ? Collections.singletonList(ItemStack.EMPTY) : super.getDrops(state, builder); } - - @Override - @SuppressWarnings("deprecation") - public int getOpacity(BlockState state, IBlockReader world, BlockPos pos) - { return ((config & (CFG_CUTOUT|CFG_TRANSLUCENT))==0) ? super.getOpacity(state, world, pos) : (state.propagatesSkylightDown(world, pos)?0:1); } - - @Override - public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) - { - if(((config & CFG_WATERLOGGABLE)!=0) && state.get(WATERLOGGED)) return false; - return super.propagatesSkylightDown(state, reader, pos); - } - - @Override - @SuppressWarnings("deprecation") - public IFluidState getFluidState(BlockState state) - { - if((config & CFG_WATERLOGGABLE)!=0) { - return state.get(WATERLOGGED) ? Fluids.WATER.getStillFluidState(false) : super.getFluidState(state); - } - return super.getFluidState(state); - } - - @Override - @SuppressWarnings("deprecation") - public BlockState updatePostPlacement(BlockState state, Direction facing, BlockState facingState, IWorld world, BlockPos pos, BlockPos facingPos) - { - if((config & CFG_WATERLOGGABLE)!=0) { - if(state.get(WATERLOGGED)) world.getPendingFluidTicks().scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); - } - return state; - } - - /** - * Water loggable version of the basic block. - */ - public static class WaterLoggable extends BlockDecor implements IWaterLoggable + public static class WaterLoggable extends StandardBlocks.WaterLoggable implements IStandardBlock, IWaterLoggable { public WaterLoggable(long config, Block.Properties properties) - { super(config|CFG_WATERLOGGABLE, properties); } + { super(config, properties); } public WaterLoggable(long config, Block.Properties properties, AxisAlignedBB aabb) - { super(config|CFG_WATERLOGGABLE, properties, aabb); } + { super(config, properties, aabb); } public WaterLoggable(long config, Block.Properties properties, VoxelShape voxel_shape) - { super(config|CFG_WATERLOGGABLE, properties, voxel_shape); } - - @Override - protected void fillStateContainer(StateContainer.Builder builder) - { super.fillStateContainer(builder); builder.add(WATERLOGGED); } + { super(config, properties, voxel_shape); } } + public static class Directed extends StandardBlocks.Directed implements IDecorBlock + { + public Directed(long config, Block.Properties builder, final AxisAlignedBB unrotatedAABB) + { super(config, builder, unrotatedAABB); } + } + + public static class DirectedWaterLoggable extends StandardBlocks.DirectedWaterLoggable implements IDecorBlock,IWaterLoggable + { + public DirectedWaterLoggable(long config, Block.Properties properties, AxisAlignedBB aabb) + { super(config, properties, aabb); } + } + + public static class Horizontal extends StandardBlocks.Horizontal implements IDecorBlock + { + public Horizontal(long config, Block.Properties builder, final AxisAlignedBB unrotatedAABB) + { super(config, builder, unrotatedAABB); } + } + + public static class HorizontalWaterLoggable extends StandardBlocks.HorizontalWaterLoggable implements IWaterLoggable + { + public HorizontalWaterLoggable(long config, Block.Properties properties, AxisAlignedBB aabb) + { super(config, properties, aabb); } + } } diff --git a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorBreaker.java b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorBreaker.java index 1919384..dfe21c5 100644 --- a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorBreaker.java +++ b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorBreaker.java @@ -40,7 +40,7 @@ import java.util.List; import java.util.Random; -public class BlockDecorBreaker extends BlockDecorDirectedHorizontal +public class BlockDecorBreaker extends BlockDecor.HorizontalWaterLoggable implements IDecorBlock { public static final BooleanProperty ACTIVE = BooleanProperty.create("active"); @@ -221,7 +221,13 @@ public class BlockDecorBreaker extends BlockDecorDirectedHorizontal private boolean breakBlock(BlockState state, BlockPos pos, World world) { if(world.isRemote || (!(world instanceof ServerWorld)) || world.restoringBlockSnapshots) return false; // retry next cycle - List drops = Block.getDrops(state, (ServerWorld)world, pos, world.getTileEntity(pos)); + List drops; + final Block block = state.getBlock(); + if((!(block instanceof IDecorBlock)) || (!((IDecorBlock)block).hasDynamicDropList())) { + drops = Block.getDrops(state, (ServerWorld)world, pos, world.getTileEntity(pos)); + } else { + drops = ((IDecorBlock)block).dropList(state, world, pos, false); + } world.removeBlock(pos, false); for(ItemStack drop:drops) spawnAsEntity(world, pos, drop); SoundType stype = state.getBlock().getSoundType(state, world, pos, null); diff --git a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorChair.java b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorChair.java index 19faea8..39f3b5d 100644 --- a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorChair.java +++ b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorChair.java @@ -28,7 +28,7 @@ import java.util.List; import java.util.Random; -public class BlockDecorChair extends BlockDecorDirected.WaterLoggable +public class BlockDecorChair extends BlockDecor.HorizontalWaterLoggable { private static boolean sitting_enabled = true; private static double sitting_probability = 0.1; diff --git a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorCraftingTable.java b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorCraftingTable.java index 1f89004..c5fb7e8 100644 --- a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorCraftingTable.java +++ b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorCraftingTable.java @@ -1,5 +1,5 @@ /* - * @file BlockDecorDirected.java + * @file BlockDecor.Directed.java * @author Stefan Wilhelm (wile) * @copyright (C) 2019 Stefan Wilhelm * @license MIT (see https://opensource.org/licenses/MIT) @@ -11,8 +11,8 @@ package wile.engineersdecor.blocks; import net.minecraft.item.crafting.*; import wile.engineersdecor.ModContent; import wile.engineersdecor.ModEngineersDecor; -import wile.engineersdecor.detail.ModAuxiliaries; -import wile.engineersdecor.detail.Networking; +import wile.engineersdecor.libmc.detail.Auxiliaries; +import wile.engineersdecor.libmc.detail.Networking; import net.minecraft.inventory.container.*; import net.minecraft.network.play.server.SSetSlotPacket; import net.minecraft.network.NetworkManager; @@ -77,10 +77,10 @@ public class BlockDecorCraftingTable // Block //-------------------------------------------------------------------------------------------------------------------- - public static final class CraftingTableBlock extends BlockDecorDirected.WaterLoggable + public static final class CraftingTableBlock extends BlockDecor.HorizontalWaterLoggable implements IDecorBlock { public CraftingTableBlock(long config, Block.Properties builder, final AxisAlignedBB unrotatedAABB) - { super(config|CFG_WATERLOGGABLE, builder, unrotatedAABB); } + { super(config, builder, unrotatedAABB); } @Override public boolean hasTileEntity(BlockState state) @@ -1359,10 +1359,10 @@ public class BlockDecorCraftingTable // Explicit grid placement. CompoundNBT nbt = new CompoundNBT(); nbt.putInt("containerslot", slotId); - if(ModAuxiliaries.isCtrlDown()) nbt.putBoolean("move-all", true); + if(Auxiliaries.isCtrlDown()) nbt.putBoolean("move-all", true); action(ACTION_PLACE_SHIFTCLICKED_STACK, nbt); return; - } else if(ModAuxiliaries.isCtrlDown()) { + } else if(Auxiliaries.isCtrlDown()) { // Move all same items from the inventory of the clicked slot // (or the crafting grid) to the corresponding target inventory. CompoundNBT nbt = new CompoundNBT(); @@ -1387,7 +1387,7 @@ public class BlockDecorCraftingTable }).isPresent(); } int count = resultSlot.getStack().getCount(); - int limit = (ModAuxiliaries.isShiftDown() ? 2 : 1) * (ModAuxiliaries.isCtrlDown() ? 4 : 1); + int limit = (Auxiliaries.isShiftDown() ? 2 : 1) * (Auxiliaries.isCtrlDown() ? 4 : 1); if(wheel_inc > 0.1) { if(count > 0) { if((count < resultSlot.getStack().getMaxStackSize()) && (count < resultSlot.getSlotStackLimit())) { diff --git a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorDirected.java b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorDirected.java deleted file mode 100644 index 4c517e6..0000000 --- a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorDirected.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * @file BlockDecorDirected.java - * @author Stefan Wilhelm (wile) - * @copyright (C) 2019 Stefan Wilhelm - * @license MIT (see https://opensource.org/licenses/MIT) - * - * Smaller (cutout) block with a defined facing. - */ -package wile.engineersdecor.blocks; - -import net.minecraft.block.IWaterLoggable; -import wile.engineersdecor.detail.ModAuxiliaries; -import net.minecraft.entity.EntityType; -import net.minecraft.state.StateContainer; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShapes; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.state.DirectionProperty; -import net.minecraft.block.Block; -import net.minecraft.block.DirectionalBlock; -import net.minecraft.block.BlockState; -import net.minecraft.world.IBlockReader; -import net.minecraft.util.Direction; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import javax.annotation.Nullable; -import java.util.ArrayList; -import java.util.Arrays; - - -public class BlockDecorDirected extends BlockDecor -{ - public static final DirectionProperty FACING = DirectionalBlock.FACING; - protected final ArrayList AABBs; - - public BlockDecorDirected(long config, Block.Properties builder, final AxisAlignedBB unrotatedAABB) - { - super(config, builder); - setDefaultState(stateContainer.getBaseState().with(FACING, Direction.UP)); - final boolean is_horizontal = ((config & BlockDecor.CFG_HORIZIONTAL)!=0); - AABBs = new ArrayList(Arrays.asList( - VoxelShapes.create(ModAuxiliaries.getRotatedAABB(unrotatedAABB, Direction.DOWN, is_horizontal)), - VoxelShapes.create(ModAuxiliaries.getRotatedAABB(unrotatedAABB, Direction.UP, is_horizontal)), - VoxelShapes.create(ModAuxiliaries.getRotatedAABB(unrotatedAABB, Direction.NORTH, is_horizontal)), - VoxelShapes.create(ModAuxiliaries.getRotatedAABB(unrotatedAABB, Direction.SOUTH, is_horizontal)), - VoxelShapes.create(ModAuxiliaries.getRotatedAABB(unrotatedAABB, Direction.WEST, is_horizontal)), - VoxelShapes.create(ModAuxiliaries.getRotatedAABB(unrotatedAABB, Direction.EAST, is_horizontal)), - VoxelShapes.create(unrotatedAABB), - VoxelShapes.create(unrotatedAABB) - )); - } - - @Override - public RenderTypeHint getRenderTypeHint() - { return ((config & CFG_CUTOUT)!=0) ? (RenderTypeHint.CUTOUT_MIPPED) : (RenderTypeHint.SOLID); } - - @Override - public boolean canSpawnInBlock() - { return false; } - - @Override - @SuppressWarnings("deprecation") - public boolean canEntitySpawn(BlockState state, IBlockReader world, BlockPos pos, EntityType entityType) - { return false; } - - @Override - public VoxelShape getShape(BlockState state, IBlockReader source, BlockPos pos, ISelectionContext selectionContext) - { return AABBs.get((state.get(FACING)).getIndex() & 0x7); } - - @Override - public VoxelShape getCollisionShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext selectionContext) - { return getShape(state, world, pos, selectionContext); } - - @Override - protected void fillStateContainer(StateContainer.Builder builder) - { super.fillStateContainer(builder); builder.add(FACING); } - - @Override - @Nullable - public BlockState getStateForPlacement(BlockItemUseContext context) - { - Direction facing = context.getFace(); - if((config & (CFG_HORIZIONTAL|CFG_LOOK_PLACEMENT)) == (CFG_HORIZIONTAL|CFG_LOOK_PLACEMENT)) { - // horizontal placement in direction the player is looking - facing = context.getPlacementHorizontalFacing(); - } else if((config & (CFG_HORIZIONTAL|CFG_LOOK_PLACEMENT)) == (CFG_HORIZIONTAL)) { - // horizontal placement on a face - if(((facing==Direction.UP)||(facing==Direction.DOWN))) return null; - } else if((config & CFG_LOOK_PLACEMENT)!=0) { - // placement in direction the player is looking, with up and down - facing = context.getNearestLookingDirection(); - } else { - // default: placement on the face the player clicking - } - if((config & CFG_OPPOSITE_PLACEMENT)!=0) facing = facing.getOpposite(); - if(((config & CFG_FLIP_PLACEMENT_SHIFTCLICK) != 0) && (context.getPlayer().func_225608_bj_()/*isSneaking()*/)) facing = facing.getOpposite(); - return super.getStateForPlacement(context).with(FACING, facing); - } - - /** - * Water loggable version of directed blocks. - */ - public static class WaterLoggable extends BlockDecorDirected implements IWaterLoggable - { - public WaterLoggable(long config, Block.Properties properties, AxisAlignedBB aabb) - { super(config|CFG_WATERLOGGABLE, properties, aabb); } - - @Override - protected void fillStateContainer(StateContainer.Builder builder) - { super.fillStateContainer(builder); builder.add(WATERLOGGED); } - } - -} diff --git a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorDirectedHorizontal.java b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorDirectedHorizontal.java deleted file mode 100644 index c065454..0000000 --- a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorDirectedHorizontal.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * @file BlockDecorDirectedHorizontal.java - * @author Stefan Wilhelm (wile) - * @copyright (C) 2019 Stefan Wilhelm - * @license MIT (see https://opensource.org/licenses/MIT) - * - * Smaller directed block with direction set narrowed - * to horizontal directions. - */ -package wile.engineersdecor.blocks; - -import net.minecraft.block.HorizontalBlock; -import net.minecraft.block.IWaterLoggable; -import net.minecraft.util.Mirror; -import net.minecraft.util.Rotation; -import net.minecraft.entity.EntityType; -import net.minecraft.state.StateContainer; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.state.DirectionProperty; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.shapes.VoxelShapes; -import net.minecraft.world.IBlockReader; -import net.minecraft.util.Direction; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import wile.engineersdecor.detail.ModAuxiliaries; - -import javax.annotation.Nullable; -import java.util.ArrayList; -import java.util.Arrays; - - -public class BlockDecorDirectedHorizontal extends BlockDecor -{ - public static final DirectionProperty HORIZONTAL_FACING = HorizontalBlock.HORIZONTAL_FACING; - protected final ArrayList AABBs; - - public BlockDecorDirectedHorizontal(long config, Block.Properties builder, final AxisAlignedBB unrotatedAABB) - { - super(config|CFG_HORIZIONTAL, builder, unrotatedAABB); - setDefaultState(stateContainer.getBaseState().with(HORIZONTAL_FACING, Direction.NORTH)); - AABBs = new ArrayList(Arrays.asList( - VoxelShapes.create(ModAuxiliaries.getRotatedAABB(unrotatedAABB, Direction.DOWN, true)), - VoxelShapes.create(ModAuxiliaries.getRotatedAABB(unrotatedAABB, Direction.UP, true)), - VoxelShapes.create(ModAuxiliaries.getRotatedAABB(unrotatedAABB, Direction.NORTH, true)), - VoxelShapes.create(ModAuxiliaries.getRotatedAABB(unrotatedAABB, Direction.SOUTH, true)), - VoxelShapes.create(ModAuxiliaries.getRotatedAABB(unrotatedAABB, Direction.WEST, true)), - VoxelShapes.create(ModAuxiliaries.getRotatedAABB(unrotatedAABB, Direction.EAST, true)), - VoxelShapes.create(unrotatedAABB), - VoxelShapes.create(unrotatedAABB) - )); - } - - @Override - public RenderTypeHint getRenderTypeHint() - { return ((config & CFG_CUTOUT)!=0) ? RenderTypeHint.CUTOUT : RenderTypeHint.SOLID; } - - @Override - public boolean canSpawnInBlock() - { return false; } - - @Override - @SuppressWarnings("deprecation") - public boolean canEntitySpawn(BlockState state, IBlockReader world, BlockPos pos, EntityType entityType) - { return false; } - - @Override - public VoxelShape getShape(BlockState state, IBlockReader source, BlockPos pos, ISelectionContext selectionContext) - { return AABBs.get((state.get(HORIZONTAL_FACING)).getIndex() & 0x7); } - - @Override - public VoxelShape getCollisionShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext selectionContext) - { return getShape(state, world, pos, selectionContext); } - - @Override - protected void fillStateContainer(StateContainer.Builder builder) - { super.fillStateContainer(builder); builder.add(HORIZONTAL_FACING); } - - @Override - @Nullable - public BlockState getStateForPlacement(BlockItemUseContext context) - { - Direction facing = context.getFace(); - if((config & CFG_LOOK_PLACEMENT) != 0) { - // horizontal placement in direction the player is looking - facing = context.getPlacementHorizontalFacing(); - } else { - // horizontal placement on a face - facing = ((facing==Direction.UP)||(facing==Direction.DOWN)) ? (context.getPlacementHorizontalFacing()) : facing; - } - if((config & CFG_OPPOSITE_PLACEMENT)!=0) facing = facing.getOpposite(); - if(((config & CFG_FLIP_PLACEMENT_SHIFTCLICK) != 0) && (context.getPlayer().func_225608_bj_()/*isSneaking()*/)) facing = facing.getOpposite(); - return super.getStateForPlacement(context).with(HORIZONTAL_FACING, facing); - } - - @Override - @SuppressWarnings("deprecation") - public BlockState rotate(BlockState state, Rotation rot) - { return state.with(HORIZONTAL_FACING, rot.rotate(state.get(HORIZONTAL_FACING))); } - - @Override - @SuppressWarnings("deprecation") - public BlockState mirror(BlockState state, Mirror mirrorIn) - { return state.rotate(mirrorIn.toRotation(state.get(HORIZONTAL_FACING))); } - - /** - * Water loggable version of directed blocks. - */ - public static class WaterLoggable extends BlockDecorDirectedHorizontal implements IWaterLoggable - { - public WaterLoggable(long config, Block.Properties properties, AxisAlignedBB aabb) - { super(config|CFG_WATERLOGGABLE, properties, aabb); } - - @Override - protected void fillStateContainer(StateContainer.Builder builder) - { super.fillStateContainer(builder); builder.add(WATERLOGGED); } - } - -} diff --git a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorDropper.java b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorDropper.java index fe3a9a4..daebe4a 100644 --- a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorDropper.java +++ b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorDropper.java @@ -10,7 +10,7 @@ package wile.engineersdecor.blocks; import wile.engineersdecor.ModContent; import wile.engineersdecor.ModEngineersDecor; -import wile.engineersdecor.detail.Networking; +import wile.engineersdecor.libmc.detail.Networking; import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.inventory.container.INamedContainerProvider; import net.minecraft.block.DoorBlock; @@ -55,7 +55,7 @@ import java.util.ArrayList; import java.util.List; -public class BlockDecorDropper extends BlockDecorDirected +public class BlockDecorDropper extends BlockDecor.Directed implements IDecorBlock { public static final BooleanProperty OPEN = DoorBlock.OPEN; diff --git a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorFence.java b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorFence.java index 2e8ccb1..d8cf297 100644 --- a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorFence.java +++ b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorFence.java @@ -8,108 +8,12 @@ */ package wile.engineersdecor.blocks; -import wile.engineersdecor.detail.ModAuxiliaries; -import net.minecraft.world.*; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.fluid.IFluidState; -import net.minecraft.entity.EntityType; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.state.StateContainer; +import wile.engineersdecor.libmc.blocks.StandardFenceBlock; import net.minecraft.block.*; -import net.minecraft.block.material.PushReaction; -import net.minecraft.block.BlockState; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.fluid.Fluids; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.text.ITextComponent; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import javax.annotation.Nullable; -import java.util.List; -public class BlockDecorFence extends WallBlock implements IDecorBlock +public class BlockDecorFence extends StandardFenceBlock implements IDecorBlock { - private final VoxelShape[] shape_voxels; - private final VoxelShape[] collision_shape_voxels; - public BlockDecorFence(long config, Block.Properties builder) - { - super(builder); - this.shape_voxels = buildWallShapes(1.5f, 1.5f, 16f, 0f, 16f); - this.collision_shape_voxels = buildWallShapes(1.5f, 1.5f, 24f, 0f, 24f); - } - - @Override - @OnlyIn(Dist.CLIENT) - public void addInformation(ItemStack stack, @Nullable IBlockReader world, List tooltip, ITooltipFlag flag) - { ModAuxiliaries.Tooltip.addInformation(stack, world, tooltip, flag, true); } - - protected VoxelShape[] buildWallShapes(float pole_width_x, float pole_width_z, float pole_height, float side_min_y, float side_max_y) - { return super.makeShapes(pole_width_x, pole_width_z, pole_height, side_min_y, side_max_y); } - - @Override - public VoxelShape getShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext selectionContext) - { return shape_voxels[this.getIndex(state)]; } - - @Override - public VoxelShape getCollisionShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext selectionContext) - { return collision_shape_voxels[this.getIndex(state)]; } - - @Override - protected void fillStateContainer(StateContainer.Builder builder) - { super.fillStateContainer(builder); } - - private boolean attachesTo(BlockState facingState, IWorldReader world, BlockPos facingPos, Direction side) - { - final Block block = facingState.getBlock(); - if((block instanceof FenceGateBlock) || (block instanceof BlockDecorFence) || (block instanceof BlockDecorWall)) return true; - final BlockState oppositeState = world.getBlockState(facingPos.offset(side, 2)); - if(!(oppositeState.getBlock() instanceof BlockDecorFence)) return false; - return facingState.isNormalCube(world, facingPos) && hasSolidSide(facingState, world, facingPos, side); - } - - public BlockState getStateForPlacement(BlockItemUseContext context) - { - IWorldReader world = context.getWorld(); - BlockPos pos = context.getPos(); - IFluidState fs = context.getWorld().getFluidState(context.getPos()); - boolean n = attachesTo(world.getBlockState(pos.north()), world, pos.north(), Direction.SOUTH); - boolean e = attachesTo(world.getBlockState(pos.east()), world, pos.east(), Direction.WEST); - boolean s = attachesTo(world.getBlockState(pos.south()), world, pos.south(), Direction.NORTH); - boolean w = attachesTo(world.getBlockState(pos.west()), world, pos.west(), Direction.EAST); - boolean not_straight = (!n || !s || e || w) && (n || s || !e || !w); - return getDefaultState().with(UP, not_straight).with(NORTH, n).with(EAST, e).with(SOUTH, s).with(WEST, w).with(WATERLOGGED, fs.getFluid() == Fluids.WATER); - } - - @Override - public BlockState updatePostPlacement(BlockState state, Direction side, BlockState facingState, IWorld world, BlockPos currentPos, BlockPos facingPos) - { - if(state.get(WATERLOGGED)) world.getPendingFluidTicks().scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickRate(world)); - if(side == Direction.DOWN) return super.updatePostPlacement(state, side, facingState, world, currentPos, facingPos); - boolean n = (side==Direction.NORTH) ? attachesTo(facingState, world, facingPos, side) : state.get(NORTH); - boolean e = (side==Direction.EAST) ? attachesTo(facingState, world, facingPos, side) : state.get(EAST); - boolean s = (side==Direction.SOUTH) ? attachesTo(facingState, world, facingPos, side) : state.get(SOUTH); - boolean w = (side==Direction.WEST) ? attachesTo(facingState, world, facingPos, side) : state.get(WEST); - boolean not_straight = (!n || !s || e || w) && (n || s || !e || !w); - return state.with(UP, not_straight).with(NORTH, n).with(EAST, e).with(SOUTH, s).with(WEST, w); - } - - @Override - @SuppressWarnings("deprecation") - public boolean canEntitySpawn(BlockState state, IBlockReader world, BlockPos pos, EntityType entityType) - { return false; } - - @Override - public boolean canSpawnInBlock() - { return false; } - - @Override - @SuppressWarnings("deprecation") - public PushReaction getPushReaction(BlockState state) - { return PushReaction.NORMAL; } + { super(config, builder); } } diff --git a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorFloorGrating.java b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorFloorGrating.java index 45625f9..0ffaf4e 100644 --- a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorFloorGrating.java +++ b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorFloorGrating.java @@ -15,17 +15,14 @@ import net.minecraft.entity.item.ItemEntity; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.shapes.VoxelShapes; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; -public class BlockDecorFloorGrating extends BlockDecor.WaterLoggable +public class BlockDecorFloorGrating extends BlockDecor.WaterLoggable implements IDecorBlock { public BlockDecorFloorGrating(long config, Block.Properties builder, final AxisAlignedBB unrotatedAABB) - { super(config|CFG_WATERLOGGABLE, builder, unrotatedAABB); } + { super(config, builder, unrotatedAABB); } @Override public RenderTypeHint getRenderTypeHint() @@ -36,39 +33,37 @@ public class BlockDecorFloorGrating extends BlockDecor.WaterLoggable { return true; } @Override - public void onLanded(IBlockReader world, Entity entity) - { - if(!(entity instanceof ItemEntity)) { - super.onLanded(world, entity); - } else { - entity.setMotion(0, -0.1,0); - entity.setPositionAndUpdate(entity.getPosition().getX(), entity.getPosition().getY()-0.3, entity.getPosition().getZ()); - } - } - - @Override - public void onFallenUpon(World world, BlockPos pos, Entity entity, float fallDistance) - { - if(!(entity instanceof ItemEntity)) { - super.onFallenUpon(world, pos, entity, fallDistance); - } else { - entity.setMotion(0, -0.1,0); - entity.setPositionAndUpdate(entity.getPosition().getX(), entity.getPosition().getY()-0.3, entity.getPosition().getZ()); - } - } + @SuppressWarnings("deprecation") + public boolean isNormalCube(BlockState state, IBlockReader worldIn, BlockPos pos) + { return false; } @Override @SuppressWarnings("deprecation") public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) { if(!(entity instanceof ItemEntity)) return; - if((entity.getPosition().getY()-pos.getY()) < 0.7) return; - double vy = MathHelper.clamp(entity.getMotion().y, -1.2, -0.2); - entity.setMotion(0, vy, 0); - entity.setPositionAndUpdate(pos.getX()+0.5, entity.getPosition().getY()-0.3, pos.getZ()+0.5); + final boolean colliding = ((entity.getPositionVec().y-pos.getY()) > 0.7); + if(colliding || (entity.getMotion().getY() > 0)) { + double x = pos.getX() + 0.5; + double y = MathHelper.clamp(entity.getPositionVec().y-0.3, pos.getY(), pos.getY()+0.6); + double z = pos.getZ() + 0.5; + double vx = entity.getMotion().getX(); + double vy = entity.getMotion().getY(); + double vz = entity.getMotion().getZ(); + if(colliding) { + vx = 0; + vy = -0.3; + vz = 0; + if((entity.getPositionVec().y-pos.getY()) > 0.8) y = pos.getY() + 0.6; + entity.prevPosX = x+0.1; + entity.prevPosY = y+0.1; + entity.prevPosZ = z+0.1; + } + vy = MathHelper.clamp(vy, -0.3, 0); + entity.setMotion(vx, vy, vz); + entity.fallDistance = 0; + entity.setPositionAndUpdate(x,y,z); + } } - @Override - public VoxelShape getCollisionShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext context) - { return (context.getEntity() instanceof ItemEntity) ? VoxelShapes.empty() : super.getCollisionShape(state, world, pos, context); } } diff --git a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorFluidFunnel.java b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorFluidFunnel.java index ea8ac45..157dc4f 100644 --- a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorFluidFunnel.java +++ b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorFluidFunnel.java @@ -42,7 +42,7 @@ import javax.annotation.Nullable; import java.util.*; -public class BlockDecorFluidFunnel extends BlockDecor +public class BlockDecorFluidFunnel extends BlockDecor implements IDecorBlock { public static final int FILL_LEVEL_MAX = 3; public static final IntegerProperty FILL_LEVEL = IntegerProperty.create("level", 0, FILL_LEVEL_MAX); diff --git a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorFurnace.java b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorFurnace.java index c64a5f4..e9c6981 100644 --- a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorFurnace.java +++ b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorFurnace.java @@ -11,7 +11,7 @@ package wile.engineersdecor.blocks; import wile.engineersdecor.ModContent; import wile.engineersdecor.ModEngineersDecor; import wile.engineersdecor.detail.ExtItems; -import wile.engineersdecor.detail.Networking; +import wile.engineersdecor.libmc.detail.Networking; import net.minecraft.tileentity.*; import net.minecraft.inventory.container.*; import net.minecraft.item.crafting.AbstractCookingRecipe; @@ -63,14 +63,14 @@ import javax.annotation.Nullable; import java.util.*; -public class BlockDecorFurnace extends BlockDecorDirected +public class BlockDecorFurnace extends BlockDecor.Horizontal { public static final BooleanProperty LIT = RedstoneTorchBlock.LIT; public BlockDecorFurnace(long config, Block.Properties builder, final AxisAlignedBB unrotatedAABB) { super(config, builder, unrotatedAABB); - setDefaultState(stateContainer.getBaseState().with(FACING, Direction.NORTH).with(LIT, false)); + setDefaultState(super.getDefaultState().with(LIT, false)); } @Override @@ -85,7 +85,7 @@ public class BlockDecorFurnace extends BlockDecorDirected @Override @Nullable public BlockState getStateForPlacement(BlockItemUseContext context) - { return super.getStateForPlacement(context).with(FACING, context.getPlacementHorizontalFacing().getOpposite()).with(LIT, false); } + { return super.getStateForPlacement(context).with(LIT, false); } @Override @SuppressWarnings("deprecation") @@ -171,7 +171,7 @@ public class BlockDecorFurnace extends BlockDecorDirected final double x=0.5+pos.getX(), y=0.5+pos.getY(), z=0.5+pos.getZ(); final double xc=0.52, xr=rnd.nextDouble()*0.4-0.2, yr=(y-0.3+rnd.nextDouble()*0.2); if(rv < 0.1d) world.playSound(x, y, z, SoundEvents.BLOCK_FURNACE_FIRE_CRACKLE, SoundCategory.BLOCKS, 0.4f, 0.5f, false); - switch(state.get(FACING)) { + switch(state.get(HORIZONTAL_FACING)) { case WEST: world.addParticle(ParticleTypes.SMOKE, x-xc, yr, z+xr, 0.0, 0.0, 0.0); break; case EAST: world.addParticle(ParticleTypes.SMOKE, x+xc, yr, z+xr, 0.0, 0.0, 0.0); break; case NORTH: world.addParticle(ParticleTypes.SMOKE, x+xr, yr, z-xc, 0.0, 0.0, 0.0); break; @@ -451,7 +451,7 @@ public class BlockDecorFurnace extends BlockDecorDirected @Override public boolean canInsertItem(int index, ItemStack itemStackIn, Direction direction) - { return isItemValidForSlot(index, itemStackIn); } + { return ((index==FIFO_INPUT_1_SLOT_NO) || (index==FIFO_INPUT_0_SLOT_NO) || (index==FIFO_FUEL_1_SLOT_NO) || (index==FIFO_FUEL_0_SLOT_NO)) && isItemValidForSlot(index, itemStackIn); } @Override public boolean canExtractItem(int index, ItemStack stack, Direction direction) diff --git a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorFurnaceElectrical.java b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorFurnaceElectrical.java index 637fc4f..2f8d44a 100644 --- a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorFurnaceElectrical.java +++ b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorFurnaceElectrical.java @@ -10,7 +10,7 @@ package wile.engineersdecor.blocks; import wile.engineersdecor.ModContent; import wile.engineersdecor.ModEngineersDecor; -import wile.engineersdecor.detail.Networking; +import wile.engineersdecor.libmc.detail.Networking; import net.minecraft.inventory.container.*; import net.minecraft.item.crafting.AbstractCookingRecipe; import net.minecraft.item.crafting.FurnaceRecipe; @@ -57,7 +57,7 @@ import javax.annotation.Nullable; import java.util.Random; -public class BlockDecorFurnaceElectrical extends BlockDecorFurnace +public class BlockDecorFurnaceElectrical extends BlockDecorFurnace implements IDecorBlock { public BlockDecorFurnaceElectrical(long config, Block.Properties builder, final AxisAlignedBB unrotatedAABB) { super(config, builder, unrotatedAABB); } @@ -274,7 +274,7 @@ public class BlockDecorFurnaceElectrical extends BlockDecorFurnace @Override public boolean canInsertItem(int index, ItemStack itemStackIn, Direction direction) - { return isItemValidForSlot(index, itemStackIn); } + { return ((index==FIFO_INPUT_0_SLOT_NO) || (index==FIFO_INPUT_1_SLOT_NO)) && isItemValidForSlot(index, itemStackIn); } @Override public boolean canExtractItem(int index, ItemStack stack, Direction direction) @@ -538,7 +538,7 @@ public class BlockDecorFurnaceElectrical extends BlockDecorFurnace if(energy_stored_ < transfer_energy_consumption_) return false; final BlockState state = world.getBlockState(pos); if(!(state.getBlock() instanceof BlockDecorFurnaceElectrical)) return false; - final Direction out_facing = state.get(FACING); + final Direction out_facing = state.get(HORIZONTAL_FACING); if(out && (!stacks_.get(FIFO_OUTPUT_1_SLOT_NO).isEmpty())) { TileEntity te = world.getTileEntity(pos.offset(out_facing)); if(te!=null) { @@ -552,7 +552,7 @@ public class BlockDecorFurnaceElectrical extends BlockDecorFurnace } } if(with_automatic_inventory_pulling_) { - final Direction inp_facing = state.get(FACING).getOpposite(); + final Direction inp_facing = state.get(HORIZONTAL_FACING).getOpposite(); if(inp && (stacks_.get(FIFO_INPUT_1_SLOT_NO).isEmpty())) { TileEntity te = world.getTileEntity(pos.offset(inp_facing)); if(te!=null) { diff --git a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorGlassBlock.java b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorGlassBlock.java index 6253b19..dbd6776 100644 --- a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorGlassBlock.java +++ b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorGlassBlock.java @@ -9,7 +9,7 @@ */ package wile.engineersdecor.blocks; -import wile.engineersdecor.detail.ModAuxiliaries; +import wile.engineersdecor.libmc.detail.Auxiliaries; import net.minecraft.world.IBlockReader; import net.minecraft.block.Block; import net.minecraft.block.BlockState; @@ -33,7 +33,7 @@ public class BlockDecorGlassBlock extends StainedGlassBlock implements IDecorBlo @Override @OnlyIn(Dist.CLIENT) public void addInformation(ItemStack stack, @Nullable IBlockReader world, List tooltip, ITooltipFlag flag) - { ModAuxiliaries.Tooltip.addInformation(stack, world, tooltip, flag, true); } + { Auxiliaries.Tooltip.addInformation(stack, world, tooltip, flag, true); } @Override public RenderTypeHint getRenderTypeHint() diff --git a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorHalfSlab.java b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorHalfSlab.java index fd8044b..a9f5818 100644 --- a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorHalfSlab.java +++ b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorHalfSlab.java @@ -9,199 +9,11 @@ */ package wile.engineersdecor.blocks; -import wile.engineersdecor.detail.ModAuxiliaries; +import wile.engineersdecor.libmc.blocks.SlabSliceBlock; import net.minecraft.block.*; -import net.minecraft.world.IWorld; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.state.IntegerProperty; -import net.minecraft.util.*; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.Vec3d; -import net.minecraft.util.math.shapes.VoxelShapes; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.fluid.Fluid; -import net.minecraft.fluid.IFluidState; -import net.minecraft.world.World; -import net.minecraft.entity.EntityType; -import net.minecraft.state.StateContainer; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.block.BlockState; -import net.minecraft.world.IBlockReader; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import wile.engineersdecor.detail.ModConfig; -import javax.annotation.Nullable; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - - -public class BlockDecorHalfSlab extends BlockDecor.WaterLoggable +public class BlockDecorHalfSlab extends SlabSliceBlock implements IDecorBlock { - public static final IntegerProperty PARTS = IntegerProperty.create("parts", 0, 14); - - protected static final VoxelShape AABBs[] = { - VoxelShapes.create(new AxisAlignedBB(0, 0./16, 0, 1, 2./16, 1)), - VoxelShapes.create(new AxisAlignedBB(0, 0./16, 0, 1, 4./16, 1)), - VoxelShapes.create(new AxisAlignedBB(0, 0./16, 0, 1, 6./16, 1)), - VoxelShapes.create(new AxisAlignedBB(0, 0./16, 0, 1, 8./16, 1)), - VoxelShapes.create(new AxisAlignedBB(0, 0./16, 0, 1, 10./16, 1)), - VoxelShapes.create(new AxisAlignedBB(0, 0./16, 0, 1, 12./16, 1)), - VoxelShapes.create(new AxisAlignedBB(0, 0./16, 0, 1, 14./16, 1)), - VoxelShapes.create(new AxisAlignedBB(0, 0./16, 0, 1, 16./16, 1)), - VoxelShapes.create(new AxisAlignedBB(0, 2./16, 0, 1, 16./16, 1)), - VoxelShapes.create(new AxisAlignedBB(0, 4./16, 0, 1, 16./16, 1)), - VoxelShapes.create(new AxisAlignedBB(0, 6./16, 0, 1, 16./16, 1)), - VoxelShapes.create(new AxisAlignedBB(0, 8./16, 0, 1, 16./16, 1)), - VoxelShapes.create(new AxisAlignedBB(0, 10./16, 0, 1, 16./16, 1)), - VoxelShapes.create(new AxisAlignedBB(0, 12./16, 0, 1, 16./16, 1)), - VoxelShapes.create(new AxisAlignedBB(0, 14./16, 0, 1, 16./16, 1)), - VoxelShapes.create(new AxisAlignedBB(0,0,0,1,1,1)) // <- with 4bit fill - }; - - protected static final int num_slabs_contained_in_parts_[] = { 1,2,3,4,5,6,7,8,7,6,5,4,3,2,1 ,0x1 }; // <- with 4bit fill - public BlockDecorHalfSlab(long config, Block.Properties builder) - { super(config|CFG_WATERLOGGABLE, builder); } - - protected boolean is_cube(BlockState state) - { return state.get(PARTS) == 0x07; } - - @Override - @OnlyIn(Dist.CLIENT) - public void addInformation(ItemStack stack, @Nullable IBlockReader world, List tooltip, ITooltipFlag flag) - { - if(!ModAuxiliaries.Tooltip.addInformation(stack, world, tooltip, flag, true)) return; - if(!ModConfig.without_direct_slab_pickup) ModAuxiliaries.Tooltip.addInformation("engineersdecor.tooltip.slabpickup", "engineersdecor.tooltip.slabpickup", tooltip, flag, true); - } - - @Override - public RenderTypeHint getRenderTypeHint() - { return (((config & CFG_TRANSLUCENT)!=0) ? (RenderTypeHint.TRANSLUCENT) : (RenderTypeHint.CUTOUT)); } - - @Override - public boolean canSpawnInBlock() - { return false; } - - @Override - @SuppressWarnings("deprecation") - public boolean canEntitySpawn(BlockState state, IBlockReader world, BlockPos pos, EntityType entityType) - { return false; } - - @Override - public VoxelShape getShape(BlockState state, IBlockReader source, BlockPos pos, ISelectionContext selectionContext) - { return AABBs[state.get(PARTS) & 0xf]; } - - @Override - public VoxelShape getCollisionShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext selectionContext) - { return getShape(state, world, pos, selectionContext); } - - @Override - protected void fillStateContainer(StateContainer.Builder builder) - { super.fillStateContainer(builder); builder.add(PARTS); } - - @Override - @Nullable - public BlockState getStateForPlacement(BlockItemUseContext context) - { - final Direction facing = context.getFace(); - double y = context.getHitVec().getY(); - return super.getStateForPlacement(context).with(PARTS, ((facing==Direction.UP) || ((facing!=Direction.DOWN) && (y < 0.6))) ? 0 : 14); - } - - @Override - @SuppressWarnings("deprecation") - public BlockState rotate(BlockState state, Rotation rot) - { return state; } - - @Override - @SuppressWarnings("deprecation") - public BlockState mirror(BlockState state, Mirror mirrorIn) - { return state; } - - @Override - public boolean hasDynamicDropList() - { return true; } - - @Override - public List dropList(BlockState state, World world, BlockPos pos, boolean explosion) - { return new ArrayList(Collections.singletonList(new ItemStack(this.asItem(), num_slabs_contained_in_parts_[state.get(PARTS) & 0xf]))); } - - @Override - @SuppressWarnings("deprecation") - public boolean onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult rayTraceResult) - { - Direction face = rayTraceResult.getFace(); - final ItemStack stack = player.getHeldItem(hand); - if(stack.isEmpty() || (Block.getBlockFromItem(stack.getItem()) != this)) return false; - if((face != Direction.UP) && (face != Direction.DOWN)) return false; - int parts = state.get(PARTS); - if((face != Direction.UP) && (parts > 7)) { - world.setBlockState(pos, state.with(PARTS, parts-1), 3); - } else if((face != Direction.DOWN) && (parts < 7)) { - world.setBlockState(pos, state.with(PARTS, parts+1), 3); - } else { - return (parts != 7); - } - if(world.isRemote) return true; - if(!player.isCreative()) { - stack.shrink(1); - if(player.inventory != null) player.inventory.markDirty(); - } - SoundType st = this.getSoundType(state, world, pos, null); - world.playSound(null, pos, st.getPlaceSound(), SoundCategory.BLOCKS, (st.getVolume()+1f)/2.5f, 0.9f*st.getPitch()); - return true; - } - - @Override - @SuppressWarnings("deprecation") - public void onBlockClicked(BlockState state, World world, BlockPos pos, PlayerEntity player) - { - if((world.isRemote) || (ModConfig.without_direct_slab_pickup)) return; - final ItemStack stack = player.getHeldItemMainhand(); - if(stack.isEmpty() || (Block.getBlockFromItem(stack.getItem()) != this)) return; - if(stack.getCount() >= stack.getMaxStackSize()) return; - Vec3d lv = player.getLookVec(); - Direction facing = Direction.getFacingFromVector((float)lv.x, (float)lv.y, (float)lv.z); - if((facing != Direction.UP) && (facing != Direction.DOWN)) return; - if(state.getBlock() != this) return; - int parts = state.get(PARTS); - if((facing == Direction.DOWN) && (parts <= 7)) { - if(parts > 0) { - world.setBlockState(pos, state.with(PARTS, parts-1), 3); - } else { - world.removeBlock(pos, false); - } - } else if((facing == Direction.UP) && (parts >= 7)) { - if(parts < 14) { - world.setBlockState(pos, state.with(PARTS, parts + 1), 3); - } else { - world.removeBlock(pos, false); - } - } else { - return; - } - if(!player.isCreative()) { - stack.grow(1); - if(player.inventory != null) player.inventory.markDirty(); // @todo: check if inventory can actually be null - } - SoundType st = this.getSoundType(state, world, pos, null); - world.playSound(player, pos, st.getPlaceSound(), SoundCategory.BLOCKS, (st.getVolume()+1f)/2.5f, 0.9f*st.getPitch()); - } - - @Override - public boolean receiveFluid(IWorld world, BlockPos pos, BlockState state, IFluidState fluidState) - { return (state.get(PARTS)==14) ? false : super.receiveFluid(world, pos, state, fluidState); } - - @Override - public boolean canContainFluid(IBlockReader world, BlockPos pos, BlockState state, Fluid fluid) - { return (state.get(PARTS)==14) ? false : super.canContainFluid(world, pos, state, fluid); } - + { super(config, builder); } } diff --git a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorHopper.java b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorHopper.java index eb24b1b..d6505f2 100644 --- a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorHopper.java +++ b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorHopper.java @@ -10,7 +10,7 @@ package wile.engineersdecor.blocks; import wile.engineersdecor.ModContent; import wile.engineersdecor.ModEngineersDecor; -import wile.engineersdecor.detail.Networking; +import wile.engineersdecor.libmc.detail.Networking; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import net.minecraft.block.Block; @@ -50,7 +50,7 @@ import java.util.ArrayList; import java.util.List; -public class BlockDecorHopper extends BlockDecorDirected +public class BlockDecorHopper extends BlockDecor.Directed implements IDecorBlock { public BlockDecorHopper(long config, Block.Properties builder, final AxisAlignedBB unrotatedAABB) { super(config, builder, unrotatedAABB); } @@ -486,18 +486,20 @@ public class BlockDecorHopper extends BlockDecorDirected ItemStack insert_stack = current_stack.copy(); if(insert_stack.getCount() > transfer_count_) insert_stack.setCount(transfer_count_); final int initial_insert_stack_size = insert_stack.getCount(); - int first_empty_slot_index = -1; if((ih == null) || ih.getSlots() <= 0) return false; + // First stack comletion insert run. for(int i=0; i= 0) && (!insert_stack.isEmpty())) { - insert_stack = ih.insertItem(first_empty_slot_index, insert_stack.copy(), false); + // First-available insert run. + if(!insert_stack.isEmpty()) { + for(int i=0; i 0) { diff --git a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorHorizontalSupport.java b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorHorizontalSupport.java index c909ec7..9e4bfb6 100644 --- a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorHorizontalSupport.java +++ b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorHorizontalSupport.java @@ -9,9 +9,8 @@ */ package wile.engineersdecor.blocks; -import net.minecraft.block.IWaterLoggable; import wile.engineersdecor.ModContent; -import wile.engineersdecor.detail.ModAuxiliaries; +import wile.engineersdecor.libmc.detail.Auxiliaries; import net.minecraft.entity.EntityType; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.block.Block; @@ -28,15 +27,13 @@ import net.minecraft.world.World; import net.minecraft.block.BlockState; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; import javax.annotation.Nullable; import java.util.ArrayList; import java.util.Arrays; -public class BlockDecorHorizontalSupport extends BlockDecor implements IWaterLoggable +public class BlockDecorHorizontalSupport extends BlockDecor.WaterLoggable implements IDecorBlock { public static final BooleanProperty EASTWEST = BooleanProperty.create("eastwest"); public static final BooleanProperty LEFTBEAM = BooleanProperty.create("leftbeam"); @@ -46,14 +43,14 @@ public class BlockDecorHorizontalSupport extends BlockDecor implements IWaterLog public BlockDecorHorizontalSupport(long config, Block.Properties builder, final AxisAlignedBB unrotatedAABB) { - super(config|CFG_HORIZIONTAL|CFG_WATERLOGGABLE, builder); + super(config|BlockDecor.CFG_HORIZIONTAL, builder); AABBs = new ArrayList(Arrays.asList( // Effective bounding box - VoxelShapes.create(ModAuxiliaries.getRotatedAABB(unrotatedAABB.grow(2.0/16, 0, 0), Direction.NORTH, true)), - VoxelShapes.create(ModAuxiliaries.getRotatedAABB(unrotatedAABB.grow(2.0/16, 0, 0), Direction.WEST, true)), + VoxelShapes.create(Auxiliaries.getRotatedAABB(unrotatedAABB.grow(2.0/16, 0, 0), Direction.NORTH, true)), + VoxelShapes.create(Auxiliaries.getRotatedAABB(unrotatedAABB.grow(2.0/16, 0, 0), Direction.WEST, true)), // Displayed bounding box - VoxelShapes.create(ModAuxiliaries.getRotatedAABB(unrotatedAABB, Direction.NORTH, true)), - VoxelShapes.create(ModAuxiliaries.getRotatedAABB(unrotatedAABB, Direction.WEST, true)) + VoxelShapes.create(Auxiliaries.getRotatedAABB(unrotatedAABB, Direction.NORTH, true)), + VoxelShapes.create(Auxiliaries.getRotatedAABB(unrotatedAABB, Direction.WEST, true)) )); } @@ -80,7 +77,7 @@ public class BlockDecorHorizontalSupport extends BlockDecor implements IWaterLog @Override protected void fillStateContainer(StateContainer.Builder builder) - { super.fillStateContainer(builder); builder.add(EASTWEST, RIGHTBEAM, LEFTBEAM, DOWNCONNECT, WATERLOGGED); } + { super.fillStateContainer(builder); builder.add(EASTWEST, RIGHTBEAM, LEFTBEAM, DOWNCONNECT); } @Override @Nullable diff --git a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorLadder.java b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorLadder.java index 8e0f88b..1e7671a 100644 --- a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorLadder.java +++ b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorLadder.java @@ -12,7 +12,7 @@ */ package wile.engineersdecor.blocks; -import wile.engineersdecor.detail.ModAuxiliaries; +import wile.engineersdecor.libmc.detail.Auxiliaries; import net.minecraft.fluid.IFluidState; import net.minecraft.world.Explosion; import net.minecraft.world.World; @@ -40,11 +40,11 @@ import java.util.List; public class BlockDecorLadder extends LadderBlock implements IDecorBlock { - protected static final AxisAlignedBB EDLADDER_UNROTATED_AABB = ModAuxiliaries.getPixeledAABB(3, 0, 0, 13, 16, 3); - protected static final VoxelShape EDLADDER_SOUTH_AABB = VoxelShapes.create(ModAuxiliaries.getRotatedAABB(EDLADDER_UNROTATED_AABB, Direction.SOUTH, false)); - protected static final VoxelShape EDLADDER_EAST_AABB = VoxelShapes.create(ModAuxiliaries.getRotatedAABB(EDLADDER_UNROTATED_AABB, Direction.EAST, false)); - protected static final VoxelShape EDLADDER_WEST_AABB = VoxelShapes.create(ModAuxiliaries.getRotatedAABB(EDLADDER_UNROTATED_AABB, Direction.WEST, false)); - protected static final VoxelShape EDLADDER_NORTH_AABB = VoxelShapes.create(ModAuxiliaries.getRotatedAABB(EDLADDER_UNROTATED_AABB, Direction.NORTH, false)); + protected static final AxisAlignedBB EDLADDER_UNROTATED_AABB = Auxiliaries.getPixeledAABB(3, 0, 0, 13, 16, 3); + protected static final VoxelShape EDLADDER_SOUTH_AABB = VoxelShapes.create(Auxiliaries.getRotatedAABB(EDLADDER_UNROTATED_AABB, Direction.SOUTH, false)); + protected static final VoxelShape EDLADDER_EAST_AABB = VoxelShapes.create(Auxiliaries.getRotatedAABB(EDLADDER_UNROTATED_AABB, Direction.EAST, false)); + protected static final VoxelShape EDLADDER_WEST_AABB = VoxelShapes.create(Auxiliaries.getRotatedAABB(EDLADDER_UNROTATED_AABB, Direction.WEST, false)); + protected static final VoxelShape EDLADDER_NORTH_AABB = VoxelShapes.create(Auxiliaries.getRotatedAABB(EDLADDER_UNROTATED_AABB, Direction.NORTH, false)); private static boolean without_speed_boost_ = false; public static void on_config(boolean without_speed_boost) @@ -60,7 +60,7 @@ public class BlockDecorLadder extends LadderBlock implements IDecorBlock @Override @OnlyIn(Dist.CLIENT) public void addInformation(ItemStack stack, @Nullable IBlockReader world, List tooltip, ITooltipFlag flag) - { ModAuxiliaries.Tooltip.addInformation(stack, world, tooltip, flag, true); } + { Auxiliaries.Tooltip.addInformation(stack, world, tooltip, flag, true); } public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos) { diff --git a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorMilker.java b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorMilker.java index 2e0d5f5..bddaa62 100644 --- a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorMilker.java +++ b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorMilker.java @@ -53,7 +53,7 @@ import java.util.Map.Entry; import java.util.stream.Collectors; -public class BlockDecorMilker extends BlockDecorDirectedHorizontal +public class BlockDecorMilker extends BlockDecor.Horizontal implements IDecorBlock { public static final BooleanProperty FILLED = BooleanProperty.create("filled"); public static final BooleanProperty ACTIVE = BooleanProperty.create("active"); diff --git a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorMineralSmelter.java b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorMineralSmelter.java index 8099030..c77c0a0 100644 --- a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorMineralSmelter.java +++ b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorMineralSmelter.java @@ -55,7 +55,7 @@ import javax.annotation.Nullable; import java.util.*; -public class BlockDecorMineralSmelter extends BlockDecorDirectedHorizontal +public class BlockDecorMineralSmelter extends BlockDecor.Horizontal implements IDecorBlock { public static final int PHASE_MAX = 3; public static final IntegerProperty PHASE = IntegerProperty.create("phase", 0, PHASE_MAX); diff --git a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorPassiveFluidAccumulator.java b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorPassiveFluidAccumulator.java index f9e0dc6..43389bd 100644 --- a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorPassiveFluidAccumulator.java +++ b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorPassiveFluidAccumulator.java @@ -14,7 +14,7 @@ package wile.engineersdecor.blocks; import wile.engineersdecor.ModContent; -import wile.engineersdecor.detail.ModAuxiliaries; +import wile.engineersdecor.libmc.detail.Auxiliaries; import net.minecraft.world.World; import net.minecraft.world.IBlockReader; import net.minecraft.block.Block; @@ -40,7 +40,7 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -public class BlockDecorPassiveFluidAccumulator extends BlockDecorDirected +public class BlockDecorPassiveFluidAccumulator extends BlockDecor.Directed implements IDecorBlock { public BlockDecorPassiveFluidAccumulator(long config, Block.Properties builder, final AxisAlignedBB unrotatedAABB) { super(config, builder, unrotatedAABB); } @@ -94,7 +94,7 @@ public class BlockDecorPassiveFluidAccumulator extends BlockDecorDirected public void send_device_stats(PlayerEntity player) { int t_vol = tank_.getAmount(); - ModAuxiliaries.playerChatMessage(player,"" + t_vol + "mB"); + Auxiliaries.playerChatMessage(player,"" + t_vol + "mB"); } public void block_changed() diff --git a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorPipeValve.java b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorPipeValve.java index dd61474..7f3329c 100644 --- a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorPipeValve.java +++ b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorPipeValve.java @@ -18,7 +18,6 @@ import net.minecraft.state.BooleanProperty; import net.minecraft.state.StateContainer; import net.minecraft.block.Block; import net.minecraft.block.BlockState; -import net.minecraft.block.IWaterLoggable; import net.minecraft.tileentity.TileEntityType; import net.minecraft.tileentity.TileEntity; import net.minecraft.item.BlockItemUseContext; @@ -41,7 +40,7 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -public class BlockDecorPipeValve extends BlockDecorDirected implements IWaterLoggable +public class BlockDecorPipeValve extends BlockDecor.DirectedWaterLoggable implements IDecorBlock { public static final BooleanProperty RS_CN_N = BooleanProperty.create("rs_n"); public static final BooleanProperty RS_CN_S = BooleanProperty.create("rs_s"); @@ -50,6 +49,11 @@ public class BlockDecorPipeValve extends BlockDecorDirected implements IWaterLog public static final BooleanProperty RS_CN_U = BooleanProperty.create("rs_u"); public static final BooleanProperty RS_CN_D = BooleanProperty.create("rs_d"); + public static final int CFG_CHECK_VALVE = 0x0; + public static final int CFG_ANALOG_VALVE = 0x1; + public static final int CFG_REDSTONE_CONTROLLED_VALVE = 0x2; + public final int valve_config; + public static void on_config(int container_size_decl, int redstone_slope) { BTileEntity.fluid_maxflow_mb = MathHelper.clamp(container_size_decl, 1, 10000); @@ -57,12 +61,12 @@ public class BlockDecorPipeValve extends BlockDecorDirected implements IWaterLog ModEngineersDecor.logger().info("Config pipe valve: maxflow:" + BTileEntity.fluid_maxflow_mb + "mb, redstone amp:" + BTileEntity.redstone_flow_slope_mb + "mb/sig"); } - public BlockDecorPipeValve(long config, Block.Properties builder, final AxisAlignedBB unrotatedAABB) - { super(config|CFG_WATERLOGGABLE, builder, unrotatedAABB); } + public BlockDecorPipeValve(long config, int valve_config, Block.Properties builder, final AxisAlignedBB unrotatedAABB) + { super(config, builder, unrotatedAABB); this.valve_config=valve_config;} private BlockState get_rsconnector_state(BlockState state, IWorld world, BlockPos pos, @Nullable BlockPos fromPos) { - if((config & (CFG_REDSTONE_CONTROLLED))==0) return state; + if((valve_config & (CFG_REDSTONE_CONTROLLED_VALVE))==0) return state; Direction.Axis bfa = state.get(FACING).getAxis(); int bfi = state.get(FACING).getIndex(); for(Direction f:Direction.values()) { @@ -88,7 +92,7 @@ public class BlockDecorPipeValve extends BlockDecorDirected implements IWaterLog private void update_te(IWorld world, BlockState state, BlockPos pos) { TileEntity te = world.getTileEntity(pos); - if(te instanceof BlockDecorPipeValve.BTileEntity) ((BlockDecorPipeValve.BTileEntity)te).block_reconfigure(state.get(FACING), config); + if(te instanceof BlockDecorPipeValve.BTileEntity) ((BlockDecorPipeValve.BTileEntity)te).block_reconfigure(state.get(FACING), config, valve_config); } @Override @@ -97,7 +101,7 @@ public class BlockDecorPipeValve extends BlockDecorDirected implements IWaterLog @Override protected void fillStateContainer(StateContainer.Builder builder) - { super.fillStateContainer(builder); builder.add(RS_CN_N, RS_CN_S, RS_CN_E, RS_CN_W, RS_CN_U, RS_CN_D, WATERLOGGED); } + { super.fillStateContainer(builder); builder.add(RS_CN_N, RS_CN_S, RS_CN_E, RS_CN_W, RS_CN_U, RS_CN_D); } @Override @Nullable @@ -147,6 +151,7 @@ public class BlockDecorPipeValve extends BlockDecorDirected implements IWaterLog private boolean filling_ = false; private boolean getlocked_ = false; private long block_config_ = 0; + private int valve_config_; public BTileEntity() { this(ModContent.TET_STRAIGHT_PIPE_VALVE); } @@ -154,10 +159,11 @@ public class BlockDecorPipeValve extends BlockDecorDirected implements IWaterLog public BTileEntity(TileEntityType te_type) { super(te_type); } - public void block_reconfigure(Direction facing, long block_config) + public void block_reconfigure(Direction facing, long block_config, int valve_config) { block_facing_ = facing; block_config_ = block_config; + valve_config_ = valve_config; } private Direction block_facing() @@ -234,10 +240,10 @@ public class BlockDecorPipeValve extends BlockDecorDirected implements IWaterLog if(te.filling_) return 0; final IFluidHandler fh = te.forward_fluid_handler(); if(fh==null) return 0; - if((te.block_config_ & CFG_REDSTONE_CONTROLLED) != 0) { + if((te.valve_config_ & CFG_REDSTONE_CONTROLLED_VALVE) != 0) { int rs = te.world.getRedstonePowerFromNeighbors(te.pos); if(rs <= 0) return 0; - if(((te.block_config_ & CFG_ANALOG) != 0) && (rs < 15)) resource.setAmount(MathHelper.clamp(rs * redstone_flow_slope_mb, 1, resource.getAmount())); + if(((te.valve_config_ & CFG_ANALOG_VALVE) != 0) && (rs < 15)) resource.setAmount(MathHelper.clamp(rs * redstone_flow_slope_mb, 1, resource.getAmount())); } FluidStack res = resource.copy(); if(res.getAmount() > fluid_maxflow_mb) res.setAmount(fluid_maxflow_mb); diff --git a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorPlacer.java b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorPlacer.java index 078c945..9635177 100644 --- a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorPlacer.java +++ b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorPlacer.java @@ -10,7 +10,7 @@ package wile.engineersdecor.blocks; import wile.engineersdecor.ModContent; import wile.engineersdecor.ModEngineersDecor; -import wile.engineersdecor.detail.Networking; +import wile.engineersdecor.libmc.detail.Networking; import net.minecraft.block.*; import net.minecraft.state.StateContainer; import net.minecraft.world.IBlockReader; @@ -54,28 +54,15 @@ import java.util.ArrayList; import java.util.List; -public class BlockDecorPlacer extends BlockDecorDirected +public class BlockDecorPlacer extends BlockDecor.Directed { public BlockDecorPlacer(long config, Block.Properties builder, final AxisAlignedBB unrotatedAABB) { super(config, builder, unrotatedAABB); } - @Override - public RenderTypeHint getRenderTypeHint() - { return RenderTypeHint.SOLID; } - @Override public VoxelShape getCollisionShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext selectionContext) { return VoxelShapes.fullCube(); } - @Override - protected void fillStateContainer(StateContainer.Builder builder) - { super.fillStateContainer(builder); } - - @Override - @Nullable - public BlockState getStateForPlacement(BlockItemUseContext context) - { return super.getStateForPlacement(context); } - @Override @SuppressWarnings("deprecation") public boolean hasComparatorInputOverride(BlockState state) @@ -455,7 +442,7 @@ public class BlockDecorPlacer extends BlockDecorDirected if(current_stack.isEmpty()) { current_slot_index_ = 0; return false; } boolean no_space = false; final Item item = current_stack.getItem(); - Block block = (item instanceof IPlantable) ? (((IPlantable)item).getPlant(world, pos).getBlock()) : Block.getBlockFromItem(item); + Block block = Block.getBlockFromItem(item); if(block == Blocks.AIR) { if(item != null) { return spit_out(facing); // Item not accepted @@ -510,10 +497,15 @@ public class BlockDecorPlacer extends BlockDecorDirected final BlockState placement_state = (use_context==null) ? (block.getDefaultState()) : (block.getStateForPlacement(use_context)); if(placement_state == null) { return spit_out(facing); - } else if(item instanceof BlockItem) { + } else if((use_context!=null) && (item instanceof BlockItem)) { if(((BlockItem)item).tryPlace(use_context) == ActionResultType.SUCCESS) { SoundType stype = block.getSoundType(placement_state, world, pos, null); if(stype != null) world.playSound(null, placement_pos, stype.getPlaceSound(), SoundCategory.BLOCKS, stype.getVolume()*0.6f, stype.getPitch()); + } else if(block instanceof IPlantable) { + if(world.setBlockState(placement_pos, placement_state, 1|2|8)) { + SoundType stype = block.getSoundType(placement_state, world, pos, null); + if(stype != null) world.playSound(null, placement_pos, stype.getPlaceSound(), SoundCategory.BLOCKS, stype.getVolume()*0.6f, stype.getPitch()); + } } else { return spit_out(facing); } diff --git a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorSlab.java b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorSlab.java index aedd416..5807557 100644 --- a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorSlab.java +++ b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorSlab.java @@ -8,173 +8,11 @@ */ package wile.engineersdecor.blocks; -import net.minecraft.util.math.*; -import wile.engineersdecor.detail.ModAuxiliaries; +import wile.engineersdecor.libmc.blocks.VariantSlabBlock; import net.minecraft.block.*; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.state.IntegerProperty; -import net.minecraft.util.*; -import net.minecraft.util.math.shapes.VoxelShapes; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.world.World; -import net.minecraft.entity.EntityType; -import net.minecraft.state.StateContainer; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.block.BlockState; -import net.minecraft.world.IBlockReader; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import wile.engineersdecor.detail.ModConfig; -import javax.annotation.Nullable; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - - -public class BlockDecorSlab extends BlockDecor.WaterLoggable +public class BlockDecorSlab extends VariantSlabBlock implements IDecorBlock { - public static final IntegerProperty PARTS = IntegerProperty.create("parts", 0, 2); - public static final IntegerProperty TEXTURE_VARIANT = IntegerProperty.create("tvariant", 0, 3); - - protected static final VoxelShape AABBs[] = { - VoxelShapes.create(new AxisAlignedBB(0, 0./16, 0, 1, 8./16, 1)), // bottom slab - VoxelShapes.create(new AxisAlignedBB(0, 8./16, 0, 1, 16./16, 1)), // top slab - VoxelShapes.create(new AxisAlignedBB(0, 0./16, 0, 1, 16./16, 1)), // both slabs - VoxelShapes.create(new AxisAlignedBB(0, 0./16, 0, 1, 16./16, 1)) // << 2bit fill - }; - protected static final int num_slabs_contained_in_parts_[] = { 1,1,2,2 }; - - protected boolean is_cube(BlockState state) - { return state.get(PARTS) >= 2; } - public BlockDecorSlab(long config, Block.Properties builder) - { super(config|CFG_WATERLOGGABLE, builder); } - - @Override - public RenderTypeHint getRenderTypeHint() - { return (((config & CFG_TRANSLUCENT)!=0) ? (RenderTypeHint.TRANSLUCENT) : (RenderTypeHint.CUTOUT)); } - - @Override - @OnlyIn(Dist.CLIENT) - public void addInformation(ItemStack stack, @Nullable IBlockReader world, List tooltip, ITooltipFlag flag) - { - if(!ModAuxiliaries.Tooltip.addInformation(stack, world, tooltip, flag, true)) return; - if(!ModConfig.without_direct_slab_pickup) ModAuxiliaries.Tooltip.addInformation("engineersdecor.tooltip.slabpickup", "engineersdecor.tooltip.slabpickup", tooltip, flag, true); - } - - @Override - @OnlyIn(Dist.CLIENT) - @SuppressWarnings("deprecation") - public boolean isSideInvisible(BlockState state, BlockState adjacentBlockState, Direction side) - { return (adjacentBlockState==state) ? true : super.isSideInvisible(state, adjacentBlockState, side); } - - @Override - public boolean canSpawnInBlock() - { return false; } - - @Override - @SuppressWarnings("deprecation") - public boolean canEntitySpawn(BlockState state, IBlockReader world, BlockPos pos, EntityType entityType) - { return false; } - - @Override - public VoxelShape getShape(BlockState state, IBlockReader source, BlockPos pos, ISelectionContext selectionContext) - { return AABBs[state.get(PARTS) & 0x3]; } - - @Override - public VoxelShape getCollisionShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext selectionContext) - { return getShape(state, world, pos, selectionContext); } - - @Override - protected void fillStateContainer(StateContainer.Builder builder) - { super.fillStateContainer(builder); builder.add(PARTS, TEXTURE_VARIANT); } - - @Override - @Nullable - public BlockState getStateForPlacement(BlockItemUseContext context) - { - BlockPos pos = context.getPos(); - if(context.getWorld().getBlockState(pos).getBlock() == this) return context.getWorld().getBlockState(pos).with(PARTS, 2).with(WATERLOGGED, false); - final int rnd = MathHelper.clamp((int)(MathHelper.getPositionRandom(context.getPos()) & 0x3), 0, 3); - final Direction face = context.getFace(); - final BlockState placement_state = super.getStateForPlacement(context).with(TEXTURE_VARIANT, rnd); // fluid state - if(face == Direction.UP) return placement_state.with(PARTS, 0); - if(face == Direction.DOWN) return placement_state.with(PARTS, 1); - if(!face.getAxis().isHorizontal()) return placement_state; - final boolean isupper = ((context.getHitVec().getY() - context.getPos().getY()) > 0.5); - return placement_state.with(PARTS, isupper ? 1 : 0); - } - - @Override - @SuppressWarnings("deprecation") - public boolean isReplaceable(BlockState state, BlockItemUseContext context) - { - if(context.getItem().getItem() != this.asItem()) return false; - if(!context.replacingClickedOnBlock()) return true; - final Direction face = context.getFace(); - final int parts = state.get(PARTS); - if((face == Direction.UP) && (parts==0)) return true; - if((face == Direction.DOWN) && (parts==1)) return true; - if(!face.getAxis().isHorizontal()) return false; - final boolean isupper = ((context.getHitVec().getY() - context.getPos().getY()) > 0.5); - return isupper ? (parts==0) : (parts==1); - } - - @Override - @SuppressWarnings("deprecation") - public BlockState rotate(BlockState state, Rotation rot) - { return state; } - - @Override - @SuppressWarnings("deprecation") - public BlockState mirror(BlockState state, Mirror mirrorIn) - { return state; } - - @Override - public boolean hasDynamicDropList() - { return true; } - - @Override - public List dropList(BlockState state, World world, BlockPos pos, boolean explosion) - { return new ArrayList(Collections.singletonList(new ItemStack(this.asItem(), num_slabs_contained_in_parts_[state.get(PARTS) & 0x3]))); } - - @Override - @SuppressWarnings("deprecation") - public void onBlockClicked(BlockState state, World world, BlockPos pos, PlayerEntity player) - { - if((world.isRemote) || (ModConfig.without_direct_slab_pickup)) return; - final ItemStack stack = player.getHeldItemMainhand(); - if(stack.isEmpty() || (Block.getBlockFromItem(stack.getItem()) != this)) return; - if(stack.getCount() >= stack.getMaxStackSize()) return; - Vec3d lv = player.getLookVec(); - Direction facing = Direction.getFacingFromVector((float)lv.x, (float)lv.y, (float)lv.z); - if((facing != Direction.UP) && (facing != Direction.DOWN)) return; - if(state.getBlock() != this) return; - int parts = state.get(PARTS); - if(facing == Direction.DOWN) { - if(parts == 2) { - world.setBlockState(pos, state.with(PARTS, 0), 3); - } else { - world.removeBlock(pos, false); - } - } else if(facing == Direction.UP) { - if(parts == 2) { - world.setBlockState(pos, state.with(PARTS, 1), 3); - } else { - world.removeBlock(pos, false); - } - } - if(!player.isCreative()) { - stack.grow(1); - if(player.inventory != null) player.inventory.markDirty(); - } - SoundType st = this.getSoundType(state, world, pos, null); - world.playSound(player, pos, st.getPlaceSound(), SoundCategory.BLOCKS, (st.getVolume()+1f)/2.5f, 0.9f*st.getPitch()); - } - + { super(config, builder); } } diff --git a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorSolarPanel.java b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorSolarPanel.java index b69103b..ce92a59 100644 --- a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorSolarPanel.java +++ b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorSolarPanel.java @@ -1,5 +1,5 @@ /* - * @file BlockDecorDirected.java + * @file BlockDecor.Directed.java * @author Stefan Wilhelm (wile) * @copyright (C) 2019 Stefan Wilhelm * @license MIT (see https://opensource.org/licenses/MIT) @@ -32,7 +32,7 @@ import net.minecraftforge.common.util.LazyOptional; import javax.annotation.Nullable; -public class BlockDecorSolarPanel extends BlockDecor +public class BlockDecorSolarPanel extends BlockDecor implements IDecorBlock { public static final IntegerProperty EXPOSITION = IntegerProperty.create("exposition", 0, 4); @@ -46,11 +46,6 @@ public class BlockDecorSolarPanel extends BlockDecor protected void fillStateContainer(StateContainer.Builder builder) { super.fillStateContainer(builder); builder.add(EXPOSITION); } - @Override - @Nullable - public BlockState getStateForPlacement(BlockItemUseContext context) - { return super.getStateForPlacement(context); } - @Override public boolean hasTileEntity(BlockState state) { return true; } diff --git a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorStairs.java b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorStairs.java index 7080d07..ed3358d 100644 --- a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorStairs.java +++ b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorStairs.java @@ -8,48 +8,15 @@ */ package wile.engineersdecor.blocks; -import wile.engineersdecor.detail.ModAuxiliaries; -import net.minecraft.entity.EntityType; -import net.minecraft.util.math.BlockPos; +import wile.engineersdecor.libmc.blocks.StandardStairsBlock; import net.minecraft.block.*; -import net.minecraft.block.material.PushReaction; import net.minecraft.block.BlockState; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.item.ItemStack; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.world.IBlockReader; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import javax.annotation.Nullable; -import java.util.List; - - -public class BlockDecorStairs extends StairsBlock implements IDecorBlock +public class BlockDecorStairs extends StandardStairsBlock implements IDecorBlock { public BlockDecorStairs(long config, BlockState state, Block.Properties properties) - { super(()->state, properties); } + { super(config, state, properties); } public BlockDecorStairs(long config, java.util.function.Supplier state, Block.Properties properties) - { super(state, properties); } - - @Override - @OnlyIn(Dist.CLIENT) - public void addInformation(ItemStack stack, @Nullable IBlockReader world, List tooltip, ITooltipFlag flag) - { ModAuxiliaries.Tooltip.addInformation(stack, world, tooltip, flag, true); } - - @Override - public boolean canSpawnInBlock() - { return false; } - - @Override - @SuppressWarnings("deprecation") - public boolean canEntitySpawn(BlockState state, IBlockReader world, BlockPos pos, EntityType entityType) - { return false; } - - @Override - @SuppressWarnings("deprecation") - public PushReaction getPushReaction(BlockState state) - { return PushReaction.NORMAL; } - + { super(config, state, properties); } } diff --git a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorStraightPole.java b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorStraightPole.java index 1e70a64..c69364e 100644 --- a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorStraightPole.java +++ b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorStraightPole.java @@ -10,10 +10,7 @@ package wile.engineersdecor.blocks; import net.minecraft.block.Block; import net.minecraft.block.BlockState; -import net.minecraft.block.IWaterLoggable; -import net.minecraft.fluid.Fluids; import net.minecraft.item.BlockItemUseContext; -import net.minecraft.state.StateContainer; import net.minecraft.world.World; import net.minecraft.util.Direction; import net.minecraft.util.math.AxisAlignedBB; @@ -21,27 +18,22 @@ import net.minecraft.util.math.BlockPos; import javax.annotation.Nullable; -public class BlockDecorStraightPole extends BlockDecorDirected implements IWaterLoggable +public class BlockDecorStraightPole extends BlockDecor.DirectedWaterLoggable implements IDecorBlock { public BlockDecorStraightPole(long config, Block.Properties builder, final AxisAlignedBB unrotatedAABB) - { super(config|CFG_WATERLOGGABLE, builder, unrotatedAABB); } - - @Override - protected void fillStateContainer(StateContainer.Builder builder) - { super.fillStateContainer(builder); builder.add(WATERLOGGED); } + { super(config, builder, unrotatedAABB); } @Override @Nullable public BlockState getStateForPlacement(BlockItemUseContext context) { Direction facing = context.getFace(); - final boolean waterlogged = context.getWorld().getFluidState(context.getPos()).getFluid()==Fluids.WATER; - BlockState state = super.getStateForPlacement(context).with(FACING, facing).with(WATERLOGGED, waterlogged); - if((config & CFG_FLIP_PLACEMENT_IF_SAME) != 0) { + BlockState state = super.getStateForPlacement(context).with(FACING, facing); + if((config & BlockDecor.CFG_FLIP_PLACEMENT_IF_SAME) != 0) { World world = context.getWorld(); BlockPos pos = context.getPos(); if(world.getBlockState(pos.offset(facing.getOpposite())).getBlock() instanceof BlockDecorStraightPole) { - state = state.with(FACING, state.get(FACING).getOpposite()).with(WATERLOGGED, waterlogged); + state = state.with(FACING, state.get(FACING).getOpposite()); } } return state; diff --git a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorTest.java b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorTest.java index 490a98c..bb7e7d3 100644 --- a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorTest.java +++ b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorTest.java @@ -9,8 +9,7 @@ package wile.engineersdecor.blocks; import wile.engineersdecor.ModContent; -import wile.engineersdecor.detail.ModAuxiliaries; -import wile.engineersdecor.detail.ModAuxiliaries.IExperimentalFeature; +import wile.engineersdecor.libmc.detail.Auxiliaries; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; @@ -44,7 +43,7 @@ import java.util.ArrayList; import java.util.List; -public class BlockDecorTest extends BlockDecorDirected implements IExperimentalFeature +public class BlockDecorTest extends BlockDecor.Directed implements Auxiliaries.IExperimentalFeature { public BlockDecorTest(long config, Block.Properties builder, final AxisAlignedBB unrotatedAABB) { super(config, builder, unrotatedAABB); } @@ -150,7 +149,7 @@ public class BlockDecorTest extends BlockDecorDirected implements IExperimentalF if(message.isEmpty()) { message = "No fluid, energy, or item interactions done yet."; } - ModAuxiliaries.playerChatMessage(player, message); + Auxiliaries.playerChatMessage(player, message); return; } } @@ -165,23 +164,23 @@ public class BlockDecorTest extends BlockDecorDirected implements IExperimentalF if(!fs.isEmpty()) { if(active_fill_fluidstack_.isEmpty()) { active_fill_fluidstack_ = fs.copy(); - ModAuxiliaries.playerChatMessage(player, "Fluid insertion fluid set: " + dump_fluid_stack(active_fill_fluidstack_)); + Auxiliaries.playerChatMessage(player, "Fluid insertion fluid set: " + dump_fluid_stack(active_fill_fluidstack_)); } else if(fs.isFluidEqual(active_fill_fluidstack_)) { active_fill_fluidstack_.grow(fs.getAmount()); - ModAuxiliaries.playerChatMessage(player, "Fluid insertion flowrate increased: " + dump_fluid_stack(active_fill_fluidstack_)); + Auxiliaries.playerChatMessage(player, "Fluid insertion flowrate increased: " + dump_fluid_stack(active_fill_fluidstack_)); } else { int amount = active_fill_fluidstack_.getAmount(); active_fill_fluidstack_ = fs.copy(); active_fill_fluidstack_.setAmount(amount); - ModAuxiliaries.playerChatMessage(player, "Fluid insertion fluid changed: " + dump_fluid_stack(active_fill_fluidstack_)); + Auxiliaries.playerChatMessage(player, "Fluid insertion fluid changed: " + dump_fluid_stack(active_fill_fluidstack_)); } } else { if(!active_fill_fluidstack_.isEmpty()) { active_fill_fluidstack_.shrink(1000); if(active_fill_fluidstack_.isEmpty()) active_fill_fluidstack_ = FluidStack.EMPTY; - ModAuxiliaries.playerChatMessage(player, "Fluid insertion flowrate decreased: " + dump_fluid_stack(active_fill_fluidstack_)); + Auxiliaries.playerChatMessage(player, "Fluid insertion flowrate decreased: " + dump_fluid_stack(active_fill_fluidstack_)); } else { - ModAuxiliaries.playerChatMessage(player, "Fluid insertion disabled."); + Auxiliaries.playerChatMessage(player, "Fluid insertion disabled."); } } passive_drain_fluidstack_ = active_fill_fluidstack_.copy(); // currently no difference diff --git a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorTreeCutter.java b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorTreeCutter.java index 1db5fc3..1230e90 100644 --- a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorTreeCutter.java +++ b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorTreeCutter.java @@ -36,7 +36,7 @@ import javax.annotation.Nullable; import java.util.Random; -public class BlockDecorTreeCutter extends BlockDecorDirectedHorizontal +public class BlockDecorTreeCutter extends BlockDecor.Horizontal { public static final BooleanProperty ACTIVE = BooleanProperty.create("active"); diff --git a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorWall.java b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorWall.java index d462812..563f4e1 100644 --- a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorWall.java +++ b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorWall.java @@ -8,112 +8,11 @@ */ package wile.engineersdecor.blocks; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.world.*; -import wile.engineersdecor.detail.ModAuxiliaries; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.fluid.IFluidState; -import net.minecraft.entity.EntityType; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.state.StateContainer; -import net.minecraft.util.math.MathHelper; +import wile.engineersdecor.libmc.blocks.VariantWallBlock; import net.minecraft.block.*; -import net.minecraft.block.material.PushReaction; -import net.minecraft.block.BlockState; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.fluid.Fluids; -import net.minecraft.item.ItemStack; -import net.minecraft.state.IntegerProperty; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.text.ITextComponent; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import javax.annotation.Nullable; -import java.util.List; - -public class BlockDecorWall extends WallBlock implements IDecorBlock +public class BlockDecorWall extends VariantWallBlock implements IDecorBlock { - private final VoxelShape[] shape_voxels; - private final VoxelShape[] collision_shape_voxels; - public static final IntegerProperty TEXTURE_VARIANT = IntegerProperty.create("tvariant", 0, 7); - public BlockDecorWall(long config, Block.Properties builder) - { - super(builder); - this.shape_voxels = buildWallShapes(4.0F, 4.0F, 16.0F, 0.0F, 16.0F); - this.collision_shape_voxels = buildWallShapes(4.0F, 4.0F, 24.0F, 0.0F, 24.0F); - } - - @Override - @OnlyIn(Dist.CLIENT) - public void addInformation(ItemStack stack, @Nullable IBlockReader world, List tooltip, ITooltipFlag flag) - { ModAuxiliaries.Tooltip.addInformation(stack, world, tooltip, flag, true); } - - protected VoxelShape[] buildWallShapes(float pole_width_x, float pole_width_z, float pole_height, float side_min_y, float side_max_y) - { return super.makeShapes(pole_width_x, pole_width_z, pole_height, side_min_y, side_max_y); } - - @Override - public VoxelShape getShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext selectionContext) - { return shape_voxels[this.getIndex(state)]; } - - @Override - public VoxelShape getCollisionShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext selectionContext) - { return collision_shape_voxels[this.getIndex(state)]; } - - @Override - protected void fillStateContainer(StateContainer.Builder builder) - { super.fillStateContainer(builder); builder.add(TEXTURE_VARIANT); } - - private boolean attachesTo(BlockState facingState, IWorldReader world, BlockPos facingPos, Direction side) - { - final Block block = facingState.getBlock(); - if((block instanceof FenceGateBlock) || (block instanceof WallBlock)) return true; - final BlockState oppositeState = world.getBlockState(facingPos.offset(side, 2)); - if(!(oppositeState.getBlock() instanceof BlockDecorWall)) return false; - return facingState.isNormalCube(world, facingPos) && hasSolidSide(facingState, world, facingPos, side); - } - - public BlockState getStateForPlacement(BlockItemUseContext context) - { - IWorldReader world = context.getWorld(); - BlockPos pos = context.getPos(); - IFluidState fs = context.getWorld().getFluidState(context.getPos()); - boolean n = attachesTo(world.getBlockState(pos.north()), world, pos.north(), Direction.SOUTH); - boolean e = attachesTo(world.getBlockState(pos.east()), world, pos.east(), Direction.WEST); - boolean s = attachesTo(world.getBlockState(pos.south()), world, pos.south(), Direction.NORTH); - boolean w = attachesTo(world.getBlockState(pos.west()), world, pos.west(), Direction.EAST); - boolean not_straight = (!n || !s || e || w) && (n || s || !e || !w); - return getDefaultState().with(UP, not_straight).with(NORTH, n).with(EAST, e).with(SOUTH, s).with(WEST, w).with(WATERLOGGED, fs.getFluid() == Fluids.WATER); - } - - @Override - public BlockState updatePostPlacement(BlockState state, Direction side, BlockState facingState, IWorld world, BlockPos currentPos, BlockPos facingPos) - { - if(state.get(WATERLOGGED)) world.getPendingFluidTicks().scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickRate(world)); - if(side == Direction.DOWN) return super.updatePostPlacement(state, side, facingState, world, currentPos, facingPos); - boolean n = (side==Direction.NORTH) ? this.attachesTo(facingState, world, facingPos, side) : state.get(NORTH); - boolean e = (side==Direction.EAST) ? this.attachesTo(facingState, world, facingPos, side) : state.get(EAST); - boolean s = (side==Direction.SOUTH) ? this.attachesTo(facingState, world, facingPos, side) : state.get(SOUTH); - boolean w = (side==Direction.WEST) ? this.attachesTo(facingState, world, facingPos, side) : state.get(WEST); - boolean not_straight = (!n || !s || e || w) && (n || s || !e || !w); - return state.with(UP, not_straight).with(NORTH, n).with(EAST, e).with(SOUTH, s).with(WEST, w).with(TEXTURE_VARIANT, ((int)MathHelper.getPositionRandom(currentPos)) & 0x7); - } - - @Override - @SuppressWarnings("deprecation") - public boolean canEntitySpawn(BlockState state, IBlockReader world, BlockPos pos, EntityType entityType) - { return false; } - - @Override - public boolean canSpawnInBlock() - { return false; } - - @Override - @SuppressWarnings("deprecation") - public PushReaction getPushReaction(BlockState state) - { return PushReaction.NORMAL; } - + { super(config, builder); } } diff --git a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorWasteIncinerator.java b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorWasteIncinerator.java index 7ea5924..6bc8e76 100644 --- a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorWasteIncinerator.java +++ b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorWasteIncinerator.java @@ -64,10 +64,6 @@ public class BlockDecorWasteIncinerator extends BlockDecor public BlockDecorWasteIncinerator(long config, Block.Properties builder, final AxisAlignedBB unrotatedAABB) { super(config, builder, unrotatedAABB); } - @Override - public RenderTypeHint getRenderTypeHint() - { return RenderTypeHint.SOLID; } - @Override protected void fillStateContainer(StateContainer.Builder builder) { super.fillStateContainer(builder); builder.add(LIT); } diff --git a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorWindow.java b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorWindow.java index 935a900..f09bd15 100644 --- a/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorWindow.java +++ b/1.15/src/main/java/wile/engineersdecor/blocks/BlockDecorWindow.java @@ -10,27 +10,21 @@ package wile.engineersdecor.blocks; import net.minecraft.block.Block; import net.minecraft.block.BlockState; -import net.minecraft.block.IWaterLoggable; import net.minecraft.item.BlockItemUseContext; -import net.minecraft.state.StateContainer; import net.minecraft.util.Direction; import net.minecraft.util.math.AxisAlignedBB; import javax.annotation.Nullable; -public class BlockDecorWindow extends BlockDecorDirected implements IWaterLoggable +public class BlockDecorWindow extends BlockDecor.DirectedWaterLoggable { public BlockDecorWindow(long config, Block.Properties builder, final AxisAlignedBB unrotatedAABB) - { super(config|CFG_WATERLOGGABLE, builder, unrotatedAABB); } + { super(config, builder, unrotatedAABB); } @Override public RenderTypeHint getRenderTypeHint() { return RenderTypeHint.TRANSLUCENT; } - @Override - protected void fillStateContainer(StateContainer.Builder builder) - { super.fillStateContainer(builder); builder.add(WATERLOGGED); } - @Override @Nullable public BlockState getStateForPlacement(BlockItemUseContext context) @@ -49,5 +43,4 @@ public class BlockDecorWindow extends BlockDecorDirected implements IWaterLoggab } return super.getStateForPlacement(context).with(FACING, facing); } - } diff --git a/1.15/src/main/java/wile/engineersdecor/blocks/IDecorBlock.java b/1.15/src/main/java/wile/engineersdecor/blocks/IDecorBlock.java index 7f14a0d..89b35b9 100644 --- a/1.15/src/main/java/wile/engineersdecor/blocks/IDecorBlock.java +++ b/1.15/src/main/java/wile/engineersdecor/blocks/IDecorBlock.java @@ -8,25 +8,8 @@ */ package wile.engineersdecor.blocks; -import net.minecraft.block.BlockState; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import java.util.Collections; -import java.util.List; +import wile.engineersdecor.libmc.blocks.StandardBlocks; - -public interface IDecorBlock +public interface IDecorBlock extends StandardBlocks.IStandardBlock { - enum RenderTypeHint { SOLID,CUTOUT,CUTOUT_MIPPED,TRANSLUCENT } - - default boolean hasDynamicDropList() - { return false; } - - default List dropList(BlockState state, World world, BlockPos pos, boolean explosion) - { return Collections.singletonList((!world.isRemote()) ? (new ItemStack(state.getBlock().asItem())) : (ItemStack.EMPTY)); } - - default RenderTypeHint getRenderTypeHint() - { return RenderTypeHint.SOLID; } - } diff --git a/1.15/src/main/java/wile/engineersdecor/detail/ModConfig.java b/1.15/src/main/java/wile/engineersdecor/detail/ModConfig.java index 3966f75..b06fecc 100644 --- a/1.15/src/main/java/wile/engineersdecor/detail/ModConfig.java +++ b/1.15/src/main/java/wile/engineersdecor/detail/ModConfig.java @@ -12,6 +12,7 @@ package wile.engineersdecor.detail; import wile.engineersdecor.ModContent; import wile.engineersdecor.ModEngineersDecor; import wile.engineersdecor.blocks.*; +import wile.engineersdecor.libmc.detail.Auxiliaries; import net.minecraft.nbt.CompoundNBT; import net.minecraft.block.Block; import net.minecraft.item.Item; @@ -500,7 +501,7 @@ public class ModConfig if(COMMON == null) return false; try { if(!COMMON.with_experimental.get()) { - if(block instanceof ModAuxiliaries.IExperimentalFeature) return true; + if(block instanceof Auxiliaries.IExperimentalFeature) return true; if(ModContent.isExperimentalBlock(block)) return true; } final String rn = block.getRegistryName().getPath(); @@ -615,8 +616,10 @@ public class ModConfig BlockDecorBreaker.BTileEntity.on_config(COMMON.block_breaker_power_consumption.get(), COMMON.block_breaker_reluctance.get(), COMMON.block_breaker_min_breaking_time.get(), COMMON.block_breaker_requires_power.get()); BlockDecorTreeCutter.BTileEntity.on_config(COMMON.tree_cuttter_energy_consumption.get(), COMMON.tree_cuttter_cutting_time_needed.get(), COMMON.tree_cuttter_requires_power.get()); BlockDecorMilker.BTileEntity.on_config(COMMON.milking_machine_energy_consumption.get(), COMMON.milking_machine_milking_delay.get()); + BlockDecorSlab.on_config(!COMMON.without_direct_slab_pickup.get()); + BlockDecorHalfSlab.on_config(!COMMON.without_direct_slab_pickup.get()); without_crafting_table = isOptedOut(ModContent.TREATED_WOOD_CRAFTING_TABLE); - immersiveengineering_installed = ModAuxiliaries.isModLoaded("immersiveengineering"); + immersiveengineering_installed = Auxiliaries.isModLoaded("immersiveengineering"); with_experimental_features_ = COMMON.with_experimental.get(); without_recipes_ = COMMON.without_recipes.get(); without_direct_slab_pickup = COMMON.without_direct_slab_pickup.get(); diff --git a/1.15/src/main/java/wile/engineersdecor/detail/ModRenderers.java b/1.15/src/main/java/wile/engineersdecor/detail/ModRenderers.java index 499f9b3..276e751 100644 --- a/1.15/src/main/java/wile/engineersdecor/detail/ModRenderers.java +++ b/1.15/src/main/java/wile/engineersdecor/detail/ModRenderers.java @@ -26,6 +26,7 @@ import net.minecraft.util.math.MathHelper; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import com.mojang.blaze3d.matrix.MatrixStack; +import wile.engineersdecor.blocks.BlockDecorCraftingTable.CraftingTableBlock; public class ModRenderers @@ -89,7 +90,7 @@ public class ModRenderers { if(tesr_error_counter <= 0) return; try { - final int di = MathHelper.clamp(te.getWorld().getBlockState(te.getPos()).get(BlockDecorCraftingTable.CraftingTableBlock.FACING).getHorizontalIndex(), 0, 3); + final int di = MathHelper.clamp(te.getWorld().getBlockState(te.getPos()).get(CraftingTableBlock.HORIZONTAL_FACING).getHorizontalIndex(), 0, 3); long posrnd = te.getPos().toLong(); posrnd = (posrnd>>16)^(posrnd<<1); for(int i=0; i<9; ++i) { diff --git a/1.15/src/main/java/wile/engineersdecor/eapi/jei/JEIPlugin.java b/1.15/src/main/java/wile/engineersdecor/eapi/jei/JEIPlugin.java index eca5d45..d8215dc 100644 --- a/1.15/src/main/java/wile/engineersdecor/eapi/jei/JEIPlugin.java +++ b/1.15/src/main/java/wile/engineersdecor/eapi/jei/JEIPlugin.java @@ -8,14 +8,12 @@ */ package wile.engineersdecor.eapi.jei; -public class JEIPlugin {} -/* -import mezz.jei.api.constants.VanillaRecipeCategoryUid; -import mezz.jei.api.registration.IRecipeTransferRegistration; import wile.engineersdecor.ModEngineersDecor; import wile.engineersdecor.blocks.BlockDecorCraftingTable; import wile.engineersdecor.detail.ModConfig; import wile.engineersdecor.ModContent; +import mezz.jei.api.constants.VanillaRecipeCategoryUid; +import mezz.jei.api.registration.IRecipeTransferRegistration; import mezz.jei.api.constants.VanillaTypes; import mezz.jei.api.runtime.IJeiRuntime; import net.minecraft.block.Block; @@ -24,6 +22,7 @@ import net.minecraft.util.ResourceLocation; import java.util.ArrayList; import java.util.List; + @mezz.jei.api.JeiPlugin public class JEIPlugin implements mezz.jei.api.IModPlugin { @@ -37,7 +36,7 @@ public class JEIPlugin implements mezz.jei.api.IModPlugin if(!ModConfig.without_crafting_table) { try { registration.addRecipeTransferHandler( - BlockDecorCraftingTable.BContainer.class, + BlockDecorCraftingTable.CraftingTableContainer.class, VanillaRecipeCategoryUid.CRAFTING, 1, 9, 10, 44 ); @@ -65,4 +64,3 @@ public class JEIPlugin implements mezz.jei.api.IModPlugin } } } -*/ \ No newline at end of file diff --git a/1.15/src/main/java/wile/engineersdecor/libmc/blocks/SlabSliceBlock.java b/1.15/src/main/java/wile/engineersdecor/libmc/blocks/SlabSliceBlock.java new file mode 100644 index 0000000..eb0f441 --- /dev/null +++ b/1.15/src/main/java/wile/engineersdecor/libmc/blocks/SlabSliceBlock.java @@ -0,0 +1,210 @@ +/* + * @file BlockDecorHalfSlab.java + * @author Stefan Wilhelm (wile) + * @copyright (C) 2019 Stefan Wilhelm + * @license MIT (see https://opensource.org/licenses/MIT) + * + * Half slab ("slab slices") characteristics class. Actually + * it's now a quater slab, but who cares. + */ +package wile.engineersdecor.libmc.blocks; + +import wile.engineersdecor.libmc.detail.Auxiliaries; +import net.minecraft.fluid.Fluid; +import net.minecraft.fluid.IFluidState; +import net.minecraft.world.IWorld; +import net.minecraft.block.*; +import net.minecraft.client.util.ITooltipFlag; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.state.IntegerProperty; +import net.minecraft.util.*; +import net.minecraft.util.math.BlockRayTraceResult; +import net.minecraft.util.math.Vec3d; +import net.minecraft.util.math.shapes.VoxelShapes; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.world.World; +import net.minecraft.entity.EntityType; +import net.minecraft.state.StateContainer; +import net.minecraft.util.math.shapes.ISelectionContext; +import net.minecraft.item.BlockItemUseContext; +import net.minecraft.block.BlockState; +import net.minecraft.world.IBlockReader; +import net.minecraft.util.math.shapes.VoxelShape; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; + +import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + + +public class SlabSliceBlock extends StandardBlocks.WaterLoggable implements StandardBlocks.IStandardBlock +{ + public static final IntegerProperty PARTS = IntegerProperty.create("parts", 0, 14); + + protected static final VoxelShape AABBs[] = { + VoxelShapes.create(new AxisAlignedBB(0, 0./16, 0, 1, 2./16, 1)), + VoxelShapes.create(new AxisAlignedBB(0, 0./16, 0, 1, 4./16, 1)), + VoxelShapes.create(new AxisAlignedBB(0, 0./16, 0, 1, 6./16, 1)), + VoxelShapes.create(new AxisAlignedBB(0, 0./16, 0, 1, 8./16, 1)), + VoxelShapes.create(new AxisAlignedBB(0, 0./16, 0, 1, 10./16, 1)), + VoxelShapes.create(new AxisAlignedBB(0, 0./16, 0, 1, 12./16, 1)), + VoxelShapes.create(new AxisAlignedBB(0, 0./16, 0, 1, 14./16, 1)), + VoxelShapes.create(new AxisAlignedBB(0, 0./16, 0, 1, 16./16, 1)), + VoxelShapes.create(new AxisAlignedBB(0, 2./16, 0, 1, 16./16, 1)), + VoxelShapes.create(new AxisAlignedBB(0, 4./16, 0, 1, 16./16, 1)), + VoxelShapes.create(new AxisAlignedBB(0, 6./16, 0, 1, 16./16, 1)), + VoxelShapes.create(new AxisAlignedBB(0, 8./16, 0, 1, 16./16, 1)), + VoxelShapes.create(new AxisAlignedBB(0, 10./16, 0, 1, 16./16, 1)), + VoxelShapes.create(new AxisAlignedBB(0, 12./16, 0, 1, 16./16, 1)), + VoxelShapes.create(new AxisAlignedBB(0, 14./16, 0, 1, 16./16, 1)), + VoxelShapes.create(new AxisAlignedBB(0,0,0,1,1,1)) // <- with 4bit fill + }; + + protected static final int num_slabs_contained_in_parts_[] = { 1,2,3,4,5,6,7,8,7,6,5,4,3,2,1 ,0x1 }; // <- with 4bit fill + private static boolean with_pickup = false; + + public static void on_config(boolean direct_slab_pickup) + { with_pickup = direct_slab_pickup; } + + public SlabSliceBlock(long config, Block.Properties builder) + { super(config, builder); } + + protected boolean is_cube(BlockState state) + { return state.get(PARTS) == 0x07; } + + @Override + @OnlyIn(Dist.CLIENT) + public void addInformation(ItemStack stack, @Nullable IBlockReader world, List tooltip, ITooltipFlag flag) + { + if(!Auxiliaries.Tooltip.addInformation(stack, world, tooltip, flag, true)) return; + if(with_pickup) Auxiliaries.Tooltip.addInformation("engineersdecor.tooltip.slabpickup", "engineersdecor.tooltip.slabpickup", tooltip, flag, true); + } + + @Override + public RenderTypeHint getRenderTypeHint() + { return (((config & StandardBlocks.CFG_TRANSLUCENT)!=0) ? (RenderTypeHint.TRANSLUCENT) : (RenderTypeHint.CUTOUT)); } + + @Override + public boolean canSpawnInBlock() + { return false; } + + @Override + @SuppressWarnings("deprecation") + public boolean canEntitySpawn(BlockState state, IBlockReader world, BlockPos pos, EntityType entityType) + { return false; } + + @Override + public VoxelShape getShape(BlockState state, IBlockReader source, BlockPos pos, ISelectionContext selectionContext) + { return AABBs[state.get(PARTS) & 0xf]; } + + @Override + public VoxelShape getCollisionShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext selectionContext) + { return getShape(state, world, pos, selectionContext); } + + @Override + protected void fillStateContainer(StateContainer.Builder builder) + { super.fillStateContainer(builder); builder.add(PARTS); } + + @Override + @Nullable + public BlockState getStateForPlacement(BlockItemUseContext context) + { + final Direction facing = context.getFace(); + double y = context.getHitVec().getY(); + return super.getStateForPlacement(context).with(PARTS, ((facing==Direction.UP) || ((facing!=Direction.DOWN) && (y < 0.6))) ? 0 : 14); + } + + @Override + @SuppressWarnings("deprecation") + public BlockState rotate(BlockState state, Rotation rot) + { return state; } + + @Override + @SuppressWarnings("deprecation") + public BlockState mirror(BlockState state, Mirror mirrorIn) + { return state; } + + @Override + public boolean hasDynamicDropList() + { return true; } + + @Override + public List dropList(BlockState state, World world, BlockPos pos, boolean explosion) + { return new ArrayList(Collections.singletonList(new ItemStack(this.asItem(), num_slabs_contained_in_parts_[state.get(PARTS) & 0xf]))); } + + @Override + @SuppressWarnings("deprecation") + public boolean onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult rayTraceResult) + { + Direction face = rayTraceResult.getFace(); + final ItemStack stack = player.getHeldItem(hand); + if(stack.isEmpty() || (Block.getBlockFromItem(stack.getItem()) != this)) return false; + if((face != Direction.UP) && (face != Direction.DOWN)) return false; + int parts = state.get(PARTS); + if((face != Direction.UP) && (parts > 7)) { + world.setBlockState(pos, state.with(PARTS, parts-1), 3); + } else if((face != Direction.DOWN) && (parts < 7)) { + world.setBlockState(pos, state.with(PARTS, parts+1), 3); + } else { + return (parts != 7); + } + if(world.isRemote) return true; + if(!player.isCreative()) { + stack.shrink(1); + if(player.inventory != null) player.inventory.markDirty(); + } + SoundType st = this.getSoundType(state, world, pos, null); + world.playSound(null, pos, st.getPlaceSound(), SoundCategory.BLOCKS, (st.getVolume()+1f)/2.5f, 0.9f*st.getPitch()); + return true; + } + + @Override + @SuppressWarnings("deprecation") + public void onBlockClicked(BlockState state, World world, BlockPos pos, PlayerEntity player) + { + if((world.isRemote) || (!with_pickup)) return; + final ItemStack stack = player.getHeldItemMainhand(); + if(stack.isEmpty() || (Block.getBlockFromItem(stack.getItem()) != this)) return; + if(stack.getCount() >= stack.getMaxStackSize()) return; + Vec3d lv = player.getLookVec(); + Direction facing = Direction.getFacingFromVector((float)lv.x, (float)lv.y, (float)lv.z); + if((facing != Direction.UP) && (facing != Direction.DOWN)) return; + if(state.getBlock() != this) return; + int parts = state.get(PARTS); + if((facing == Direction.DOWN) && (parts <= 7)) { + if(parts > 0) { + world.setBlockState(pos, state.with(PARTS, parts-1), 3); + } else { + world.removeBlock(pos, false); + } + } else if((facing == Direction.UP) && (parts >= 7)) { + if(parts < 14) { + world.setBlockState(pos, state.with(PARTS, parts + 1), 3); + } else { + world.removeBlock(pos, false); + } + } else { + return; + } + if(!player.isCreative()) { + stack.grow(1); + if(player.inventory != null) player.inventory.markDirty(); // @todo: check if inventory can actually be null + } + SoundType st = this.getSoundType(state, world, pos, null); + world.playSound(player, pos, st.getPlaceSound(), SoundCategory.BLOCKS, (st.getVolume()+1f)/2.5f, 0.9f*st.getPitch()); + } + + @Override + public boolean receiveFluid(IWorld world, BlockPos pos, BlockState state, IFluidState fluidState) + { return (state.get(PARTS)==14) ? false : super.receiveFluid(world, pos, state, fluidState); } + + @Override + public boolean canContainFluid(IBlockReader world, BlockPos pos, BlockState state, Fluid fluid) + { return (state.get(PARTS)==14) ? false : super.canContainFluid(world, pos, state, fluid); } + +} diff --git a/1.15/src/main/java/wile/engineersdecor/libmc/blocks/StandardBlocks.java b/1.15/src/main/java/wile/engineersdecor/libmc/blocks/StandardBlocks.java new file mode 100644 index 0000000..310ce11 --- /dev/null +++ b/1.15/src/main/java/wile/engineersdecor/libmc/blocks/StandardBlocks.java @@ -0,0 +1,386 @@ +/* + * @file BlockDecorFull.java + * @author Stefan Wilhelm (wile) + * @copyright (C) 2019 Stefan Wilhelm + * @license MIT (see https://opensource.org/licenses/MIT) + * + * Common functionality class for decor blocks. + * Mainly needed for: + * - MC block defaults. + * - Tooltip functionality + * - Model initialisation + */ +package wile.engineersdecor.libmc.blocks; + +import net.minecraft.util.math.BlockRayTraceResult; +import net.minecraft.world.server.ServerWorld; +import wile.engineersdecor.libmc.detail.Auxiliaries; +import net.minecraft.block.*; +import net.minecraft.entity.EntityType; +import net.minecraft.state.DirectionProperty; +import net.minecraft.state.StateContainer; +import net.minecraft.state.BooleanProperty; +import net.minecraft.state.properties.BlockStateProperties; +import net.minecraft.entity.item.ItemEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.fluid.IFluidState; +import net.minecraft.fluid.Fluids; +import net.minecraft.world.IWorld; +import net.minecraft.world.Explosion; +import net.minecraft.world.World; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.shapes.ISelectionContext; +import net.minecraft.util.math.shapes.VoxelShape; +import net.minecraft.util.math.shapes.VoxelShapes; +import net.minecraft.block.material.PushReaction; +import net.minecraft.item.BlockItemUseContext; +import net.minecraft.item.ItemStack; +import net.minecraft.world.IBlockReader; +import net.minecraft.world.storage.loot.LootContext; +import net.minecraft.client.util.ITooltipFlag; +import net.minecraft.util.*; +import net.minecraft.util.text.ITextComponent; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; + +import javax.annotation.Nullable; +import java.util.*; + + +public class StandardBlocks +{ + public static final long CFG_DEFAULT = 0x0000000000000000L; // no special config + public static final long CFG_CUTOUT = 0x0000000000000001L; // cutout rendering + public static final long CFG_MIPPED = 0x0000000000000002L; // cutout mipped rendering + public static final long CFG_TRANSLUCENT = 0x0000000000000004L; // indicates a block/pane is glass like (transparent, etc) + public static final long CFG_WATERLOGGABLE = 0x0000000000000008L; // The derived block extends IWaterLoggable + public static final long CFG_HORIZIONTAL = 0x0000000000000010L; // horizontal block, affects bounding box calculation at construction time and placement + public static final long CFG_LOOK_PLACEMENT = 0x0000000000000020L; // placed in direction the player is looking when placing. + public static final long CFG_FACING_PLACEMENT = 0x0000000000000040L; // placed on the facing the player has clicked. + public static final long CFG_OPPOSITE_PLACEMENT = 0x0000000000000080L; // placed placed in the opposite direction of the face the player clicked. + public static final long CFG_FLIP_PLACEMENT_IF_SAME = 0x0000000000000100L; // placement direction flipped if an instance of the same class was clicked + public static final long CFG_FLIP_PLACEMENT_SHIFTCLICK = 0x0000000000000200L; // placement direction flipped if player is sneaking + public static final long CFG_STRICT_CONNECTIONS = 0x0000000000000400L; // blocks do not connect to similar blocks around (implementation details may vary a bit) + + public interface IStandardBlock + { + default boolean hasDynamicDropList() + { return false; } + + default List dropList(BlockState state, World world, BlockPos pos, boolean explosion) + { return Collections.singletonList((!world.isRemote()) ? (new ItemStack(state.getBlock().asItem())) : (ItemStack.EMPTY)); } + + enum RenderTypeHint { SOLID,CUTOUT,CUTOUT_MIPPED,TRANSLUCENT } + + default RenderTypeHint getRenderTypeHint() + { return RenderTypeHint.SOLID; } + } + + public static class BaseBlock extends Block implements IStandardBlock + { + public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; + public final long config; + public final VoxelShape vshape; + + public BaseBlock(long conf, Block.Properties properties) + { this(conf, properties, Auxiliaries.getPixeledAABB(0, 0, 0, 16, 16,16 )); } + + public BaseBlock(long conf, Block.Properties properties, AxisAlignedBB aabb) + { super(properties); config = conf; vshape = VoxelShapes.create(aabb); } + + public BaseBlock(long conf, Block.Properties properties, VoxelShape voxel_shape) + { super(properties); config = conf; vshape = voxel_shape; } + + ///////////// -------------------------------------------------------------------------------------------------------- + // 1.15 transition + + public boolean onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) + { return false; } + + @Deprecated + public ActionResultType func_225533_a_(BlockState p_225533_1_, World p_225533_2_, BlockPos p_225533_3_, PlayerEntity p_225533_4_, Hand p_225533_5_, BlockRayTraceResult p_225533_6_) + { + return onBlockActivated(p_225533_1_,p_225533_2_,p_225533_3_,p_225533_4_,p_225533_5_,p_225533_6_) ? ActionResultType.SUCCESS : ActionResultType.PASS; + } + + @Deprecated + public void func_225534_a_(BlockState p_225534_1_, ServerWorld p_225534_2_, BlockPos p_225534_3_, Random p_225534_4_) + { tick(p_225534_1_,p_225534_2_,p_225534_3_,p_225534_4_); } + + public void tick(BlockState state, World world, BlockPos pos, Random rnd) + {} + + // 1.15 /transition + ///////////// -------------------------------------------------------------------------------------------------------- + + @Override + @OnlyIn(Dist.CLIENT) + public void addInformation(ItemStack stack, @Nullable IBlockReader world, List tooltip, ITooltipFlag flag) + { Auxiliaries.Tooltip.addInformation(stack, world, tooltip, flag, true); } + + @Override + public RenderTypeHint getRenderTypeHint() + { return ((config & CFG_CUTOUT)!=0) ? RenderTypeHint.CUTOUT : RenderTypeHint.SOLID; } + + @Override + @SuppressWarnings("deprecation") + public VoxelShape getShape(BlockState state, IBlockReader source, BlockPos pos, ISelectionContext selectionContext) + { return vshape; } + + @Override + @SuppressWarnings("deprecation") + public VoxelShape getCollisionShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext selectionContext) + { return vshape; } + + @Override + @Nullable + public BlockState getStateForPlacement(BlockItemUseContext context) + { + BlockState state = super.getStateForPlacement(context); + if((config & CFG_WATERLOGGABLE)!=0) { + IFluidState fs = context.getWorld().getFluidState(context.getPos()); + state = state.with(WATERLOGGED,fs.getFluid()==Fluids.WATER); + } + return state; + } + + @Override + public boolean canSpawnInBlock() + { return false; } + + @Override + @SuppressWarnings("deprecation") + public PushReaction getPushReaction(BlockState state) + { return PushReaction.NORMAL; } + + @Override + @SuppressWarnings("deprecation") + public void onReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean isMoving) + { + if(state.hasTileEntity() && (state.getBlock() != newState.getBlock())) { + world.removeTileEntity(pos); + world.updateComparatorOutputLevel(pos, this); + } + } + + public static boolean dropBlock(BlockState state, World world, BlockPos pos, @Nullable PlayerEntity player) + { + if(!(state.getBlock() instanceof IStandardBlock)) { world.removeBlock(pos, false); return true; } + if(!world.isRemote()) { + if((player==null) || (!player.isCreative())) { + ((IStandardBlock)state.getBlock()).dropList(state, world, pos, player==null).forEach(stack->world.addEntity(new ItemEntity(world, pos.getX()+0.5, pos.getY()+0.5, pos.getZ()+0.5, stack))); + } + } + if(state.getBlock().hasTileEntity(state)) world.removeTileEntity(pos); + world.removeBlock(pos, false); + return true; + } + + @Override + public boolean removedByPlayer(BlockState state, World world, BlockPos pos, PlayerEntity player, boolean willHarvest, IFluidState fluid) + { return hasDynamicDropList() ? dropBlock(state, world, pos, player) : super.removedByPlayer(state, world,pos , player, willHarvest, fluid); } + + @Override + public void onExplosionDestroy(World world, BlockPos pos, Explosion explosion) + { if(hasDynamicDropList()) dropBlock(world.getBlockState(pos), world, pos, null); } + + @Override + @SuppressWarnings("deprecation") + public List getDrops(BlockState state, LootContext.Builder builder) + { return hasDynamicDropList() ? Collections.singletonList(ItemStack.EMPTY) : super.getDrops(state, builder); } + + @Override + public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) + { + if((config & CFG_WATERLOGGABLE)!=0) { + if(state.get(WATERLOGGED)) return false; + } + return super.propagatesSkylightDown(state, reader, pos); + } + + @Override + @SuppressWarnings("deprecation") + public IFluidState getFluidState(BlockState state) + { + if((config & CFG_WATERLOGGABLE)!=0) { + return state.get(WATERLOGGED) ? Fluids.WATER.getStillFluidState(false) : super.getFluidState(state); + } + return super.getFluidState(state); + } + + @Override + @SuppressWarnings("deprecation") + public BlockState updatePostPlacement(BlockState state, Direction facing, BlockState facingState, IWorld world, BlockPos pos, BlockPos facingPos) + { + if((config & CFG_WATERLOGGABLE)!=0) { + if(state.get(WATERLOGGED)) world.getPendingFluidTicks().scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); + } + return state; + } + } + + public static class WaterLoggable extends BaseBlock implements IWaterLoggable, IStandardBlock + { + public WaterLoggable(long config, Block.Properties properties) + { super(config|CFG_WATERLOGGABLE, properties); } + + public WaterLoggable(long config, Block.Properties properties, AxisAlignedBB aabb) + { super(config|CFG_WATERLOGGABLE, properties, aabb); } + + public WaterLoggable(long config, Block.Properties properties, VoxelShape voxel_shape) + { super(config|CFG_WATERLOGGABLE, properties, voxel_shape); } + + @Override + protected void fillStateContainer(StateContainer.Builder builder) + { super.fillStateContainer(builder); builder.add(WATERLOGGED); } + } + + public static class Directed extends BaseBlock implements IStandardBlock + { + public static final DirectionProperty FACING = DirectionalBlock.FACING; + protected final ArrayList AABBs; + + public Directed(long config, Block.Properties builder, final AxisAlignedBB unrotatedAABB) + { + super(config, builder); + setDefaultState(stateContainer.getBaseState().with(FACING, Direction.UP)); + final boolean is_horizontal = ((config & CFG_HORIZIONTAL)!=0); + AABBs = new ArrayList(Arrays.asList( + VoxelShapes.create(Auxiliaries.getRotatedAABB(unrotatedAABB, Direction.DOWN, is_horizontal)), + VoxelShapes.create(Auxiliaries.getRotatedAABB(unrotatedAABB, Direction.UP, is_horizontal)), + VoxelShapes.create(Auxiliaries.getRotatedAABB(unrotatedAABB, Direction.NORTH, is_horizontal)), + VoxelShapes.create(Auxiliaries.getRotatedAABB(unrotatedAABB, Direction.SOUTH, is_horizontal)), + VoxelShapes.create(Auxiliaries.getRotatedAABB(unrotatedAABB, Direction.WEST, is_horizontal)), + VoxelShapes.create(Auxiliaries.getRotatedAABB(unrotatedAABB, Direction.EAST, is_horizontal)), + VoxelShapes.create(unrotatedAABB), + VoxelShapes.create(unrotatedAABB) + )); + } + + @Override + public boolean canSpawnInBlock() + { return false; } + + @Override + @SuppressWarnings("deprecation") + public boolean canEntitySpawn(BlockState state, IBlockReader world, BlockPos pos, EntityType entityType) + { return false; } + + @Override + public VoxelShape getShape(BlockState state, IBlockReader source, BlockPos pos, ISelectionContext selectionContext) + { return AABBs.get((state.get(FACING)).getIndex() & 0x7); } + + @Override + public VoxelShape getCollisionShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext selectionContext) + { return getShape(state, world, pos, selectionContext); } + + @Override + protected void fillStateContainer(StateContainer.Builder builder) + { super.fillStateContainer(builder); builder.add(FACING); } + + @Override + @Nullable + public BlockState getStateForPlacement(BlockItemUseContext context) + { + Direction facing = context.getFace(); + if((config & (CFG_HORIZIONTAL|CFG_LOOK_PLACEMENT)) == (CFG_HORIZIONTAL|CFG_LOOK_PLACEMENT)) { + // horizontal placement in direction the player is looking + facing = context.getPlacementHorizontalFacing(); + } else if((config & (CFG_HORIZIONTAL|CFG_LOOK_PLACEMENT)) == (CFG_HORIZIONTAL)) { + // horizontal placement on a face + if(((facing==Direction.UP)||(facing==Direction.DOWN))) return null; + } else if((config & CFG_LOOK_PLACEMENT)!=0) { + // placement in direction the player is looking, with up and down + facing = context.getNearestLookingDirection(); + } else { + // default: placement on the face the player clicking + } + if((config & CFG_OPPOSITE_PLACEMENT)!=0) facing = facing.getOpposite(); + if(((config & CFG_FLIP_PLACEMENT_SHIFTCLICK) != 0) && (context.getPlayer().func_225608_bj_()/*isSneaking()*/)) facing = facing.getOpposite(); + return super.getStateForPlacement(context).with(FACING, facing); + } + } + + public static class Horizontal extends BaseBlock implements IStandardBlock + { + public static final DirectionProperty HORIZONTAL_FACING = HorizontalBlock.HORIZONTAL_FACING; + protected final ArrayList AABBs; + + public Horizontal(long config, Block.Properties builder, final AxisAlignedBB unrotatedAABB) + { + super(config|CFG_HORIZIONTAL, builder, unrotatedAABB); + setDefaultState(stateContainer.getBaseState().with(HORIZONTAL_FACING, Direction.NORTH)); + AABBs = new ArrayList(Arrays.asList( + VoxelShapes.create(Auxiliaries.getRotatedAABB(unrotatedAABB, Direction.DOWN, true)), + VoxelShapes.create(Auxiliaries.getRotatedAABB(unrotatedAABB, Direction.UP, true)), + VoxelShapes.create(Auxiliaries.getRotatedAABB(unrotatedAABB, Direction.NORTH, true)), + VoxelShapes.create(Auxiliaries.getRotatedAABB(unrotatedAABB, Direction.SOUTH, true)), + VoxelShapes.create(Auxiliaries.getRotatedAABB(unrotatedAABB, Direction.WEST, true)), + VoxelShapes.create(Auxiliaries.getRotatedAABB(unrotatedAABB, Direction.EAST, true)), + VoxelShapes.create(unrotatedAABB), + VoxelShapes.create(unrotatedAABB) + )); + } + + @Override + public VoxelShape getShape(BlockState state, IBlockReader source, BlockPos pos, ISelectionContext selectionContext) + { return AABBs.get((state.get(HORIZONTAL_FACING)).getIndex() & 0x7); } + + @Override + public VoxelShape getCollisionShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext selectionContext) + { return getShape(state, world, pos, selectionContext); } + + @Override + protected void fillStateContainer(StateContainer.Builder builder) + { super.fillStateContainer(builder); builder.add(HORIZONTAL_FACING); } + + @Override + @Nullable + public BlockState getStateForPlacement(BlockItemUseContext context) + { + Direction facing = context.getFace(); + if((config & CFG_LOOK_PLACEMENT) != 0) { + // horizontal placement in direction the player is looking + facing = context.getPlacementHorizontalFacing(); + } else { + // horizontal placement on a face + facing = ((facing==Direction.UP)||(facing==Direction.DOWN)) ? (context.getPlacementHorizontalFacing()) : facing; + } + if((config & CFG_OPPOSITE_PLACEMENT)!=0) facing = facing.getOpposite(); + if(((config & CFG_FLIP_PLACEMENT_SHIFTCLICK) != 0) && (context.getPlayer().func_225608_bj_()/*isSneaking()*/)) facing = facing.getOpposite(); + return super.getStateForPlacement(context).with(HORIZONTAL_FACING, facing); + } + + @Override + @SuppressWarnings("deprecation") + public BlockState rotate(BlockState state, Rotation rot) + { return state.with(HORIZONTAL_FACING, rot.rotate(state.get(HORIZONTAL_FACING))); } + + @Override + @SuppressWarnings("deprecation") + public BlockState mirror(BlockState state, Mirror mirrorIn) + { return state.rotate(mirrorIn.toRotation(state.get(HORIZONTAL_FACING))); } + } + + public static class DirectedWaterLoggable extends Directed implements IWaterLoggable, IStandardBlock + { + public DirectedWaterLoggable(long config, Block.Properties properties, AxisAlignedBB aabb) + { super(config|CFG_WATERLOGGABLE, properties, aabb); } + + @Override + protected void fillStateContainer(StateContainer.Builder builder) + { super.fillStateContainer(builder); builder.add(WATERLOGGED); } + } + + public static class HorizontalWaterLoggable extends Horizontal implements IWaterLoggable, IStandardBlock + { + public HorizontalWaterLoggable(long config, Block.Properties properties, AxisAlignedBB aabb) + { super(config|CFG_WATERLOGGABLE|CFG_HORIZIONTAL, properties, aabb); } + + @Override + protected void fillStateContainer(StateContainer.Builder builder) + { super.fillStateContainer(builder); builder.add(WATERLOGGED); } + } + +} diff --git a/1.15/src/main/java/wile/engineersdecor/libmc/blocks/StandardFenceBlock.java b/1.15/src/main/java/wile/engineersdecor/libmc/blocks/StandardFenceBlock.java new file mode 100644 index 0000000..44c273e --- /dev/null +++ b/1.15/src/main/java/wile/engineersdecor/libmc/blocks/StandardFenceBlock.java @@ -0,0 +1,114 @@ +/* + * @file BlockDecorWall.java + * @author Stefan Wilhelm (wile) + * @copyright (C) 2019 Stefan Wilhelm + * @license MIT (see https://opensource.org/licenses/MIT) + * + * Wall blocks. + */ +package wile.engineersdecor.libmc.blocks; + +import wile.engineersdecor.libmc.detail.Auxiliaries; +import net.minecraft.world.*; +import net.minecraft.fluid.IFluidState; +import net.minecraft.entity.EntityType; +import net.minecraft.util.math.shapes.ISelectionContext; +import net.minecraft.state.StateContainer; +import net.minecraft.block.*; +import net.minecraft.block.material.PushReaction; +import net.minecraft.block.BlockState; +import net.minecraft.client.util.ITooltipFlag; +import net.minecraft.fluid.Fluids; +import net.minecraft.item.BlockItemUseContext; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Direction; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.shapes.VoxelShape; +import net.minecraft.util.text.ITextComponent; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import javax.annotation.Nullable; +import java.util.List; + + +public class StandardFenceBlock extends WallBlock implements StandardBlocks.IStandardBlock +{ + private final VoxelShape[] shape_voxels; + private final VoxelShape[] collision_shape_voxels; + + public StandardFenceBlock(long config, Block.Properties builder) + { + super(builder); + this.shape_voxels = buildWallShapes(1.5f, 1.5f, 16f, 0f, 16f); + this.collision_shape_voxels = buildWallShapes(1.5f, 1.5f, 24f, 0f, 24f); + } + + @Override + @OnlyIn(Dist.CLIENT) + public void addInformation(ItemStack stack, @Nullable IBlockReader world, List tooltip, ITooltipFlag flag) + { Auxiliaries.Tooltip.addInformation(stack, world, tooltip, flag, true); } + + protected VoxelShape[] buildWallShapes(float pole_width_x, float pole_width_z, float pole_height, float side_min_y, float side_max_y) + { return super.makeShapes(pole_width_x, pole_width_z, pole_height, side_min_y, side_max_y); } + + @Override + public VoxelShape getShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext selectionContext) + { return shape_voxels[this.getIndex(state)]; } + + @Override + public VoxelShape getCollisionShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext selectionContext) + { return collision_shape_voxels[this.getIndex(state)]; } + + @Override + protected void fillStateContainer(StateContainer.Builder builder) + { super.fillStateContainer(builder); } + + private boolean attachesTo(BlockState facingState, IWorldReader world, BlockPos facingPos, Direction side) + { + final Block block = facingState.getBlock(); + if((block instanceof FenceGateBlock) || (block instanceof StandardFenceBlock) || (block instanceof VariantWallBlock)) return true; + final BlockState oppositeState = world.getBlockState(facingPos.offset(side, 2)); + if(!(oppositeState.getBlock() instanceof StandardFenceBlock)) return false; + return facingState.isNormalCube(world, facingPos) && hasSolidSide(facingState, world, facingPos, side); + } + + public BlockState getStateForPlacement(BlockItemUseContext context) + { + IWorldReader world = context.getWorld(); + BlockPos pos = context.getPos(); + IFluidState fs = context.getWorld().getFluidState(context.getPos()); + boolean n = attachesTo(world.getBlockState(pos.north()), world, pos.north(), Direction.SOUTH); + boolean e = attachesTo(world.getBlockState(pos.east()), world, pos.east(), Direction.WEST); + boolean s = attachesTo(world.getBlockState(pos.south()), world, pos.south(), Direction.NORTH); + boolean w = attachesTo(world.getBlockState(pos.west()), world, pos.west(), Direction.EAST); + boolean not_straight = (!n || !s || e || w) && (n || s || !e || !w); + return getDefaultState().with(UP, not_straight).with(NORTH, n).with(EAST, e).with(SOUTH, s).with(WEST, w).with(WATERLOGGED, fs.getFluid() == Fluids.WATER); + } + + @Override + public BlockState updatePostPlacement(BlockState state, Direction side, BlockState facingState, IWorld world, BlockPos currentPos, BlockPos facingPos) + { + if(state.get(WATERLOGGED)) world.getPendingFluidTicks().scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickRate(world)); + if(side == Direction.DOWN) return super.updatePostPlacement(state, side, facingState, world, currentPos, facingPos); + boolean n = (side==Direction.NORTH) ? attachesTo(facingState, world, facingPos, side) : state.get(NORTH); + boolean e = (side==Direction.EAST) ? attachesTo(facingState, world, facingPos, side) : state.get(EAST); + boolean s = (side==Direction.SOUTH) ? attachesTo(facingState, world, facingPos, side) : state.get(SOUTH); + boolean w = (side==Direction.WEST) ? attachesTo(facingState, world, facingPos, side) : state.get(WEST); + boolean not_straight = (!n || !s || e || w) && (n || s || !e || !w); + return state.with(UP, not_straight).with(NORTH, n).with(EAST, e).with(SOUTH, s).with(WEST, w); + } + + @Override + @SuppressWarnings("deprecation") + public boolean canEntitySpawn(BlockState state, IBlockReader world, BlockPos pos, EntityType entityType) + { return false; } + + @Override + public boolean canSpawnInBlock() + { return false; } + + @Override + @SuppressWarnings("deprecation") + public PushReaction getPushReaction(BlockState state) + { return PushReaction.NORMAL; } +} diff --git a/1.15/src/main/java/wile/engineersdecor/libmc/blocks/StandardStairsBlock.java b/1.15/src/main/java/wile/engineersdecor/libmc/blocks/StandardStairsBlock.java new file mode 100644 index 0000000..12a694c --- /dev/null +++ b/1.15/src/main/java/wile/engineersdecor/libmc/blocks/StandardStairsBlock.java @@ -0,0 +1,53 @@ +/* + * @file StandardStairsBlock.java + * @author Stefan Wilhelm (wile) + * @copyright (C) 2019 Stefan Wilhelm + * @license MIT (see https://opensource.org/licenses/MIT) + * + * Stairs and roof blocks, almost entirely based on vanilla stairs. + */ +package wile.engineersdecor.libmc.blocks; + +import wile.engineersdecor.libmc.detail.Auxiliaries; +import net.minecraft.entity.EntityType; +import net.minecraft.util.math.BlockPos; +import net.minecraft.block.*; +import net.minecraft.block.material.PushReaction; +import net.minecraft.block.BlockState; +import net.minecraft.client.util.ITooltipFlag; +import net.minecraft.item.ItemStack; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.world.IBlockReader; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import javax.annotation.Nullable; +import java.util.List; + + +public class StandardStairsBlock extends StairsBlock implements StandardBlocks.IStandardBlock +{ + public StandardStairsBlock(long config, BlockState state, Block.Properties properties) + { super(()->state, properties); } + + public StandardStairsBlock(long config, java.util.function.Supplier state, Block.Properties properties) + { super(state, properties); } + + @Override + @OnlyIn(Dist.CLIENT) + public void addInformation(ItemStack stack, @Nullable IBlockReader world, List tooltip, ITooltipFlag flag) + { Auxiliaries.Tooltip.addInformation(stack, world, tooltip, flag, true); } + + @Override + public boolean canSpawnInBlock() + { return false; } + + @Override + @SuppressWarnings("deprecation") + public boolean canEntitySpawn(BlockState state, IBlockReader world, BlockPos pos, EntityType entityType) + { return false; } + + @Override + @SuppressWarnings("deprecation") + public PushReaction getPushReaction(BlockState state) + { return PushReaction.NORMAL; } +} diff --git a/1.15/src/main/java/wile/engineersdecor/libmc/blocks/VariantSlabBlock.java b/1.15/src/main/java/wile/engineersdecor/libmc/blocks/VariantSlabBlock.java new file mode 100644 index 0000000..640a2d9 --- /dev/null +++ b/1.15/src/main/java/wile/engineersdecor/libmc/blocks/VariantSlabBlock.java @@ -0,0 +1,182 @@ +/* + * @file VariantSlabBlock.java + * @author Stefan Wilhelm (wile) + * @copyright (C) 2019 Stefan Wilhelm + * @license MIT (see https://opensource.org/licenses/MIT) + * + * Standard half block horizontal slab characteristics class. + */ +package wile.engineersdecor.libmc.blocks; + +import wile.engineersdecor.libmc.detail.Auxiliaries; +import net.minecraft.world.World; +import net.minecraft.world.IBlockReader; +import net.minecraft.state.StateContainer; +import net.minecraft.block.*; +import net.minecraft.block.BlockState; +import net.minecraft.item.ItemStack; +import net.minecraft.item.BlockItemUseContext; +import net.minecraft.state.IntegerProperty; +import net.minecraft.util.*; +import net.minecraft.util.math.*; +import net.minecraft.util.math.shapes.VoxelShapes; +import net.minecraft.util.math.shapes.ISelectionContext; +import net.minecraft.util.math.shapes.VoxelShape; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.client.util.ITooltipFlag; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + + +public class VariantSlabBlock extends StandardBlocks.WaterLoggable implements StandardBlocks.IStandardBlock +{ + public static final IntegerProperty PARTS = IntegerProperty.create("parts", 0, 2); + public static final IntegerProperty TEXTURE_VARIANT = IntegerProperty.create("tvariant", 0, 3); + + protected static final VoxelShape AABBs[] = { + VoxelShapes.create(new AxisAlignedBB(0, 0./16, 0, 1, 8./16, 1)), // bottom slab + VoxelShapes.create(new AxisAlignedBB(0, 8./16, 0, 1, 16./16, 1)), // top slab + VoxelShapes.create(new AxisAlignedBB(0, 0./16, 0, 1, 16./16, 1)), // both slabs + VoxelShapes.create(new AxisAlignedBB(0, 0./16, 0, 1, 16./16, 1)) // << 2bit fill + }; + protected static final int num_slabs_contained_in_parts_[] = { 1,1,2,2 }; + private static boolean with_pickup = false; + + public static void on_config(boolean direct_slab_pickup) + { with_pickup = direct_slab_pickup; } + + protected boolean is_cube(BlockState state) + { return state.get(PARTS) >= 2; } + + public VariantSlabBlock(long config, Block.Properties builder) + { super(config, builder); } + + @Override + public RenderTypeHint getRenderTypeHint() + { return (((config & StandardBlocks.CFG_TRANSLUCENT)!=0) ? (RenderTypeHint.TRANSLUCENT) : (RenderTypeHint.CUTOUT)); } + + @Override + @OnlyIn(Dist.CLIENT) + public void addInformation(ItemStack stack, @Nullable IBlockReader world, List tooltip, ITooltipFlag flag) + { + if(!Auxiliaries.Tooltip.addInformation(stack, world, tooltip, flag, true)) return; + if(with_pickup) Auxiliaries.Tooltip.addInformation("engineersdecor.tooltip.slabpickup", "engineersdecor.tooltip.slabpickup", tooltip, flag, true); + } + + @Override + @OnlyIn(Dist.CLIENT) + @SuppressWarnings("deprecation") + public boolean isSideInvisible(BlockState state, BlockState adjacentBlockState, Direction side) + { return (adjacentBlockState==state) ? true : super.isSideInvisible(state, adjacentBlockState, side); } + + @Override + public boolean canSpawnInBlock() + { return false; } + + @Override + @SuppressWarnings("deprecation") + public boolean canEntitySpawn(BlockState state, IBlockReader world, BlockPos pos, EntityType entityType) + { return false; } + + @Override + public VoxelShape getShape(BlockState state, IBlockReader source, BlockPos pos, ISelectionContext selectionContext) + { return AABBs[state.get(PARTS) & 0x3]; } + + @Override + public VoxelShape getCollisionShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext selectionContext) + { return getShape(state, world, pos, selectionContext); } + + @Override + protected void fillStateContainer(StateContainer.Builder builder) + { super.fillStateContainer(builder); builder.add(PARTS, TEXTURE_VARIANT); } + + @Override + @Nullable + public BlockState getStateForPlacement(BlockItemUseContext context) + { + BlockPos pos = context.getPos(); + if(context.getWorld().getBlockState(pos).getBlock() == this) return context.getWorld().getBlockState(pos).with(PARTS, 2).with(WATERLOGGED, false); + final int rnd = MathHelper.clamp((int)(MathHelper.getPositionRandom(context.getPos()) & 0x3), 0, 3); + final Direction face = context.getFace(); + final BlockState placement_state = super.getStateForPlacement(context).with(TEXTURE_VARIANT, rnd); // fluid state + if(face == Direction.UP) return placement_state.with(PARTS, 0); + if(face == Direction.DOWN) return placement_state.with(PARTS, 1); + if(!face.getAxis().isHorizontal()) return placement_state; + final boolean isupper = ((context.getHitVec().getY() - context.getPos().getY()) > 0.5); + return placement_state.with(PARTS, isupper ? 1 : 0); + } + + @Override + @SuppressWarnings("deprecation") + public boolean isReplaceable(BlockState state, BlockItemUseContext context) + { + if(context.getItem().getItem() != this.asItem()) return false; + if(!context.replacingClickedOnBlock()) return true; + final Direction face = context.getFace(); + final int parts = state.get(PARTS); + if((face == Direction.UP) && (parts==0)) return true; + if((face == Direction.DOWN) && (parts==1)) return true; + if(!face.getAxis().isHorizontal()) return false; + final boolean isupper = ((context.getHitVec().getY() - context.getPos().getY()) > 0.5); + return isupper ? (parts==0) : (parts==1); + } + + @Override + @SuppressWarnings("deprecation") + public BlockState rotate(BlockState state, Rotation rot) + { return state; } + + @Override + @SuppressWarnings("deprecation") + public BlockState mirror(BlockState state, Mirror mirrorIn) + { return state; } + + @Override + public boolean hasDynamicDropList() + { return true; } + + @Override + public List dropList(BlockState state, World world, BlockPos pos, boolean explosion) + { return new ArrayList(Collections.singletonList(new ItemStack(this.asItem(), num_slabs_contained_in_parts_[state.get(PARTS) & 0x3]))); } + + @Override + @SuppressWarnings("deprecation") + public void onBlockClicked(BlockState state, World world, BlockPos pos, PlayerEntity player) + { + if((world.isRemote) || (!with_pickup)) return; + final ItemStack stack = player.getHeldItemMainhand(); + if(stack.isEmpty() || (Block.getBlockFromItem(stack.getItem()) != this)) return; + if(stack.getCount() >= stack.getMaxStackSize()) return; + Vec3d lv = player.getLookVec(); + Direction facing = Direction.getFacingFromVector((float)lv.x, (float)lv.y, (float)lv.z); + if((facing != Direction.UP) && (facing != Direction.DOWN)) return; + if(state.getBlock() != this) return; + int parts = state.get(PARTS); + if(facing == Direction.DOWN) { + if(parts == 2) { + world.setBlockState(pos, state.with(PARTS, 0), 3); + } else { + world.removeBlock(pos, false); + } + } else if(facing == Direction.UP) { + if(parts == 2) { + world.setBlockState(pos, state.with(PARTS, 1), 3); + } else { + world.removeBlock(pos, false); + } + } + if(!player.isCreative()) { + stack.grow(1); + if(player.inventory != null) player.inventory.markDirty(); + } + SoundType st = this.getSoundType(state, world, pos, null); + world.playSound(player, pos, st.getPlaceSound(), SoundCategory.BLOCKS, (st.getVolume()+1f)/2.5f, 0.9f*st.getPitch()); + } + +} diff --git a/1.15/src/main/java/wile/engineersdecor/libmc/blocks/VariantWallBlock.java b/1.15/src/main/java/wile/engineersdecor/libmc/blocks/VariantWallBlock.java new file mode 100644 index 0000000..e7df989 --- /dev/null +++ b/1.15/src/main/java/wile/engineersdecor/libmc/blocks/VariantWallBlock.java @@ -0,0 +1,117 @@ +/* + * @file VariantWallBlock.java + * @author Stefan Wilhelm (wile) + * @copyright (C) 2019 Stefan Wilhelm + * @license MIT (see https://opensource.org/licenses/MIT) + * + * Wall blocks. + */ +package wile.engineersdecor.libmc.blocks; + +import wile.engineersdecor.libmc.detail.Auxiliaries; +import net.minecraft.item.BlockItemUseContext; +import net.minecraft.world.*; +import net.minecraft.fluid.IFluidState; +import net.minecraft.entity.EntityType; +import net.minecraft.util.math.shapes.ISelectionContext; +import net.minecraft.state.StateContainer; +import net.minecraft.util.math.MathHelper; +import net.minecraft.block.*; +import net.minecraft.block.material.PushReaction; +import net.minecraft.block.BlockState; +import net.minecraft.client.util.ITooltipFlag; +import net.minecraft.fluid.Fluids; +import net.minecraft.item.ItemStack; +import net.minecraft.state.IntegerProperty; +import net.minecraft.util.Direction; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.shapes.VoxelShape; +import net.minecraft.util.text.ITextComponent; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import javax.annotation.Nullable; +import java.util.List; + + +public class VariantWallBlock extends WallBlock implements StandardBlocks.IStandardBlock +{ + private final VoxelShape[] shape_voxels; + private final VoxelShape[] collision_shape_voxels; + public static final IntegerProperty TEXTURE_VARIANT = IntegerProperty.create("tvariant", 0, 7); + + public VariantWallBlock(long config, Block.Properties builder) + { + super(builder); + this.shape_voxels = buildWallShapes(4.0F, 4.0F, 16.0F, 0.0F, 16.0F); + this.collision_shape_voxels = buildWallShapes(4.0F, 4.0F, 24.0F, 0.0F, 24.0F); + } + + @Override + @OnlyIn(Dist.CLIENT) + public void addInformation(ItemStack stack, @Nullable IBlockReader world, List tooltip, ITooltipFlag flag) + { Auxiliaries.Tooltip.addInformation(stack, world, tooltip, flag, true); } + + protected VoxelShape[] buildWallShapes(float pole_width_x, float pole_width_z, float pole_height, float side_min_y, float side_max_y) + { return super.makeShapes(pole_width_x, pole_width_z, pole_height, side_min_y, side_max_y); } + + @Override + public VoxelShape getShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext selectionContext) + { return shape_voxels[this.getIndex(state)]; } + + @Override + public VoxelShape getCollisionShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext selectionContext) + { return collision_shape_voxels[this.getIndex(state)]; } + + @Override + protected void fillStateContainer(StateContainer.Builder builder) + { super.fillStateContainer(builder); builder.add(TEXTURE_VARIANT); } + + private boolean attachesTo(BlockState facingState, IWorldReader world, BlockPos facingPos, Direction side) + { + final Block block = facingState.getBlock(); + if((block instanceof FenceGateBlock) || (block instanceof WallBlock)) return true; + final BlockState oppositeState = world.getBlockState(facingPos.offset(side, 2)); + if(!(oppositeState.getBlock() instanceof VariantWallBlock)) return false; + return facingState.isNormalCube(world, facingPos) && hasSolidSide(facingState, world, facingPos, side); + } + + public BlockState getStateForPlacement(BlockItemUseContext context) + { + IWorldReader world = context.getWorld(); + BlockPos pos = context.getPos(); + IFluidState fs = context.getWorld().getFluidState(context.getPos()); + boolean n = attachesTo(world.getBlockState(pos.north()), world, pos.north(), Direction.SOUTH); + boolean e = attachesTo(world.getBlockState(pos.east()), world, pos.east(), Direction.WEST); + boolean s = attachesTo(world.getBlockState(pos.south()), world, pos.south(), Direction.NORTH); + boolean w = attachesTo(world.getBlockState(pos.west()), world, pos.west(), Direction.EAST); + boolean not_straight = (!n || !s || e || w) && (n || s || !e || !w); + return getDefaultState().with(UP, not_straight).with(NORTH, n).with(EAST, e).with(SOUTH, s).with(WEST, w).with(WATERLOGGED, fs.getFluid() == Fluids.WATER); + } + + @Override + public BlockState updatePostPlacement(BlockState state, Direction side, BlockState facingState, IWorld world, BlockPos currentPos, BlockPos facingPos) + { + if(state.get(WATERLOGGED)) world.getPendingFluidTicks().scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickRate(world)); + if(side == Direction.DOWN) return super.updatePostPlacement(state, side, facingState, world, currentPos, facingPos); + boolean n = (side==Direction.NORTH) ? this.attachesTo(facingState, world, facingPos, side) : state.get(NORTH); + boolean e = (side==Direction.EAST) ? this.attachesTo(facingState, world, facingPos, side) : state.get(EAST); + boolean s = (side==Direction.SOUTH) ? this.attachesTo(facingState, world, facingPos, side) : state.get(SOUTH); + boolean w = (side==Direction.WEST) ? this.attachesTo(facingState, world, facingPos, side) : state.get(WEST); + boolean not_straight = (!n || !s || e || w) && (n || s || !e || !w); + return state.with(UP, not_straight).with(NORTH, n).with(EAST, e).with(SOUTH, s).with(WEST, w).with(TEXTURE_VARIANT, ((int)MathHelper.getPositionRandom(currentPos)) & 0x7); + } + + @Override + @SuppressWarnings("deprecation") + public boolean canEntitySpawn(BlockState state, IBlockReader world, BlockPos pos, EntityType entityType) + { return false; } + + @Override + public boolean canSpawnInBlock() + { return false; } + + @Override + @SuppressWarnings("deprecation") + public PushReaction getPushReaction(BlockState state) + { return PushReaction.NORMAL; } +} diff --git a/1.15/src/main/java/wile/engineersdecor/datagen/ModLootTables.java b/1.15/src/main/java/wile/engineersdecor/libmc/datagen/LootTableGen.java similarity index 80% rename from 1.15/src/main/java/wile/engineersdecor/datagen/ModLootTables.java rename to 1.15/src/main/java/wile/engineersdecor/libmc/datagen/LootTableGen.java index 0352958..0ac2125 100644 --- a/1.15/src/main/java/wile/engineersdecor/datagen/ModLootTables.java +++ b/1.15/src/main/java/wile/engineersdecor/libmc/datagen/LootTableGen.java @@ -6,11 +6,10 @@ * * Loot table generator. */ -package wile.engineersdecor.datagen; +package wile.engineersdecor.libmc.datagen; -import wile.engineersdecor.ModContent; -import wile.engineersdecor.blocks.IDecorBlock; -import wile.engineersdecor.detail.ModAuxiliaries; +import wile.engineersdecor.libmc.blocks.StandardBlocks; +import wile.engineersdecor.libmc.detail.Auxiliaries; import net.minecraft.block.Block; import net.minecraft.data.*; import net.minecraft.util.ResourceLocation; @@ -26,24 +25,26 @@ import java.nio.file.Path; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.function.Supplier; -public class ModLootTables extends LootTableProvider +public class LootTableGen extends LootTableProvider { private static final Logger LOGGER = LogManager.getLogger(); private static final Gson GSON = (new GsonBuilder()).setPrettyPrinting().disableHtmlEscaping().create(); private final DataGenerator generator; + private final Supplier> block_listing; //-------------------------------------------------------------------------------------------------------------------- - public ModLootTables(DataGenerator gen) - { super(gen); generator=gen; } + public LootTableGen(DataGenerator gen, Supplier> block_list_supplier) + { super(gen); generator=gen; block_listing = block_list_supplier; } //-- LootTableProvider ----------------------------------------------------------------------------------------------- @Override public String getName() - { return ModAuxiliaries.MODID + " Loot Tables"; } + { return Auxiliaries.modid() + " Loot Tables"; } @Override public void act(DirectoryCache cache) @@ -54,9 +55,9 @@ public class ModLootTables extends LootTableProvider private Map generate() { final HashMap tables = new HashMap(); - final List blocks = ModContent.allBlocks(); + final List blocks = block_listing.get(); blocks.forEach((block)->{ - if((!(block instanceof IDecorBlock)) || (!(((IDecorBlock)block).hasDynamicDropList()))) { + if((!(block instanceof StandardBlocks.IStandardBlock)) || (!(((StandardBlocks.IStandardBlock)block).hasDynamicDropList()))) { tables.put( block.getLootTable(), defaultBlockDrops(block.getRegistryName().getPath() + "_dlt", block) diff --git a/1.15/src/main/java/wile/engineersdecor/detail/ModAuxiliaries.java b/1.15/src/main/java/wile/engineersdecor/libmc/detail/Auxiliaries.java similarity index 75% rename from 1.15/src/main/java/wile/engineersdecor/detail/ModAuxiliaries.java rename to 1.15/src/main/java/wile/engineersdecor/libmc/detail/Auxiliaries.java index a30195c..900f272 100644 --- a/1.15/src/main/java/wile/engineersdecor/detail/ModAuxiliaries.java +++ b/1.15/src/main/java/wile/engineersdecor/libmc/detail/Auxiliaries.java @@ -1,16 +1,16 @@ /* - * @file ModAuxiliaries.java + * @file Auxiliaries.java * @author Stefan Wilhelm (wile) * @copyright (C) 2018 Stefan Wilhelm * @license MIT (see https://opensource.org/licenses/MIT) * * General commonly used functionality. */ -package wile.engineersdecor.detail; +package wile.engineersdecor.libmc.detail; -import wile.engineersdecor.ModEngineersDecor; import net.minecraft.client.util.InputMappings; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.Direction; import net.minecraft.util.SharedConstants; import net.minecraft.util.text.ITextComponent; @@ -32,16 +32,34 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; import java.util.List; +import java.util.function.Supplier; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; -public class ModAuxiliaries +public class Auxiliaries { - public static final String MODID = ModEngineersDecor.MODID; - public static final Logger LOGGER = ModEngineersDecor.logger(); - public static final ModEngineersDecor.ISidedProxy PROXY = ModEngineersDecor.proxy; + private static String modid; + private static Logger logger; + private static Supplier server_config_supplier = ()->new CompoundNBT(); + + public static void init(String modid, Logger logger, Supplier server_config_supplier) + { + Auxiliaries.modid = modid; + Auxiliaries.logger = logger; + Auxiliaries.server_config_supplier = server_config_supplier; + } + + // ------------------------------------------------------------------------------------------------------------------- + // Mod specific exports + // ------------------------------------------------------------------------------------------------------------------- + + public static String modid() + { return modid; } + + public static Logger logger() + { return logger; } // ------------------------------------------------------------------------------------------------------------------- // Sideness, system/environment, tagging interfaces @@ -58,15 +76,15 @@ public class ModAuxiliaries @OnlyIn(Dist.CLIENT) public static final boolean isShiftDown() { - return (InputMappings.isKeyDown(PROXY.mc().func_228018_at_()/*getMainWindow()*/.getHandle(), GLFW.GLFW_KEY_LEFT_SHIFT) || - InputMappings.isKeyDown(PROXY.mc().func_228018_at_()/*getMainWindow()*/.getHandle(), GLFW.GLFW_KEY_RIGHT_SHIFT)); + return (InputMappings.isKeyDown(SidedProxy.mc().func_228018_at_()/*getMainWindow()*/.getHandle(), GLFW.GLFW_KEY_LEFT_SHIFT) || + InputMappings.isKeyDown(SidedProxy.mc().func_228018_at_()/*getMainWindow()*/.getHandle(), GLFW.GLFW_KEY_RIGHT_SHIFT)); } @OnlyIn(Dist.CLIENT) public static final boolean isCtrlDown() { - return (InputMappings.isKeyDown(PROXY.mc().func_228018_at_()/*getMainWindow()*/.getHandle(), GLFW.GLFW_KEY_LEFT_CONTROL) || - InputMappings.isKeyDown(PROXY.mc().func_228018_at_()/*getMainWindow()*/.getHandle(), GLFW.GLFW_KEY_RIGHT_CONTROL)); + return (InputMappings.isKeyDown(SidedProxy.mc().func_228018_at_()/*getMainWindow()*/.getHandle(), GLFW.GLFW_KEY_LEFT_CONTROL) || + InputMappings.isKeyDown(SidedProxy.mc().func_228018_at_()/*getMainWindow()*/.getHandle(), GLFW.GLFW_KEY_RIGHT_CONTROL)); } // ------------------------------------------------------------------------------------------------------------------- @@ -74,44 +92,13 @@ public class ModAuxiliaries // ------------------------------------------------------------------------------------------------------------------- public static final void logInfo(final String msg) - { LOGGER.info(msg); } + { logger.info(msg); } public static final void logWarn(final String msg) - { LOGGER.warn(msg); } + { logger.warn(msg); } public static final void logError(final String msg) - { LOGGER.error(msg); } - - // ------------------------------------------------------------------------------------------------------------------- - // Block handling - // ------------------------------------------------------------------------------------------------------------------- - - public static final AxisAlignedBB getPixeledAABB(double x0, double y0, double z0, double x1, double y1, double z1) - { return new AxisAlignedBB(x0/16.0, y0/16.0, z0/16.0, x1/16.0, y1/16.0, z1/16.0); } - - public static final AxisAlignedBB getRotatedAABB(AxisAlignedBB bb, Direction new_facing, boolean horizontal_rotation) - { - if(!horizontal_rotation) { - switch(new_facing.getIndex()) { - case 0: return new AxisAlignedBB(1-bb.maxX, 1-bb.maxZ, 1-bb.maxY, 1-bb.minX, 1-bb.minZ, 1-bb.minY); // D - case 1: return new AxisAlignedBB(1-bb.maxX, bb.minZ, bb.minY, 1-bb.minX, bb.maxZ, bb.maxY); // U - case 2: return new AxisAlignedBB(1-bb.maxX, bb.minY, 1-bb.maxZ, 1-bb.minX, bb.maxY, 1-bb.minZ); // N - case 3: return new AxisAlignedBB( bb.minX, bb.minY, bb.minZ, bb.maxX, bb.maxY, bb.maxZ); // S --> bb - case 4: return new AxisAlignedBB(1-bb.maxZ, bb.minY, bb.minX, 1-bb.minZ, bb.maxY, bb.maxX); // W - case 5: return new AxisAlignedBB( bb.minZ, bb.minY, 1-bb.maxX, bb.maxZ, bb.maxY, 1-bb.minX); // E - } - } else { - switch(new_facing.getIndex()) { - case 0: return new AxisAlignedBB( bb.minX, bb.minY, bb.minZ, bb.maxX, bb.maxY, bb.maxZ); // D --> bb - case 1: return new AxisAlignedBB( bb.minX, bb.minY, bb.minZ, bb.maxX, bb.maxY, bb.maxZ); // U --> bb - case 2: return new AxisAlignedBB( bb.minX, bb.minY, bb.minZ, bb.maxX, bb.maxY, bb.maxZ); // N --> bb - case 3: return new AxisAlignedBB(1-bb.maxX, bb.minY, 1-bb.maxZ, 1-bb.minX, bb.maxY, 1-bb.minZ); // S - case 4: return new AxisAlignedBB( bb.minZ, bb.minY, 1-bb.maxX, bb.maxZ, bb.maxY, 1-bb.minX); // W - case 5: return new AxisAlignedBB(1-bb.maxZ, bb.minY, bb.minX, 1-bb.minZ, bb.maxY, bb.maxX); // E - } - } - return bb; - } + { logger.error(msg); } // ------------------------------------------------------------------------------------------------------------------- // Localization, text formatting @@ -123,7 +110,7 @@ public class ModAuxiliaries */ public static TranslationTextComponent localizable(String modtrkey, @Nullable TextFormatting color, Object... args) { - TranslationTextComponent tr = new TranslationTextComponent(MODID+"."+modtrkey, args); + TranslationTextComponent tr = new TranslationTextComponent(modid+"."+modtrkey, args); if(color!=null) tr.getStyle().setColor(color); return tr; } @@ -132,7 +119,7 @@ public class ModAuxiliaries { return localizable(modtrkey, null); } public static TranslationTextComponent localizable_block_key(String blocksubkey) - { return new TranslationTextComponent("block."+MODID+"."+blocksubkey); } + { return new TranslationTextComponent("block."+modid+"."+blocksubkey); } @OnlyIn(Dist.CLIENT) public static String localize(String translationKey, Object... args) @@ -153,10 +140,10 @@ public class ModAuxiliaries boolean not = key.startsWith("!"); if(not) key = key.replaceFirst("!", ""); m = kv[1].trim(); - if(!ModConfig.getServerConfig().contains(key)) { + if(!server_config_supplier.get().contains(key)) { m = ""; } else { - boolean r = ModConfig.getServerConfig().getBoolean(key); + boolean r = server_config_supplier.get().getBoolean(key); if(not) r = !r; if(!r) m = ""; } @@ -197,14 +184,14 @@ public class ModAuxiliaries { // Note: intentionally not using keybinding here, this must be `control` or `shift`. MC uses lwjgl Keyboard, // so using this also here should be ok. - final boolean help_available = (helpTranslationKey != null) && ModAuxiliaries.hasTranslation(helpTranslationKey + ".help"); - final boolean tip_available = (advancedTooltipTranslationKey != null) && ModAuxiliaries.hasTranslation(helpTranslationKey + ".tip"); + final boolean help_available = (helpTranslationKey != null) && Auxiliaries.hasTranslation(helpTranslationKey + ".help"); + final boolean tip_available = (advancedTooltipTranslationKey != null) && Auxiliaries.hasTranslation(helpTranslationKey + ".tip"); if((!help_available) && (!tip_available)) return false; if(helpCondition()) { if(!help_available) return false; String s = localize(helpTranslationKey + ".help"); if(s.isEmpty()) return false; - tooltip.add(new StringTextComponent(s)); + tooltip.add(new StringTextComponent(s)); // @todo: check how to optimise that (to use TranslationTextComponent directly without compat losses) return true; } else if(extendedTipCondition()) { if(!tip_available) return false; @@ -214,8 +201,8 @@ public class ModAuxiliaries return true; } else if(addAdvancedTooltipHints) { String s = ""; - if(tip_available) s += localize(MODID + ".tooltip.hint.extended") + (help_available ? " " : ""); - if(help_available) s += localize(MODID + ".tooltip.hint.help"); + if(tip_available) s += localize(modid + ".tooltip.hint.extended") + (help_available ? " " : ""); + if(help_available) s += localize(modid + ".tooltip.hint.help"); tooltip.add(new StringTextComponent(s)); } return false; @@ -238,14 +225,44 @@ public class ModAuxiliaries if(!s.isEmpty()) player.sendMessage(new TranslationTextComponent(s)); } + // ------------------------------------------------------------------------------------------------------------------- + // Block handling + // ------------------------------------------------------------------------------------------------------------------- + + public static final AxisAlignedBB getPixeledAABB(double x0, double y0, double z0, double x1, double y1, double z1) + { return new AxisAlignedBB(x0/16.0, y0/16.0, z0/16.0, x1/16.0, y1/16.0, z1/16.0); } + + public static final AxisAlignedBB getRotatedAABB(AxisAlignedBB bb, Direction new_facing, boolean horizontal_rotation) + { + if(!horizontal_rotation) { + switch(new_facing.getIndex()) { + case 0: return new AxisAlignedBB(1-bb.maxX, bb.minZ, bb.minY, 1-bb.minX, bb.maxZ, bb.maxY); // D + case 1: return new AxisAlignedBB(1-bb.maxX, 1-bb.maxZ, 1-bb.maxY, 1-bb.minX, 1-bb.minZ, 1-bb.minY); // U + case 2: return new AxisAlignedBB( bb.minX, bb.minY, bb.minZ, bb.maxX, bb.maxY, bb.maxZ); // N --> bb + case 3: return new AxisAlignedBB(1-bb.maxX, bb.minY, 1-bb.maxZ, 1-bb.minX, bb.maxY, 1-bb.minZ); // S + case 4: return new AxisAlignedBB( bb.minZ, bb.minY, 1-bb.maxX, bb.maxZ, bb.maxY, 1-bb.minX); // W + case 5: return new AxisAlignedBB(1-bb.maxZ, bb.minY, bb.minX, 1-bb.minZ, bb.maxY, bb.maxX); // E + } + } else { + switch(new_facing.getIndex()) { + case 0: return new AxisAlignedBB( bb.minX, bb.minY, bb.minZ, bb.maxX, bb.maxY, bb.maxZ); // D --> bb + case 1: return new AxisAlignedBB( bb.minX, bb.minY, bb.minZ, bb.maxX, bb.maxY, bb.maxZ); // U --> bb + case 2: return new AxisAlignedBB( bb.minX, bb.minY, bb.minZ, bb.maxX, bb.maxY, bb.maxZ); // N --> bb + case 3: return new AxisAlignedBB(1-bb.maxX, bb.minY, 1-bb.maxZ, 1-bb.minX, bb.maxY, 1-bb.minZ); // S + case 4: return new AxisAlignedBB( bb.minZ, bb.minY, 1-bb.maxX, bb.maxZ, bb.maxY, 1-bb.minX); // W + case 5: return new AxisAlignedBB(1-bb.maxZ, bb.minY, bb.minX, 1-bb.minZ, bb.maxY, bb.maxX); // E + } + } + return bb; + } + // ------------------------------------------------------------------------------------------------------------------- // JAR resource related // ------------------------------------------------------------------------------------------------------------------- - public static String loadResourceText(String path) + public static String loadResourceText(InputStream is) { try { - InputStream is = ModAuxiliaries.class.getResourceAsStream(path); if(is==null) return ""; BufferedReader br = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8)); return br.lines().collect(Collectors.joining("\n")); @@ -254,15 +271,17 @@ public class ModAuxiliaries } } + public static String loadResourceText(String path) + { return loadResourceText(Auxiliaries.class.getResourceAsStream(path)); } + public static void logGitVersion(String mod_name) { try { // Done during construction to have an exact version in case of a crash while registering. - String version = ModAuxiliaries.loadResourceText("/.gitversion-" + MODID).trim(); + String version = Auxiliaries.loadResourceText("/.gitversion-" + modid).trim(); logInfo(mod_name+((version.isEmpty())?(" (dev build)"):(" GIT id #"+version)) + "."); } catch(Throwable e) { // (void)e; well, then not. Priority is not to get unneeded crashes because of version logging. } } - } diff --git a/1.15/src/main/java/wile/engineersdecor/detail/Networking.java b/1.15/src/main/java/wile/engineersdecor/libmc/detail/Networking.java similarity index 94% rename from 1.15/src/main/java/wile/engineersdecor/detail/Networking.java rename to 1.15/src/main/java/wile/engineersdecor/libmc/detail/Networking.java index 6e465d2..1744cee 100644 --- a/1.15/src/main/java/wile/engineersdecor/detail/Networking.java +++ b/1.15/src/main/java/wile/engineersdecor/libmc/detail/Networking.java @@ -6,9 +6,8 @@ * * Main client/server message handling. */ -package wile.engineersdecor.detail; +package wile.engineersdecor.libmc.detail; -import wile.engineersdecor.ModEngineersDecor; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.fml.network.NetworkEvent; @@ -29,14 +28,14 @@ import java.util.function.Supplier; public class Networking { private static final String PROTOCOL = "1"; + private static SimpleChannel DEFAULT_CHANNEL; - private static final SimpleChannel DEFAULT_CHANNEL = NetworkRegistry.ChannelBuilder - .named(new ResourceLocation(ModEngineersDecor.MODID, "default_ch")) - .clientAcceptedVersions(PROTOCOL::equals).serverAcceptedVersions(PROTOCOL::equals).networkProtocolVersion(() -> PROTOCOL) - .simpleChannel(); - - public static void init() + public static void init(String modid) { + DEFAULT_CHANNEL = NetworkRegistry.ChannelBuilder + .named(new ResourceLocation(modid, "default_ch")) + .clientAcceptedVersions(PROTOCOL::equals).serverAcceptedVersions(PROTOCOL::equals).networkProtocolVersion(() -> PROTOCOL) + .simpleChannel(); int discr = -1; DEFAULT_CHANNEL.registerMessage(++discr, PacketTileNotifyClientToServer.class, PacketTileNotifyClientToServer::compose, PacketTileNotifyClientToServer::parse, PacketTileNotifyClientToServer.Handler::handle); DEFAULT_CHANNEL.registerMessage(++discr, PacketTileNotifyServerToClient.class, PacketTileNotifyServerToClient::compose, PacketTileNotifyServerToClient::parse, PacketTileNotifyServerToClient.Handler::handle); @@ -128,7 +127,7 @@ public class Networking public static void handle(final PacketTileNotifyServerToClient pkt, final Supplier ctx) { ctx.get().enqueueWork(() -> { - World world = ModEngineersDecor.proxy.getWorldClientSide(); + World world = SidedProxy.getWorldClientSide(); if(world == null) return; final TileEntity te = world.getTileEntity(pkt.pos); if(!(te instanceof IPacketTileNotifyReceiver)) return; @@ -230,7 +229,7 @@ public class Networking public static void handle(final PacketContainerSyncServerToClient pkt, final Supplier ctx) { ctx.get().enqueueWork(() -> { - PlayerEntity player = ModEngineersDecor.proxy.getPlayerClientSide(); + PlayerEntity player = SidedProxy.getPlayerClientSide(); if(!(player.openContainer instanceof INetworkSynchronisableContainer)) return; if(player.openContainer.windowId != pkt.id) return; ((INetworkSynchronisableContainer)player.openContainer).onServerPacketReceived(pkt.id,pkt.nbt); diff --git a/1.15/src/main/java/wile/engineersdecor/detail/OptionalRecipeCondition.java b/1.15/src/main/java/wile/engineersdecor/libmc/detail/OptionalRecipeCondition.java similarity index 53% rename from 1.15/src/main/java/wile/engineersdecor/detail/OptionalRecipeCondition.java rename to 1.15/src/main/java/wile/engineersdecor/libmc/detail/OptionalRecipeCondition.java index 66ec968..b69791b 100644 --- a/1.15/src/main/java/wile/engineersdecor/detail/OptionalRecipeCondition.java +++ b/1.15/src/main/java/wile/engineersdecor/libmc/detail/OptionalRecipeCondition.java @@ -6,11 +6,11 @@ * * Recipe condition to enable opt'ing out JSON based recipes. */ -package wile.engineersdecor.detail; +package wile.engineersdecor.libmc.detail; -import wile.engineersdecor.ModEngineersDecor; import net.minecraft.block.Block; import net.minecraft.item.Item; +import net.minecraft.tags.ItemTags; import net.minecraft.util.ResourceLocation; import net.minecraft.util.JSONUtils; import net.minecraftforge.common.crafting.conditions.ICondition; @@ -20,22 +20,58 @@ import net.minecraftforge.registries.ForgeRegistries; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; +import org.apache.logging.log4j.Logger; + import javax.annotation.Nullable; import java.util.ArrayList; import java.util.List; +import java.util.function.Predicate; public class OptionalRecipeCondition implements ICondition { - private static final ResourceLocation NAME = new ResourceLocation(ModEngineersDecor.MODID, "optional"); + private static ResourceLocation NAME; + private static Logger LOGGER; private final List all_required; private final List any_missing; + private final List all_required_tags; + private final List any_missing_tags; private final @Nullable ResourceLocation result; private final boolean experimental; - public OptionalRecipeCondition(ResourceLocation result, List required, List missing, boolean isexperimental) - { all_required = required; any_missing = missing; this.result = result; experimental=isexperimental; } + private static boolean with_experimental = false; + private static boolean without_recipes = false; + private static Predicate block_optouts = (block)->false; + private static Predicate item_optouts = (item)->false; + + + public static void init(String modid, Logger logger) + { + NAME = new ResourceLocation(modid, "optional"); + LOGGER = logger; + } + + public static void on_config(boolean enable_experimental, boolean disable_all_recipes, + Predicate block_optout_provider, + Predicate item_optout_provider) + { + with_experimental = enable_experimental; + without_recipes = disable_all_recipes; + block_optouts = block_optout_provider; + item_optouts = item_optout_provider; + } + + + public OptionalRecipeCondition(ResourceLocation result, List required, List missing, List required_tags, List missing_tags, boolean isexperimental) + { + all_required = required; + any_missing = missing; + all_required_tags = required_tags; + any_missing_tags = missing_tags; + this.result = result; + experimental=isexperimental; + } @Override public ResourceLocation getID() @@ -47,8 +83,10 @@ public class OptionalRecipeCondition implements ICondition StringBuilder sb = new StringBuilder(); sb.append("Optional recipe, all-required: ["); for(ResourceLocation e:all_required) sb.append(e.toString()).append(","); + for(ResourceLocation e:all_required_tags) sb.append("#").append(e.toString()).append(","); sb.delete(sb.length()-1, sb.length()).append("], any-missing: ["); for(ResourceLocation e:any_missing) sb.append(e.toString()).append(","); + for(ResourceLocation e:any_missing_tags) sb.append("#").append(e.toString()).append(","); sb.delete(sb.length()-1, sb.length()).append("]"); if(experimental) sb.append(" EXPERIMENTAL"); return sb.toString(); @@ -57,34 +95,41 @@ public class OptionalRecipeCondition implements ICondition @Override public boolean test() { - if(ModConfig.withoutRecipes()) return false; - if((experimental) && (!ModConfig.withExperimental())) return false; - final IForgeRegistry block_registry = ForgeRegistries.BLOCKS; + if(without_recipes) return false; + if((experimental) && (!with_experimental)) return false; final IForgeRegistry item_registry = ForgeRegistries.ITEMS; if(result != null) { boolean item_registered = item_registry.containsKey(result); - boolean block_registered = block_registry.containsKey(result); - if((!block_registered) && (!item_registered)) return false; // required result not registered - if(item_registered && ModConfig.isOptedOut(item_registry.getValue(result))) return false; - if(block_registered && ModConfig.isOptedOut(block_registry.getValue(result))) return false; + if(!item_registered) return false; // required result not registered + if(item_registered && item_optouts.test(item_registry.getValue(result))) return false; + if(ForgeRegistries.BLOCKS.containsKey(result) && block_optouts.test(ForgeRegistries.BLOCKS.getValue(result))) return false; } if(!all_required.isEmpty()) { for(ResourceLocation rl:all_required) { - if((!block_registry.containsKey(rl)) && (!item_registry.containsKey(rl))) return false; + if(!item_registry.containsKey(rl)) return false; + } + } + if(!all_required_tags.isEmpty()) { + for(ResourceLocation rl:all_required_tags) { + if(!ItemTags.getCollection().getTagMap().containsKey(rl)) return false; } } if(!any_missing.isEmpty()) { for(ResourceLocation rl:any_missing) { - // At least one item missing, enable this recipe as alternative recipe for another one that check the missing item as required item. - // --> e.g. if IE not installed there is no slag. One recipe requires slag, and another one (for the same result) is used if there - // is no slag. - if((!block_registry.containsKey(rl)) && (!item_registry.containsKey(rl))) return true; + if(!item_registry.containsKey(rl)) return true; + } + return false; + } + if(!any_missing_tags.isEmpty()) { + for(ResourceLocation rl:any_missing_tags) { + if(!ItemTags.getCollection().getTagMap().containsKey(rl)) return true; } return false; } return true; } + public static class Serializer implements IConditionSerializer { public static final Serializer INSTANCE = new Serializer(); @@ -110,17 +155,33 @@ public class OptionalRecipeCondition implements ICondition { List required = new ArrayList<>(); List missing = new ArrayList<>(); + List required_tags = new ArrayList<>(); + List missing_tags = new ArrayList<>(); ResourceLocation result = null; boolean experimental = false; if(json.has("result")) result = new ResourceLocation(json.get("result").getAsString()); if(json.has("required")) { - for(JsonElement e:JSONUtils.getJsonArray(json, "required")) required.add(new ResourceLocation(e.getAsString())); + for(JsonElement e:JSONUtils.getJsonArray(json, "required")) { + String s = e.getAsString(); + if(s.startsWith("#")) { + required_tags.add(new ResourceLocation(s.substring(1))); + } else { + required.add(new ResourceLocation(s)); + } + } } if(json.has("missing")) { - for(JsonElement e:JSONUtils.getJsonArray(json, "missing")) missing.add(new ResourceLocation(e.getAsString())); + for(JsonElement e:JSONUtils.getJsonArray(json, "missing")) { + String s = e.getAsString(); + if(s.startsWith("#")) { + missing_tags.add(new ResourceLocation(s.substring(1))); + } else { + missing.add(new ResourceLocation(s)); + } + } } if(json.has("experimental")) experimental = json.get("experimental").getAsBoolean(); - return new OptionalRecipeCondition(result, required, missing, experimental); + return new OptionalRecipeCondition(result, required, missing, required_tags, missing_tags, experimental); } } } diff --git a/1.15/src/main/java/wile/engineersdecor/libmc/detail/SidedProxy.java b/1.15/src/main/java/wile/engineersdecor/libmc/detail/SidedProxy.java new file mode 100644 index 0000000..cc99a9c --- /dev/null +++ b/1.15/src/main/java/wile/engineersdecor/libmc/detail/SidedProxy.java @@ -0,0 +1,58 @@ +package wile.engineersdecor.libmc.detail; + +import net.minecraft.client.Minecraft; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.World; +import net.minecraftforge.fml.DistExecutor; +import javax.annotation.Nullable; +import java.util.Optional; + +public class SidedProxy +{ + @Nullable + public static PlayerEntity getPlayerClientSide() + { return proxy.getPlayerClientSide(); } + + @Nullable + public static World getWorldClientSide() + { return proxy.getWorldClientSide(); } + + @Nullable + public static Minecraft mc() + { return proxy.mc(); } + + @Nullable + public static Optional isCtrlDown() + { return proxy.isCtrlDown(); } + + @Nullable + public static Optional isShiftDown() + { return proxy.isShiftDown(); } + + // -------------------------------------------------------------------------------------------------------- + + private static ISidedProxy proxy = DistExecutor.runForDist(()->ClientProxy::new, ()->ServerProxy::new); + + private interface ISidedProxy + { + default @Nullable PlayerEntity getPlayerClientSide() { return null; } + default @Nullable World getWorldClientSide() { return null; } + default @Nullable Minecraft mc() { return null; } + default Optional isCtrlDown() { return Optional.empty(); } + default Optional isShiftDown() { return Optional.empty(); } + } + + private static final class ClientProxy implements ISidedProxy + { + public @Nullable PlayerEntity getPlayerClientSide() { return Minecraft.getInstance().player; } + public @Nullable World getWorldClientSide() { return Minecraft.getInstance().world; } + public @Nullable Minecraft mc() { return Minecraft.getInstance(); } + public Optional isCtrlDown() { return Optional.of(Auxiliaries.isCtrlDown()); } + public Optional isShiftDown() { return Optional.of(Auxiliaries.isShiftDown()); } + } + + private static final class ServerProxy implements ISidedProxy + { + } + +} \ No newline at end of file diff --git a/1.15/src/main/resources/assets/engineersdecor/blockstates/small_electrical_furnace.json b/1.15/src/main/resources/assets/engineersdecor/blockstates/small_electrical_furnace.json index 5759f7b..8286de3 100644 --- a/1.15/src/main/resources/assets/engineersdecor/blockstates/small_electrical_furnace.json +++ b/1.15/src/main/resources/assets/engineersdecor/blockstates/small_electrical_furnace.json @@ -4,13 +4,9 @@ "facing=south,lit=false": { "model": "engineersdecor:block/furnace/small_electrical_furnace_model", "y": 180 }, "facing=west,lit=false": { "model": "engineersdecor:block/furnace/small_electrical_furnace_model", "y": 270 }, "facing=east,lit=false": { "model": "engineersdecor:block/furnace/small_electrical_furnace_model", "y": 90 }, - "facing=up,lit=false": { "model": "engineersdecor:block/furnace/small_electrical_furnace_model", "y": 0 }, - "facing=down,lit=false": { "model": "engineersdecor:block/furnace/small_electrical_furnace_model", "y": 0 }, "facing=north,lit=true": { "model": "engineersdecor:block/furnace/small_electrical_furnace_model_lit", "y": 0 }, "facing=south,lit=true": { "model": "engineersdecor:block/furnace/small_electrical_furnace_model_lit", "y": 180 }, "facing=west,lit=true": { "model": "engineersdecor:block/furnace/small_electrical_furnace_model_lit", "y": 270 }, - "facing=east,lit=true": { "model": "engineersdecor:block/furnace/small_electrical_furnace_model_lit", "y": 90 }, - "facing=up,lit=true": { "model": "engineersdecor:block/furnace/small_electrical_furnace_model_lit", "y": 0 }, - "facing=down,lit=true": { "model": "engineersdecor:block/furnace/small_electrical_furnace_model_lit", "y": 0 } + "facing=east,lit=true": { "model": "engineersdecor:block/furnace/small_electrical_furnace_model_lit", "y": 90 } } } diff --git a/1.15/src/main/resources/assets/engineersdecor/blockstates/small_lab_furnace.json b/1.15/src/main/resources/assets/engineersdecor/blockstates/small_lab_furnace.json index b330c50..9eaa12d 100644 --- a/1.15/src/main/resources/assets/engineersdecor/blockstates/small_lab_furnace.json +++ b/1.15/src/main/resources/assets/engineersdecor/blockstates/small_lab_furnace.json @@ -4,13 +4,9 @@ "facing=south,lit=false": { "model": "engineersdecor:block/furnace/small_lab_furnace_model", "y": 180 }, "facing=west,lit=false": { "model": "engineersdecor:block/furnace/small_lab_furnace_model", "y": 270 }, "facing=east,lit=false": { "model": "engineersdecor:block/furnace/small_lab_furnace_model", "y": 90 }, - "facing=up,lit=false": { "model": "engineersdecor:block/furnace/small_lab_furnace_model", "y": 0 }, - "facing=down,lit=false": { "model": "engineersdecor:block/furnace/small_lab_furnace_model", "y": 0 }, "facing=north,lit=true": { "model": "engineersdecor:block/furnace/small_lab_furnace_model_lit", "y": 0 }, "facing=south,lit=true": { "model": "engineersdecor:block/furnace/small_lab_furnace_model_lit", "y": 180 }, "facing=west,lit=true": { "model": "engineersdecor:block/furnace/small_lab_furnace_model_lit", "y": 270 }, - "facing=east,lit=true": { "model": "engineersdecor:block/furnace/small_lab_furnace_model_lit", "y": 90 }, - "facing=up,lit=true": { "model": "engineersdecor:block/furnace/small_lab_furnace_model", "y": 0 }, - "facing=down,lit=true": { "model": "engineersdecor:block/furnace/small_lab_furnace_model", "y": 0 } + "facing=east,lit=true": { "model": "engineersdecor:block/furnace/small_lab_furnace_model_lit", "y": 90 } } } diff --git a/1.15/src/main/resources/assets/engineersdecor/blockstates/treated_wood_crafting_table.json b/1.15/src/main/resources/assets/engineersdecor/blockstates/treated_wood_crafting_table.json index d6f3f9c..82a14e4 100644 --- a/1.15/src/main/resources/assets/engineersdecor/blockstates/treated_wood_crafting_table.json +++ b/1.15/src/main/resources/assets/engineersdecor/blockstates/treated_wood_crafting_table.json @@ -3,8 +3,6 @@ "facing=north": { "model": "engineersdecor:block/crafting_table/treated_wood_crafting_table_model" }, "facing=south": { "model": "engineersdecor:block/crafting_table/treated_wood_crafting_table_model", "y":180 }, "facing=west": { "model": "engineersdecor:block/crafting_table/treated_wood_crafting_table_model", "y":270 }, - "facing=east": { "model": "engineersdecor:block/crafting_table/treated_wood_crafting_table_model", "y":90 }, - "facing=up": { "model": "engineersdecor:block/crafting_table/treated_wood_crafting_table_model" }, - "facing=down": { "model": "engineersdecor:block/crafting_table/treated_wood_crafting_table_model" } + "facing=east": { "model": "engineersdecor:block/crafting_table/treated_wood_crafting_table_model", "y":90 } } } \ No newline at end of file diff --git a/1.15/src/main/resources/assets/engineersdecor/models/block/furniture/steel_floor_grating_model.json b/1.15/src/main/resources/assets/engineersdecor/models/block/furniture/steel_floor_grating_model.json index d6d598d..c0dec34 100644 --- a/1.15/src/main/resources/assets/engineersdecor/models/block/furniture/steel_floor_grating_model.json +++ b/1.15/src/main/resources/assets/engineersdecor/models/block/furniture/steel_floor_grating_model.json @@ -173,15 +173,28 @@ } ], "display": { + "thirdperson_righthand": { + "rotation": [66, 0, 0], + "translation": [0.25, 0, -2.75], + "scale": [0.3, 0.3, 0.3] + }, + "firstperson_righthand": { + "rotation": [-4, -1, 58], + "translation": [2.5, 0.25, 1.75], + "scale": [0.3, 0.3, 0.3] + }, "ground": { - "translation": [0, 1.75, 0], + "translation": [0, 1.75, 0], "scale": [0.2, 0.2, 0.2] }, "gui": { "rotation": [30, 225, 0], + "translation": [0, -2, 0], "scale": [0.625, 0.625, 0.625] }, "fixed": { + "rotation": [-90, 0, 1], + "translation": [0, 0.25, 3.25], "scale": [0.5, 0.5, 0.5] } } diff --git a/1.15/src/main/resources/data/engineersdecor/recipes/testing/collision_test1_diorite.json b/1.15/src/main/resources/data/engineersdecor/recipes/testing/collision_test1_diorite.json deleted file mode 100644 index 138ffb8..0000000 --- a/1.15/src/main/resources/data/engineersdecor/recipes/testing/collision_test1_diorite.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "conditions": [ - { - "type": "engineersdecor:optional", - "experimental": true - } - ], - "type": "minecraft:crafting_shaped", - "pattern": [ - "DDD", - " D ", - " D " - ], - "key": { - "D": { "item": "minecraft:diorite" } - }, - "result": { - "item": "minecraft:stone", - "count": 1 - } -} diff --git a/1.15/src/main/resources/data/engineersdecor/recipes/testing/collision_test2_diorite.json b/1.15/src/main/resources/data/engineersdecor/recipes/testing/collision_test2_diorite.json deleted file mode 100644 index a2ba7c7..0000000 --- a/1.15/src/main/resources/data/engineersdecor/recipes/testing/collision_test2_diorite.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "conditions": [ - { - "type": "engineersdecor:optional", - "experimental": true - } - ], - "type": "minecraft:crafting_shaped", - "pattern": [ - "DDD", - " D ", - " D " - ], - "key": { - "D": { "item": "minecraft:diorite" } - }, - "result": { - "item": "minecraft:granite", - "count": 1 - } -} diff --git a/1.15/src/main/resources/data/engineersdecor/recipes/testing/collision_test3_diorite.json b/1.15/src/main/resources/data/engineersdecor/recipes/testing/collision_test3_diorite.json deleted file mode 100644 index a8cc4b3..0000000 --- a/1.15/src/main/resources/data/engineersdecor/recipes/testing/collision_test3_diorite.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "conditions": [ - { - "type": "engineersdecor:optional", - "experimental": true - } - ], - "type": "minecraft:crafting_shaped", - "pattern": [ - "DDD", - " D ", - " D " - ], - "key": { - "D": { "item": "minecraft:diorite" } - }, - "result": { - "item": "minecraft:andesite", - "count": 1 - } -} diff --git a/meta/update.json b/meta/update.json index 21c45a4..ad34133 100644 --- a/meta/update.json +++ b/meta/update.json @@ -2,13 +2,14 @@ "homepage": "https://www.curseforge.com/minecraft/mc-mods/engineers-decor/", "promos": { "1.12.2-recommended": "1.0.18", - "1.12.2-latest": "1.0.19-b1", + "1.12.2-latest": "1.0.19-b2", "1.14.4-recommended": "", - "1.14.4-latest": "1.0.19-b1", + "1.14.4-latest": "1.0.19-b2", "1.15.2-recommended": "", - "1.15.2-latest": "1.0.19-b1" + "1.15.2-latest": "1.0.19-b2" }, "1.12.2": { + "1.0.19-b2": "[F] Fixed Floor Grating item pass-through jitters (thx Cid).\n[M] Removed obsolete recipe collision testing recipes.", "1.0.19-b1": "[F] Fixed Tree Cutter / Block Breaker not accepting small energy transfers (thx WindFox, issue #82).", "1.0.18": "[R] Release based on v1.0.18-b2. Release-to-release changes: * Tree cutter config fixes. * Treated Wood Crafting Table mouse tweaks. * Lang updates.\n[M] Lang update ru_ru (PR#77, thanks Smollet777).", "1.0.18-b2": "[A] Added Treated Wood Crafting table tweaks (ctrl-shift moves all same stacks from the inventory, mouse wheel over crafting slot increases/decreases crafting grid stacks).\n[F] EN Lang file fixed (issue #76, thx Riverstar907).\n[F] Fixed Tree Cutter not respecting power-required config (thx federsavo, issue #77).", @@ -85,6 +86,7 @@ "1.0.0-b1": "[A] Initial structure.\n[A] Added clinker bricks and clinker brick stairs.\n[A] Added slag bricks and slag brick stairs.\n[A] Added metal rung ladder.\n[A] Added staggered metal steps ladder.\n[A] Added treated wood ladder.\n[A] Added treated wood pole.\n[A] Added treated wood table." }, "1.14.4": { + "1.0.19-b2": "[F] Fixed Floor Grating item pass-through jitters (thx Cid).\n[M] Removed obsolete recipe collision testing recipes.\n[F] Fixed missing Block Breaker dynamic block drops.\n[F] Block Placer planting race condition issue fixed (issue #83, thx jcardii).\n[F] Factory Hopper: Added second standard insertion after smart-insert to circumcent compat issues (issue #84, thx NillerMedDild).", "1.0.19-b1": "[F] Fixed Tree Cutter / Block Breaker not accepting small energy transfers (thx WindFox, issue #82).", "1.0.18-b4": "[M] Lang update ru_ru (PR#77, thanks Smollet777).\n[F] Fixed Milking machine cow path issue, added milking delay cow tracking.\n[F] Slab / Slab Slice placement adapted to vanilla standard.", "1.0.18-b3": "[A] Added Treated Wood Crafting table tweaks (ctrl-shift moves all same stacks from the inventory, mouse wheel over crafting slot increases/decreases crafting grid stacks).\n[F] EN Lang file fixed (issue #76, thx Riverstar907).\n[F] Fixed Tree Cutter not respecting power-required config (thx federsavo, issue #77).\n[F] Fixed Small Solar Panel not exposing energy capability (thx MatthiasMann, issue #78).", @@ -128,6 +130,7 @@ "1.0.7-b3": "[A] Initial 1.14.2 port of decorative blocks." }, "1.15.2": { + "1.0.19-b2": "[F] Fixed Floor Grating item pass-through jitters (thx Cid).\n[M] Removed obsolete recipe collision testing recipes.\n[F] Fixed missing Block Breaker dynamic block drops.\n[F] Block Placer planting race condition issue fixed (issue #83, thx jcardii).\n[F] Factory Hopper: Added second standard insertion run after smart-insert to circumcent compat issues (issue #84, thx NillerMedDild).\n[A] Enabled JEI plugin (issue #85, thx ProsperCraft/Goshen).", "1.0.19-b1": "[U] Update to 1.15.2.\n[F] Fixed Tree Cutter / Block Breaker not accepting small energy transfers (thx WindFox, issue #82).", "1.0.18-b4": "[A] Ported Treated Wood Crafting Table item rendering.\n[F] Fixed Milking machine cow path issue, added milking delay cow tracking.\n[F] Slab / Slab Slice placement adapted to vanilla standard.\n[M] Lang update ru_ru (PR#77, thanks Smollet777).", "1.0.18-b3": "[A] Added Treated Wood Crafting Table tweaks (ctrl-shift moves all same stacks from the inventory, mouse wheel over crafting slot increases/decreases crafting grid stacks).\n[F] EN Lang file fixed (issue #76, thx Riverstar907).\n[F] Fixed Tree Cutter not respecting power-required config (thx federsavo, issue #77).\n[F] Fixed Small Solar Panel not exposing energy capability (thx MatthiasMann, issue #78).",