From 82c24848729237996efaf0ad20941fbb42dc067e Mon Sep 17 00:00:00 2001 From: stfwi Date: Sun, 2 Jan 2022 20:10:56 +0100 Subject: [PATCH] Block entity parent saving corrected. Forge/gradle update. Fixed waterlogging. --- .gitignore | 1 + Makefile | 1 + build.gradle | 46 ++- gradle.properties | 4 +- gradle/wrapper/gradle-wrapper.properties | 2 +- meta/update.json | 5 +- readme.md | 6 +- .../wile/engineersdecor/blocks/EdBreaker.java | 6 +- .../blocks/EdCraftingTable.java | 6 +- .../wile/engineersdecor/blocks/EdDropper.java | 6 +- .../blocks/EdElectricalFurnace.java | 6 +- .../engineersdecor/blocks/EdFluidBarrel.java | 8 +- .../engineersdecor/blocks/EdFluidFunnel.java | 6 +- .../wile/engineersdecor/blocks/EdFreezer.java | 6 +- .../wile/engineersdecor/blocks/EdFurnace.java | 6 +- .../engineersdecor/blocks/EdHatchBlock.java | 23 +- .../wile/engineersdecor/blocks/EdHopper.java | 6 +- .../engineersdecor/blocks/EdLabeledCrate.java | 6 +- .../wile/engineersdecor/blocks/EdMilker.java | 9 +- .../blocks/EdMineralSmelter.java | 6 +- .../engineersdecor/blocks/EdPipeValve.java | 4 + .../wile/engineersdecor/blocks/EdPlacer.java | 6 +- .../engineersdecor/blocks/EdSolarPanel.java | 6 +- .../engineersdecor/blocks/EdTestBlock.java | 6 +- .../engineersdecor/blocks/EdTreeCutter.java | 8 +- .../blocks/EdWasteIncinerator.java | 6 +- .../libmc/blocks/StandardBlocks.java | 268 +++++++++++++----- .../libmc/blocks/StandardEntityBlocks.java | 31 +- .../libmc/detail/Auxiliaries.java | 9 +- 29 files changed, 370 insertions(+), 139 deletions(-) diff --git a/.gitignore b/.gitignore index 2041e76..47856ec 100644 --- a/.gitignore +++ b/.gitignore @@ -43,3 +43,4 @@ signing.* tests Thumbs.db tmp +todo.* diff --git a/Makefile b/Makefile index fe9c06e..c11d4f9 100644 --- a/Makefile +++ b/Makefile @@ -72,6 +72,7 @@ mrproper: clean-all init: @echo "[1.18] Initialising eclipse workspace using gradle ..." @$(GRADLE) eclipse + -@$(GRADLE) hideOfficialWarningUntilChanged sanitize: @echo "[1.18] Running sanitising tasks ..." diff --git a/build.gradle b/build.gradle index 6a1f058..fb23806 100644 --- a/build.gradle +++ b/build.gradle @@ -2,18 +2,17 @@ // Engineer's decor mod gradle build. buildscript { repositories { - maven { url = 'https://maven.minecraftforge.net' } - mavenCentral() + maven { url = 'https://maven.minecraftforge.net' } + mavenCentral() } dependencies { - classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true + classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true } } apply plugin: 'net.minecraftforge.gradle' apply plugin: 'eclipse' apply plugin: 'maven-publish' java.toolchain.languageVersion = JavaLanguageVersion.of(17) -println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch')) //----------------------------------------------------------------------------- version = "${version_engineersdecor}" group = "wile.engineersdecor" @@ -68,27 +67,22 @@ jar { } jar.finalizedBy('reobfJar') -// def reobfFile = file("$buildDir/reobfJar/output.jar") -// def reobfArtifact = artifacts.add('default', reobfFile) { type 'jar'; builtBy 'reobfJar' } - -//import net.minecraftforge.gradle.common.task.SignJar -// task signJar(type: SignJar, dependsOn: jar) { -// onlyIf { project.hasProperty("keystore_file") } -// if(project.hasProperty("keystore_file")) { -// keyStore = project.getProperty("keystore_file") -// alias = project.getProperty("keystore_alias") -// storePass = project.getProperty("keystore_pass") -// keyPass = project.getProperty("keystore_keypass") -// inputFile = jar.archivePath -// outputFile = jar.archivePath -// } else { -// logger.warn("[WARNING] Signing skipped.") -// } -// } -// build.dependsOn signJar - -publishing { - publications { mavenJava(MavenPublication) { artifact jar } } - repositories { maven { url "file:///${project.projectDir}/mcmodsrepo" } } +// Signing +import net.minecraftforge.gradle.common.tasks.SignJar +project.afterEvaluate { + task signJar(type: SignJar, dependsOn: jar) { + onlyIf { project.hasProperty("keystore_file") } + if(project.hasProperty("keystore_file")) { + keyStore = project.getProperty("keystore_file") + alias = project.getProperty("keystore_alias") + storePass = project.getProperty("keystore_pass") + keyPass = project.getProperty("keystore_keypass") + inputFile = jar.archiveFile + outputFile = jar.archiveFile + } else { + logger.warn("[WARNING] Signing skipped.") + } + } + reobfJar.finalizedBy('signJar') } diff --git a/gradle.properties b/gradle.properties index 0b7a3b0..45da38e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,5 +3,5 @@ org.gradle.daemon=false org.gradle.jvmargs=-Xmx8G version_minecraft=1.18.1 version_forge_minecraft=1.18.1-39.0.5 -version_jei=1.18.1:9.1.2.50 -version_engineersdecor=1.1.19-b1 +version_jei=1.18.1:9.1.2.54 +version_engineersdecor=1.1.19-b2 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 0595cf7..e750102 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions-snapshots/gradle-7.2-20210702220150+0000-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/meta/update.json b/meta/update.json index fda01fb..e42459a 100644 --- a/meta/update.json +++ b/meta/update.json @@ -1,7 +1,8 @@ { "homepage": "https://www.curseforge.com/minecraft/mc-mods/engineers-decor/", "1.18.1": { - "1.1.19-b1": "[R] Initial 1.18.1 port.", + "1.1.19-b2": "[F] Fixed waterlogging.\n[F] Block entity parent saving corrected, ticker unified.\n[U] Forge/gradle update.", + "1.1.19-b1": "[U] Initial 1.18.1 port.", "1.1.18": "[F] Block Placer placement context issue fix.\n[F] Fixed compatibility to Forge >=37.0.82.\n[M] Update lang ru_ru (PR#191, Smollet777).", "1.1.17": "[R] Initial 1.17.1 release.", "1.1.17-b5": "[F] Refurbished Mineral Melter code.\n[F] Fixed Block Placer item insertion.", @@ -48,6 +49,6 @@ }, "promos": { "1.18.1-recommended": "1.1.18", - "1.18.1-latest": "1.1.19-b1" + "1.18.1-latest": "1.1.19-b2" } } \ No newline at end of file diff --git a/readme.md b/readme.md index 5bf3d99..31cf0e1 100644 --- a/readme.md +++ b/readme.md @@ -11,7 +11,11 @@ Mod sources for Minecraft version 1.18.x. ## Version history - - v1.1.19-b1 [R] Initial 1.18.1 port. + - v1.1.19-b2 [F] Fixed waterlogging. + [F] Block entity parent saving corrected, ticker unified. + [U] Forge/gradle update. + + - v1.1.19-b1 [U] Initial 1.18.1 port. - v1.1.18 [F] Block Placer placement context issue fix. [F] Fixed compatibility to Forge >=37.0.82. diff --git a/src/main/java/wile/engineersdecor/blocks/EdBreaker.java b/src/main/java/wile/engineersdecor/blocks/EdBreaker.java index e31fc62..9373ca6 100644 --- a/src/main/java/wile/engineersdecor/blocks/EdBreaker.java +++ b/src/main/java/wile/engineersdecor/blocks/EdBreaker.java @@ -98,6 +98,10 @@ public class EdBreaker public BlockEntityType getBlockEntityType() { return ModContent.TET_SMALL_BLOCK_BREAKER; } + @Override + public boolean isBlockEntityTicking(Level world, BlockState state) + { return true; } + @Override protected void createBlockStateDefinition(StateDefinition.Builder builder) { super.createBlockStateDefinition(builder); builder.add(ACTIVE); } @@ -220,7 +224,7 @@ public class EdBreaker @Override protected void saveAdditional(CompoundTag nbt) - { super.save(nbt); writenbt(nbt); } + { super.saveAdditional(nbt); writenbt(nbt); } @Override public void setRemoved() diff --git a/src/main/java/wile/engineersdecor/blocks/EdCraftingTable.java b/src/main/java/wile/engineersdecor/blocks/EdCraftingTable.java index a8006a3..37f6087 100644 --- a/src/main/java/wile/engineersdecor/blocks/EdCraftingTable.java +++ b/src/main/java/wile/engineersdecor/blocks/EdCraftingTable.java @@ -98,6 +98,10 @@ public class EdCraftingTable public BlockEntityType getBlockEntityType() { return ModContent.TET_CRAFTING_TABLE; } + @Override + public boolean isBlockEntityTicking(Level world, BlockState state) + { return false; } + @Override public boolean shouldCheckWeakPower(BlockState state, LevelReader world, BlockPos pos, Direction side) { return false; } @@ -211,7 +215,7 @@ public class EdCraftingTable @Override protected void saveAdditional(CompoundTag nbt) - { super.save(nbt); writenbt(nbt); } + { super.saveAdditional(nbt); writenbt(nbt); } @Override public CompoundTag getUpdateTag() diff --git a/src/main/java/wile/engineersdecor/blocks/EdDropper.java b/src/main/java/wile/engineersdecor/blocks/EdDropper.java index 2170bd4..042cb02 100644 --- a/src/main/java/wile/engineersdecor/blocks/EdDropper.java +++ b/src/main/java/wile/engineersdecor/blocks/EdDropper.java @@ -93,6 +93,10 @@ public class EdDropper public BlockEntityType getBlockEntityType() { return ModContent.TET_FACTORY_DROPPER; } + @Override + public boolean isBlockEntityTicking(Level world, BlockState state) + { return true; } + @Override public RenderTypeHint getRenderTypeHint() { return RenderTypeHint.SOLID; } @@ -294,7 +298,7 @@ public class EdDropper @Override protected void saveAdditional(CompoundTag nbt) - { super.save(nbt); writenbt(nbt, false); } + { super.saveAdditional(nbt); writenbt(nbt, false); } @Override public void setRemoved() diff --git a/src/main/java/wile/engineersdecor/blocks/EdElectricalFurnace.java b/src/main/java/wile/engineersdecor/blocks/EdElectricalFurnace.java index 267a48d..efee0a4 100644 --- a/src/main/java/wile/engineersdecor/blocks/EdElectricalFurnace.java +++ b/src/main/java/wile/engineersdecor/blocks/EdElectricalFurnace.java @@ -96,6 +96,10 @@ public class EdElectricalFurnace public BlockEntityType getBlockEntityType() { return ModContent.TET_SMALL_ELECTRICAL_FURNACE; } + @Override + public boolean isBlockEntityTicking(Level world, BlockState state) + { return true; } + @Override public VoxelShape getCollisionShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext selectionContext) { return Shapes.block(); } @@ -338,7 +342,7 @@ public class EdElectricalFurnace @Override protected void saveAdditional(CompoundTag nbt) - { super.save(nbt); writenbt(nbt); } + { super.saveAdditional(nbt); writenbt(nbt); } @Override public void setRemoved() diff --git a/src/main/java/wile/engineersdecor/blocks/EdFluidBarrel.java b/src/main/java/wile/engineersdecor/blocks/EdFluidBarrel.java index e76fead..1e85351 100644 --- a/src/main/java/wile/engineersdecor/blocks/EdFluidBarrel.java +++ b/src/main/java/wile/engineersdecor/blocks/EdFluidBarrel.java @@ -104,6 +104,10 @@ public class EdFluidBarrel public BlockEntityType getBlockEntityType() { return ModContent.TET_FLUID_BARREL; } + @Override + public boolean isBlockEntityTicking(Level world, BlockState state) + { return true; } + @Override public BlockItem getBlockItem(Block block, Item.Properties builder) { return new FluidBarrelItem(block, builder); } @@ -272,7 +276,7 @@ public class EdFluidBarrel @Override protected void saveAdditional(CompoundTag nbt) - { super.save(nbt); writenbt(nbt); } + { super.saveAdditional(nbt); writenbt(nbt); } @Override public void setRemoved() @@ -379,7 +383,7 @@ public class EdFluidBarrel @Override public int getBarWidth(ItemStack stack) - { return Math.round(13f * ((stack.getMaxDamage()<=0) ? (1f) : Mth.clamp((float)stack.getDamageValue()/(float)stack.getMaxDamage(), 0f, 1f))); } + { return (int)Math.round(13f * Mth.clamp(((double)(getFluid(stack).getAmount()))/((double)capacity_), 0.0, 1.0)); } @Override public int getBarColor(ItemStack stack) diff --git a/src/main/java/wile/engineersdecor/blocks/EdFluidFunnel.java b/src/main/java/wile/engineersdecor/blocks/EdFluidFunnel.java index 9042cd6..c390a8b 100644 --- a/src/main/java/wile/engineersdecor/blocks/EdFluidFunnel.java +++ b/src/main/java/wile/engineersdecor/blocks/EdFluidFunnel.java @@ -82,6 +82,10 @@ public class EdFluidFunnel public BlockEntityType getBlockEntityType() { return ModContent.TET_SMALL_FLUID_FUNNEL; } + @Override + public boolean isBlockEntityTicking(Level world, BlockState state) + { return true; } + @Override public RenderTypeHint getRenderTypeHint() { return RenderTypeHint.CUTOUT; } @@ -215,7 +219,7 @@ public class EdFluidFunnel @Override protected void saveAdditional(CompoundTag nbt) - { super.save(nbt); writenbt(nbt); } + { super.saveAdditional(nbt); writenbt(nbt); } @Override public void setRemoved() diff --git a/src/main/java/wile/engineersdecor/blocks/EdFreezer.java b/src/main/java/wile/engineersdecor/blocks/EdFreezer.java index 814f572..39867cf 100644 --- a/src/main/java/wile/engineersdecor/blocks/EdFreezer.java +++ b/src/main/java/wile/engineersdecor/blocks/EdFreezer.java @@ -81,6 +81,10 @@ public class EdFreezer public BlockEntityType getBlockEntityType() { return ModContent.TET_FREEZER; } + @Override + public boolean isBlockEntityTicking(Level world, BlockState state) + { return true; } + @Override public VoxelShape getCollisionShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext selectionContext) { return Shapes.block(); } @@ -264,7 +268,7 @@ public class EdFreezer @Override protected void saveAdditional(CompoundTag nbt) - { super.save(nbt); writenbt(nbt); } + { super.saveAdditional(nbt); writenbt(nbt); } @Override public void setRemoved() diff --git a/src/main/java/wile/engineersdecor/blocks/EdFurnace.java b/src/main/java/wile/engineersdecor/blocks/EdFurnace.java index 35564a0..560a81f 100644 --- a/src/main/java/wile/engineersdecor/blocks/EdFurnace.java +++ b/src/main/java/wile/engineersdecor/blocks/EdFurnace.java @@ -94,6 +94,10 @@ public class EdFurnace public BlockEntityType getBlockEntityType() { return ModContent.TET_SMALL_LAB_FURNACE; } + @Override + public boolean isBlockEntityTicking(Level world, BlockState state) + { return true; } + @Override protected void createBlockStateDefinition(StateDefinition.Builder builder) { super.createBlockStateDefinition(builder); builder.add(LIT); } @@ -386,7 +390,7 @@ public class EdFurnace @Override protected void saveAdditional(CompoundTag nbt) - { super.save(nbt); writenbt(nbt); } + { super.saveAdditional(nbt); writenbt(nbt); } @Override public void setRemoved() diff --git a/src/main/java/wile/engineersdecor/blocks/EdHatchBlock.java b/src/main/java/wile/engineersdecor/blocks/EdHatchBlock.java index dbc8407..a76c6a0 100644 --- a/src/main/java/wile/engineersdecor/blocks/EdHatchBlock.java +++ b/src/main/java/wile/engineersdecor/blocks/EdHatchBlock.java @@ -33,11 +33,14 @@ import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; import wile.engineersdecor.libmc.blocks.StandardBlocks; +import wile.engineersdecor.libmc.detail.Auxiliaries; import javax.annotation.Nullable; import java.util.ArrayList; +import java.util.Arrays; public class EdHatchBlock extends StandardBlocks.HorizontalWaterLoggable @@ -55,6 +58,20 @@ public class EdHatchBlock extends StandardBlocks.HorizontalWaterLoggable public EdHatchBlock(long config, BlockBehaviour.Properties builder, final AABB[] unrotatedAABBsClosed, final AABB[] unrotatedAABBsOpen) { super(config, builder, unrotatedAABBsClosed); vshapes_open = makeHorizontalShapeLookup(unrotatedAABBsOpen); } + protected static ArrayList makeHorizontalShapeLookup(final AABB[] unrotatedAABBs) + { + return new ArrayList<>(Arrays.asList( + Shapes.block(), + Shapes.block(), + Auxiliaries.getUnionShape(Auxiliaries.getRotatedAABB(unrotatedAABBs, Direction.NORTH, true)), + Auxiliaries.getUnionShape(Auxiliaries.getRotatedAABB(unrotatedAABBs, Direction.SOUTH, true)), + Auxiliaries.getUnionShape(Auxiliaries.getRotatedAABB(unrotatedAABBs, Direction.WEST, true)), + Auxiliaries.getUnionShape(Auxiliaries.getRotatedAABB(unrotatedAABBs, Direction.EAST, true)), + Shapes.block(), + Shapes.block() + )); + } + @Override public RenderTypeHint getRenderTypeHint() { return RenderTypeHint.CUTOUT; } @@ -63,6 +80,10 @@ public class EdHatchBlock extends StandardBlocks.HorizontalWaterLoggable public VoxelShape getShape(BlockState state, BlockGetter source, BlockPos pos, CollisionContext selectionContext) { return state.getValue(OPEN) ? vshapes_open.get((state.getValue(HORIZONTAL_FACING)).get3DDataValue() & 0x7) : super.getShape(state, source, pos, selectionContext); } + @Override + public VoxelShape getCollisionShape(BlockState state, BlockGetter source, BlockPos pos, CollisionContext selectionContext) + { return getShape(state, source, pos, selectionContext); } + @Override public boolean propagatesSkylightDown(BlockState state, BlockGetter reader, BlockPos pos) { return state.getValue(OPEN); } @@ -135,6 +156,6 @@ public class EdHatchBlock extends StandardBlocks.HorizontalWaterLoggable Vec3 v = centre.subtract(ppos); if(ppos.y() < (centre.y()-0.1) || (v.lengthSqr() > 0.3)) return; v = v.scale(0.3); - player.push(v.x, 0, v.z); + player.push(v.x, -0.1, v.z); } } diff --git a/src/main/java/wile/engineersdecor/blocks/EdHopper.java b/src/main/java/wile/engineersdecor/blocks/EdHopper.java index 8926afd..57f1239 100644 --- a/src/main/java/wile/engineersdecor/blocks/EdHopper.java +++ b/src/main/java/wile/engineersdecor/blocks/EdHopper.java @@ -75,6 +75,10 @@ public class EdHopper public BlockEntityType getBlockEntityType() { return ModContent.TET_FACTORY_HOPPER; } + @Override + public boolean isBlockEntityTicking(Level world, BlockState state) + { return true; } + @Override public VoxelShape getCollisionShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) { return Shapes.block(); } @@ -274,7 +278,7 @@ public class EdHopper @Override protected void saveAdditional(CompoundTag nbt) - { super.save(nbt); writenbt(nbt, false); } + { super.saveAdditional(nbt); writenbt(nbt, false); } @Override public void setRemoved() diff --git a/src/main/java/wile/engineersdecor/blocks/EdLabeledCrate.java b/src/main/java/wile/engineersdecor/blocks/EdLabeledCrate.java index b369491..78a0f32 100644 --- a/src/main/java/wile/engineersdecor/blocks/EdLabeledCrate.java +++ b/src/main/java/wile/engineersdecor/blocks/EdLabeledCrate.java @@ -90,6 +90,10 @@ public class EdLabeledCrate public BlockEntityType getBlockEntityType() { return ModContent.TET_LABELED_CRATE; } + @Override + public boolean isBlockEntityTicking(Level world, BlockState state) + { return false; } + @Override @SuppressWarnings("deprecation") public boolean hasAnalogOutputSignal(BlockState state) @@ -278,7 +282,7 @@ public class EdLabeledCrate @Override protected void saveAdditional(CompoundTag nbt) - { super.save(nbt); writenbt(nbt); } + { super.saveAdditional(nbt); writenbt(nbt); } @Override public void setRemoved() diff --git a/src/main/java/wile/engineersdecor/blocks/EdMilker.java b/src/main/java/wile/engineersdecor/blocks/EdMilker.java index 0bce06c..740679d 100644 --- a/src/main/java/wile/engineersdecor/blocks/EdMilker.java +++ b/src/main/java/wile/engineersdecor/blocks/EdMilker.java @@ -42,6 +42,7 @@ import net.minecraft.world.level.material.Fluids; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.Vec3; +import net.minecraft.world.phys.shapes.Shapes; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.energy.CapabilityEnergy; import net.minecraftforge.energy.IEnergyStorage; @@ -117,7 +118,7 @@ public class EdMilker public MilkerBlock(long config, BlockBehaviour.Properties builder, final AABB[] unrotatedAABBs) { super(config, builder, unrotatedAABBs); - overrideCollisionShape(Auxiliaries.getPixeledAABB(0,0,0, 16,24,16)); + cshapes.replaceAll((state,shape)->Shapes.create(Auxiliaries.getPixeledAABB(0,0,0, 16,24,16))); } @Override @@ -125,6 +126,10 @@ public class EdMilker public BlockEntityType getBlockEntityType() { return ModContent.TET_SMALL_MILKING_MACHINE; } + @Override + public boolean isBlockEntityTicking(Level world, BlockState state) + { return true; } + @Override protected void createBlockStateDefinition(StateDefinition.Builder builder) { super.createBlockStateDefinition(builder); builder.add(ACTIVE); builder.add(FILLED); } @@ -283,7 +288,7 @@ public class EdMilker @Override protected void saveAdditional(CompoundTag nbt) - { super.save(nbt); writenbt(nbt, false); } + { super.saveAdditional(nbt); writenbt(nbt, false); } @Override public void setRemoved() diff --git a/src/main/java/wile/engineersdecor/blocks/EdMineralSmelter.java b/src/main/java/wile/engineersdecor/blocks/EdMineralSmelter.java index fc9c47a..a3527d9 100644 --- a/src/main/java/wile/engineersdecor/blocks/EdMineralSmelter.java +++ b/src/main/java/wile/engineersdecor/blocks/EdMineralSmelter.java @@ -87,6 +87,10 @@ public class EdMineralSmelter public BlockEntityType getBlockEntityType() { return ModContent.TET_MINERAL_SMELTER; } + @Override + public boolean isBlockEntityTicking(Level world, BlockState state) + { return true; } + @Override public VoxelShape getCollisionShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext selectionContext) { return Shapes.block(); } @@ -368,7 +372,7 @@ public class EdMineralSmelter @Override protected void saveAdditional(CompoundTag nbt) - { super.save(nbt); writenbt(nbt); } + { super.saveAdditional(nbt); writenbt(nbt); } @Override public void setRemoved() diff --git a/src/main/java/wile/engineersdecor/blocks/EdPipeValve.java b/src/main/java/wile/engineersdecor/blocks/EdPipeValve.java index 96c37e0..273a1e6 100644 --- a/src/main/java/wile/engineersdecor/blocks/EdPipeValve.java +++ b/src/main/java/wile/engineersdecor/blocks/EdPipeValve.java @@ -80,6 +80,10 @@ public class EdPipeValve public BlockEntityType getBlockEntityType() { return ModContent.TET_STRAIGHT_PIPE_VALVE; } + @Override + public boolean isBlockEntityTicking(Level world, BlockState state) + { return false; } + @Override public VoxelShape getCollisionShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext selectionContext) { return Shapes.block(); } diff --git a/src/main/java/wile/engineersdecor/blocks/EdPlacer.java b/src/main/java/wile/engineersdecor/blocks/EdPlacer.java index b27cacb..9a3c329 100644 --- a/src/main/java/wile/engineersdecor/blocks/EdPlacer.java +++ b/src/main/java/wile/engineersdecor/blocks/EdPlacer.java @@ -88,6 +88,10 @@ public class EdPlacer public BlockEntityType getBlockEntityType() { return ModContent.TET_FACTORY_PLACER; } + @Override + public boolean isBlockEntityTicking(Level world, BlockState state) + { return true; } + @Override public VoxelShape getCollisionShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext selectionContext) { return Shapes.block(); } @@ -261,7 +265,7 @@ public class EdPlacer @Override protected void saveAdditional(CompoundTag nbt) - { super.save(nbt); writenbt(nbt, false); } + { super.saveAdditional(nbt); writenbt(nbt, false); } @Override public void setRemoved() diff --git a/src/main/java/wile/engineersdecor/blocks/EdSolarPanel.java b/src/main/java/wile/engineersdecor/blocks/EdSolarPanel.java index 0081349..36cd74a 100644 --- a/src/main/java/wile/engineersdecor/blocks/EdSolarPanel.java +++ b/src/main/java/wile/engineersdecor/blocks/EdSolarPanel.java @@ -81,6 +81,10 @@ public class EdSolarPanel public BlockEntityType getBlockEntityType() { return ModContent.TET_SMALL_SOLAR_PANEL; } + @Override + public boolean isBlockEntityTicking(Level world, BlockState state) + { return true; } + @Override protected void createBlockStateDefinition(StateDefinition.Builder builder) { super.createBlockStateDefinition(builder); builder.add(EXPOSITION); } @@ -153,7 +157,7 @@ public class EdSolarPanel @Override protected void saveAdditional(CompoundTag nbt) - { super.save(nbt); writenbt(nbt, false); } + { super.saveAdditional(nbt); writenbt(nbt, false); } @Override public void setRemoved() diff --git a/src/main/java/wile/engineersdecor/blocks/EdTestBlock.java b/src/main/java/wile/engineersdecor/blocks/EdTestBlock.java index 8cc3450..b8d6a4d 100644 --- a/src/main/java/wile/engineersdecor/blocks/EdTestBlock.java +++ b/src/main/java/wile/engineersdecor/blocks/EdTestBlock.java @@ -67,6 +67,10 @@ public class EdTestBlock public BlockEntityType getBlockEntityType() { return ModContent.TET_TEST_BLOCK; } + @Override + public boolean isBlockEntityTicking(Level world, BlockState state) + { return true; } + @Override public VoxelShape getCollisionShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext selectionContext) { return Shapes.block(); } @@ -168,7 +172,7 @@ public class EdTestBlock @Override protected void saveAdditional(CompoundTag nbt) { - super.save(nbt); + super.saveAdditional(nbt); tank_.save(nbt); battery_.save(nbt); nbt.putInt("rf_fed_avg", rf_fed_avg); diff --git a/src/main/java/wile/engineersdecor/blocks/EdTreeCutter.java b/src/main/java/wile/engineersdecor/blocks/EdTreeCutter.java index 10f2f45..18c1e37 100644 --- a/src/main/java/wile/engineersdecor/blocks/EdTreeCutter.java +++ b/src/main/java/wile/engineersdecor/blocks/EdTreeCutter.java @@ -69,6 +69,10 @@ public class EdTreeCutter public BlockEntityType getBlockEntityType() { return ModContent.TET_SMALL_TREE_CUTTER; } + @Override + public boolean isBlockEntityTicking(Level world, BlockState state) + { return true; } + @Override protected void createBlockStateDefinition(StateDefinition.Builder builder) { super.createBlockStateDefinition(builder); builder.add(ACTIVE); } @@ -83,7 +87,7 @@ public class EdTreeCutter { if((state.getBlock()!=this) || (!state.getValue(ACTIVE))) return; // Sound - if(true || (world.getGameTime() & 0x1) == 0) { + /*if((world.getGameTime() & 0x1) == 0)*/ { world.playLocalSound(pos.getX(), pos.getY(), pos.getZ(), SoundEvents.WOOD_HIT, SoundSource.BLOCKS, 0.1f, 1.0f, false); } // Particles @@ -174,7 +178,7 @@ public class EdTreeCutter @Override protected void saveAdditional(CompoundTag nbt) - { super.save(nbt); writenbt(nbt); } + { super.saveAdditional(nbt); writenbt(nbt); } @Override public void setRemoved() diff --git a/src/main/java/wile/engineersdecor/blocks/EdWasteIncinerator.java b/src/main/java/wile/engineersdecor/blocks/EdWasteIncinerator.java index 7e92b6b..80e1a10 100644 --- a/src/main/java/wile/engineersdecor/blocks/EdWasteIncinerator.java +++ b/src/main/java/wile/engineersdecor/blocks/EdWasteIncinerator.java @@ -87,6 +87,10 @@ public class EdWasteIncinerator public BlockEntityType getBlockEntityType() { return ModContent.TET_WASTE_INCINERATOR; } + @Override + public boolean isBlockEntityTicking(Level world, BlockState state) + { return true; } + @Override protected void createBlockStateDefinition(StateDefinition.Builder builder) { super.createBlockStateDefinition(builder); builder.add(LIT); } @@ -224,7 +228,7 @@ public class EdWasteIncinerator @Override protected void saveAdditional(CompoundTag nbt) - { writenbt(nbt); } + { super.saveAdditional(nbt); writenbt(nbt); } @Override public void setRemoved() diff --git a/src/main/java/wile/engineersdecor/libmc/blocks/StandardBlocks.java b/src/main/java/wile/engineersdecor/libmc/blocks/StandardBlocks.java index 87836ce..7ef78d1 100644 --- a/src/main/java/wile/engineersdecor/libmc/blocks/StandardBlocks.java +++ b/src/main/java/wile/engineersdecor/libmc/blocks/StandardBlocks.java @@ -16,6 +16,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerLevel; +import net.minecraft.sounds.SoundEvent; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.SpawnPlacements; import net.minecraft.world.item.BlockItem; @@ -34,6 +35,7 @@ import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.level.block.state.properties.BooleanProperty; import net.minecraft.world.level.block.state.properties.DirectionProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.FluidState; import net.minecraft.world.level.material.Fluids; @@ -52,6 +54,7 @@ import wile.engineersdecor.libmc.detail.Auxiliaries; import javax.annotation.Nullable; import java.util.*; +import java.util.function.Function; import java.util.function.Supplier; @@ -102,8 +105,9 @@ public class StandardBlocks BlockItem getBlockItem(Block block, Item.Properties builder); } - public static class BaseBlock extends Block implements IStandardBlock, LiquidBlockContainer + public static class BaseBlock extends Block implements IStandardBlock, SimpleWaterloggedBlock { + public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; public final long config; public BaseBlock(long conf, BlockBehaviour.Properties properties) @@ -111,6 +115,7 @@ public class StandardBlocks super(properties); config = conf; BlockState state = getStateDefinition().any(); + if((conf & CFG_WATERLOGGABLE)!=0) state = state.setValue(WATERLOGGED, false); registerDefaultState(state); } @@ -127,14 +132,6 @@ public class StandardBlocks public RenderTypeHint getRenderTypeHint() { return getRenderTypeHint(config); } - @Override - public boolean canPlaceLiquid(BlockGetter world, BlockPos pos, BlockState state, Fluid fluid) - { return false; } - - @Override - public boolean placeLiquid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidstate) - { return false; } - @Override @SuppressWarnings("deprecation") public boolean isPathfindable(BlockState state, BlockGetter world, BlockPos pos, PathComputationType type) @@ -164,11 +161,42 @@ public class StandardBlocks return dropList(state, world, te, is_explosion); } + @Override + public boolean propagatesSkylightDown(BlockState state, BlockGetter reader, BlockPos pos) + { return (((config & CFG_WATERLOGGABLE)==0) || (!state.getValue(WATERLOGGED))) && super.propagatesSkylightDown(state, reader, pos); } + + @Override + @SuppressWarnings("deprecation") + public FluidState getFluidState(BlockState state) + { return (((config & CFG_WATERLOGGABLE)!=0) && state.getValue(WATERLOGGED)) ? Fluids.WATER.getSource(false) : super.getFluidState(state); } + + @Override + @SuppressWarnings("deprecation") + public BlockState updateShape(BlockState state, Direction facing, BlockState facingState, LevelAccessor world, BlockPos pos, BlockPos facingPos) + { + if(((config & CFG_WATERLOGGABLE)!=0) && (state.getValue(WATERLOGGED))) world.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); + return state; + } + + @Override // SimpleWaterloggedBlock + public boolean canPlaceLiquid(BlockGetter world, BlockPos pos, BlockState state, Fluid fluid) + { return ((config & CFG_WATERLOGGABLE)!=0) && SimpleWaterloggedBlock.super.canPlaceLiquid(world, pos, state, fluid); } + + @Override // SimpleWaterloggedBlock + public boolean placeLiquid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) + { return ((config & CFG_WATERLOGGABLE)!=0) && SimpleWaterloggedBlock.super.placeLiquid(world, pos, state, fluidState); } + + @Override // SimpleWaterloggedBlock + public ItemStack pickupBlock(LevelAccessor world, BlockPos pos, BlockState state) + { return ((config & CFG_WATERLOGGABLE)!=0) ? (SimpleWaterloggedBlock.super.pickupBlock(world, pos, state)) : (ItemStack.EMPTY); } + + @Override // SimpleWaterloggedBlock + public Optional getPickupSound() + { return ((config & CFG_WATERLOGGABLE)!=0) ? (SimpleWaterloggedBlock.super.getPickupSound()) : Optional.empty(); } } public static class Cutout extends BaseBlock implements IStandardBlock { - public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; private final VoxelShape vshape; public Cutout(long conf, BlockBehaviour.Properties properties) @@ -185,7 +213,6 @@ public class StandardBlocks super(conf, properties); vshape = voxel_shape; BlockState state = getStateDefinition().any(); - if((conf & CFG_WATERLOGGABLE)!=0) state = state.setValue(WATERLOGGED, false); registerDefaultState(state); } @@ -271,41 +298,41 @@ public class StandardBlocks public static class Directed extends Cutout implements IStandardBlock { - public static final DirectionProperty FACING = DirectionalBlock.FACING; - protected final ArrayList vshapes; - protected final ArrayList cshapes; + public static final DirectionProperty FACING = BlockStateProperties.FACING; + protected final Map vshapes; + + public Directed(long config, BlockBehaviour.Properties properties, final Function, Map> shape_supplier) + { + super(config, properties); + registerDefaultState(stateDefinition.any().setValue(FACING, Direction.UP)); + vshapes = shape_supplier.apply(getStateDefinition().getPossibleStates()); + } public Directed(long config, BlockBehaviour.Properties properties, final Supplier> shape_supplier) { - super(config, properties); - registerDefaultState(super.defaultBlockState().setValue(FACING, Direction.UP)); - vshapes = shape_supplier.get(); - cshapes = new ArrayList<>(vshapes); + this(config, properties, (states)->{ + final Map vshapes = new HashMap<>(); + final ArrayList indexed_shapes = shape_supplier.get(); + for(BlockState state:states) vshapes.put(state, indexed_shapes.get(state.getValue(FACING).get3DDataValue())); + return vshapes; + }); } public Directed(long config, BlockBehaviour.Properties properties, final AABB[] unrotatedAABBs) { - this(config, properties, ()->{ + this(config, properties, (states)->{ final boolean is_horizontal = ((config & CFG_HORIZIONTAL)!=0); - return new ArrayList<>(Arrays.asList( - Auxiliaries.getUnionShape(Auxiliaries.getRotatedAABB(unrotatedAABBs, Direction.DOWN, is_horizontal)), - Auxiliaries.getUnionShape(Auxiliaries.getRotatedAABB(unrotatedAABBs, Direction.UP, is_horizontal)), - Auxiliaries.getUnionShape(Auxiliaries.getRotatedAABB(unrotatedAABBs, Direction.NORTH, is_horizontal)), - Auxiliaries.getUnionShape(Auxiliaries.getRotatedAABB(unrotatedAABBs, Direction.SOUTH, is_horizontal)), - Auxiliaries.getUnionShape(Auxiliaries.getRotatedAABB(unrotatedAABBs, Direction.WEST, is_horizontal)), - Auxiliaries.getUnionShape(Auxiliaries.getRotatedAABB(unrotatedAABBs, Direction.EAST, is_horizontal)), - Shapes.block(), - Shapes.block() - )); + Map vshapes = new HashMap<>(); + for(BlockState state:states) { + vshapes.put(state, Auxiliaries.getUnionShape(Auxiliaries.getRotatedAABB(unrotatedAABBs, state.getValue(FACING), is_horizontal))); + } + return vshapes; }); } public Directed(long config, BlockBehaviour.Properties properties, final AABB unrotatedAABB) { this(config, properties, new AABB[]{unrotatedAABB}); } - protected void overrideCollisionShape(final AABB unrotatedAABB) - { for(int i=0; i builder) @@ -330,6 +357,8 @@ public class StandardBlocks @Nullable public BlockState getStateForPlacement(BlockPlaceContext context) { + BlockState state = super.getStateForPlacement(context); + if(state == null) return null; Direction facing = context.getClickedFace(); if((config & (CFG_HORIZIONTAL|CFG_LOOK_PLACEMENT)) == (CFG_HORIZIONTAL|CFG_LOOK_PLACEMENT)) { // horizontal placement in direction the player is looking @@ -342,64 +371,141 @@ public class StandardBlocks facing = context.getNearestLookingDirection(); } if((config & CFG_OPPOSITE_PLACEMENT)!=0) facing = facing.getOpposite(); - if(((config & CFG_FLIP_PLACEMENT_SHIFTCLICK) != 0) && (context.getPlayer().isShiftKeyDown())) facing = facing.getOpposite(); - return super.getStateForPlacement(context).setValue(FACING, facing); + if(((config & CFG_FLIP_PLACEMENT_SHIFTCLICK) != 0) && (context.getPlayer()!=null) && (context.getPlayer().isShiftKeyDown())) facing = facing.getOpposite(); + return state.setValue(FACING, facing); + } + } + + public static class AxisAligned extends Cutout implements IStandardBlock + { + public static final EnumProperty AXIS = BlockStateProperties.AXIS; + protected final ArrayList vshapes; + + public AxisAligned(long config, BlockBehaviour.Properties properties, final Supplier> shape_supplier) + { + super(config, properties); + registerDefaultState(super.defaultBlockState().setValue(AXIS, Direction.Axis.X)); + vshapes = shape_supplier.get(); + } + + public AxisAligned(long config, BlockBehaviour.Properties properties, final AABB[] unrotatedAABBs) + { + this(config, properties, ()-> new ArrayList<>(Arrays.asList( + Auxiliaries.getUnionShape(Auxiliaries.getRotatedAABB(unrotatedAABBs, Direction.EAST, false)), + Auxiliaries.getUnionShape(Auxiliaries.getRotatedAABB(unrotatedAABBs, Direction.UP, false)), + Auxiliaries.getUnionShape(Auxiliaries.getRotatedAABB(unrotatedAABBs, Direction.SOUTH, false)), + Shapes.block() + ))); + } + + public AxisAligned(long config, BlockBehaviour.Properties properties, final AABB unrotatedAABB) + { this(config, properties, new AABB[]{unrotatedAABB}); } + + @Override + public boolean isPossibleToRespawnInThis() + { return false; } + + @Override + public boolean isValidSpawn(BlockState state, BlockGetter world, BlockPos pos, SpawnPlacements.Type type, @Nullable EntityType entityType) + { return false; } + + @Override + public VoxelShape getShape(BlockState state, BlockGetter source, BlockPos pos, CollisionContext selectionContext) + { return vshapes.get((state.getValue(AXIS)).ordinal() & 0x3); } + + @Override + public VoxelShape getCollisionShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext selectionContext) + { return getShape(state, world, pos, selectionContext); } + + @Override + protected void createBlockStateDefinition(StateDefinition.Builder builder) + { super.createBlockStateDefinition(builder); builder.add(AXIS); } + + @Override + @Nullable + public BlockState getStateForPlacement(BlockPlaceContext context) + { + Direction facing; + if((config & CFG_LOOK_PLACEMENT)!=0) { + facing = context.getNearestLookingDirection(); + } else { + facing = context.getClickedFace(); + } + return super.getStateForPlacement(context).setValue(AXIS, facing.getAxis()); + } + + @Override + @SuppressWarnings("deprecation") + public BlockState rotate(BlockState state, Rotation rotation) + { + switch(rotation) { + case CLOCKWISE_90: + case COUNTERCLOCKWISE_90: + switch(state.getValue(AXIS)) { + case X: return state.setValue(AXIS, Direction.Axis.Z); + case Z: return state.setValue(AXIS, Direction.Axis.X); + } + } + return state; } } public static class Horizontal extends Cutout implements IStandardBlock { public static final DirectionProperty HORIZONTAL_FACING = BlockStateProperties.HORIZONTAL_FACING; - protected final ArrayList vshapes; - protected final ArrayList cshapes; + protected final Map vshapes; + protected final Map cshapes; + + public Horizontal(long config, BlockBehaviour.Properties properties, final Function, Map> shape_supplier) + { + super(config|CFG_HORIZIONTAL, properties); + registerDefaultState(stateDefinition.any().setValue(HORIZONTAL_FACING, Direction.NORTH)); + vshapes = shape_supplier.apply(getStateDefinition().getPossibleStates()); + cshapes = shape_supplier.apply(getStateDefinition().getPossibleStates()); + } public Horizontal(long config, BlockBehaviour.Properties properties, final Supplier> shape_supplier) { - super(config|CFG_HORIZIONTAL, properties); - registerDefaultState(super.defaultBlockState().setValue(HORIZONTAL_FACING, Direction.NORTH)); - vshapes = shape_supplier.get(); - cshapes = new ArrayList<>(vshapes); + this(config, properties, (states)->{ + final Map vshapes = new HashMap<>(); + final ArrayList indexed_shapes = shape_supplier.get(); + for(BlockState state:states) vshapes.put(state, indexed_shapes.get(state.getValue(HORIZONTAL_FACING).get3DDataValue())); + return vshapes; + }); } - public Horizontal(long config, BlockBehaviour.Properties properties, final AABB[] unrotatedAABBs) - { this(config, properties, ()->makeHorizontalShapeLookup(unrotatedAABBs)); } - public Horizontal(long config, BlockBehaviour.Properties properties, final AABB unrotatedAABB) { this(config, properties, new AABB[]{unrotatedAABB}); } - protected static ArrayList makeHorizontalShapeLookup(final AABB[] unrotatedAABBs) + public Horizontal(long config, BlockBehaviour.Properties properties, final AABB[] unrotatedAABBs) { - return new ArrayList<>(Arrays.asList( - Shapes.block(), - Shapes.block(), - Auxiliaries.getUnionShape(Auxiliaries.getRotatedAABB(unrotatedAABBs, Direction.NORTH, true)), - Auxiliaries.getUnionShape(Auxiliaries.getRotatedAABB(unrotatedAABBs, Direction.SOUTH, true)), - Auxiliaries.getUnionShape(Auxiliaries.getRotatedAABB(unrotatedAABBs, Direction.WEST, true)), - Auxiliaries.getUnionShape(Auxiliaries.getRotatedAABB(unrotatedAABBs, Direction.EAST, true)), - Shapes.block(), - Shapes.block() - )); + this(config, properties, (states)->{ + Map vshapes = new HashMap<>(); + for(BlockState state:states) { + vshapes.put(state, Auxiliaries.getUnionShape(Auxiliaries.getRotatedAABB(unrotatedAABBs, state.getValue(HORIZONTAL_FACING), true))); + } + return vshapes; + }); } - protected void overrideCollisionShape(final AABB unrotatedAABB) - { for(int i=0; i builder) { super.createBlockStateDefinition(builder); builder.add(HORIZONTAL_FACING); } + @Override + public VoxelShape getShape(BlockState state, BlockGetter source, BlockPos pos, CollisionContext selectionContext) + { return vshapes.get(state); } + + @Override + public VoxelShape getCollisionShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext selectionContext) + { return cshapes.get(state); } + @Override @Nullable public BlockState getStateForPlacement(BlockPlaceContext context) { + BlockState state = super.getStateForPlacement(context); + if(state == null) return null; Direction facing = context.getClickedFace(); if((config & CFG_LOOK_PLACEMENT) != 0) { // horizontal placement in direction the player is looking @@ -409,8 +515,8 @@ public class StandardBlocks facing = ((facing==Direction.UP)||(facing==Direction.DOWN)) ? (context.getHorizontalDirection()) : facing; } if((config & CFG_OPPOSITE_PLACEMENT)!=0) facing = facing.getOpposite(); - if(((config & CFG_FLIP_PLACEMENT_SHIFTCLICK) != 0) && (context.getPlayer().isShiftKeyDown())) facing = facing.getOpposite(); - return super.getStateForPlacement(context).setValue(HORIZONTAL_FACING, facing); + if(((config & CFG_FLIP_PLACEMENT_SHIFTCLICK) != 0) && (context.getPlayer()!=null) && (context.getPlayer().isShiftKeyDown())) facing = facing.getOpposite(); + return state.setValue(HORIZONTAL_FACING, facing); } @Override @@ -432,6 +538,9 @@ public class StandardBlocks public DirectedWaterLoggable(long config, BlockBehaviour.Properties properties, AABB[] aabbs) { super(config|CFG_WATERLOGGABLE, properties, aabbs); } + public DirectedWaterLoggable(long config, BlockBehaviour.Properties properties, final Function, Map> shape_supplier) + { super(config|CFG_WATERLOGGABLE, properties, shape_supplier); } + public DirectedWaterLoggable(long config, BlockBehaviour.Properties properties, final Supplier> shape_supplier) { super(config|CFG_WATERLOGGABLE, properties, shape_supplier); } @@ -440,6 +549,22 @@ public class StandardBlocks { super.createBlockStateDefinition(builder); builder.add(WATERLOGGED); } } + public static class AxisAlignedWaterLoggable extends AxisAligned implements IStandardBlock + { + public AxisAlignedWaterLoggable(long config, BlockBehaviour.Properties properties, AABB aabb) + { super(config|CFG_WATERLOGGABLE, properties, aabb); } + + public AxisAlignedWaterLoggable(long config, BlockBehaviour.Properties properties, AABB[] aabbs) + { super(config|CFG_WATERLOGGABLE, properties, aabbs); } + + public AxisAlignedWaterLoggable(long config, BlockBehaviour.Properties properties, final Supplier> shape_supplier) + { super(config|CFG_WATERLOGGABLE, properties, shape_supplier); } + + @Override + protected void createBlockStateDefinition(StateDefinition.Builder builder) + { super.createBlockStateDefinition(builder); builder.add(WATERLOGGED); } + } + public static class HorizontalWaterLoggable extends Horizontal implements IStandardBlock { public HorizontalWaterLoggable(long config, BlockBehaviour.Properties properties, AABB aabb) @@ -451,6 +576,9 @@ public class StandardBlocks public HorizontalWaterLoggable(long config, BlockBehaviour.Properties properties, final Supplier> shape_supplier) { super(config|CFG_WATERLOGGABLE|CFG_HORIZIONTAL, properties, shape_supplier); } + public HorizontalWaterLoggable(long config, BlockBehaviour.Properties properties, final Function, Map> shape_supplier) + { super(config|CFG_WATERLOGGABLE|CFG_HORIZIONTAL, properties, shape_supplier); } + @Override protected void createBlockStateDefinition(StateDefinition.Builder builder) { super.createBlockStateDefinition(builder); builder.add(WATERLOGGED); } @@ -465,7 +593,7 @@ public class StandardBlocks protected final Map shapes; protected final Map collision_shapes; - public HorizontalFourWayWaterLoggable(long config, BlockBehaviour.Properties properties, AABB base_aabb, final AABB side_aabb[], int railing_height_extension) + public HorizontalFourWayWaterLoggable(long config, BlockBehaviour.Properties properties, AABB base_aabb, final AABB[] side_aabb, int railing_height_extension) { super(config, properties, base_aabb); Map build_shapes = new HashMap<>(); diff --git a/src/main/java/wile/engineersdecor/libmc/blocks/StandardEntityBlocks.java b/src/main/java/wile/engineersdecor/libmc/blocks/StandardEntityBlocks.java index eb8905a..c30c3a9 100644 --- a/src/main/java/wile/engineersdecor/libmc/blocks/StandardEntityBlocks.java +++ b/src/main/java/wile/engineersdecor/libmc/blocks/StandardEntityBlocks.java @@ -31,20 +31,8 @@ public class StandardEntityBlocks @Nullable BlockEntityType getBlockEntityType(); - @Override - @Nullable - default BlockEntity newBlockEntity(BlockPos pos, BlockState state) - { return (getBlockEntityType()==null) ? null : getBlockEntityType().create(pos, state); } - - @Override - @Nullable - default BlockEntityTicker getTicker(Level world, BlockState state, BlockEntityType te_type) - { return (world.isClientSide) ? (null) : ((Level w, BlockPos p, BlockState s, T te) -> ((StandardBlockEntity)te).tick()); } // To be evaluated if - - @Override - @Nullable - default GameEventListener getListener(Level world, T te) - { return null; } + default boolean isBlockEntityTicking(Level world, BlockState state) + { return false; } default InteractionResult useOpenGui(BlockState state, Level world, BlockPos pos, Player player) { @@ -54,6 +42,21 @@ public class StandardEntityBlocks player.openMenu((MenuProvider)te); return InteractionResult.CONSUME; } + + @Override + @Nullable + default BlockEntity newBlockEntity(BlockPos pos, BlockState state) + { return (getBlockEntityType()==null) ? null : getBlockEntityType().create(pos, state); } + + @Override + @Nullable + default BlockEntityTicker getTicker(Level world, BlockState state, BlockEntityType te_type) + { return (world.isClientSide || (!isBlockEntityTicking(world, state))) ? (null) : ((Level w, BlockPos p, BlockState s, T te) -> ((StandardBlockEntity)te).tick()); } + + @Override + @Nullable + default GameEventListener getListener(Level world, T te) + { return null; } } public static abstract class StandardBlockEntity extends BlockEntity diff --git a/src/main/java/wile/engineersdecor/libmc/detail/Auxiliaries.java b/src/main/java/wile/engineersdecor/libmc/detail/Auxiliaries.java index 9f4cdb7..eae6b9a 100644 --- a/src/main/java/wile/engineersdecor/libmc/detail/Auxiliaries.java +++ b/src/main/java/wile/engineersdecor/libmc/detail/Auxiliaries.java @@ -121,12 +121,17 @@ public class Auxiliaries // ------------------------------------------------------------------------------------------------------------------- /** - * Text localisation wrapper, implicitly prepends `MODID` to the + * Text localization wrapper, implicitly prepends `MODID` to the * translation keys. Forces formatting argument, nullable if no special formatting shall be applied.. */ public static TranslatableComponent localizable(String modtrkey, Object... args) + { return new TranslatableComponent((modtrkey.startsWith("block.") || (modtrkey.startsWith("item."))) ? (modtrkey) : (modid+"."+modtrkey), args); } + + public static TranslatableComponent localizable(String modtrkey, @Nullable ChatFormatting color, Object... args) { - return new TranslatableComponent((modtrkey.startsWith("block.") || (modtrkey.startsWith("item."))) ? (modtrkey) : (modid+"."+modtrkey), args); + TranslatableComponent tr = new TranslatableComponent(modid+"."+modtrkey, args); + if(color!=null) tr.withStyle(color); + return tr; } public static TranslatableComponent localizable(String modtrkey)