More decorative blocks

This commit is contained in:
Sebastian Hartte
2020-06-01 17:26:36 +02:00
parent 2a1ba12516
commit 36af72faeb
6 changed files with 44 additions and 76 deletions
@@ -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 )
// {
@@ -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" ) )
@@ -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 <http://www.gnu.org/licenses/lgpl>.
*/
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 );
}
}
@@ -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() );
}
}
@@ -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<Block> 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;