Utils ported

This commit is contained in:
Sebastian Hartte
2020-06-28 15:47:44 +02:00
parent 46955643b9
commit f5412152a4
132 changed files with 488 additions and 528 deletions
@@ -38,7 +38,7 @@ import appeng.util.Platform;
public class CellWorkbenchBlock extends AEBaseTileBlock<CellWorkbenchBlockEntity> {
public CellWorkbenchBlock() {
super(defaultProps(Material.IRON));
super(defaultProps(Material.METAL));
}
@Override
@@ -25,6 +25,8 @@ import javax.annotation.Nullable;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.render.model.json.Transformation;
import net.minecraft.client.util.math.AffineTransformation;
import net.minecraft.util.math.Box;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
@@ -32,8 +34,7 @@ import org.apache.commons.lang3.tuple.Pair;
import net.minecraft.block.BlockState;
import net.minecraft.block.Material;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.renderer.TransformationMatrix;
import net.minecraft.client.renderer.Vector3f;
import net.minecraft.client.util.math.Vector3f;
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
import net.minecraft.entity.player.PlayerEntity;
@@ -63,9 +64,7 @@ import appeng.util.Platform;
public class ChargerBlock extends AEBaseTileBlock<ChargerBlockEntity> {
public ChargerBlock() {
super(defaultProps(Material.IRON).notSolid());
this.setFullSize(this.setOpaque(false));
super(defaultProps(Material.METAL));
}
@Override
@@ -92,7 +91,7 @@ public class ChargerBlock extends AEBaseTileBlock<ChargerBlockEntity> {
@Override
@Environment(EnvType.CLIENT)
public void animateTick(final BlockState state, final World w, final BlockPos pos, final Random r) {
public void randomDisplayTick(final BlockState state, final World w, final BlockPos pos, final Random r) {
if (!AEConfig.instance().isEnableEffects()) {
return;
}
@@ -111,7 +110,7 @@ public class ChargerBlock extends AEBaseTileBlock<ChargerBlockEntity> {
for (int bolts = 0; bolts < 3; bolts++) {
if (AppEng.proxy.shouldAddParticles(r)) {
MinecraftClient.getInstance().particles.addParticle(ParticleTypes.LIGHTNING, xOff + 0.5 + pos.getX(),
MinecraftClient.getInstance().particleManager.addParticle(ParticleTypes.LIGHTNING, xOff + 0.5 + pos.getX(),
yOff + 0.5 + pos.getY(), zOff + 0.5 + pos.getZ(), 0.0, 0.0, 0.0);
}
}
@@ -120,7 +119,7 @@ public class ChargerBlock extends AEBaseTileBlock<ChargerBlockEntity> {
}
@Override
public VoxelShape getShape(BlockState state, BlockView w, BlockPos pos, ShapeContext context) {
public VoxelShape getOutlineShape(BlockState state, BlockView w, BlockPos pos, ShapeContext context) {
final ChargerBlockEntity tile = this.getBlockEntity(w, pos);
if (tile != null) {
@@ -166,15 +165,15 @@ public class ChargerBlock extends AEBaseTileBlock<ChargerBlockEntity> {
break;
}
return VoxelShapes.create(bb.getBoundingBox());
return VoxelShapes.cuboid(bb.getBoundingBox());
}
return VoxelShapes.create(new Box(0.0, 0, 0.0, 1.0, 1.0, 1.0));
return VoxelShapes.cuboid(new Box(0.0, 0, 0.0, 1.0, 1.0, 1.0));
}
@Override
public VoxelShape getCollisionShape(BlockState state, BlockView worldIn, BlockPos pos,
ShapeContext context) {
return VoxelShapes.create(new Box(0.0, 0.0, 0.0, 1.0, 1.0, 1.0));
return VoxelShapes.cuboid(new Box(0.0, 0.0, 0.0, 1.0, 1.0, 1.0));
}
@Environment(EnvType.CLIENT)
@@ -183,8 +182,8 @@ public class ChargerBlock extends AEBaseTileBlock<ChargerBlockEntity> {
}
@Environment(EnvType.CLIENT)
private static Pair<ItemStack, TransformationMatrix> getRenderedItem(ChargerBlockEntity tile) {
TransformationMatrix transform = new TransformationMatrix(new Vector3f(0.5f, 0.375f, 0.5f), null, null, null);
private static Pair<ItemStack, Transformation> getRenderedItem(ChargerBlockEntity tile) {
Transformation transform = new Transformation(new Vector3f(), new Vector3f(0.5f, 0.375f, 0.5f), new Vector3f(1f, 1f, 1f));
return new ImmutablePair<>(tile.getInternalInventory().getInvStack(0), transform);
}
@@ -39,7 +39,7 @@ import appeng.util.Platform;
public class CondenserBlock extends AEBaseTileBlock<CondenserBlockEntity> {
public CondenserBlock() {
super(defaultProps(Material.IRON));
super(defaultProps(Material.METAL));
}
@Override
@@ -53,7 +53,7 @@ public class CondenserBlock extends AEBaseTileBlock<CondenserBlockEntity> {
final CondenserBlockEntity tc = this.getBlockEntity(w, pos);
if (tc != null && !player.isInSneakingPose()) {
ContainerOpener.openContainer(CondenserContainer.TYPE, player,
ContainerLocator.forTileEntitySide(tc, hit.getFace()));
ContainerLocator.forTileEntitySide(tc, hit.getSide()));
return ActionResult.SUCCESS;
}
}
@@ -56,7 +56,7 @@ public class InscriberBlock extends AEBaseTileBlock<InscriberBlockEntity> {
if (tg != null) {
if (!tg.isClient()) {
ContainerOpener.openContainer(InscriberContainer.TYPE, p,
ContainerLocator.forTileEntitySide(tg, hit.getFace()));
ContainerLocator.forTileEntitySide(tg, hit.getSide()));
}
return ActionResult.SUCCESS;
}
@@ -9,7 +9,7 @@ import appeng.bootstrap.TileEntityRenderingCustomizer;
import appeng.client.render.tesr.InscriberTESR;
import appeng.tile.misc.InscriberBlockEntity;
public class InscriberRendering extends TileEntityRenderingCustomizer<InscriberBlockEntity> {
public class InscriberRendering implements TileEntityRenderingCustomizer<InscriberBlockEntity> {
@Environment(EnvType.CLIENT)
@Override
@@ -25,8 +25,8 @@ import net.minecraft.block.BlockState;
import net.minecraft.block.Material;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.state.BooleanProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.StateManager;
import net.minecraft.util.ActionResult;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.Direction;
@@ -44,15 +44,15 @@ import appeng.util.Platform;
public class InterfaceBlock extends AEBaseTileBlock<InterfaceBlockEntity> {
private static final BooleanProperty OMNIDIRECTIONAL = BooleanProperty.create("omnidirectional");
private static final BooleanProperty OMNIDIRECTIONAL = BooleanProperty.of("omnidirectional");
public InterfaceBlock() {
super(defaultProps(Material.IRON));
super(defaultProps(Material.METAL));
}
@Override
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
super.fillStateContainer(builder);
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
super.appendProperties(builder);
builder.add(OMNIDIRECTIONAL);
}
@@ -72,7 +72,7 @@ public class InterfaceBlock extends AEBaseTileBlock<InterfaceBlockEntity> {
if (tg != null) {
if (Platform.isServer()) {
ContainerOpener.openContainer(InterfaceContainer.TYPE, p,
ContainerLocator.forTileEntitySide(tg, hit.getFace()));
ContainerLocator.forTileEntitySide(tg, hit.getSide()));
}
return ActionResult.SUCCESS;
}
@@ -18,23 +18,18 @@
package appeng.block.misc;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Material;
import net.minecraft.state.BooleanProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.block.*;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.Properties;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.block.ShapeContext;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockView;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.IWorldReader;
import net.minecraft.world.WorldView;
import net.minecraft.world.World;
import appeng.api.util.IOrientable;
@@ -46,44 +41,48 @@ import appeng.tile.misc.LightDetectorBlockEntity;
public class LightDetectorBlock extends AEBaseTileBlock<LightDetectorBlockEntity> implements IOrientableBlock {
// Used to alternate between two variants of the fixture on adjacent blocks
public static final BooleanProperty ODD = BooleanProperty.create("odd");
public static final BooleanProperty ODD = BooleanProperty.of("odd");
public LightDetectorBlock() {
super(defaultProps(Material.MISCELLANEOUS).notSolid());
this.setDefaultState(this.getDefaultState().with(BlockStateProperties.FACING, Direction.UP).with(ODD, false));
super(defaultProps(Material.SUPPORTED));
this.setDefaultState(this.getDefaultState().with(Properties.FACING, Direction.UP).with(ODD, false));
}
@Override
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
super.fillStateContainer(builder);
builder.add(BlockStateProperties.FACING);
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
super.appendProperties(builder);
builder.add(Properties.FACING);
builder.add(ODD);
}
@Override
public int getWeakPower(final BlockState state, final BlockView w, final BlockPos pos, final Direction side) {
public int getWeakRedstonePower(final BlockState state, final BlockView w, final BlockPos pos, final Direction side) {
if (w instanceof World && this.getBlockEntity(w, pos).isReady()) {
// FIXME: This is ... uhm... fishy
return ((World) w).getLight(pos) - 6;
return ((World) w).getLightLevel(pos) - 6;
}
return 0;
}
@Override
public void onNeighborChange(BlockState state, IWorldReader world, BlockPos pos, BlockPos neighbor) {
super.onNeighborChange(state, world, pos, neighbor);
public boolean emitsRedstonePower(BlockState state) {
return true;
}
public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState newState, WorldAccess world, BlockPos pos, BlockPos posFrom) {
final Direction up = this.getOrientable(world, pos).getUp();
if (!this.canPlaceAt(world, pos, up.getOpposite())) {
// FIXME: Double check that this actually updates neighbors
return Blocks.AIR.getDefaultState();
}
final LightDetectorBlockEntity tld = this.getBlockEntity(world, pos);
if (tld != null) {
tld.updateLight();
}
}
@Override
public void animateTick(final BlockState state, final World worldIn, final BlockPos pos, final Random rand) {
// cancel out lightning
return state;
}
@Override
@@ -94,11 +93,11 @@ public class LightDetectorBlock extends AEBaseTileBlock<LightDetectorBlockEntity
private boolean canPlaceAt(final BlockView w, final BlockPos pos, final Direction dir) {
final BlockPos test = pos.offset(dir);
BlockState blockstate = w.getBlockState(test);
return blockstate.isSolidSide(w, test, dir.getOpposite());
return blockstate.isSideSolidFullSquare(w, test, dir.getOpposite());
}
@Override
public VoxelShape getShape(BlockState state, BlockView w, BlockPos pos, ShapeContext context) {
public VoxelShape getOutlineShape(BlockState state, BlockView w, BlockPos pos, ShapeContext context) {
// FIXME: We should / rather MUST use state here because at startup, this gets
// called without a world
@@ -108,7 +107,7 @@ public class LightDetectorBlock extends AEBaseTileBlock<LightDetectorBlockEntity
final double yOff = -0.3 * up.getOffsetY();
final double zOff = -0.3 * up.getOffsetZ();
return VoxelShapes
.create(new Box(xOff + 0.3, yOff + 0.3, zOff + 0.3, xOff + 0.7, yOff + 0.7, zOff + 0.7));
.cuboid(new Box(xOff + 0.3, yOff + 0.3, zOff + 0.3, xOff + 0.7, yOff + 0.7, zOff + 0.7));
}
@Override
@@ -118,22 +117,7 @@ public class LightDetectorBlock extends AEBaseTileBlock<LightDetectorBlockEntity
}
@Override
public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos,
boolean isMoving) {
final Direction up = this.getOrientable(world, pos).getUp();
if (!this.canPlaceAt(world, pos, up.getOpposite())) {
this.dropTorch(world, pos);
}
}
private void dropTorch(final World w, final BlockPos pos) {
final BlockState prev = w.getBlockState(pos);
w.breakBlock(pos, true);
w.updateListeners(pos, prev, w.getBlockState(pos), 3);
}
@Override
public boolean isValidPosition(BlockState state, IWorldReader w, BlockPos pos) {
public boolean canPlaceAt(BlockState state, WorldView w, BlockPos pos) {
for (final Direction dir : Direction.values()) {
if (this.canPlaceAt(w, pos, dir)) {
return true;
@@ -144,7 +128,7 @@ public class LightDetectorBlock extends AEBaseTileBlock<LightDetectorBlockEntity
@Override
public IOrientable getOrientable(final BlockView w, final BlockPos pos) {
return new MetaRotation(w, pos, BlockStateProperties.FACING);
return new MetaRotation(w, pos, Properties.FACING);
}
}
@@ -30,10 +30,10 @@ import net.minecraft.block.Blocks;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.block.Material;
import net.minecraft.state.BooleanProperty;
import net.minecraft.state.DirectionProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.DirectionProperty;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.Properties;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.BlockPos;
@@ -42,7 +42,7 @@ import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockView;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.IWorldReader;
import net.minecraft.world.WorldView;
import net.minecraft.world.World;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
@@ -68,42 +68,42 @@ public class QuartzFixtureBlock extends AEBaseBlock implements IOrientableBlock
final double yOff = -0.3 * facing.getOffsetY();
final double zOff = -0.3 * facing.getOffsetZ();
VoxelShape shape = VoxelShapes
.create(new Box(xOff + 0.3, yOff + 0.3, zOff + 0.3, xOff + 0.7, yOff + 0.7, zOff + 0.7));
.cuboid(new Box(xOff + 0.3, yOff + 0.3, zOff + 0.3, xOff + 0.7, yOff + 0.7, zOff + 0.7));
SHAPES.put(facing, shape);
}
}
// Cannot use the vanilla FACING property here because it excludes facing DOWN
public static final DirectionProperty FACING = BlockStateProperties.FACING;
public static final DirectionProperty FACING = Properties.FACING;
// Used to alternate between two variants of the fixture on adjacent blocks
public static final BooleanProperty ODD = BooleanProperty.create("odd");
public static final BooleanProperty ODD = BooleanProperty.of("odd");
public QuartzFixtureBlock() {
super(defaultProps(Material.MISCELLANEOUS).doesNotBlockMovement().strength(0).lightValue(14)
super(defaultProps(Material.SUPPORTED).noCollision().strength(0).lightLevel(14)
.sounds(BlockSoundGroup.GLASS));
this.setDefaultState(getDefaultState().with(FACING, Direction.UP).with(ODD, false));
}
@Override
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
builder.add(FACING, ODD);
}
// For reference, see WallTorchBlock
@Override
@Nullable
public BlockState getStateForPlacement(ItemPlacementContext context) {
BlockState blockstate = super.getStateForPlacement(context);
public BlockState getPlacementState(ItemPlacementContext context) {
BlockState blockstate = super.getPlacementState(context);
BlockPos pos = context.getBlockPos();
// Set the even/odd property
boolean oddPlacement = ((pos.getX() + pos.getY() + pos.getZ()) % 2) != 0;
blockstate = blockstate.with(ODD, oddPlacement);
IWorldReader iworldreader = context.getWorld();
Direction[] adirection = context.getNearestLookingDirections();
WorldView iworldreader = context.getWorld();
Direction[] adirection = context.getPlacementDirections();
for (Direction direction : adirection) {
if (canPlaceAt(iworldreader, pos, direction)) {
@@ -117,7 +117,7 @@ public class QuartzFixtureBlock extends AEBaseBlock implements IOrientableBlock
// Break the fixture if the block it is attached to is changed so that it could
// no longer be placed
@Override
public BlockState updatePostPlacement(BlockState state, Direction facing, BlockState facingState, WorldAccess worldIn,
public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState facingState, WorldAccess worldIn,
BlockPos pos, BlockPos facingPos) {
Direction fixtureFacing = state.get(FACING);
if (facing.getOpposite() == fixtureFacing && !canPlaceAt(worldIn, pos, facing)) {
@@ -133,21 +133,21 @@ public class QuartzFixtureBlock extends AEBaseBlock implements IOrientableBlock
return this.canPlaceAt(w, pos, up.getOpposite());
}
private boolean canPlaceAt(final IWorldReader w, final BlockPos pos, final Direction dir) {
private boolean canPlaceAt(final WorldView w, final BlockPos pos, final Direction dir) {
final BlockPos test = pos.offset(dir);
BlockState blockstate = w.getBlockState(test);
return blockstate.isSolidSide(w, test, dir.getOpposite());
return blockstate.isSideSolidFullSquare(w, test, dir.getOpposite());
}
@Override
public VoxelShape getShape(BlockState state, BlockView worldIn, BlockPos pos, ShapeContext context) {
public VoxelShape getOutlineShape(BlockState state, BlockView worldIn, BlockPos pos, ShapeContext context) {
Direction facing = state.get(FACING);
return SHAPES.get(facing);
}
@Override
@Environment(EnvType.CLIENT)
public void animateTick(final BlockState state, final World w, final BlockPos pos, final Random r) {
public void randomDisplayTick(final BlockState state, final World w, final BlockPos pos, final Random r) {
if (!AEConfig.instance().isEnableEffects()) {
return;
}
@@ -170,7 +170,7 @@ public class QuartzFixtureBlock extends AEBaseBlock implements IOrientableBlock
// 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,
public void neighborUpdate(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos,
boolean isMoving) {
final Direction up = this.getOrientable(world, pos).getUp();
if (!this.canPlaceAt(world, pos, up.getOpposite())) {
@@ -185,7 +185,7 @@ public class QuartzFixtureBlock extends AEBaseBlock implements IOrientableBlock
}
@Override
public boolean isValidPosition(BlockState state, IWorldReader w, BlockPos pos) {
public boolean canPlaceAt(BlockState state, WorldView w, BlockPos pos) {
for (final Direction dir : Direction.values()) {
if (this.canPlaceAt(w, pos, dir)) {
return true;
@@ -199,9 +199,4 @@ public class QuartzFixtureBlock extends AEBaseBlock implements IOrientableBlock
return new MetaRotation(w, pos, FACING);
}
@Override
public boolean isOpaque() {
return false;
}
}
@@ -26,8 +26,8 @@ import net.minecraft.block.BlockState;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.block.Material;
import net.minecraft.client.MinecraftClient;
import net.minecraft.state.BooleanProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.StateManager;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@@ -44,7 +44,7 @@ import appeng.util.Platform;
public class QuartzGrowthAcceleratorBlock extends AEBaseTileBlock<QuartzGrowthAcceleratorBlockEntity>
implements IOrientableBlock {
private static final BooleanProperty POWERED = BooleanProperty.create("powered");
private static final BooleanProperty POWERED = BooleanProperty.of("powered");
public QuartzGrowthAcceleratorBlock() {
super(defaultProps(Material.STONE).sounds(BlockSoundGroup.METAL));
@@ -57,14 +57,14 @@ public class QuartzGrowthAcceleratorBlock extends AEBaseTileBlock<QuartzGrowthAc
}
@Override
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
super.fillStateContainer(builder);
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
super.appendProperties(builder);
builder.add(POWERED);
}
@Environment(EnvType.CLIENT)
@Override
public void animateTick(final BlockState state, final World w, final BlockPos pos, final Random r) {
public void randomDisplayTick(final BlockState state, final World w, final BlockPos pos, final Random r) {
if (!AEConfig.instance().isEnableEffects()) {
return;
}
@@ -99,30 +99,30 @@ public class QuartzGrowthAcceleratorBlock extends AEBaseTileBlock<QuartzGrowthAc
case 0:
dx = 0.6;
dz = d1;
pt = new BlockPos(x + west.getOffsetX(), y + west.getOffsetY(), z + west.getZOffset());
pt = new BlockPos(x + west.getOffsetX(), y + west.getOffsetY(), z + west.getOffsetZ());
break;
case 1:
dx = d1;
dz += 0.6;
pt = new BlockPos(x + forward.getOffsetX(), y + forward.getOffsetY(), z + forward.getZOffset());
pt = new BlockPos(x + forward.getOffsetX(), y + forward.getOffsetY(), z + forward.getOffsetZ());
break;
case 2:
dx = d1;
dz = -0.6;
pt = new BlockPos(x - forward.getOffsetX(), y - forward.getOffsetY(), z - forward.getZOffset());
pt = new BlockPos(x - forward.getOffsetX(), y - forward.getOffsetY(), z - forward.getOffsetZ());
break;
case 3:
dx = -0.6;
dz = d1;
pt = new BlockPos(x - west.getOffsetX(), y - west.getOffsetY(), z - west.getZOffset());
pt = new BlockPos(x - west.getOffsetX(), y - west.getOffsetY(), z - west.getOffsetZ());
break;
}
if (!w.getBlockState(pt).getBlock().isAir(w.getBlockState(pt), w, pt)) {
if (!w.getBlockState(pt).isAir()) {
return;
}
@@ -134,7 +134,7 @@ public class QuartzGrowthAcceleratorBlock extends AEBaseTileBlock<QuartzGrowthAc
ry += dz * forward.getOffsetY();
rz += dz * forward.getOffsetZ();
MinecraftClient.getInstance().particles.addParticle(ParticleTypes.LIGHTNING, rx, ry, rz, 0.0D, 0.0D, 0.0D);
MinecraftClient.getInstance().particleManager.addParticle(ParticleTypes.LIGHTNING, rx, ry, rz, 0.0D, 0.0D, 0.0D);
}
}
@@ -25,8 +25,8 @@ import net.minecraft.block.BlockState;
import net.minecraft.block.Material;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.state.BooleanProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.StateManager;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
@@ -41,17 +41,17 @@ import appeng.tile.misc.SecurityStationBlockEntity;
public class SecurityStationBlock extends AEBaseTileBlock<SecurityStationBlockEntity> {
private static final BooleanProperty POWERED = BooleanProperty.create("powered");
private static final BooleanProperty POWERED = BooleanProperty.of("powered");
public SecurityStationBlock() {
super(defaultProps(Material.IRON));
super(defaultProps(Material.METAL));
this.setDefaultState(this.getDefaultState().with(POWERED, false));
}
@Override
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
super.fillStateContainer(builder);
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
super.appendProperties(builder);
builder.add(POWERED);
}
@@ -74,7 +74,7 @@ public class SecurityStationBlock extends AEBaseTileBlock<SecurityStationBlockEn
}
ContainerOpener.openContainer(SecurityStationContainer.TYPE, p,
ContainerLocator.forTileEntitySide(tg, hit.getFace()));
ContainerLocator.forTileEntitySide(tg, hit.getSide()));
return ActionResult.SUCCESS;
}
return ActionResult.PASS;
@@ -29,7 +29,7 @@ import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockView;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.IWorldReader;
import net.minecraft.world.WorldView;
import net.minecraft.world.World;
import appeng.block.AEBaseTileBlock;
@@ -53,11 +53,11 @@ public class SkyCompassBlock extends AEBaseTileBlock<SkyCompassBlockEntity> {
private boolean canPlaceAt(final BlockView w, final BlockPos pos, final Direction dir) {
final BlockPos test = pos.offset(dir);
BlockState blockstate = w.getBlockState(test);
return blockstate.isSolidSide(w, test, dir.getOpposite());
return blockstate.isSideSolidFullSquare(w, test, dir.getOpposite());
}
@Override
public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos,
public void neighborUpdate(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos,
boolean isMoving) {
final SkyCompassBlockEntity sc = this.getBlockEntity(world, pos);
final Direction forward = sc.getForward();
@@ -73,7 +73,7 @@ public class SkyCompassBlock extends AEBaseTileBlock<SkyCompassBlockEntity> {
}
@Override
public boolean isValidPosition(BlockState state, IWorldReader w, BlockPos pos) {
public boolean canPlaceAt(BlockState state, WorldView w, BlockPos pos) {
for (final Direction dir : Direction.values()) {
if (this.canPlaceAt(w, pos, dir)) {
return true;
@@ -83,7 +83,7 @@ public class SkyCompassBlock extends AEBaseTileBlock<SkyCompassBlockEntity> {
}
@Override
public VoxelShape getShape(BlockState state, BlockView w, BlockPos pos, ShapeContext context) {
public VoxelShape getOutlineShape(BlockState state, BlockView w, BlockPos pos, ShapeContext context) {
// TODO: This definitely needs to be memoized
@@ -139,7 +139,7 @@ public class SkyCompassBlock extends AEBaseTileBlock<SkyCompassBlockEntity> {
break;
}
return VoxelShapes.create(new Box(minX, minY, minZ, maxX, maxY, maxZ));
return VoxelShapes.cuboid(new Box(minX, minY, minZ, maxX, maxY, maxZ));
}
return VoxelShapes.empty();
}
@@ -26,7 +26,7 @@ import appeng.bootstrap.TileEntityRenderingCustomizer;
import appeng.client.render.tesr.SkyCompassTESR;
import appeng.tile.misc.SkyCompassBlockEntity;
public class SkyCompassRendering extends TileEntityRenderingCustomizer<SkyCompassBlockEntity> {
public class SkyCompassRendering implements TileEntityRenderingCustomizer<SkyCompassBlockEntity> {
@Override
@Environment(EnvType.CLIENT)
@@ -25,23 +25,22 @@ import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.AbstractArrowEntity;
import net.minecraft.entity.projectile.PersistentProjectileEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvents;
import net.minecraft.sound.SoundCategory;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.block.ShapeContext;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.Explosion;
import net.minecraft.world.explosion.Explosion;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.server.world.ServerWorld;
import appeng.block.AEBaseBlock;
import appeng.entity.TinyTNTPrimedEntity;
@@ -49,11 +48,10 @@ import appeng.entity.TinyTNTPrimedEntity;
public class TinyTNTBlock extends AEBaseBlock {
private static final VoxelShape SHAPE = VoxelShapes
.create(new Box(0.25f, 0.0f, 0.25f, 0.75f, 0.5f, 0.75f));
.cuboid(new Box(0.25f, 0.0f, 0.25f, 0.75f, 0.5f, 0.75f));
public TinyTNTBlock(Settings props) {
super(props);
setFullSize(setOpaque(false));
}
@Override
@@ -62,7 +60,7 @@ public class TinyTNTBlock extends AEBaseBlock {
}
@Override
public VoxelShape getShape(BlockState state, BlockView worldIn, BlockPos pos, ShapeContext context) {
public VoxelShape getOutlineShape(BlockState state, BlockView worldIn, BlockPos pos, ShapeContext context) {
return SHAPE;
}
@@ -72,8 +70,8 @@ public class TinyTNTBlock extends AEBaseBlock {
if (heldItem != null && heldItem.getItem() == Items.FLINT_AND_STEEL) {
this.startFuse(w, pos, player);
w.removeBlock(pos, false);
heldItem.damageItem(1, player, p -> {
p.sendBreakAnimation(hand);
heldItem.damage(1, player, p -> {
p.sendToolBreakStatus(hand);
}); // FIXME Check if onBroken is equivalent
return ActionResult.SUCCESS;
} else {
@@ -92,9 +90,8 @@ public class TinyTNTBlock extends AEBaseBlock {
}
@Override
public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos,
boolean isMoving) {
if (world.getRedstonePowerFromNeighbors(pos) > 0) {
public void neighborUpdate(BlockState state, World world, BlockPos pos, Block block, BlockPos fromPos, boolean notify) {
if (world.isReceivingRedstonePower(pos)) {
this.startFuse(world, pos, null);
world.removeBlock(pos, false);
}
@@ -104,27 +101,23 @@ public class TinyTNTBlock extends AEBaseBlock {
public void onBlockAdded(BlockState state, World w, BlockPos pos, BlockState oldState, boolean isMoving) {
super.onBlockAdded(state, w, pos, oldState, isMoving);
if (w.getRedstonePowerFromNeighbors(pos) > 0) {
if (w.getReceivedStrongRedstonePower(pos) > 0) {
this.startFuse(w, pos, null);
w.removeBlock(pos, false);
}
}
@Override
public void onEntityWalk(final World w, final BlockPos pos, final Entity entity) {
if (entity instanceof AbstractArrowEntity && !w.isClient) {
final AbstractArrowEntity entityarrow = (AbstractArrowEntity) entity;
public void onSteppedOn(final World w, final BlockPos pos, final Entity entity) {
if (entity instanceof PersistentProjectileEntity && !w.isClient) {
final PersistentProjectileEntity entityarrow = (PersistentProjectileEntity) entity;
if (entityarrow.isBurning()) {
if (entityarrow.isOnFire()) {
LivingEntity igniter = null;
// Check if the shooter still exists
if (w instanceof ServerWorld) {
ServerWorld serverWorld = (ServerWorld) w;
Entity shooter = serverWorld.getEntityByUuid(entityarrow.shootingEntity);
if (shooter instanceof LivingEntity) {
igniter = (LivingEntity) shooter;
}
Entity shooter = entityarrow.getOwner();
if (shooter instanceof LivingEntity) {
igniter = (LivingEntity) shooter;
}
this.startFuse(w, pos, igniter);
w.removeBlock(pos, false);
@@ -133,18 +126,18 @@ public class TinyTNTBlock extends AEBaseBlock {
}
@Override
public boolean canDropFromExplosion(final Explosion exp) {
public boolean shouldDropItemsOnExplosion(final Explosion exp) {
return false;
}
@Override
public void onExplosionDestroy(final World w, final BlockPos pos, final Explosion exp) {
super.onExplosionDestroy(w, pos, exp);
public void onDestroyedByExplosion(final World w, final BlockPos pos, final Explosion exp) {
super.onDestroyedByExplosion(w, pos, exp);
if (!w.isClient) {
final TinyTNTPrimedEntity primedTinyTNTEntity = new TinyTNTPrimedEntity(w, pos.getX() + 0.5F,
pos.getY() + 0.5F, pos.getZ() + 0.5F, exp.getExplosivePlacedBy());
pos.getY() + 0.5F, pos.getZ() + 0.5F, exp.getCausingEntity());
primedTinyTNTEntity
.setFuse(w.rand.nextInt(primedTinyTNTEntity.getFuse() / 4) + primedTinyTNTEntity.getFuse() / 8);
.setFuse(w.random.nextInt(primedTinyTNTEntity.getFuse() / 4) + primedTinyTNTEntity.getFuse() / 8);
w.spawnEntity(primedTinyTNTEntity);
}
}
@@ -27,9 +27,9 @@ import net.minecraft.block.BlockState;
import net.minecraft.block.Material;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.particles.ParticleTypes;
import net.minecraft.state.BooleanProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.StateManager;
import net.minecraft.util.ActionResult;
import net.minecraft.util.math.Direction;
import net.minecraft.util.Hand;
@@ -42,17 +42,16 @@ import appeng.container.ContainerLocator;
import appeng.container.ContainerOpener;
import appeng.container.implementations.VibrationChamberContainer;
import appeng.core.AEConfig;
import appeng.tile.AEBaseBlockEntity;
import appeng.tile.misc.VibrationChamberBlockEntity;
import appeng.util.Platform;
public final class VibrationChamberBlock extends AEBaseTileBlock<VibrationChamberBlockEntity> {
// Indicates that the vibration chamber is currently working
private static final BooleanProperty ACTIVE = BooleanProperty.create("active");
private static final BooleanProperty ACTIVE = BooleanProperty.of("active");
public VibrationChamberBlock() {
super(defaultProps(Material.IRON).strength(4.2F));
super(defaultProps(Material.METAL).strength(4.2F));
this.setDefaultState(this.getDefaultState().with(ACTIVE, false));
}
@@ -62,8 +61,8 @@ public final class VibrationChamberBlock extends AEBaseTileBlock<VibrationChambe
}
@Override
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
super.fillStateContainer(builder);
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
super.appendProperties(builder);
builder.add(ACTIVE);
}
@@ -78,7 +77,7 @@ public final class VibrationChamberBlock extends AEBaseTileBlock<VibrationChambe
final VibrationChamberBlockEntity tc = this.getBlockEntity(w, pos);
if (tc != null && !player.isInSneakingPose()) {
ContainerOpener.openContainer(VibrationChamberContainer.TYPE, player,
ContainerLocator.forTileEntitySide(tc, hit.getFace()));
ContainerLocator.forTileEntitySide(tc, hit.getSide()));
return ActionResult.SUCCESS;
}
}
@@ -87,44 +86,41 @@ public final class VibrationChamberBlock extends AEBaseTileBlock<VibrationChambe
}
@Override
public void animateTick(final BlockState state, final World w, final BlockPos pos, final Random r) {
public void randomDisplayTick(final BlockState state, final World w, final BlockPos pos, final Random r) {
if (!AEConfig.instance().isEnableEffects()) {
return;
}
final AEBaseBlockEntity tile = this.getBlockEntity(w, pos);
if (tile instanceof VibrationChamberBlockEntity) {
final VibrationChamberBlockEntity tc = (VibrationChamberBlockEntity) tile;
if (tc.isOn) {
double f1 = pos.getX() + 0.5F;
double f2 = pos.getY() + 0.5F;
double f3 = pos.getZ() + 0.5F;
final VibrationChamberBlockEntity tile = this.getBlockEntity(w, pos);
if (tile != null && tile.isOn) {
double f1 = pos.getX() + 0.5F;
double f2 = pos.getY() + 0.5F;
double f3 = pos.getZ() + 0.5F;
final Direction forward = tc.getForward();
final Direction up = tc.getUp();
final Direction forward = tile.getForward();
final Direction up = tile.getUp();
final int west_x = forward.getOffsetY() * up.getOffsetZ() - forward.getOffsetZ() * up.getOffsetY();
final int west_y = forward.getOffsetZ() * up.getOffsetX() - forward.getOffsetX() * up.getOffsetZ();
final int west_z = forward.getOffsetX() * up.getOffsetY() - forward.getOffsetY() * up.getOffsetX();
final int west_x = forward.getOffsetY() * up.getOffsetZ() - forward.getOffsetZ() * up.getOffsetY();
final int west_y = forward.getOffsetZ() * up.getOffsetX() - forward.getOffsetX() * up.getOffsetZ();
final int west_z = forward.getOffsetX() * up.getOffsetY() - forward.getOffsetY() * up.getOffsetX();
f1 += forward.getOffsetX() * 0.6;
f2 += forward.getOffsetY() * 0.6;
f3 += forward.getOffsetZ() * 0.6;
f1 += forward.getOffsetX() * 0.6;
f2 += forward.getOffsetY() * 0.6;
f3 += forward.getOffsetZ() * 0.6;
final double ox = r.nextDouble();
final double oy = r.nextDouble() * 0.2f;
final double ox = r.nextDouble();
final double oy = r.nextDouble() * 0.2f;
f1 += up.getOffsetX() * (-0.3 + oy);
f2 += up.getOffsetY() * (-0.3 + oy);
f3 += up.getOffsetZ() * (-0.3 + oy);
f1 += up.getOffsetX() * (-0.3 + oy);
f2 += up.getOffsetY() * (-0.3 + oy);
f3 += up.getOffsetZ() * (-0.3 + oy);
f1 += west_x * (0.3 * ox - 0.15);
f2 += west_y * (0.3 * ox - 0.15);
f3 += west_z * (0.3 * ox - 0.15);
f1 += west_x * (0.3 * ox - 0.15);
f2 += west_y * (0.3 * ox - 0.15);
f3 += west_z * (0.3 * ox - 0.15);
w.addParticle(ParticleTypes.SMOKE, f1, f2, f3, 0.0D, 0.0D, 0.0D);
w.addParticle(ParticleTypes.FLAME, f1, f2, f3, 0.0D, 0.0D, 0.0D);
}
w.addParticle(ParticleTypes.SMOKE, f1, f2, f3, 0.0D, 0.0D, 0.0D);
w.addParticle(ParticleTypes.FLAME, f1, f2, f3, 0.0D, 0.0D, 0.0D);
}
}
}