From 36af72faeb690be3c8c0e5214b53e2e80411e9c9 Mon Sep 17 00:00:00 2001 From: Sebastian Hartte Date: Mon, 1 Jun 2020 17:26:36 +0200 Subject: [PATCH] More decorative blocks --- build.gradle | 1 + .../appeng/block/misc/BlockQuartzFixture.java | 2 +- .../core/api/definitions/ApiBlocks.java | 37 ++++++++++-------- .../appeng/decorative/solid/BlockFluix.java | 33 ---------------- .../decorative/solid/BlockSkyStone.java | 38 ++++++++----------- .../java/appeng/services/CompassService.java | 9 +++-- 6 files changed, 44 insertions(+), 76 deletions(-) delete mode 100644 src/main/java/appeng/decorative/solid/BlockFluix.java diff --git a/build.gradle b/build.gradle index e42eb9ef0..089946b79 100644 --- a/build.gradle +++ b/build.gradle @@ -145,6 +145,7 @@ sourceSets { include 'appeng/services/compass/ICompassCallback.java' include 'appeng/hooks/CompassResult.java' include 'appeng/container/ContainerOpenContext.java' + include 'appeng/decorative/solid/BlockSkyStone.java' // include 'appeng/client/ClientHelper.java' // include 'appeng/server/ServerHelper.java' diff --git a/src/main/java/appeng/block/misc/BlockQuartzFixture.java b/src/main/java/appeng/block/misc/BlockQuartzFixture.java index 0c8274a0f..a9b3804ba 100644 --- a/src/main/java/appeng/block/misc/BlockQuartzFixture.java +++ b/src/main/java/appeng/block/misc/BlockQuartzFixture.java @@ -171,7 +171,7 @@ public class BlockQuartzFixture extends AEBaseBlock implements IOrientableBlock } } - // FIXME: Replaced by the postPlaceupdate stuff above + // FIXME: Replaced by the postPlaceupdate stuff above, but check item drops! // @Override // public void neighborChanged( BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos ) // { diff --git a/src/main/java/appeng/core/api/definitions/ApiBlocks.java b/src/main/java/appeng/core/api/definitions/ApiBlocks.java index be18a17e8..498fc384b 100644 --- a/src/main/java/appeng/core/api/definitions/ApiBlocks.java +++ b/src/main/java/appeng/core/api/definitions/ApiBlocks.java @@ -38,6 +38,7 @@ import net.minecraft.block.material.Material; import net.minecraft.client.renderer.RenderType; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import static appeng.decorative.solid.BlockSkyStone.SkystoneType; /** @@ -175,21 +176,27 @@ public final class ApiBlocks implements IBlocks }) .build(); -// this.fluixBlock = registry.features( AEFeature.FLUIX ).block( "fluix_block", BlockFluix::new ).build(); -// -// this.skyStoneBlock = registry.features( AEFeature.SKY_STONE ) -// .block( "sky_stone_block", () -> new BlockSkyStone( SkystoneType.STONE ) ) -// .build(); -// this.smoothSkyStoneBlock = registry.features( AEFeature.SKY_STONE ) -// .block( "smooth_sky_stone_block", () -> new BlockSkyStone( SkystoneType.BLOCK ) ) -// .build(); -// this.skyStoneBrick = deco.block( "sky_stone_brick", () -> new BlockSkyStone( SkystoneType.BRICK ) ) -// .addFeatures( AEFeature.SKY_STONE ) -// .build(); -// this.skyStoneSmallBrick = deco.block( "sky_stone_small_brick", () -> new BlockSkyStone( SkystoneType.SMALL_BRICK ) ) -// .addFeatures( AEFeature.SKY_STONE ) -// .build(); -// + this.fluixBlock = registry.features( AEFeature.FLUIX ).block( "fluix_block", () -> new AEDecorativeBlock(QUARTZ_PROPERTIES) ).build(); + + this.skyStoneBlock = registry.features( AEFeature.SKY_STONE ) + .block( "sky_stone_block", () -> new BlockSkyStone( SkystoneType.STONE, Block.Properties.create(Material.ROCK) + .hardnessAndResistance(50, 150) + .harvestLevel(3) ) ) + .build(); + + this.smoothSkyStoneBlock = registry.features( AEFeature.SKY_STONE ) + .block( "smooth_sky_stone_block", () -> new BlockSkyStone( SkystoneType.BLOCK, Block.Properties.create(Material.ROCK) + .hardnessAndResistance(50, 150) ) ) + .build(); + this.skyStoneBrick = deco.block( "sky_stone_brick", () -> new BlockSkyStone( SkystoneType.BRICK, Block.Properties.create(Material.ROCK) + .hardnessAndResistance(50, 150) ) ) + .addFeatures( AEFeature.SKY_STONE ) + .build(); + this.skyStoneSmallBrick = deco.block( "sky_stone_small_brick", () -> new BlockSkyStone( SkystoneType.SMALL_BRICK, Block.Properties.create(Material.ROCK) + .hardnessAndResistance(50, 150) ) ) + .addFeatures( AEFeature.SKY_STONE ) + .build(); + // this.skyStoneChest = registry.block( "sky_stone_chest", () -> new BlockSkyChest( SkyChestType.STONE ) ) // .features( AEFeature.SKY_STONE, AEFeature.SKY_STONE_CHESTS ) // .tileEntity( new TileEntityDefinition( TileSkyChest.class, "sky_stone_chest" ) ) diff --git a/src/main/java/appeng/decorative/solid/BlockFluix.java b/src/main/java/appeng/decorative/solid/BlockFluix.java deleted file mode 100644 index ecf4ab982..000000000 --- a/src/main/java/appeng/decorative/solid/BlockFluix.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * This file is part of Applied Energistics 2. - * Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. - * - * Applied Energistics 2 is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Applied Energistics 2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Applied Energistics 2. If not, see . - */ - -package appeng.decorative.solid; - - -import net.minecraft.block.material.Material; - -import appeng.decorative.AEDecorativeBlock; - - -public final class BlockFluix extends AEDecorativeBlock -{ - public BlockFluix() - { - super( Material.ROCK ); - } -} diff --git a/src/main/java/appeng/decorative/solid/BlockSkyStone.java b/src/main/java/appeng/decorative/solid/BlockSkyStone.java index 197586d76..b3ee8c732 100644 --- a/src/main/java/appeng/decorative/solid/BlockSkyStone.java +++ b/src/main/java/appeng/decorative/solid/BlockSkyStone.java @@ -19,38 +19,30 @@ package appeng.decorative.solid; -import net.minecraft.block.material.Material; import net.minecraft.block.BlockState; -import net.minecraft.inventory.EntityEquipmentSlot; +import net.minecraft.inventory.EquipmentSlotType; import net.minecraft.item.ItemStack; +import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IWorld; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.ToolType; import net.minecraftforge.event.entity.player.PlayerEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import appeng.block.AEBaseBlock; -import appeng.core.worlddata.WorldData; import appeng.util.Platform; public class BlockSkyStone extends AEBaseBlock { - private static final float BLOCK_RESISTANCE = 150.0f; private static final float BREAK_SPEAK_SCALAR = 0.1f; private static final double BREAK_SPEAK_THRESHOLD = 7.0; private final SkystoneType type; - public BlockSkyStone( final SkystoneType type ) - { - super( Material.ROCK ); - this.setHardness( 50 ); - this.blockResistance = BLOCK_RESISTANCE; - if( type == SkystoneType.STONE ) - { - this.setHarvestLevel( "pickaxe", 3 ); - } - + public BlockSkyStone(SkystoneType type, Properties props) { + super(props); this.type = type; MinecraftForge.EVENT_BUS.register( this ); @@ -59,14 +51,14 @@ public class BlockSkyStone extends AEBaseBlock @SubscribeEvent public void breakFaster( final PlayerEvent.BreakSpeed event ) { - if( event.getState().getBlock() == this && event.getPlayerEntity() != null ) + if( event.getState().getBlock() == this && event.getPlayer() != null ) { - final ItemStack is = event.getPlayerEntity().getItemStackFromSlot( EntityEquipmentSlot.MAINHAND ); + final ItemStack is = event.getPlayer().getItemStackFromSlot( EquipmentSlotType.MAINHAND ); int level = -1; if( !is.isEmpty() ) { - level = is.getItem().getHarvestLevel( is, "pickaxe", event.getPlayerEntity(), event.getState() ); + level = is.getItem().getHarvestLevel( is, ToolType.PICKAXE, event.getPlayer(), event.getState() ); } if( this.type != SkystoneType.STONE || level >= 3 || event.getOriginalSpeed() > BREAK_SPEAK_THRESHOLD ) @@ -77,13 +69,13 @@ public class BlockSkyStone extends AEBaseBlock } @Override - public void onBlockAdded( final World w, final BlockPos pos, final BlockState state ) - { - super.onBlockAdded( w, pos, state ); + public BlockState updatePostPlacement(BlockState stateIn, Direction facing, BlockState facingState, IWorld worldIn, BlockPos currentPos, BlockPos facingPos) { if( Platform.isServer() ) { - WorldData.instance().compassData().service().updateArea( w, pos.getX(), pos.getY(), pos.getZ() ); + // FIXME WorldData.instance().compassData().service().updateArea( worldIn, currentPos.getX(), currentPos.getY(), currentPos.getZ() ); } + + return super.updatePostPlacement(stateIn, facing, facingState, worldIn, currentPos, facingPos); } @Override @@ -92,7 +84,7 @@ public class BlockSkyStone extends AEBaseBlock if( Platform.isServer() ) { - WorldData.instance().compassData().service().updateArea( w, pos.getX(), pos.getY(), pos.getZ() ); + // FIXME WorldData.instance().compassData().service().updateArea( w, pos.getX(), pos.getY(), pos.getZ() ); } } diff --git a/src/main/java/appeng/services/CompassService.java b/src/main/java/appeng/services/CompassService.java index 90e1ed3e2..d38ff303f 100644 --- a/src/main/java/appeng/services/CompassService.java +++ b/src/main/java/appeng/services/CompassService.java @@ -39,6 +39,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.IWorld; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.IChunk; import net.minecraftforge.event.world.WorldEvent; import appeng.api.AEApi; @@ -123,7 +124,7 @@ public final class CompassService this.updateArea( w, x, CHUNK_SIZE + 224, z ); } - public Future updateArea( final World w, final int x, final int y, final int z ) + public Future updateArea( final IWorld w, final int x, final int y, final int z ) { this.jobSize++; @@ -135,7 +136,7 @@ public final class CompassService final int hi_y = low_y + 32; // lower level... - final Chunk c = w.getChunk( cx, cz ); + final IChunk c = w.getChunk( cx, cz ); Optional maybeBlock = Api.INSTANCE.definitions().blocks().skyStoneBlock().maybeBlock(); if( maybeBlock.isPresent() ) @@ -214,14 +215,14 @@ public final class CompassService private class CMUpdatePost implements Runnable { - public final World world; + public final IWorld world; public final int chunkX; public final int chunkZ; public final int doubleChunkY; // 32 blocks instead of 16. public final boolean value; - public CMUpdatePost( final World w, final int cx, final int cz, final int dcy, final boolean val ) + public CMUpdatePost( final IWorld w, final int cx, final int cz, final int dcy, final boolean val ) { this.world = w; this.chunkX = cx;