1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-10-30 05:12:58 +00:00

It now compiles.

This commit is contained in:
Jacob Farley
2020-08-31 19:09:22 -05:00
parent cb549d8f43
commit 76fe33760d
212 changed files with 3518 additions and 5783 deletions

View File

@@ -6,7 +6,9 @@
package dan200.computercraft.shared.common;
import net.minecraft.block.Block;
import net.minecraft.block.BlockEntityProvider;
import net.minecraft.block.BlockState;
import net.minecraft.block.BlockWithEntity;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.entity.player.PlayerEntity;
@@ -15,16 +17,17 @@ import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.WorldView;
import net.minecraftforge.fml.RegistryObject;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Random;
public abstract class BlockGeneric extends Block
public abstract class BlockGeneric extends BlockWithEntity
{
private final BlockEntityType<? extends TileGeneric> type;
@@ -63,13 +66,6 @@ public abstract class BlockGeneric extends Block
if( tile instanceof TileGeneric ) ((TileGeneric) tile).onNeighbourChange( neighbourPos );
}
@Override
public final void onNeighborChange( BlockState state, WorldView world, BlockPos pos, BlockPos neighbour )
{
BlockEntity tile = world.getBlockEntity( pos );
if( tile instanceof TileGeneric ) ((TileGeneric) tile).onNeighbourTileEntityChange( neighbour );
}
@Override
@Deprecated
public void scheduledTick( @Nonnull BlockState state, ServerWorld world, @Nonnull BlockPos pos, @Nonnull Random rand )
@@ -78,22 +74,10 @@ public abstract class BlockGeneric extends Block
if( te instanceof TileGeneric ) ((TileGeneric) te).blockTick();
}
@Override
public boolean hasTileEntity( BlockState state )
{
return true;
}
@Nullable
@Override
public BlockEntity createTileEntity( @Nonnull BlockState state, @Nonnull BlockView world )
public BlockEntity createBlockEntity(@Nonnull BlockView world )
{
return type.get().instantiate();
}
@Override
public boolean canBeReplacedByLeaves( BlockState state, WorldView world, BlockPos pos )
{
return false;
return type.instantiate();
}
}

View File

@@ -56,7 +56,7 @@ public final class ColourableRecipe extends SpecialCraftingRecipe
@Nonnull
@Override
public ItemStack getCraftingResult( @Nonnull CraftingInventory inv )
public ItemStack craft( @Nonnull CraftingInventory inv )
{
ItemStack colourable = ItemStack.EMPTY;

View File

@@ -5,14 +5,17 @@
*/
package dan200.computercraft.shared.common;
import dan200.computercraft.shared.Registry;
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;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.screen.NamedScreenHandlerFactory;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.screen.ScreenHandlerType;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.Text;
import net.minecraft.util.Hand;
import javax.annotation.Nonnull;
@@ -31,9 +34,14 @@ public class ContainerHeldItem extends ScreenHandler
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, HeldItemContainerData data )
{
return new ContainerHeldItem( Registry.ModContainers.PRINTOUT.get(), id, inventory.player, data.getHand() );
return new ContainerHeldItem( ComputerCraftRegistry.ModContainers.PRINTOUT, id, inventory.player, data.getHand() );
}
@Nonnull
@@ -51,7 +59,7 @@ public class ContainerHeldItem extends ScreenHandler
return stack == this.stack || !stack.isEmpty() && !this.stack.isEmpty() && stack.getItem() == this.stack.getItem();
}
public static class Factory implements NamedScreenHandlerFactory
public static class Factory implements NamedScreenHandlerFactory, ExtendedScreenHandlerFactory
{
private final ScreenHandlerType<ContainerHeldItem> type;
private final Text name;
@@ -77,5 +85,10 @@ public class ContainerHeldItem extends ScreenHandler
{
return new ContainerHeldItem( type, id, player, hand );
}
@Override
public void writeScreenOpeningData(ServerPlayerEntity serverPlayerEntity, PacketByteBuf packetByteBuf) {
packetByteBuf.writeEnumConstant(hand);
}
}
}

View File

@@ -5,6 +5,7 @@
*/
package dan200.computercraft.shared.common;
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,7 +19,7 @@ import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import javax.annotation.Nonnull;
public abstract class TileGeneric extends BlockEntity
public abstract class TileGeneric extends BlockEntity implements BlockEntityClientSerializable
{
public TileGeneric( BlockEntityType<? extends TileGeneric> type )
{
@@ -89,9 +90,14 @@ public abstract class TileGeneric extends BlockEntity
}
@Override
public final void onDataPacket( ClientConnection net, BlockEntityUpdateS2CPacket packet )
{
if( packet.getBlockEntityType() == 0 ) readDescription( packet.getCompoundTag() );
public CompoundTag toClientTag(CompoundTag compoundTag) {
writeDescription(compoundTag);
return compoundTag;
}
@Override
public void fromClientTag(CompoundTag compoundTag) {
readDescription(compoundTag);
}
@Nonnull
@@ -102,11 +108,4 @@ public abstract class TileGeneric extends BlockEntity
writeDescription( tag );
return tag;
}
@Override
public void handleUpdateTag( @Nonnull BlockState state, @Nonnull CompoundTag tag )
{
super.handleUpdateTag( state, tag );
readDescription( tag );
}
}