1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-11-12 03:13:00 +00:00

Reformat everything

This commit is contained in:
Jonathan Coates
2021-06-09 07:53:21 +01:00
parent a6c7236fa0
commit b429095f88
409 changed files with 20797 additions and 15102 deletions

View File

@@ -6,11 +6,6 @@
package dan200.computercraft.shared.common;
import java.util.Random;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import net.minecraft.block.Block;
import net.minecraft.block.BlockRenderType;
import net.minecraft.block.BlockState;
@@ -26,40 +21,52 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
public abstract class BlockGeneric extends BlockWithEntity {
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Random;
public abstract class BlockGeneric extends BlockWithEntity
{
private final BlockEntityType<? extends TileGeneric> type;
public BlockGeneric(Settings settings, BlockEntityType<? extends TileGeneric> type) {
super(settings);
public BlockGeneric( Settings settings, BlockEntityType<? extends TileGeneric> type )
{
super( settings );
this.type = type;
}
@Override
public BlockRenderType getRenderType(BlockState state) {
public BlockRenderType getRenderType( BlockState state )
{
return BlockRenderType.MODEL;
}
@Override
@Deprecated
public final void neighborUpdate(@Nonnull BlockState state, World world, @Nonnull BlockPos pos, @Nonnull Block neighbourBlock,
@Nonnull BlockPos neighbourPos, boolean isMoving) {
BlockEntity tile = world.getBlockEntity(pos);
if (tile instanceof TileGeneric) {
((TileGeneric) tile).onNeighbourChange(neighbourPos);
public final void neighborUpdate( @Nonnull BlockState state, World world, @Nonnull BlockPos pos, @Nonnull Block neighbourBlock,
@Nonnull BlockPos neighbourPos, boolean isMoving )
{
BlockEntity tile = world.getBlockEntity( pos );
if( tile instanceof TileGeneric )
{
((TileGeneric) tile).onNeighbourChange( neighbourPos );
}
}
@Override
@Deprecated
public final void onStateReplaced(@Nonnull BlockState block, @Nonnull World world, @Nonnull BlockPos pos, BlockState replace, boolean bool) {
if (block.getBlock() == replace.getBlock()) {
public final void onStateReplaced( @Nonnull BlockState block, @Nonnull World world, @Nonnull BlockPos pos, BlockState replace, boolean bool )
{
if( block.getBlock() == replace.getBlock() )
{
return;
}
BlockEntity tile = world.getBlockEntity(pos);
super.onStateReplaced(block, world, pos, replace, bool);
world.removeBlockEntity(pos);
if (tile instanceof TileGeneric) {
BlockEntity tile = world.getBlockEntity( pos );
super.onStateReplaced( block, world, pos, replace, bool );
world.removeBlockEntity( pos );
if( tile instanceof TileGeneric )
{
((TileGeneric) tile).destroy();
}
}
@@ -67,24 +74,28 @@ public abstract class BlockGeneric extends BlockWithEntity {
@Nonnull
@Override
@Deprecated
public final ActionResult onUse(@Nonnull BlockState state, World world, @Nonnull BlockPos pos, @Nonnull PlayerEntity player, @Nonnull Hand hand,
@Nonnull BlockHitResult hit) {
BlockEntity tile = world.getBlockEntity(pos);
return tile instanceof TileGeneric ? ((TileGeneric) tile).onActivate(player, hand, hit) : ActionResult.PASS;
public final ActionResult onUse( @Nonnull BlockState state, World world, @Nonnull BlockPos pos, @Nonnull PlayerEntity player, @Nonnull Hand hand,
@Nonnull BlockHitResult hit )
{
BlockEntity tile = world.getBlockEntity( pos );
return tile instanceof TileGeneric ? ((TileGeneric) tile).onActivate( player, hand, hit ) : ActionResult.PASS;
}
@Override
@Deprecated
public void scheduledTick(@Nonnull BlockState state, ServerWorld world, @Nonnull BlockPos pos, @Nonnull Random rand) {
BlockEntity te = world.getBlockEntity(pos);
if (te instanceof TileGeneric) {
public void scheduledTick( @Nonnull BlockState state, ServerWorld world, @Nonnull BlockPos pos, @Nonnull Random rand )
{
BlockEntity te = world.getBlockEntity( pos );
if( te instanceof TileGeneric )
{
((TileGeneric) te).blockTick();
}
}
@Nullable
@Override
public BlockEntity createBlockEntity(@Nonnull BlockView world) {
public BlockEntity createBlockEntity( @Nonnull BlockView world )
{
return this.type.instantiate();
}
}

View File

@@ -8,21 +8,23 @@ package dan200.computercraft.shared.common;
import dan200.computercraft.core.terminal.Terminal;
import dan200.computercraft.shared.network.client.TerminalState;
import net.minecraft.nbt.CompoundTag;
public class ClientTerminal implements ITerminal {
public class ClientTerminal implements ITerminal
{
private boolean m_colour;
private Terminal m_terminal;
private boolean m_terminalChanged;
public ClientTerminal(boolean colour) {
public ClientTerminal( boolean colour )
{
this.m_colour = colour;
this.m_terminal = null;
this.m_terminalChanged = false;
}
public boolean pollTerminalChanged() {
public boolean pollTerminalChanged()
{
boolean changed = this.m_terminalChanged;
this.m_terminalChanged = false;
return changed;
@@ -31,48 +33,64 @@ public class ClientTerminal implements ITerminal {
// ITerminal implementation
@Override
public Terminal getTerminal() {
public Terminal getTerminal()
{
return this.m_terminal;
}
@Override
public boolean isColour() {
public boolean isColour()
{
return this.m_colour;
}
public void read(TerminalState state) {
public void read( TerminalState state )
{
this.m_colour = state.colour;
if (state.hasTerminal()) {
this.resizeTerminal(state.width, state.height);
state.apply(this.m_terminal);
} else {
if( state.hasTerminal() )
{
this.resizeTerminal( state.width, state.height );
state.apply( this.m_terminal );
}
else
{
this.deleteTerminal();
}
}
private void resizeTerminal(int width, int height) {
if (this.m_terminal == null) {
this.m_terminal = new Terminal(width, height, () -> this.m_terminalChanged = true);
private void resizeTerminal( int width, int height )
{
if( this.m_terminal == null )
{
this.m_terminal = new Terminal( width, height, () -> this.m_terminalChanged = true );
this.m_terminalChanged = true;
} else {
this.m_terminal.resize(width, height);
}
else
{
this.m_terminal.resize( width, height );
}
}
private void deleteTerminal() {
if (this.m_terminal != null) {
private void deleteTerminal()
{
if( this.m_terminal != null )
{
this.m_terminal = null;
this.m_terminalChanged = true;
}
}
public void readDescription(CompoundTag nbt) {
this.m_colour = nbt.getBoolean("colour");
if (nbt.contains("terminal")) {
CompoundTag terminal = nbt.getCompound("terminal");
this.resizeTerminal(terminal.getInt("term_width"), terminal.getInt("term_height"));
this.m_terminal.readFromNBT(terminal);
} else {
public void readDescription( CompoundTag nbt )
{
this.m_colour = nbt.getBoolean( "colour" );
if( nbt.contains( "terminal" ) )
{
CompoundTag terminal = nbt.getCompound( "terminal" );
this.resizeTerminal( terminal.getInt( "term_width" ), terminal.getInt( "term_height" ) );
this.m_terminal.readFromNBT( terminal );
}
else
{
this.deleteTerminal();
}
}

View File

@@ -6,11 +6,8 @@
package dan200.computercraft.shared.common;
import javax.annotation.Nonnull;
import dan200.computercraft.shared.util.ColourTracker;
import dan200.computercraft.shared.util.ColourUtils;
import net.minecraft.inventory.CraftingInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.recipe.RecipeSerializer;
@@ -20,31 +17,44 @@ import net.minecraft.util.DyeColor;
import net.minecraft.util.Identifier;
import net.minecraft.world.World;
public final class ColourableRecipe extends SpecialCraftingRecipe {
public static final RecipeSerializer<?> SERIALIZER = new SpecialRecipeSerializer<>(ColourableRecipe::new);
import javax.annotation.Nonnull;
private ColourableRecipe(Identifier id) {
super(id);
public final class ColourableRecipe extends SpecialCraftingRecipe
{
public static final RecipeSerializer<?> SERIALIZER = new SpecialRecipeSerializer<>( ColourableRecipe::new );
private ColourableRecipe( Identifier id )
{
super( id );
}
@Override
public boolean matches(@Nonnull CraftingInventory inv, @Nonnull World world) {
public boolean matches( @Nonnull CraftingInventory inv, @Nonnull World world )
{
boolean hasColourable = false;
boolean hasDye = false;
for (int i = 0; i < inv.size(); i++) {
ItemStack stack = inv.getStack(i);
if (stack.isEmpty()) {
for( int i = 0; i < inv.size(); i++ )
{
ItemStack stack = inv.getStack( i );
if( stack.isEmpty() )
{
continue;
}
if (stack.getItem() instanceof IColouredItem) {
if (hasColourable) {
if( stack.getItem() instanceof IColouredItem )
{
if( hasColourable )
{
return false;
}
hasColourable = true;
} else if (ColourUtils.getStackColour(stack) != null) {
}
else if( ColourUtils.getStackColour( stack ) != null )
{
hasDye = true;
} else {
}
else
{
return false;
}
}
@@ -54,15 +64,18 @@ public final class ColourableRecipe extends SpecialCraftingRecipe {
@Nonnull
@Override
public ItemStack craft(@Nonnull CraftingInventory inv) {
public ItemStack craft( @Nonnull CraftingInventory inv )
{
ItemStack colourable = ItemStack.EMPTY;
ColourTracker tracker = new ColourTracker();
for (int i = 0; i < inv.size(); i++) {
ItemStack stack = inv.getStack(i);
for( int i = 0; i < inv.size(); i++ )
{
ItemStack stack = inv.getStack( i );
if (stack.isEmpty()) {
if( stack.isEmpty() )
{
continue;
}
else
@@ -80,13 +93,15 @@ public final class ColourableRecipe extends SpecialCraftingRecipe {
}
@Override
public boolean fits(int x, int y) {
public boolean fits( int x, int y )
{
return x >= 2 && y >= 2;
}
@Override
@Nonnull
public RecipeSerializer<?> getSerializer() {
public RecipeSerializer<?> getSerializer()
{
return SERIALIZER;
}
}

View File

@@ -6,12 +6,9 @@
package dan200.computercraft.shared.common;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import dan200.computercraft.shared.ComputerCraftRegistry;
import dan200.computercraft.shared.network.container.HeldItemContainerData;
import net.fabricmc.fabric.api.screenhandler.v1.ExtendedScreenHandlerFactory;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.ItemStack;
@@ -23,49 +20,59 @@ import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.Text;
import net.minecraft.util.Hand;
import net.fabricmc.fabric.api.screenhandler.v1.ExtendedScreenHandlerFactory;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class ContainerHeldItem extends ScreenHandler {
public class ContainerHeldItem extends ScreenHandler
{
private final ItemStack stack;
private final Hand hand;
public ContainerHeldItem(ScreenHandlerType<? extends ContainerHeldItem> type, int id, PlayerEntity player, Hand hand) {
super(type, id);
public ContainerHeldItem( ScreenHandlerType<? extends ContainerHeldItem> type, int id, PlayerEntity player, Hand hand )
{
super( type, id );
this.hand = hand;
this.stack = player.getStackInHand(hand)
.copy();
this.stack = player.getStackInHand( hand )
.copy();
}
public static ContainerHeldItem createPrintout(int id, PlayerInventory inventory, PacketByteBuf data) {
return createPrintout(id, inventory, new HeldItemContainerData(data));
public static ContainerHeldItem createPrintout( int id, PlayerInventory inventory, PacketByteBuf data )
{
return createPrintout( id, inventory, new HeldItemContainerData( data ) );
}
public static ContainerHeldItem createPrintout(int id, PlayerInventory inventory, HeldItemContainerData data) {
return new ContainerHeldItem(ComputerCraftRegistry.ModContainers.PRINTOUT, id, inventory.player, data.getHand());
public static ContainerHeldItem createPrintout( int id, PlayerInventory inventory, HeldItemContainerData data )
{
return new ContainerHeldItem( ComputerCraftRegistry.ModContainers.PRINTOUT, id, inventory.player, data.getHand() );
}
@Nonnull
public ItemStack getStack() {
public ItemStack getStack()
{
return this.stack;
}
@Override
public boolean canUse(@Nonnull PlayerEntity player) {
if (!player.isAlive()) {
public boolean canUse( @Nonnull PlayerEntity player )
{
if( !player.isAlive() )
{
return false;
}
ItemStack stack = player.getStackInHand(this.hand);
ItemStack stack = player.getStackInHand( this.hand );
return stack == this.stack || !stack.isEmpty() && !this.stack.isEmpty() && stack.getItem() == this.stack.getItem();
}
public static class Factory implements NamedScreenHandlerFactory, ExtendedScreenHandlerFactory {
public static class Factory implements NamedScreenHandlerFactory, ExtendedScreenHandlerFactory
{
private final ScreenHandlerType<ContainerHeldItem> type;
private final Text name;
private final Hand hand;
public Factory(ScreenHandlerType<ContainerHeldItem> type, ItemStack stack, Hand hand) {
public Factory( ScreenHandlerType<ContainerHeldItem> type, ItemStack stack, Hand hand )
{
this.type = type;
this.name = stack.getName();
this.hand = hand;
@@ -73,19 +80,22 @@ public class ContainerHeldItem extends ScreenHandler {
@Nonnull
@Override
public Text getDisplayName() {
public Text getDisplayName()
{
return this.name;
}
@Nullable
@Override
public ScreenHandler createMenu(int id, @Nonnull PlayerInventory inventory, @Nonnull PlayerEntity player) {
return new ContainerHeldItem(this.type, id, player, this.hand);
public ScreenHandler createMenu( int id, @Nonnull PlayerInventory inventory, @Nonnull PlayerEntity player )
{
return new ContainerHeldItem( this.type, id, player, this.hand );
}
@Override
public void writeScreenOpeningData(ServerPlayerEntity serverPlayerEntity, PacketByteBuf packetByteBuf) {
packetByteBuf.writeEnumConstant(this.hand);
public void writeScreenOpeningData( ServerPlayerEntity serverPlayerEntity, PacketByteBuf packetByteBuf )
{
packetByteBuf.writeEnumConstant( this.hand );
}
}
}

View File

@@ -6,28 +6,32 @@
package dan200.computercraft.shared.common;
import javax.annotation.Nonnull;
import dan200.computercraft.api.redstone.IBundledRedstoneProvider;
import net.minecraft.block.Block;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
public class DefaultBundledRedstoneProvider implements IBundledRedstoneProvider {
import javax.annotation.Nonnull;
public class DefaultBundledRedstoneProvider implements IBundledRedstoneProvider
{
@Override
public int getBundledRedstoneOutput(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull Direction side) {
return getDefaultBundledRedstoneOutput(world, pos, side);
public int getBundledRedstoneOutput( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull Direction side )
{
return getDefaultBundledRedstoneOutput( world, pos, side );
}
public static int getDefaultBundledRedstoneOutput(World world, BlockPos pos, Direction side) {
Block block = world.getBlockState(pos)
.getBlock();
if (block instanceof IBundledRedstoneBlock) {
public static int getDefaultBundledRedstoneOutput( World world, BlockPos pos, Direction side )
{
Block block = world.getBlockState( pos )
.getBlock();
if( block instanceof IBundledRedstoneBlock )
{
IBundledRedstoneBlock generic = (IBundledRedstoneBlock) block;
if (generic.getBundledRedstoneConnectivity(world, pos, side)) {
return generic.getBundledRedstoneOutput(world, pos, side);
if( generic.getBundledRedstoneConnectivity( world, pos, side ) )
{
return generic.getBundledRedstoneOutput( world, pos, side );
}
}
return -1;

View File

@@ -10,8 +10,9 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
public interface IBundledRedstoneBlock {
boolean getBundledRedstoneConnectivity(World world, BlockPos pos, Direction side);
public interface IBundledRedstoneBlock
{
boolean getBundledRedstoneConnectivity( World world, BlockPos pos, Direction side );
int getBundledRedstoneOutput(World world, BlockPos pos, Direction side);
int getBundledRedstoneOutput( World world, BlockPos pos, Direction side );
}

View File

@@ -9,33 +9,42 @@ package dan200.computercraft.shared.common;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
public interface IColouredItem {
public interface IColouredItem
{
String NBT_COLOUR = "Color";
default int getColour(ItemStack stack) {
return getColourBasic(stack);
default int getColour( ItemStack stack )
{
return getColourBasic( stack );
}
static int getColourBasic(ItemStack stack) {
static int getColourBasic( ItemStack stack )
{
CompoundTag tag = stack.getTag();
return tag != null && tag.contains(NBT_COLOUR) ? tag.getInt(NBT_COLOUR) : -1;
return tag != null && tag.contains( NBT_COLOUR ) ? tag.getInt( NBT_COLOUR ) : -1;
}
default ItemStack withColour(ItemStack stack, int colour) {
default ItemStack withColour( ItemStack stack, int colour )
{
ItemStack copy = stack.copy();
setColourBasic(copy, colour);
setColourBasic( copy, colour );
return copy;
}
static void setColourBasic(ItemStack stack, int colour) {
if (colour == -1) {
static void setColourBasic( ItemStack stack, int colour )
{
if( colour == -1 )
{
CompoundTag tag = stack.getTag();
if (tag != null) {
tag.remove(NBT_COLOUR);
if( tag != null )
{
tag.remove( NBT_COLOUR );
}
} else {
}
else
{
stack.getOrCreateTag()
.putInt(NBT_COLOUR, colour);
.putInt( NBT_COLOUR, colour );
}
}
}

View File

@@ -8,7 +8,8 @@ package dan200.computercraft.shared.common;
import dan200.computercraft.core.terminal.Terminal;
public interface ITerminal {
public interface ITerminal
{
Terminal getTerminal();
boolean isColour();

View File

@@ -6,79 +6,95 @@
package dan200.computercraft.shared.common;
import java.util.concurrent.atomic.AtomicBoolean;
import dan200.computercraft.core.terminal.Terminal;
import dan200.computercraft.shared.network.client.TerminalState;
import net.minecraft.nbt.CompoundTag;
public class ServerTerminal implements ITerminal {
import java.util.concurrent.atomic.AtomicBoolean;
public class ServerTerminal implements ITerminal
{
private final boolean m_colour;
private final AtomicBoolean m_terminalChanged = new AtomicBoolean(false);
private final AtomicBoolean m_terminalChanged = new AtomicBoolean( false );
private Terminal m_terminal;
private boolean m_terminalChangedLastFrame = false;
public ServerTerminal(boolean colour) {
public ServerTerminal( boolean colour )
{
this.m_colour = colour;
this.m_terminal = null;
}
public ServerTerminal(boolean colour, int terminalWidth, int terminalHeight) {
public ServerTerminal( boolean colour, int terminalWidth, int terminalHeight )
{
this.m_colour = colour;
this.m_terminal = new Terminal(terminalWidth, terminalHeight, this::markTerminalChanged);
this.m_terminal = new Terminal( terminalWidth, terminalHeight, this::markTerminalChanged );
}
protected void markTerminalChanged() {
this.m_terminalChanged.set(true);
protected void markTerminalChanged()
{
this.m_terminalChanged.set( true );
}
protected void resize(int width, int height) {
if (this.m_terminal == null) {
this.m_terminal = new Terminal(width, height, this::markTerminalChanged);
protected void resize( int width, int height )
{
if( this.m_terminal == null )
{
this.m_terminal = new Terminal( width, height, this::markTerminalChanged );
this.markTerminalChanged();
} else {
this.m_terminal.resize(width, height);
}
else
{
this.m_terminal.resize( width, height );
}
}
public void delete() {
if (this.m_terminal != null) {
public void delete()
{
if( this.m_terminal != null )
{
this.m_terminal = null;
this.markTerminalChanged();
}
}
public void update() {
this.m_terminalChangedLastFrame = this.m_terminalChanged.getAndSet(false);
public void update()
{
this.m_terminalChangedLastFrame = this.m_terminalChanged.getAndSet( false );
}
public boolean hasTerminalChanged() {
public boolean hasTerminalChanged()
{
return this.m_terminalChangedLastFrame;
}
@Override
public Terminal getTerminal() {
public Terminal getTerminal()
{
return this.m_terminal;
}
@Override
public boolean isColour() {
public boolean isColour()
{
return this.m_colour;
}
public TerminalState write() {
return new TerminalState(this.m_colour, this.m_terminal);
public TerminalState write()
{
return new TerminalState( this.m_colour, this.m_terminal );
}
public void writeDescription(CompoundTag nbt) {
nbt.putBoolean("colour", this.m_colour);
if (this.m_terminal != null) {
public void writeDescription( CompoundTag nbt )
{
nbt.putBoolean( "colour", this.m_colour );
if( this.m_terminal != null )
{
CompoundTag terminal = new CompoundTag();
terminal.putInt("term_width", this.m_terminal.getWidth());
terminal.putInt("term_height", this.m_terminal.getHeight());
this.m_terminal.writeToNBT(terminal);
nbt.put("terminal", terminal);
terminal.putInt( "term_width", this.m_terminal.getWidth() );
terminal.putInt( "term_height", this.m_terminal.getHeight() );
this.m_terminal.writeToNBT( terminal );
nbt.put( "terminal", terminal );
}
}
}

View File

@@ -6,8 +6,7 @@
package dan200.computercraft.shared.common;
import javax.annotation.Nonnull;
import net.fabricmc.fabric.api.block.entity.BlockEntityClientSerializable;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityType;
@@ -18,71 +17,88 @@ import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.fabricmc.fabric.api.block.entity.BlockEntityClientSerializable;
import javax.annotation.Nonnull;
public abstract class TileGeneric extends BlockEntity implements BlockEntityClientSerializable {
public TileGeneric(BlockEntityType<? extends TileGeneric> type) {
super(type);
public abstract class TileGeneric extends BlockEntity implements BlockEntityClientSerializable
{
public TileGeneric( BlockEntityType<? extends TileGeneric> type )
{
super( type );
}
public void destroy() {
public void destroy()
{
}
public void onChunkUnloaded() {
public void onChunkUnloaded()
{
}
public final void updateBlock() {
public final void updateBlock()
{
this.markDirty();
BlockPos pos = this.getPos();
BlockState state = this.getCachedState();
this.getWorld().updateListeners(pos, state, state, 3);
this.getWorld().updateListeners( pos, state, state, 3 );
}
@Nonnull
public ActionResult onActivate(PlayerEntity player, Hand hand, BlockHitResult hit) {
public ActionResult onActivate( PlayerEntity player, Hand hand, BlockHitResult hit )
{
return ActionResult.PASS;
}
public void onNeighbourChange(@Nonnull BlockPos neighbour) {
public void onNeighbourChange( @Nonnull BlockPos neighbour )
{
}
public void onNeighbourTileEntityChange(@Nonnull BlockPos neighbour) {
public void onNeighbourTileEntityChange( @Nonnull BlockPos neighbour )
{
}
protected void blockTick() {
protected void blockTick()
{
}
public boolean isUsable(PlayerEntity player, boolean ignoreRange) {
if (player == null || !player.isAlive() || this.getWorld().getBlockEntity(this.getPos()) != this) {
public boolean isUsable( PlayerEntity player, boolean ignoreRange )
{
if( player == null || !player.isAlive() || this.getWorld().getBlockEntity( this.getPos() ) != this )
{
return false;
}
if (ignoreRange) {
if( ignoreRange )
{
return true;
}
double range = this.getInteractRange(player);
double range = this.getInteractRange( player );
BlockPos pos = this.getPos();
return player.getEntityWorld() == this.getWorld() && player.squaredDistanceTo(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5) <= range * range;
return player.getEntityWorld() == this.getWorld() && player.squaredDistanceTo( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 ) <= range * range;
}
protected double getInteractRange(PlayerEntity player) {
protected double getInteractRange( PlayerEntity player )
{
return 8.0;
}
@Override
public void fromClientTag(CompoundTag compoundTag) {
this.readDescription(compoundTag);
public void fromClientTag( CompoundTag compoundTag )
{
this.readDescription( compoundTag );
}
protected void readDescription(@Nonnull CompoundTag nbt) {
protected void readDescription( @Nonnull CompoundTag nbt )
{
}
@Override
public CompoundTag toClientTag(CompoundTag compoundTag) {
this.writeDescription(compoundTag);
public CompoundTag toClientTag( CompoundTag compoundTag )
{
this.writeDescription( compoundTag );
return compoundTag;
}
protected void writeDescription(@Nonnull CompoundTag nbt) {
protected void writeDescription( @Nonnull CompoundTag nbt )
{
}
}