mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-01-11 18:00:29 +00:00
Switch to Forge's DeferredRegister
Well, mostly. We currently don't do recipe serializers as I'm a little too lazy. For items, blocks and TE types this does make registration nicer - we've some helper functions which help reduce duplication. Some types (containers, TEs, etc..) are a little less nice, as we now must define the registry object (i.e. the WhateverType<?>) in a separate class to the class it constructs. However, it's probably a worthwhile price to pay.
This commit is contained in:
parent
e4c422d6f9
commit
613a28a5af
@ -9,27 +9,12 @@ import dan200.computercraft.api.turtle.event.TurtleAction;
|
||||
import dan200.computercraft.core.apis.http.options.Action;
|
||||
import dan200.computercraft.core.apis.http.options.AddressRule;
|
||||
import dan200.computercraft.shared.Config;
|
||||
import dan200.computercraft.shared.computer.blocks.BlockComputer;
|
||||
import dan200.computercraft.shared.Registry;
|
||||
import dan200.computercraft.shared.computer.core.ClientComputerRegistry;
|
||||
import dan200.computercraft.shared.computer.core.ServerComputerRegistry;
|
||||
import dan200.computercraft.shared.computer.items.ItemComputer;
|
||||
import dan200.computercraft.shared.media.items.ItemDisk;
|
||||
import dan200.computercraft.shared.media.items.ItemPrintout;
|
||||
import dan200.computercraft.shared.media.items.ItemTreasureDisk;
|
||||
import dan200.computercraft.shared.peripheral.diskdrive.BlockDiskDrive;
|
||||
import dan200.computercraft.shared.peripheral.modem.wired.BlockCable;
|
||||
import dan200.computercraft.shared.peripheral.modem.wired.BlockWiredModemFull;
|
||||
import dan200.computercraft.shared.peripheral.modem.wired.ItemBlockCable;
|
||||
import dan200.computercraft.shared.peripheral.modem.wireless.BlockWirelessModem;
|
||||
import dan200.computercraft.shared.peripheral.monitor.BlockMonitor;
|
||||
import dan200.computercraft.shared.peripheral.monitor.MonitorRenderer;
|
||||
import dan200.computercraft.shared.peripheral.printer.BlockPrinter;
|
||||
import dan200.computercraft.shared.peripheral.speaker.BlockSpeaker;
|
||||
import dan200.computercraft.shared.pocket.items.ItemPocketComputer;
|
||||
import dan200.computercraft.shared.pocket.peripherals.PocketModem;
|
||||
import dan200.computercraft.shared.pocket.peripherals.PocketSpeaker;
|
||||
import dan200.computercraft.shared.turtle.blocks.BlockTurtle;
|
||||
import dan200.computercraft.shared.turtle.items.ItemTurtle;
|
||||
import dan200.computercraft.shared.turtle.upgrades.*;
|
||||
import net.minecraft.resources.IReloadableResourceManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
@ -117,53 +102,6 @@ public final class ComputerCraft
|
||||
public static final int terminalWidth_pocketComputer = 26;
|
||||
public static final int terminalHeight_pocketComputer = 20;
|
||||
|
||||
// Blocks and Items
|
||||
public static final class Blocks
|
||||
{
|
||||
public static BlockComputer computerNormal;
|
||||
public static BlockComputer computerAdvanced;
|
||||
public static BlockComputer computerCommand;
|
||||
|
||||
public static BlockTurtle turtleNormal;
|
||||
public static BlockTurtle turtleAdvanced;
|
||||
|
||||
public static BlockSpeaker speaker;
|
||||
public static BlockDiskDrive diskDrive;
|
||||
public static BlockPrinter printer;
|
||||
|
||||
public static BlockMonitor monitorNormal;
|
||||
public static BlockMonitor monitorAdvanced;
|
||||
|
||||
public static BlockWirelessModem wirelessModemNormal;
|
||||
public static BlockWirelessModem wirelessModemAdvanced;
|
||||
|
||||
public static BlockWiredModemFull wiredModemFull;
|
||||
public static BlockCable cable;
|
||||
}
|
||||
|
||||
public static final class Items
|
||||
{
|
||||
public static ItemComputer computerNormal;
|
||||
public static ItemComputer computerAdvanced;
|
||||
public static ItemComputer computerCommand;
|
||||
|
||||
public static ItemPocketComputer pocketComputerNormal;
|
||||
public static ItemPocketComputer pocketComputerAdvanced;
|
||||
|
||||
public static ItemTurtle turtleNormal;
|
||||
public static ItemTurtle turtleAdvanced;
|
||||
|
||||
public static ItemDisk disk;
|
||||
public static ItemTreasureDisk treasureDisk;
|
||||
|
||||
public static ItemPrintout printedPage;
|
||||
public static ItemPrintout printedPages;
|
||||
public static ItemPrintout printedBook;
|
||||
|
||||
public static ItemBlockCable.Cable cable;
|
||||
public static ItemBlockCable.WiredModem wiredModem;
|
||||
}
|
||||
|
||||
public static final class TurtleUpgrades
|
||||
{
|
||||
public static TurtleModem wirelessModemNormal;
|
||||
@ -194,7 +132,8 @@ public final class ComputerCraft
|
||||
|
||||
public ComputerCraft()
|
||||
{
|
||||
Config.load();
|
||||
Config.setup();
|
||||
Registry.setup();
|
||||
}
|
||||
|
||||
public static InputStream getResourceFile( String domain, String subPath )
|
||||
|
@ -5,12 +5,15 @@
|
||||
*/
|
||||
package dan200.computercraft.api.pocket;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IItemProvider;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraftforge.common.util.NonNullSupplier;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* A base class for {@link IPocketUpgrade}s.
|
||||
@ -21,23 +24,48 @@ public abstract class AbstractPocketUpgrade implements IPocketUpgrade
|
||||
{
|
||||
private final ResourceLocation id;
|
||||
private final String adjective;
|
||||
private final ItemStack stack;
|
||||
private final NonNullSupplier<ItemStack> stack;
|
||||
|
||||
protected AbstractPocketUpgrade( ResourceLocation id, String adjective, ItemStack stack )
|
||||
protected AbstractPocketUpgrade( ResourceLocation id, String adjective, NonNullSupplier<ItemStack> stack )
|
||||
{
|
||||
this.id = id;
|
||||
this.adjective = adjective;
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
protected AbstractPocketUpgrade( ResourceLocation id, NonNullSupplier<ItemStack> item )
|
||||
{
|
||||
this( id, Util.makeTranslationKey( "upgrade", id ) + ".adjective", item );
|
||||
}
|
||||
|
||||
protected AbstractPocketUpgrade( ResourceLocation id, String adjective, ItemStack stack )
|
||||
{
|
||||
this( id, adjective, () -> stack );
|
||||
}
|
||||
|
||||
protected AbstractPocketUpgrade( ResourceLocation id, ItemStack stack )
|
||||
{
|
||||
this( id, () -> stack );
|
||||
}
|
||||
|
||||
protected AbstractPocketUpgrade( ResourceLocation id, String adjective, IItemProvider item )
|
||||
{
|
||||
this( id, adjective, new ItemStack( item ) );
|
||||
this( id, adjective, new CachedStack( () -> item ) );
|
||||
}
|
||||
|
||||
protected AbstractPocketUpgrade( ResourceLocation id, IItemProvider item )
|
||||
{
|
||||
this( id, Util.makeTranslationKey( "upgrade", id ) + ".adjective", new ItemStack( item ) );
|
||||
this( id, new CachedStack( () -> item ) );
|
||||
}
|
||||
|
||||
protected AbstractPocketUpgrade( ResourceLocation id, String adjective, Supplier<? extends IItemProvider> item )
|
||||
{
|
||||
this( id, adjective, new CachedStack( item ) );
|
||||
}
|
||||
|
||||
protected AbstractPocketUpgrade( ResourceLocation id, Supplier<? extends IItemProvider> item )
|
||||
{
|
||||
this( id, new CachedStack( item ) );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@ -58,6 +86,32 @@ public abstract class AbstractPocketUpgrade implements IPocketUpgrade
|
||||
@Override
|
||||
public final ItemStack getCraftingItem()
|
||||
{
|
||||
return stack;
|
||||
return stack.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Caches the construction of an item stack.
|
||||
*
|
||||
* @see dan200.computercraft.api.turtle.AbstractTurtleUpgrade For explanation of this class.
|
||||
*/
|
||||
private static final class CachedStack implements NonNullSupplier<ItemStack>
|
||||
{
|
||||
private final Supplier<? extends IItemProvider> provider;
|
||||
private Item item;
|
||||
private ItemStack stack;
|
||||
|
||||
CachedStack( Supplier<? extends IItemProvider> provider )
|
||||
{
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack get()
|
||||
{
|
||||
Item item = provider.get().asItem();
|
||||
if( item == this.item && stack != null ) return stack;
|
||||
return stack = new ItemStack( this.item = item );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,12 +5,15 @@
|
||||
*/
|
||||
package dan200.computercraft.api.turtle;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IItemProvider;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraftforge.common.util.NonNullSupplier;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* A base class for {@link ITurtleUpgrade}s.
|
||||
@ -22,9 +25,9 @@ public abstract class AbstractTurtleUpgrade implements ITurtleUpgrade
|
||||
private final ResourceLocation id;
|
||||
private final TurtleUpgradeType type;
|
||||
private final String adjective;
|
||||
private final ItemStack stack;
|
||||
private final NonNullSupplier<ItemStack> stack;
|
||||
|
||||
protected AbstractTurtleUpgrade( ResourceLocation id, TurtleUpgradeType type, String adjective, ItemStack stack )
|
||||
protected AbstractTurtleUpgrade( ResourceLocation id, TurtleUpgradeType type, String adjective, NonNullSupplier<ItemStack> stack )
|
||||
{
|
||||
this.id = id;
|
||||
this.type = type;
|
||||
@ -32,19 +35,39 @@ public abstract class AbstractTurtleUpgrade implements ITurtleUpgrade
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
protected AbstractTurtleUpgrade( ResourceLocation id, TurtleUpgradeType type, String adjective, IItemProvider item )
|
||||
{
|
||||
this( id, type, adjective, new ItemStack( item ) );
|
||||
}
|
||||
|
||||
protected AbstractTurtleUpgrade( ResourceLocation id, TurtleUpgradeType type, ItemStack stack )
|
||||
protected AbstractTurtleUpgrade( ResourceLocation id, TurtleUpgradeType type, NonNullSupplier<ItemStack> stack )
|
||||
{
|
||||
this( id, type, Util.makeTranslationKey( "upgrade", id ) + ".adjective", stack );
|
||||
}
|
||||
|
||||
protected AbstractTurtleUpgrade( ResourceLocation id, TurtleUpgradeType type, String adjective, ItemStack stack )
|
||||
{
|
||||
this( id, type, adjective, () -> stack );
|
||||
}
|
||||
|
||||
protected AbstractTurtleUpgrade( ResourceLocation id, TurtleUpgradeType type, ItemStack stack )
|
||||
{
|
||||
this( id, type, () -> stack );
|
||||
}
|
||||
|
||||
protected AbstractTurtleUpgrade( ResourceLocation id, TurtleUpgradeType type, String adjective, IItemProvider item )
|
||||
{
|
||||
this( id, type, adjective, new CachedStack( () -> item ) );
|
||||
}
|
||||
|
||||
protected AbstractTurtleUpgrade( ResourceLocation id, TurtleUpgradeType type, IItemProvider item )
|
||||
{
|
||||
this( id, type, new ItemStack( item ) );
|
||||
this( id, type, new CachedStack( () -> item ) );
|
||||
}
|
||||
|
||||
protected AbstractTurtleUpgrade( ResourceLocation id, TurtleUpgradeType type, String adjective, Supplier<? extends IItemProvider> item )
|
||||
{
|
||||
this( id, type, adjective, new CachedStack( item ) );
|
||||
}
|
||||
|
||||
protected AbstractTurtleUpgrade( ResourceLocation id, TurtleUpgradeType type, Supplier<? extends IItemProvider> item )
|
||||
{
|
||||
this( id, type, new CachedStack( item ) );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@ -72,6 +95,32 @@ public abstract class AbstractTurtleUpgrade implements ITurtleUpgrade
|
||||
@Override
|
||||
public final ItemStack getCraftingItem()
|
||||
{
|
||||
return stack;
|
||||
return stack.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* A supplier which converts an item into an item stack.
|
||||
*
|
||||
* Constructing item stacks is somewhat expensive due to attaching capabilities. We cache it if given a consistent item.
|
||||
*/
|
||||
private static final class CachedStack implements NonNullSupplier<ItemStack>
|
||||
{
|
||||
private final Supplier<? extends IItemProvider> provider;
|
||||
private Item item;
|
||||
private ItemStack stack;
|
||||
|
||||
CachedStack( Supplier<? extends IItemProvider> provider )
|
||||
{
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack get()
|
||||
{
|
||||
Item item = provider.get().asItem();
|
||||
if( item == this.item && stack != null ) return stack;
|
||||
return stack = new ItemStack( this.item = item );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ package dan200.computercraft.client;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.client.render.TurtleModelLoader;
|
||||
import dan200.computercraft.shared.Registry;
|
||||
import dan200.computercraft.shared.common.IColouredItem;
|
||||
import dan200.computercraft.shared.media.items.ItemDisk;
|
||||
import dan200.computercraft.shared.media.items.ItemTreasureDisk;
|
||||
@ -109,7 +110,7 @@ public final class ClientRegistry
|
||||
@SubscribeEvent
|
||||
public static void onItemColours( ColorHandlerEvent.Item event )
|
||||
{
|
||||
if( ComputerCraft.Items.disk == null || ComputerCraft.Blocks.turtleNormal == null )
|
||||
if( Registry.ModItems.DISK == null || Registry.ModBlocks.TURTLE_NORMAL == null )
|
||||
{
|
||||
ComputerCraft.log.warn( "Block/item registration has failed. Skipping registration of item colours." );
|
||||
return;
|
||||
@ -117,12 +118,12 @@ public final class ClientRegistry
|
||||
|
||||
event.getItemColors().register(
|
||||
( stack, layer ) -> layer == 1 ? ((ItemDisk) stack.getItem()).getColour( stack ) : 0xFFFFFF,
|
||||
ComputerCraft.Items.disk
|
||||
Registry.ModItems.DISK.get()
|
||||
);
|
||||
|
||||
event.getItemColors().register(
|
||||
( stack, layer ) -> layer == 1 ? ItemTreasureDisk.getColour( stack ) : 0xFFFFFF,
|
||||
ComputerCraft.Items.treasureDisk
|
||||
Registry.ModItems.TREASURE_DISK.get()
|
||||
);
|
||||
|
||||
event.getItemColors().register( ( stack, layer ) -> {
|
||||
@ -139,12 +140,12 @@ public final class ClientRegistry
|
||||
return light == -1 ? Colour.BLACK.getHex() : light;
|
||||
}
|
||||
}
|
||||
}, ComputerCraft.Items.pocketComputerNormal, ComputerCraft.Items.pocketComputerAdvanced );
|
||||
}, Registry.ModItems.POCKET_COMPUTER_NORMAL.get(), Registry.ModItems.POCKET_COMPUTER_ADVANCED.get() );
|
||||
|
||||
// Setup turtle colours
|
||||
event.getItemColors().register(
|
||||
( stack, tintIndex ) -> tintIndex == 0 ? ((IColouredItem) stack.getItem()).getColour( stack ) : 0xFFFFFF,
|
||||
ComputerCraft.Blocks.turtleNormal, ComputerCraft.Blocks.turtleAdvanced
|
||||
Registry.ModBlocks.TURTLE_NORMAL.get(), Registry.ModBlocks.TURTLE_ADVANCED.get()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -10,17 +10,11 @@ import dan200.computercraft.client.gui.*;
|
||||
import dan200.computercraft.client.render.TileEntityMonitorRenderer;
|
||||
import dan200.computercraft.client.render.TileEntityTurtleRenderer;
|
||||
import dan200.computercraft.client.render.TurtlePlayerRenderer;
|
||||
import dan200.computercraft.shared.common.ContainerHeldItem;
|
||||
import dan200.computercraft.shared.Registry;
|
||||
import dan200.computercraft.shared.computer.inventory.ContainerComputer;
|
||||
import dan200.computercraft.shared.computer.inventory.ContainerViewComputer;
|
||||
import dan200.computercraft.shared.peripheral.diskdrive.ContainerDiskDrive;
|
||||
import dan200.computercraft.shared.peripheral.monitor.ClientMonitor;
|
||||
import dan200.computercraft.shared.peripheral.monitor.TileMonitor;
|
||||
import dan200.computercraft.shared.peripheral.printer.ContainerPrinter;
|
||||
import dan200.computercraft.shared.pocket.inventory.ContainerPocketComputer;
|
||||
import dan200.computercraft.shared.turtle.blocks.TileTurtle;
|
||||
import dan200.computercraft.shared.turtle.core.TurtlePlayer;
|
||||
import dan200.computercraft.shared.turtle.inventory.ContainerTurtle;
|
||||
import net.minecraft.client.gui.ScreenManager;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.RenderTypeLookup;
|
||||
@ -41,36 +35,36 @@ public final class ComputerCraftProxyClient
|
||||
registerContainers();
|
||||
|
||||
// While turtles themselves are not transparent, their upgrades may be.
|
||||
RenderTypeLookup.setRenderLayer( ComputerCraft.Blocks.turtleNormal, RenderType.getTranslucent() );
|
||||
RenderTypeLookup.setRenderLayer( ComputerCraft.Blocks.turtleAdvanced, RenderType.getTranslucent() );
|
||||
RenderTypeLookup.setRenderLayer( Registry.ModBlocks.TURTLE_NORMAL.get(), RenderType.getTranslucent() );
|
||||
RenderTypeLookup.setRenderLayer( Registry.ModBlocks.TURTLE_ADVANCED.get(), RenderType.getTranslucent() );
|
||||
|
||||
// Monitors' textures have transparent fronts and so count as cutouts.
|
||||
RenderTypeLookup.setRenderLayer( ComputerCraft.Blocks.monitorNormal, RenderType.getCutout() );
|
||||
RenderTypeLookup.setRenderLayer( ComputerCraft.Blocks.monitorAdvanced, RenderType.getCutout() );
|
||||
RenderTypeLookup.setRenderLayer( Registry.ModBlocks.MONITOR_NORMAL.get(), RenderType.getCutout() );
|
||||
RenderTypeLookup.setRenderLayer( Registry.ModBlocks.MONITOR_ADVANCED.get(), RenderType.getCutout() );
|
||||
|
||||
// Setup TESRs
|
||||
ClientRegistry.bindTileEntityRenderer( TileMonitor.FACTORY_NORMAL, TileEntityMonitorRenderer::new );
|
||||
ClientRegistry.bindTileEntityRenderer( TileMonitor.FACTORY_ADVANCED, TileEntityMonitorRenderer::new );
|
||||
ClientRegistry.bindTileEntityRenderer( TileTurtle.FACTORY_NORMAL, TileEntityTurtleRenderer::new );
|
||||
ClientRegistry.bindTileEntityRenderer( TileTurtle.FACTORY_ADVANCED, TileEntityTurtleRenderer::new );
|
||||
ClientRegistry.bindTileEntityRenderer( Registry.ModTiles.MONITOR_NORMAL.get(), TileEntityMonitorRenderer::new );
|
||||
ClientRegistry.bindTileEntityRenderer( Registry.ModTiles.MONITOR_ADVANCED.get(), TileEntityMonitorRenderer::new );
|
||||
ClientRegistry.bindTileEntityRenderer( Registry.ModTiles.TURTLE_NORMAL.get(), TileEntityTurtleRenderer::new );
|
||||
ClientRegistry.bindTileEntityRenderer( Registry.ModTiles.TURTLE_ADVANCED.get(), TileEntityTurtleRenderer::new );
|
||||
// TODO: ClientRegistry.bindTileEntityRenderer( TileCable.FACTORY, x -> new TileEntityCableRenderer() );
|
||||
|
||||
RenderingRegistry.registerEntityRenderingHandler( TurtlePlayer.TYPE, TurtlePlayerRenderer::new );
|
||||
RenderingRegistry.registerEntityRenderingHandler( Registry.ModEntities.TURTLE_PLAYER.get(), TurtlePlayerRenderer::new );
|
||||
}
|
||||
|
||||
private static void registerContainers()
|
||||
{
|
||||
// My IDE doesn't think so, but we do actually need these generics.
|
||||
|
||||
ScreenManager.<ContainerComputer, GuiComputer<ContainerComputer>>registerFactory( ContainerComputer.TYPE, GuiComputer::create );
|
||||
ScreenManager.<ContainerPocketComputer, GuiComputer<ContainerPocketComputer>>registerFactory( ContainerPocketComputer.TYPE, GuiComputer::createPocket );
|
||||
ScreenManager.registerFactory( ContainerTurtle.TYPE, GuiTurtle::new );
|
||||
ScreenManager.<ContainerComputer, GuiComputer<ContainerComputer>>registerFactory( Registry.ModContainers.COMPUTER.get(), GuiComputer::create );
|
||||
ScreenManager.<ContainerPocketComputer, GuiComputer<ContainerPocketComputer>>registerFactory( Registry.ModContainers.POCKET_COMPUTER.get(), GuiComputer::createPocket );
|
||||
ScreenManager.registerFactory( Registry.ModContainers.TURTLE.get(), GuiTurtle::new );
|
||||
|
||||
ScreenManager.registerFactory( ContainerPrinter.TYPE, GuiPrinter::new );
|
||||
ScreenManager.registerFactory( ContainerDiskDrive.TYPE, GuiDiskDrive::new );
|
||||
ScreenManager.registerFactory( ContainerHeldItem.PRINTOUT_TYPE, GuiPrintout::new );
|
||||
ScreenManager.registerFactory( Registry.ModContainers.PRINTER.get(), GuiPrinter::new );
|
||||
ScreenManager.registerFactory( Registry.ModContainers.DISK_DRIVE.get(), GuiDiskDrive::new );
|
||||
ScreenManager.registerFactory( Registry.ModContainers.PRINTOUT.get(), GuiPrintout::new );
|
||||
|
||||
ScreenManager.<ContainerViewComputer, GuiComputer<ContainerViewComputer>>registerFactory( ContainerViewComputer.TYPE, GuiComputer::createView );
|
||||
ScreenManager.<ContainerViewComputer, GuiComputer<ContainerViewComputer>>registerFactory( Registry.ModContainers.VIEW_COMPUTER.get(), GuiComputer::createView );
|
||||
}
|
||||
|
||||
@Mod.EventBusSubscriber( modid = ComputerCraft.MOD_ID, value = Dist.CLIENT )
|
||||
|
@ -8,6 +8,7 @@ package dan200.computercraft.client.render;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.shared.Registry;
|
||||
import dan200.computercraft.shared.peripheral.modem.wired.BlockCable;
|
||||
import dan200.computercraft.shared.peripheral.modem.wired.CableShapes;
|
||||
import dan200.computercraft.shared.util.WorldUtil;
|
||||
@ -51,7 +52,7 @@ public final class CableHighlightRenderer
|
||||
BlockState state = world.getBlockState( pos );
|
||||
|
||||
// We only care about instances with both cable and modem.
|
||||
if( state.getBlock() != ComputerCraft.Blocks.cable || state.get( BlockCable.MODEM ).getFacing() == null || !state.get( BlockCable.CABLE ) )
|
||||
if( state.getBlock() != Registry.ModBlocks.CABLE.get() || state.get( BlockCable.MODEM ).getFacing() == null || !state.get( BlockCable.CABLE ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
package dan200.computercraft.data;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.shared.Registry;
|
||||
import dan200.computercraft.shared.data.BlockNamedEntityLootCondition;
|
||||
import dan200.computercraft.shared.data.HasComputerIdLootCondition;
|
||||
import dan200.computercraft.shared.data.PlayerCreativeLootCondition;
|
||||
@ -17,6 +18,7 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.storage.loot.*;
|
||||
import net.minecraft.world.storage.loot.conditions.Alternative;
|
||||
import net.minecraft.world.storage.loot.conditions.SurvivesExplosion;
|
||||
import net.minecraftforge.fml.RegistryObject;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
@ -30,19 +32,19 @@ public class LootTables extends LootTableProvider
|
||||
@Override
|
||||
protected void registerLoot( BiConsumer<ResourceLocation, LootTable> add )
|
||||
{
|
||||
basicDrop( add, ComputerCraft.Blocks.diskDrive );
|
||||
basicDrop( add, ComputerCraft.Blocks.monitorNormal );
|
||||
basicDrop( add, ComputerCraft.Blocks.monitorAdvanced );
|
||||
basicDrop( add, ComputerCraft.Blocks.printer );
|
||||
basicDrop( add, ComputerCraft.Blocks.speaker );
|
||||
basicDrop( add, ComputerCraft.Blocks.wiredModemFull );
|
||||
basicDrop( add, ComputerCraft.Blocks.wirelessModemNormal );
|
||||
basicDrop( add, ComputerCraft.Blocks.wirelessModemAdvanced );
|
||||
basicDrop( add, Registry.ModBlocks.DISK_DRIVE );
|
||||
basicDrop( add, Registry.ModBlocks.MONITOR_NORMAL );
|
||||
basicDrop( add, Registry.ModBlocks.MONITOR_ADVANCED );
|
||||
basicDrop( add, Registry.ModBlocks.PRINTER );
|
||||
basicDrop( add, Registry.ModBlocks.SPEAKER );
|
||||
basicDrop( add, Registry.ModBlocks.WIRED_MODEM_FULL );
|
||||
basicDrop( add, Registry.ModBlocks.WIRELESS_MODEM_NORMAL );
|
||||
basicDrop( add, Registry.ModBlocks.WIRELESS_MODEM_ADVANCED );
|
||||
|
||||
computerDrop( add, ComputerCraft.Blocks.computerNormal );
|
||||
computerDrop( add, ComputerCraft.Blocks.computerAdvanced );
|
||||
computerDrop( add, ComputerCraft.Blocks.turtleNormal );
|
||||
computerDrop( add, ComputerCraft.Blocks.turtleAdvanced );
|
||||
computerDrop( add, Registry.ModBlocks.COMPUTER_NORMAL );
|
||||
computerDrop( add, Registry.ModBlocks.COMPUTER_ADVANCED );
|
||||
computerDrop( add, Registry.ModBlocks.TURTLE_NORMAL );
|
||||
computerDrop( add, Registry.ModBlocks.TURTLE_ADVANCED );
|
||||
|
||||
add.accept( ComputerCraftProxyCommon.ForgeHandlers.LOOT_TREASURE_DISK, LootTable
|
||||
.builder()
|
||||
@ -50,8 +52,9 @@ public class LootTables extends LootTableProvider
|
||||
.build() );
|
||||
}
|
||||
|
||||
private static void basicDrop( BiConsumer<ResourceLocation, LootTable> add, Block block )
|
||||
private static <T extends Block> void basicDrop( BiConsumer<ResourceLocation, LootTable> add, RegistryObject<T> wrapper )
|
||||
{
|
||||
Block block = wrapper.get();
|
||||
add.accept( block.getLootTable(), LootTable
|
||||
.builder()
|
||||
.setParameterSet( LootParameterSets.BLOCK )
|
||||
@ -63,8 +66,9 @@ public class LootTables extends LootTableProvider
|
||||
).build() );
|
||||
}
|
||||
|
||||
private static void computerDrop( BiConsumer<ResourceLocation, LootTable> add, Block block )
|
||||
private static <T extends Block> void computerDrop( BiConsumer<ResourceLocation, LootTable> add, RegistryObject<T> wrapper )
|
||||
{
|
||||
Block block = wrapper.get();
|
||||
add.accept( block.getLootTable(), LootTable
|
||||
.builder()
|
||||
.setParameterSet( LootParameterSets.BLOCK )
|
||||
|
@ -8,6 +8,7 @@ package dan200.computercraft.data;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.data.Tags.CCTags;
|
||||
import dan200.computercraft.shared.Registry;
|
||||
import dan200.computercraft.shared.TurtleUpgrades;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.pocket.items.PocketComputerItemFactory;
|
||||
@ -55,12 +56,12 @@ public class Recipes extends RecipeProvider
|
||||
for( Colour colour : Colour.VALUES )
|
||||
{
|
||||
ShapelessRecipeBuilder
|
||||
.shapelessRecipe( ComputerCraft.Items.disk )
|
||||
.shapelessRecipe( Registry.ModItems.DISK.get() )
|
||||
.addIngredient( Tags.Items.DUSTS_REDSTONE )
|
||||
.addIngredient( Items.PAPER )
|
||||
.addIngredient( DyeItem.getItem( ofColour( colour ) ) )
|
||||
.setGroup( "computercraft:disk" )
|
||||
.addCriterion( "has_drive", inventoryChange( ComputerCraft.Blocks.diskDrive ) )
|
||||
.addCriterion( "has_drive", inventoryChange( Registry.ModBlocks.DISK_DRIVE.get() ) )
|
||||
.build( RecipeWrapper.wrap(
|
||||
ImpostorShapelessRecipe.SERIALIZER, add,
|
||||
x -> x.putInt( "color", colour.getHex() )
|
||||
@ -140,7 +141,7 @@ public class Recipes extends RecipeProvider
|
||||
private void basicRecipes( @Nonnull Consumer<IFinishedRecipe> add )
|
||||
{
|
||||
ShapedRecipeBuilder
|
||||
.shapedRecipe( ComputerCraft.Items.cable, 6 )
|
||||
.shapedRecipe( Registry.ModItems.CABLE.get(), 6 )
|
||||
.patternLine( " # " )
|
||||
.patternLine( "#R#" )
|
||||
.patternLine( " # " )
|
||||
@ -151,7 +152,7 @@ public class Recipes extends RecipeProvider
|
||||
.build( add );
|
||||
|
||||
ShapedRecipeBuilder
|
||||
.shapedRecipe( ComputerCraft.Blocks.computerNormal )
|
||||
.shapedRecipe( Registry.ModBlocks.COMPUTER_NORMAL.get() )
|
||||
.patternLine( "###" )
|
||||
.patternLine( "#R#" )
|
||||
.patternLine( "#G#" )
|
||||
@ -162,7 +163,7 @@ public class Recipes extends RecipeProvider
|
||||
.build( add );
|
||||
|
||||
ShapedRecipeBuilder
|
||||
.shapedRecipe( ComputerCraft.Blocks.computerAdvanced )
|
||||
.shapedRecipe( Registry.ModBlocks.COMPUTER_ADVANCED.get() )
|
||||
.patternLine( "###" )
|
||||
.patternLine( "#R#" )
|
||||
.patternLine( "#G#" )
|
||||
@ -173,7 +174,7 @@ public class Recipes extends RecipeProvider
|
||||
.build( add );
|
||||
|
||||
ShapedRecipeBuilder
|
||||
.shapedRecipe( ComputerCraft.Blocks.computerCommand )
|
||||
.shapedRecipe( Registry.ModBlocks.COMPUTER_COMMAND.get() )
|
||||
.patternLine( "###" )
|
||||
.patternLine( "#R#" )
|
||||
.patternLine( "#G#" )
|
||||
@ -184,7 +185,7 @@ public class Recipes extends RecipeProvider
|
||||
.build( add );
|
||||
|
||||
ShapedRecipeBuilder
|
||||
.shapedRecipe( ComputerCraft.Blocks.diskDrive )
|
||||
.shapedRecipe( Registry.ModBlocks.DISK_DRIVE.get() )
|
||||
.patternLine( "###" )
|
||||
.patternLine( "#R#" )
|
||||
.patternLine( "#R#" )
|
||||
@ -194,7 +195,7 @@ public class Recipes extends RecipeProvider
|
||||
.build( add );
|
||||
|
||||
ShapedRecipeBuilder
|
||||
.shapedRecipe( ComputerCraft.Blocks.monitorNormal )
|
||||
.shapedRecipe( Registry.ModBlocks.MONITOR_NORMAL.get() )
|
||||
.patternLine( "###" )
|
||||
.patternLine( "#G#" )
|
||||
.patternLine( "###" )
|
||||
@ -204,7 +205,7 @@ public class Recipes extends RecipeProvider
|
||||
.build( add );
|
||||
|
||||
ShapedRecipeBuilder
|
||||
.shapedRecipe( ComputerCraft.Blocks.monitorAdvanced, 4 )
|
||||
.shapedRecipe( Registry.ModBlocks.MONITOR_ADVANCED.get(), 4 )
|
||||
.patternLine( "###" )
|
||||
.patternLine( "#G#" )
|
||||
.patternLine( "###" )
|
||||
@ -214,7 +215,7 @@ public class Recipes extends RecipeProvider
|
||||
.build( add );
|
||||
|
||||
ShapedRecipeBuilder
|
||||
.shapedRecipe( ComputerCraft.Items.pocketComputerNormal )
|
||||
.shapedRecipe( Registry.ModItems.POCKET_COMPUTER_NORMAL.get() )
|
||||
.patternLine( "###" )
|
||||
.patternLine( "#A#" )
|
||||
.patternLine( "#G#" )
|
||||
@ -226,7 +227,7 @@ public class Recipes extends RecipeProvider
|
||||
.build( add );
|
||||
|
||||
ShapedRecipeBuilder
|
||||
.shapedRecipe( ComputerCraft.Items.pocketComputerAdvanced )
|
||||
.shapedRecipe( Registry.ModItems.POCKET_COMPUTER_ADVANCED.get() )
|
||||
.patternLine( "###" )
|
||||
.patternLine( "#A#" )
|
||||
.patternLine( "#G#" )
|
||||
@ -238,7 +239,7 @@ public class Recipes extends RecipeProvider
|
||||
.build( add );
|
||||
|
||||
ShapedRecipeBuilder
|
||||
.shapedRecipe( ComputerCraft.Blocks.printer )
|
||||
.shapedRecipe( Registry.ModBlocks.PRINTER.get() )
|
||||
.patternLine( "###" )
|
||||
.patternLine( "#R#" )
|
||||
.patternLine( "#D#" )
|
||||
@ -249,7 +250,7 @@ public class Recipes extends RecipeProvider
|
||||
.build( add );
|
||||
|
||||
ShapedRecipeBuilder
|
||||
.shapedRecipe( ComputerCraft.Blocks.speaker )
|
||||
.shapedRecipe( Registry.ModBlocks.SPEAKER.get() )
|
||||
.patternLine( "###" )
|
||||
.patternLine( "#N#" )
|
||||
.patternLine( "#R#" )
|
||||
@ -260,29 +261,29 @@ public class Recipes extends RecipeProvider
|
||||
.build( add );
|
||||
|
||||
ShapedRecipeBuilder
|
||||
.shapedRecipe( ComputerCraft.Items.wiredModem )
|
||||
.shapedRecipe( Registry.ModItems.WIRED_MODEM.get() )
|
||||
.patternLine( "###" )
|
||||
.patternLine( "#R#" )
|
||||
.patternLine( "###" )
|
||||
.key( '#', Tags.Items.STONE )
|
||||
.key( 'R', Tags.Items.DUSTS_REDSTONE )
|
||||
.addCriterion( "has_computer", inventoryChange( CCTags.COMPUTER ) )
|
||||
.addCriterion( "has_cable", inventoryChange( ComputerCraft.Items.cable ) )
|
||||
.addCriterion( "has_cable", inventoryChange( Registry.ModItems.CABLE.get() ) )
|
||||
.build( add );
|
||||
|
||||
ShapelessRecipeBuilder
|
||||
.shapelessRecipe( ComputerCraft.Blocks.wiredModemFull )
|
||||
.addIngredient( ComputerCraft.Items.wiredModem )
|
||||
.shapelessRecipe( Registry.ModBlocks.WIRED_MODEM_FULL.get() )
|
||||
.addIngredient( Registry.ModItems.WIRED_MODEM.get() )
|
||||
.addCriterion( "has_modem", inventoryChange( CCTags.WIRED_MODEM ) )
|
||||
.build( add, new ResourceLocation( ComputerCraft.MOD_ID, "wired_modem_full_from" ) );
|
||||
ShapelessRecipeBuilder
|
||||
.shapelessRecipe( ComputerCraft.Items.wiredModem )
|
||||
.addIngredient( ComputerCraft.Blocks.wiredModemFull )
|
||||
.shapelessRecipe( Registry.ModItems.WIRED_MODEM.get() )
|
||||
.addIngredient( Registry.ModBlocks.WIRED_MODEM_FULL.get() )
|
||||
.addCriterion( "has_modem", inventoryChange( CCTags.WIRED_MODEM ) )
|
||||
.build( add, new ResourceLocation( ComputerCraft.MOD_ID, "wired_modem_full_to" ) );
|
||||
|
||||
ShapedRecipeBuilder
|
||||
.shapedRecipe( ComputerCraft.Blocks.wirelessModemNormal )
|
||||
.shapedRecipe( Registry.ModBlocks.WIRELESS_MODEM_NORMAL.get() )
|
||||
.patternLine( "###" )
|
||||
.patternLine( "#E#" )
|
||||
.patternLine( "###" )
|
||||
@ -292,14 +293,14 @@ public class Recipes extends RecipeProvider
|
||||
.build( add );
|
||||
|
||||
ShapedRecipeBuilder
|
||||
.shapedRecipe( ComputerCraft.Blocks.wirelessModemAdvanced )
|
||||
.shapedRecipe( Registry.ModBlocks.WIRELESS_MODEM_ADVANCED.get() )
|
||||
.patternLine( "###" )
|
||||
.patternLine( "#E#" )
|
||||
.patternLine( "###" )
|
||||
.key( '#', Tags.Items.INGOTS_GOLD )
|
||||
.key( 'E', Items.ENDER_EYE )
|
||||
.addCriterion( "has_computer", inventoryChange( CCTags.COMPUTER ) )
|
||||
.addCriterion( "has_wireless", inventoryChange( ComputerCraft.Blocks.wirelessModemNormal ) )
|
||||
.addCriterion( "has_wireless", inventoryChange( Registry.ModBlocks.WIRELESS_MODEM_NORMAL.get() ) )
|
||||
.build( add );
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
package dan200.computercraft.data;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.shared.Registry;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.data.ItemTagsProvider;
|
||||
import net.minecraft.item.Item;
|
||||
@ -35,14 +36,14 @@ public class Tags extends ItemTagsProvider
|
||||
protected void registerTags()
|
||||
{
|
||||
getBuilder( COMPUTER )
|
||||
.add( ComputerCraft.Items.computerNormal )
|
||||
.add( ComputerCraft.Items.computerAdvanced )
|
||||
.add( ComputerCraft.Items.computerCommand );
|
||||
getBuilder( TURTLE ).add( ComputerCraft.Items.turtleNormal, ComputerCraft.Items.turtleAdvanced );
|
||||
getBuilder( WIRED_MODEM ).add( ComputerCraft.Items.wiredModem, ComputerCraft.Blocks.wiredModemFull.asItem() );
|
||||
.add( Registry.ModItems.COMPUTER_NORMAL.get() )
|
||||
.add( Registry.ModItems.COMPUTER_ADVANCED.get() )
|
||||
.add( Registry.ModItems.COMPUTER_COMMAND.get() );
|
||||
getBuilder( TURTLE ).add( Registry.ModItems.TURTLE_NORMAL.get(), Registry.ModItems.TURTLE_ADVANCED.get() );
|
||||
getBuilder( WIRED_MODEM ).add( Registry.ModItems.WIRED_MODEM.get(), Registry.ModItems.WIRED_MODEM_FULL.get() );
|
||||
getBuilder( MONITOR )
|
||||
.add( ComputerCraft.Blocks.monitorNormal.asItem() )
|
||||
.add( ComputerCraft.Blocks.monitorAdvanced.asItem() );
|
||||
.add( Registry.ModItems.MONITOR_NORMAL.get() )
|
||||
.add( Registry.ModItems.MONITOR_ADVANCED.get() );
|
||||
}
|
||||
|
||||
private static Tag<Item> item( String name )
|
||||
|
@ -270,7 +270,7 @@ public final class Config
|
||||
clientSpec = clientBuilder.build();
|
||||
}
|
||||
|
||||
public static void load()
|
||||
public static void setup()
|
||||
{
|
||||
ModLoadingContext.get().registerConfig( ModConfig.Type.SERVER, serverSpec );
|
||||
ModLoadingContext.get().registerConfig( ModConfig.Type.CLIENT, clientSpec );
|
||||
|
@ -22,6 +22,10 @@ import dan200.computercraft.shared.media.items.ItemPrintout;
|
||||
import dan200.computercraft.shared.media.items.ItemTreasureDisk;
|
||||
import dan200.computercraft.shared.media.recipes.DiskRecipe;
|
||||
import dan200.computercraft.shared.media.recipes.PrintoutRecipe;
|
||||
import dan200.computercraft.shared.network.container.ComputerContainerData;
|
||||
import dan200.computercraft.shared.network.container.ContainerData;
|
||||
import dan200.computercraft.shared.network.container.HeldItemContainerData;
|
||||
import dan200.computercraft.shared.network.container.ViewComputerContainerData;
|
||||
import dan200.computercraft.shared.peripheral.diskdrive.BlockDiskDrive;
|
||||
import dan200.computercraft.shared.peripheral.diskdrive.ContainerDiskDrive;
|
||||
import dan200.computercraft.shared.peripheral.diskdrive.TileDiskDrive;
|
||||
@ -49,10 +53,12 @@ import dan200.computercraft.shared.turtle.recipes.TurtleRecipe;
|
||||
import dan200.computercraft.shared.turtle.recipes.TurtleUpgradeRecipe;
|
||||
import dan200.computercraft.shared.turtle.upgrades.*;
|
||||
import dan200.computercraft.shared.util.CreativeTabMain;
|
||||
import dan200.computercraft.shared.util.FixedPointTileEntityType;
|
||||
import dan200.computercraft.shared.util.ImpostorRecipe;
|
||||
import dan200.computercraft.shared.util.ImpostorShapelessRecipe;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.EntityClassification;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.item.BlockItem;
|
||||
@ -60,12 +66,20 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.crafting.IRecipeSerializer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.RegistryObject;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.registries.IForgeRegistry;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Mod.EventBusSubscriber( modid = ComputerCraft.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD )
|
||||
public final class Registry
|
||||
@ -76,211 +90,153 @@ public final class Registry
|
||||
{
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerBlocks( RegistryEvent.Register<Block> event )
|
||||
public static final class ModBlocks
|
||||
{
|
||||
IForgeRegistry<Block> registry = event.getRegistry();
|
||||
static final DeferredRegister<Block> BLOCKS = new DeferredRegister<>( ForgeRegistries.BLOCKS, ComputerCraft.MOD_ID );
|
||||
|
||||
// Computers
|
||||
ComputerCraft.Blocks.computerNormal = new BlockComputer(
|
||||
Block.Properties.create( Material.ROCK ).hardnessAndResistance( 2.0f ),
|
||||
ComputerFamily.NORMAL, TileComputer.FACTORY_NORMAL
|
||||
);
|
||||
private static Block.Properties properties()
|
||||
{
|
||||
return Block.Properties.create( Material.ROCK ).hardnessAndResistance( 2 );
|
||||
}
|
||||
|
||||
ComputerCraft.Blocks.computerAdvanced = new BlockComputer(
|
||||
Block.Properties.create( Material.ROCK ).hardnessAndResistance( 2.0f ),
|
||||
ComputerFamily.ADVANCED, TileComputer.FACTORY_ADVANCED
|
||||
);
|
||||
private static Block.Properties turtleProperties()
|
||||
{
|
||||
return Block.Properties.create( Material.ROCK ).hardnessAndResistance( 2.5f );
|
||||
}
|
||||
|
||||
ComputerCraft.Blocks.computerCommand = new BlockComputer(
|
||||
private static Block.Properties modemProperties()
|
||||
{
|
||||
return Block.Properties.create( Material.ROCK ).hardnessAndResistance( 1.5f );
|
||||
}
|
||||
|
||||
public static final RegistryObject<BlockComputer> COMPUTER_NORMAL = BLOCKS.register( "computer_normal",
|
||||
() -> new BlockComputer( properties(), ComputerFamily.NORMAL, ModTiles.COMPUTER_NORMAL ) );
|
||||
public static final RegistryObject<BlockComputer> COMPUTER_ADVANCED = BLOCKS.register( "computer_advanced",
|
||||
() -> new BlockComputer( properties(), ComputerFamily.ADVANCED, ModTiles.COMPUTER_ADVANCED ) );
|
||||
|
||||
public static final RegistryObject<BlockComputer> COMPUTER_COMMAND = BLOCKS.register( "computer_command", () -> new BlockComputer(
|
||||
Block.Properties.create( Material.ROCK ).hardnessAndResistance( -1, 6000000.0F ),
|
||||
ComputerFamily.COMMAND, TileCommandComputer.FACTORY
|
||||
);
|
||||
ComputerFamily.COMMAND, ModTiles.COMPUTER_COMMAND
|
||||
) );
|
||||
|
||||
registry.registerAll(
|
||||
ComputerCraft.Blocks.computerNormal.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "computer_normal" ) ),
|
||||
ComputerCraft.Blocks.computerAdvanced.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "computer_advanced" ) ),
|
||||
ComputerCraft.Blocks.computerCommand.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "computer_command" ) )
|
||||
);
|
||||
public static final RegistryObject<BlockTurtle> TURTLE_NORMAL = BLOCKS.register( "turtle_normal",
|
||||
() -> new BlockTurtle( turtleProperties(), ComputerFamily.NORMAL, ModTiles.TURTLE_NORMAL ) );
|
||||
public static final RegistryObject<BlockTurtle> TURTLE_ADVANCED = BLOCKS.register( "turtle_advanced",
|
||||
() -> new BlockTurtle( turtleProperties(), ComputerFamily.ADVANCED, ModTiles.TURTLE_ADVANCED ) );
|
||||
|
||||
// Turtles
|
||||
ComputerCraft.Blocks.turtleNormal = new BlockTurtle(
|
||||
Block.Properties.create( Material.ROCK ).hardnessAndResistance( 2.5f ),
|
||||
ComputerFamily.NORMAL, TileTurtle.FACTORY_NORMAL
|
||||
);
|
||||
public static final RegistryObject<BlockSpeaker> SPEAKER = BLOCKS.register( "speaker", () -> new BlockSpeaker( properties() ) );
|
||||
public static final RegistryObject<BlockDiskDrive> DISK_DRIVE = BLOCKS.register( "disk_drive", () -> new BlockDiskDrive( properties() ) );
|
||||
public static final RegistryObject<BlockPrinter> PRINTER = BLOCKS.register( "printer", () -> new BlockPrinter( properties() ) );
|
||||
|
||||
ComputerCraft.Blocks.turtleAdvanced = new BlockTurtle(
|
||||
Block.Properties.create( Material.ROCK ).hardnessAndResistance( 2.5f ),
|
||||
ComputerFamily.ADVANCED, TileTurtle.FACTORY_ADVANCED
|
||||
);
|
||||
public static final RegistryObject<BlockMonitor> MONITOR_NORMAL = BLOCKS.register( "monitor_normal",
|
||||
() -> new BlockMonitor( properties(), ModTiles.MONITOR_NORMAL ) );
|
||||
public static final RegistryObject<BlockMonitor> MONITOR_ADVANCED = BLOCKS.register( "monitor_advanced",
|
||||
() -> new BlockMonitor( properties(), ModTiles.MONITOR_ADVANCED ) );
|
||||
|
||||
registry.registerAll(
|
||||
ComputerCraft.Blocks.turtleNormal.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "turtle_normal" ) ),
|
||||
ComputerCraft.Blocks.turtleAdvanced.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "turtle_advanced" ) )
|
||||
);
|
||||
public static final RegistryObject<BlockWirelessModem> WIRELESS_MODEM_NORMAL = BLOCKS.register( "wireless_modem_normal",
|
||||
() -> new BlockWirelessModem( properties(), ModTiles.WIRELESS_MODEM_NORMAL ) );
|
||||
public static final RegistryObject<BlockWirelessModem> WIRELESS_MODEM_ADVANCED = BLOCKS.register( "wireless_modem_advanced",
|
||||
() -> new BlockWirelessModem( properties(), ModTiles.WIRELESS_MODEM_ADVANCED ) );
|
||||
|
||||
// Peripherals
|
||||
ComputerCraft.Blocks.speaker = new BlockSpeaker(
|
||||
Block.Properties.create( Material.ROCK ).hardnessAndResistance( 2 )
|
||||
);
|
||||
|
||||
ComputerCraft.Blocks.diskDrive = new BlockDiskDrive(
|
||||
Block.Properties.create( Material.ROCK ).hardnessAndResistance( 2 )
|
||||
);
|
||||
|
||||
ComputerCraft.Blocks.monitorNormal = new BlockMonitor(
|
||||
Block.Properties.create( Material.ROCK ).hardnessAndResistance( 2 ),
|
||||
TileMonitor.FACTORY_NORMAL
|
||||
);
|
||||
|
||||
ComputerCraft.Blocks.monitorAdvanced = new BlockMonitor(
|
||||
Block.Properties.create( Material.ROCK ).hardnessAndResistance( 2 ),
|
||||
TileMonitor.FACTORY_ADVANCED
|
||||
);
|
||||
|
||||
ComputerCraft.Blocks.printer = new BlockPrinter(
|
||||
Block.Properties.create( Material.ROCK ).hardnessAndResistance( 2 )
|
||||
);
|
||||
|
||||
ComputerCraft.Blocks.wirelessModemNormal = new BlockWirelessModem(
|
||||
Block.Properties.create( Material.ROCK ).hardnessAndResistance( 2 ),
|
||||
TileWirelessModem.FACTORY_NORMAL
|
||||
);
|
||||
|
||||
ComputerCraft.Blocks.wirelessModemAdvanced = new BlockWirelessModem(
|
||||
Block.Properties.create( Material.ROCK ).hardnessAndResistance( 2 ),
|
||||
TileWirelessModem.FACTORY_ADVANCED
|
||||
);
|
||||
|
||||
ComputerCraft.Blocks.wiredModemFull = new BlockWiredModemFull(
|
||||
Block.Properties.create( Material.ROCK ).hardnessAndResistance( 1.5f )
|
||||
);
|
||||
|
||||
ComputerCraft.Blocks.cable = new BlockCable(
|
||||
Block.Properties.create( Material.ROCK ).hardnessAndResistance( 1.5f )
|
||||
);
|
||||
|
||||
registry.registerAll(
|
||||
ComputerCraft.Blocks.speaker.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "speaker" ) ),
|
||||
ComputerCraft.Blocks.diskDrive.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "disk_drive" ) ),
|
||||
ComputerCraft.Blocks.monitorNormal.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "monitor_normal" ) ),
|
||||
ComputerCraft.Blocks.monitorAdvanced.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "monitor_advanced" ) ),
|
||||
ComputerCraft.Blocks.printer.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "printer" ) ),
|
||||
ComputerCraft.Blocks.wirelessModemNormal.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "wireless_modem_normal" ) ),
|
||||
ComputerCraft.Blocks.wirelessModemAdvanced.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "wireless_modem_advanced" ) ),
|
||||
ComputerCraft.Blocks.wiredModemFull.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "wired_modem_full" ) ),
|
||||
ComputerCraft.Blocks.cable.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "cable" ) )
|
||||
);
|
||||
public static final RegistryObject<BlockWiredModemFull> WIRED_MODEM_FULL = BLOCKS.register( "wired_modem_full",
|
||||
() -> new BlockWiredModemFull( modemProperties() ) );
|
||||
public static final RegistryObject<BlockCable> CABLE = BLOCKS.register( "cable", () -> new BlockCable( modemProperties() ) );
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerTileEntities( RegistryEvent.Register<TileEntityType<?>> event )
|
||||
public static class ModTiles
|
||||
{
|
||||
IForgeRegistry<TileEntityType<?>> registry = event.getRegistry();
|
||||
static final DeferredRegister<TileEntityType<?>> TILES = new DeferredRegister<>( ForgeRegistries.TILE_ENTITIES, ComputerCraft.MOD_ID );
|
||||
|
||||
// Computers
|
||||
registry.registerAll( TileComputer.FACTORY_NORMAL, TileComputer.FACTORY_ADVANCED, TileCommandComputer.FACTORY );
|
||||
private static <T extends TileEntity> RegistryObject<TileEntityType<T>> ofBlock( RegistryObject<? extends Block> block, Function<TileEntityType<T>, T> factory )
|
||||
{
|
||||
return TILES.register( block.getId().getPath(), () -> FixedPointTileEntityType.create( block, factory ) );
|
||||
}
|
||||
|
||||
// Turtles
|
||||
registry.registerAll( TileTurtle.FACTORY_NORMAL, TileTurtle.FACTORY_ADVANCED );
|
||||
public static final RegistryObject<TileEntityType<TileMonitor>> MONITOR_NORMAL =
|
||||
ofBlock( ModBlocks.MONITOR_NORMAL, f -> new TileMonitor( f, false ) );
|
||||
public static final RegistryObject<TileEntityType<TileMonitor>> MONITOR_ADVANCED =
|
||||
ofBlock( ModBlocks.MONITOR_ADVANCED, f -> new TileMonitor( f, true ) );
|
||||
|
||||
// Peripherals
|
||||
registry.registerAll(
|
||||
TileSpeaker.FACTORY,
|
||||
TileDiskDrive.FACTORY,
|
||||
TileMonitor.FACTORY_NORMAL,
|
||||
TileMonitor.FACTORY_ADVANCED,
|
||||
TilePrinter.FACTORY,
|
||||
TileWirelessModem.FACTORY_NORMAL,
|
||||
TileWirelessModem.FACTORY_ADVANCED,
|
||||
TileWiredModemFull.FACTORY,
|
||||
TileCable.FACTORY
|
||||
);
|
||||
public static final RegistryObject<TileEntityType<TileComputer>> COMPUTER_NORMAL =
|
||||
ofBlock( ModBlocks.COMPUTER_NORMAL, f -> new TileComputer( ComputerFamily.NORMAL, f ) );
|
||||
public static final RegistryObject<TileEntityType<TileComputer>> COMPUTER_ADVANCED =
|
||||
ofBlock( ModBlocks.COMPUTER_ADVANCED, f -> new TileComputer( ComputerFamily.ADVANCED, f ) );
|
||||
public static final RegistryObject<TileEntityType<TileCommandComputer>> COMPUTER_COMMAND =
|
||||
ofBlock( ModBlocks.COMPUTER_COMMAND, f -> new TileCommandComputer( ComputerFamily.COMMAND, f ) );
|
||||
|
||||
public static final RegistryObject<TileEntityType<TileTurtle>> TURTLE_NORMAL =
|
||||
ofBlock( ModBlocks.TURTLE_NORMAL, f -> new TileTurtle( f, ComputerFamily.NORMAL ) );
|
||||
public static final RegistryObject<TileEntityType<TileTurtle>> TURTLE_ADVANCED =
|
||||
ofBlock( ModBlocks.TURTLE_ADVANCED, f -> new TileTurtle( f, ComputerFamily.ADVANCED ) );
|
||||
|
||||
public static final RegistryObject<TileEntityType<TileSpeaker>> SPEAKER = ofBlock( ModBlocks.SPEAKER, TileSpeaker::new );
|
||||
public static final RegistryObject<TileEntityType<TileDiskDrive>> DISK_DRIVE = ofBlock( ModBlocks.DISK_DRIVE, TileDiskDrive::new );
|
||||
public static final RegistryObject<TileEntityType<TilePrinter>> PRINTER = ofBlock( ModBlocks.PRINTER, TilePrinter::new );
|
||||
public static final RegistryObject<TileEntityType<TileWiredModemFull>> WIRED_MODEM_FULL = ofBlock( ModBlocks.WIRED_MODEM_FULL, TileWiredModemFull::new );
|
||||
public static final RegistryObject<TileEntityType<TileCable>> CABLE = ofBlock( ModBlocks.CABLE, TileCable::new );
|
||||
|
||||
public static final RegistryObject<TileEntityType<TileWirelessModem>> WIRELESS_MODEM_NORMAL =
|
||||
ofBlock( ModBlocks.WIRELESS_MODEM_NORMAL, f -> new TileWirelessModem( f, false ) );
|
||||
public static final RegistryObject<TileEntityType<TileWirelessModem>> WIRELESS_MODEM_ADVANCED =
|
||||
ofBlock( ModBlocks.WIRELESS_MODEM_ADVANCED, f -> new TileWirelessModem( f, true ) );
|
||||
}
|
||||
|
||||
private static <T extends BlockItem> T setupItemBlock( T item )
|
||||
public static final class ModItems
|
||||
{
|
||||
item.setRegistryName( item.getBlock().getRegistryName() );
|
||||
return item;
|
||||
}
|
||||
static final DeferredRegister<Item> ITEMS = new DeferredRegister<>( ForgeRegistries.ITEMS, ComputerCraft.MOD_ID );
|
||||
|
||||
private static Item.Properties defaultItem()
|
||||
{
|
||||
return new Item.Properties().group( mainItemGroup );
|
||||
private static Item.Properties properties()
|
||||
{
|
||||
return new Item.Properties().group( mainItemGroup );
|
||||
}
|
||||
|
||||
private static <B extends Block, I extends Item> RegistryObject<I> ofBlock( RegistryObject<B> parent, BiFunction<B, Item.Properties, I> supplier )
|
||||
{
|
||||
return ITEMS.register( parent.getId().getPath(), () -> supplier.apply( parent.get(), properties() ) );
|
||||
}
|
||||
|
||||
public static final RegistryObject<ItemComputer> COMPUTER_NORMAL = ofBlock( ModBlocks.COMPUTER_NORMAL, ItemComputer::new );
|
||||
public static final RegistryObject<ItemComputer> COMPUTER_ADVANCED = ofBlock( ModBlocks.COMPUTER_ADVANCED, ItemComputer::new );
|
||||
public static final RegistryObject<ItemComputer> COMPUTER_COMMAND = ofBlock( ModBlocks.COMPUTER_COMMAND, ItemComputer::new );
|
||||
|
||||
public static final RegistryObject<ItemPocketComputer> POCKET_COMPUTER_NORMAL = ITEMS.register( "pocket_computer_normal",
|
||||
() -> new ItemPocketComputer( properties().maxStackSize( 1 ), ComputerFamily.NORMAL ) );
|
||||
public static final RegistryObject<ItemPocketComputer> POCKET_COMPUTER_ADVANCED = ITEMS.register( "pocket_computer_advanced",
|
||||
() -> new ItemPocketComputer( properties().maxStackSize( 1 ), ComputerFamily.ADVANCED ) );
|
||||
|
||||
public static final RegistryObject<ItemTurtle> TURTLE_NORMAL = ofBlock( ModBlocks.TURTLE_NORMAL, ItemTurtle::new );
|
||||
public static final RegistryObject<ItemTurtle> TURTLE_ADVANCED = ofBlock( ModBlocks.TURTLE_ADVANCED, ItemTurtle::new );
|
||||
|
||||
public static final RegistryObject<ItemDisk> DISK =
|
||||
ITEMS.register( "disk", () -> new ItemDisk( properties().maxStackSize( 1 ) ) );
|
||||
public static final RegistryObject<ItemTreasureDisk> TREASURE_DISK =
|
||||
ITEMS.register( "treasure_disk", () -> new ItemTreasureDisk( properties().maxStackSize( 1 ) ) );
|
||||
|
||||
public static final RegistryObject<ItemPrintout> PRINTED_PAGE = ITEMS.register( "printed_page",
|
||||
() -> new ItemPrintout( properties().maxStackSize( 1 ), ItemPrintout.Type.PAGE ) );
|
||||
public static final RegistryObject<ItemPrintout> PRINTED_PAGES = ITEMS.register( "printed_pages",
|
||||
() -> new ItemPrintout( properties().maxStackSize( 1 ), ItemPrintout.Type.PAGES ) );
|
||||
public static final RegistryObject<ItemPrintout> PRINTED_BOOK = ITEMS.register( "printed_book",
|
||||
() -> new ItemPrintout( properties().maxStackSize( 1 ), ItemPrintout.Type.BOOK ) );
|
||||
|
||||
public static final RegistryObject<BlockItem> SPEAKER = ofBlock( ModBlocks.SPEAKER, BlockItem::new );
|
||||
public static final RegistryObject<BlockItem> DISK_DRIVE = ofBlock( ModBlocks.DISK_DRIVE, BlockItem::new );
|
||||
public static final RegistryObject<BlockItem> PRINTER = ofBlock( ModBlocks.PRINTER, BlockItem::new );
|
||||
public static final RegistryObject<BlockItem> MONITOR_NORMAL = ofBlock( ModBlocks.MONITOR_NORMAL, BlockItem::new );
|
||||
public static final RegistryObject<BlockItem> MONITOR_ADVANCED = ofBlock( ModBlocks.MONITOR_ADVANCED, BlockItem::new );
|
||||
public static final RegistryObject<BlockItem> WIRELESS_MODEM_NORMAL = ofBlock( ModBlocks.WIRELESS_MODEM_NORMAL, BlockItem::new );
|
||||
public static final RegistryObject<BlockItem> WIRELESS_MODEM_ADVANCED = ofBlock( ModBlocks.WIRELESS_MODEM_ADVANCED, BlockItem::new );
|
||||
public static final RegistryObject<BlockItem> WIRED_MODEM_FULL = ofBlock( ModBlocks.WIRED_MODEM_FULL, BlockItem::new );
|
||||
|
||||
public static final RegistryObject<ItemBlockCable.Cable> CABLE = ITEMS.register( "cable",
|
||||
() -> new ItemBlockCable.Cable( ModBlocks.CABLE.get(), properties() ) );
|
||||
public static final RegistryObject<ItemBlockCable.WiredModem> WIRED_MODEM = ITEMS.register( "wired_modem",
|
||||
() -> new ItemBlockCable.WiredModem( ModBlocks.CABLE.get(), properties() ) );
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerItems( RegistryEvent.Register<Item> event )
|
||||
{
|
||||
IForgeRegistry<Item> registry = event.getRegistry();
|
||||
|
||||
// Computer
|
||||
ComputerCraft.Items.computerNormal = new ItemComputer( ComputerCraft.Blocks.computerNormal, defaultItem() );
|
||||
ComputerCraft.Items.computerAdvanced = new ItemComputer( ComputerCraft.Blocks.computerAdvanced, defaultItem() );
|
||||
ComputerCraft.Items.computerCommand = new ItemComputer( ComputerCraft.Blocks.computerCommand, defaultItem() );
|
||||
|
||||
registry.registerAll(
|
||||
setupItemBlock( ComputerCraft.Items.computerNormal ),
|
||||
setupItemBlock( ComputerCraft.Items.computerAdvanced ),
|
||||
setupItemBlock( ComputerCraft.Items.computerCommand )
|
||||
);
|
||||
|
||||
// Turtle
|
||||
ComputerCraft.Items.turtleNormal = new ItemTurtle( ComputerCraft.Blocks.turtleNormal, defaultItem() );
|
||||
ComputerCraft.Items.turtleAdvanced = new ItemTurtle( ComputerCraft.Blocks.turtleAdvanced, defaultItem() );
|
||||
registry.registerAll(
|
||||
setupItemBlock( ComputerCraft.Items.turtleNormal ),
|
||||
setupItemBlock( ComputerCraft.Items.turtleAdvanced )
|
||||
);
|
||||
|
||||
// Pocket computer
|
||||
ComputerCraft.Items.pocketComputerNormal = new ItemPocketComputer( defaultItem().maxStackSize( 1 ), ComputerFamily.NORMAL );
|
||||
ComputerCraft.Items.pocketComputerAdvanced = new ItemPocketComputer( defaultItem().maxStackSize( 1 ), ComputerFamily.ADVANCED );
|
||||
|
||||
registry.registerAll(
|
||||
ComputerCraft.Items.pocketComputerNormal.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "pocket_computer_normal" ) ),
|
||||
ComputerCraft.Items.pocketComputerAdvanced.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "pocket_computer_advanced" ) )
|
||||
);
|
||||
|
||||
// Floppy disk
|
||||
ComputerCraft.Items.disk = new ItemDisk( defaultItem().maxStackSize( 1 ) );
|
||||
ComputerCraft.Items.treasureDisk = new ItemTreasureDisk( defaultItem().maxStackSize( 1 ) );
|
||||
|
||||
registry.registerAll(
|
||||
ComputerCraft.Items.disk.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "disk" ) ),
|
||||
ComputerCraft.Items.treasureDisk.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "treasure_disk" ) )
|
||||
);
|
||||
|
||||
// Printouts
|
||||
ComputerCraft.Items.printedPage = new ItemPrintout( defaultItem().maxStackSize( 1 ), ItemPrintout.Type.PAGE );
|
||||
ComputerCraft.Items.printedPages = new ItemPrintout( defaultItem().maxStackSize( 1 ), ItemPrintout.Type.PAGES );
|
||||
ComputerCraft.Items.printedBook = new ItemPrintout( defaultItem().maxStackSize( 1 ), ItemPrintout.Type.BOOK );
|
||||
|
||||
registry.registerAll(
|
||||
ComputerCraft.Items.printedPage.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "printed_page" ) ),
|
||||
ComputerCraft.Items.printedPages.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "printed_pages" ) ),
|
||||
ComputerCraft.Items.printedBook.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "printed_book" ) )
|
||||
);
|
||||
|
||||
// Peripherals
|
||||
registry.registerAll(
|
||||
setupItemBlock( new BlockItem( ComputerCraft.Blocks.speaker, defaultItem() ) ),
|
||||
setupItemBlock( new BlockItem( ComputerCraft.Blocks.diskDrive, defaultItem() ) ),
|
||||
setupItemBlock( new BlockItem( ComputerCraft.Blocks.printer, defaultItem() ) ),
|
||||
setupItemBlock( new BlockItem( ComputerCraft.Blocks.monitorNormal, defaultItem() ) ),
|
||||
setupItemBlock( new BlockItem( ComputerCraft.Blocks.monitorAdvanced, defaultItem() ) ),
|
||||
setupItemBlock( new BlockItem( ComputerCraft.Blocks.wirelessModemNormal, defaultItem() ) ),
|
||||
setupItemBlock( new BlockItem( ComputerCraft.Blocks.wirelessModemAdvanced, defaultItem() ) ),
|
||||
setupItemBlock( new BlockItem( ComputerCraft.Blocks.wiredModemFull, defaultItem() ) )
|
||||
);
|
||||
|
||||
ComputerCraft.Items.cable = new ItemBlockCable.Cable( ComputerCraft.Blocks.cable, defaultItem() );
|
||||
ComputerCraft.Items.wiredModem = new ItemBlockCable.WiredModem( ComputerCraft.Blocks.cable, defaultItem() );
|
||||
registry.registerAll(
|
||||
ComputerCraft.Items.cable.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "cable" ) ),
|
||||
ComputerCraft.Items.wiredModem.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "wired_modem" ) )
|
||||
);
|
||||
|
||||
registerTurtleUpgrades();
|
||||
registerPocketUpgrades();
|
||||
}
|
||||
@ -303,7 +259,7 @@ public final class Registry
|
||||
ComputerCraft.TurtleUpgrades.diamondSword = new TurtleSword( new ResourceLocation( "minecraft", "diamond_sword" ), Items.DIAMOND_SWORD );
|
||||
ComputerCraftAPI.registerTurtleUpgrade( ComputerCraft.TurtleUpgrades.diamondSword );
|
||||
|
||||
ComputerCraft.TurtleUpgrades.diamondShovel = new TurtleShovel( new ResourceLocation( "minecraft", "diamond_shovel" ), net.minecraft.item.Items.DIAMOND_SHOVEL );
|
||||
ComputerCraft.TurtleUpgrades.diamondShovel = new TurtleShovel( new ResourceLocation( "minecraft", "diamond_shovel" ), Items.DIAMOND_SHOVEL );
|
||||
ComputerCraftAPI.registerTurtleUpgrade( ComputerCraft.TurtleUpgrades.diamondShovel );
|
||||
|
||||
ComputerCraft.TurtleUpgrades.diamondPickaxe = new TurtleTool( new ResourceLocation( "minecraft", "diamond_pickaxe" ), Items.DIAMOND_PICKAXE );
|
||||
@ -323,32 +279,47 @@ public final class Registry
|
||||
ComputerCraftAPI.registerPocketUpgrade( ComputerCraft.PocketUpgrades.speaker = new PocketSpeaker() );
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerEntities( RegistryEvent.Register<EntityType<?>> registry )
|
||||
public static class ModEntities
|
||||
{
|
||||
registry.getRegistry().register( TurtlePlayer.TYPE.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "turtle_player" ) ) );
|
||||
static final DeferredRegister<EntityType<?>> ENTITIES = new DeferredRegister<>( ForgeRegistries.ENTITIES, ComputerCraft.MOD_ID );
|
||||
|
||||
public static final RegistryObject<EntityType<TurtlePlayer>> TURTLE_PLAYER = ENTITIES.register( "turtle_player", () ->
|
||||
EntityType.Builder.<TurtlePlayer>create( EntityClassification.MISC )
|
||||
.disableSerialization()
|
||||
.disableSummoning()
|
||||
.size( 0, 0 )
|
||||
.build( ComputerCraft.MOD_ID + ":turtle_player" ) );
|
||||
}
|
||||
|
||||
public static class ModContainers
|
||||
{
|
||||
static final DeferredRegister<ContainerType<?>> CONTAINERS = new DeferredRegister<>( ForgeRegistries.CONTAINERS, ComputerCraft.MOD_ID );
|
||||
|
||||
public static final RegistryObject<ContainerType<ContainerComputer>> COMPUTER = CONTAINERS.register( "computer",
|
||||
() -> ContainerData.toType( ComputerContainerData::new, ContainerComputer::new ) );
|
||||
|
||||
public static final RegistryObject<ContainerType<ContainerPocketComputer>> POCKET_COMPUTER = CONTAINERS.register( "pocket_computer",
|
||||
() -> ContainerData.toType( ComputerContainerData::new, ContainerPocketComputer::new ) );
|
||||
|
||||
public static final RegistryObject<ContainerType<ContainerTurtle>> TURTLE = CONTAINERS.register( "turtle",
|
||||
() -> ContainerData.toType( ComputerContainerData::new, ContainerTurtle::new ) );
|
||||
|
||||
public static final RegistryObject<ContainerType<ContainerDiskDrive>> DISK_DRIVE = CONTAINERS.register( "disk_drive",
|
||||
() -> new ContainerType<>( ContainerDiskDrive::new ) );
|
||||
|
||||
public static final RegistryObject<ContainerType<ContainerPrinter>> PRINTER = CONTAINERS.register( "printer",
|
||||
() -> new ContainerType<>( ContainerPrinter::new ) );
|
||||
|
||||
public static final RegistryObject<ContainerType<ContainerHeldItem>> PRINTOUT = CONTAINERS.register( "printout",
|
||||
() -> ContainerData.toType( HeldItemContainerData::new, ContainerHeldItem::createPrintout ) );
|
||||
|
||||
public static final RegistryObject<ContainerType<ContainerViewComputer>> VIEW_COMPUTER = CONTAINERS.register( "view_computer",
|
||||
() -> ContainerData.toType( ViewComputerContainerData::new, ContainerViewComputer::new ) );
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerContainers( RegistryEvent.Register<ContainerType<?>> event )
|
||||
public static void registerRecipeSerializers( RegistryEvent.Register<IRecipeSerializer<?>> event )
|
||||
{
|
||||
event.getRegistry().registerAll(
|
||||
ContainerComputer.TYPE.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "computer" ) ),
|
||||
ContainerPocketComputer.TYPE.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "pocket_computer" ) ),
|
||||
ContainerTurtle.TYPE.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "turtle" ) ),
|
||||
|
||||
ContainerDiskDrive.TYPE.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "disk_drive" ) ),
|
||||
ContainerPrinter.TYPE.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "printer" ) ),
|
||||
ContainerHeldItem.PRINTOUT_TYPE.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "printout" ) ),
|
||||
|
||||
ContainerViewComputer.TYPE.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "view_computer" ) )
|
||||
);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void regsterRecipeSerializers( RegistryEvent.Register<IRecipeSerializer<?>> event )
|
||||
{
|
||||
|
||||
event.getRegistry().registerAll(
|
||||
ColourableRecipe.SERIALIZER.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "colour" ) ),
|
||||
ComputerUpgradeRecipe.SERIALIZER.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "computer_upgrade" ) ),
|
||||
@ -361,4 +332,14 @@ public final class Registry
|
||||
ImpostorRecipe.SERIALIZER.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "impostor_shaped" ) )
|
||||
);
|
||||
}
|
||||
|
||||
public static void setup()
|
||||
{
|
||||
IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
ModBlocks.BLOCKS.register( bus );
|
||||
ModTiles.TILES.register( bus );
|
||||
ModItems.ITEMS.register( bus );
|
||||
ModEntities.ENTITIES.register( bus );
|
||||
ModContainers.CONTAINERS.register( bus );
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.common;
|
||||
|
||||
import dan200.computercraft.shared.util.NamedTileEntityType;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@ -19,6 +18,7 @@ import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraftforge.fml.RegistryObject;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
@ -26,13 +26,12 @@ import java.util.Random;
|
||||
|
||||
public abstract class BlockGeneric extends Block
|
||||
{
|
||||
private final TileEntityType<? extends TileGeneric> type;
|
||||
private final RegistryObject<? extends TileEntityType<? extends TileGeneric>> type;
|
||||
|
||||
public BlockGeneric( Properties settings, NamedTileEntityType<? extends TileGeneric> type )
|
||||
public BlockGeneric( Properties settings, RegistryObject<? extends TileEntityType<? extends TileGeneric>> type )
|
||||
{
|
||||
super( settings );
|
||||
this.type = type;
|
||||
type.setBlock( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -89,7 +88,7 @@ public abstract class BlockGeneric extends Block
|
||||
@Override
|
||||
public TileEntity createTileEntity( @Nonnull BlockState state, @Nonnull IBlockReader world )
|
||||
{
|
||||
return type.create();
|
||||
return type.get().create();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.common;
|
||||
|
||||
import dan200.computercraft.shared.network.container.ContainerData;
|
||||
import dan200.computercraft.shared.Registry;
|
||||
import dan200.computercraft.shared.network.container.HeldItemContainerData;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
@ -21,8 +21,6 @@ import javax.annotation.Nullable;
|
||||
|
||||
public class ContainerHeldItem extends Container
|
||||
{
|
||||
public static final ContainerType<ContainerHeldItem> PRINTOUT_TYPE = ContainerData.toType( HeldItemContainerData::new, ContainerHeldItem::createPrintout );
|
||||
|
||||
private final ItemStack stack;
|
||||
private final Hand hand;
|
||||
|
||||
@ -34,9 +32,9 @@ public class ContainerHeldItem extends Container
|
||||
stack = player.getHeldItem( hand ).copy();
|
||||
}
|
||||
|
||||
private static ContainerHeldItem createPrintout( int id, PlayerInventory inventory, HeldItemContainerData data )
|
||||
public static ContainerHeldItem createPrintout( int id, PlayerInventory inventory, HeldItemContainerData data )
|
||||
{
|
||||
return new ContainerHeldItem( PRINTOUT_TYPE, id, inventory.player, data.getHand() );
|
||||
return new ContainerHeldItem( Registry.ModContainers.PRINTOUT.get(), id, inventory.player, data.getHand() );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
@ -8,7 +8,6 @@ package dan200.computercraft.shared.computer.blocks;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.computer.core.ComputerState;
|
||||
import dan200.computercraft.shared.computer.items.ComputerItemFactory;
|
||||
import dan200.computercraft.shared.util.NamedTileEntityType;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
@ -17,7 +16,9 @@ import net.minecraft.state.DirectionProperty;
|
||||
import net.minecraft.state.EnumProperty;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraftforge.fml.RegistryObject;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
@ -27,7 +28,7 @@ public class BlockComputer extends BlockComputerBase<TileComputer>
|
||||
public static final EnumProperty<ComputerState> STATE = EnumProperty.create( "state", ComputerState.class );
|
||||
public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING;
|
||||
|
||||
public BlockComputer( Properties settings, ComputerFamily family, NamedTileEntityType<? extends TileComputer> type )
|
||||
public BlockComputer( Properties settings, ComputerFamily family, RegistryObject<? extends TileEntityType<? extends TileComputer>> type )
|
||||
{
|
||||
super( settings, family, type );
|
||||
setDefaultState( getDefaultState()
|
||||
|
@ -12,13 +12,13 @@ import dan200.computercraft.shared.common.IBundledRedstoneBlock;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.computer.core.ServerComputer;
|
||||
import dan200.computercraft.shared.computer.items.IComputerItem;
|
||||
import dan200.computercraft.shared.util.NamedTileEntityType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.stats.Stats;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@ -28,6 +28,7 @@ import net.minecraft.world.World;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraft.world.storage.loot.LootContext;
|
||||
import net.minecraft.world.storage.loot.LootParameters;
|
||||
import net.minecraftforge.fml.RegistryObject;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
@ -38,7 +39,7 @@ public abstract class BlockComputerBase<T extends TileComputerBase> extends Bloc
|
||||
|
||||
private final ComputerFamily family;
|
||||
|
||||
protected BlockComputerBase( Properties settings, ComputerFamily family, NamedTileEntityType<? extends T> type )
|
||||
protected BlockComputerBase( Properties settings, ComputerFamily family, RegistryObject<? extends TileEntityType<? extends T>> type )
|
||||
{
|
||||
super( settings, type );
|
||||
this.family = family;
|
||||
@ -46,7 +47,7 @@ public abstract class BlockComputerBase<T extends TileComputerBase> extends Bloc
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void onBlockAdded( BlockState state, World world, BlockPos pos, BlockState oldState, boolean isMoving )
|
||||
public void onBlockAdded( @Nonnull BlockState state, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull BlockState oldState, boolean isMoving )
|
||||
{
|
||||
super.onBlockAdded( state, world, pos, oldState, isMoving );
|
||||
|
||||
@ -56,14 +57,14 @@ public abstract class BlockComputerBase<T extends TileComputerBase> extends Bloc
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean canProvidePower( BlockState state )
|
||||
public boolean canProvidePower( @Nonnull BlockState state )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public int getStrongPower( BlockState state, IBlockReader world, BlockPos pos, Direction incomingSide )
|
||||
public int getStrongPower( @Nonnull BlockState state, IBlockReader world, @Nonnull BlockPos pos, @Nonnull Direction incomingSide )
|
||||
{
|
||||
TileEntity entity = world.getTileEntity( pos );
|
||||
if( !(entity instanceof TileComputerBase) ) return 0;
|
||||
@ -86,7 +87,7 @@ public abstract class BlockComputerBase<T extends TileComputerBase> extends Bloc
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public int getWeakPower( BlockState state, IBlockReader world, BlockPos pos, Direction incomingSide )
|
||||
public int getWeakPower( @Nonnull BlockState state, @Nonnull IBlockReader world, @Nonnull BlockPos pos, @Nonnull Direction incomingSide )
|
||||
{
|
||||
return getStrongPower( state, world, pos, incomingSide );
|
||||
}
|
||||
@ -126,7 +127,7 @@ public abstract class BlockComputerBase<T extends TileComputerBase> extends Bloc
|
||||
}
|
||||
|
||||
@Override
|
||||
public void harvestBlock( @Nonnull World world, PlayerEntity player, @Nonnull BlockPos pos, BlockState state, @Nullable TileEntity tile, @Nonnull ItemStack tool )
|
||||
public void harvestBlock( @Nonnull World world, PlayerEntity player, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nullable TileEntity tile, @Nonnull ItemStack tool )
|
||||
{
|
||||
// Don't drop blocks here - see onBlockHarvested.
|
||||
player.addStat( Stats.BLOCK_MINED.get( this ) );
|
||||
@ -134,7 +135,7 @@ public abstract class BlockComputerBase<T extends TileComputerBase> extends Bloc
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockHarvested( World world, @Nonnull BlockPos pos, BlockState state, @Nonnull PlayerEntity player )
|
||||
public void onBlockHarvested( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nonnull PlayerEntity player )
|
||||
{
|
||||
if( !(world instanceof ServerWorld) ) return;
|
||||
|
||||
@ -162,7 +163,7 @@ public abstract class BlockComputerBase<T extends TileComputerBase> extends Bloc
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy( World world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack )
|
||||
public void onBlockPlacedBy( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull BlockState state, LivingEntity placer, @Nonnull ItemStack stack )
|
||||
{
|
||||
super.onBlockPlacedBy( world, pos, state, placer, stack );
|
||||
|
||||
|
@ -9,13 +9,11 @@ import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.shared.computer.apis.CommandAPI;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.computer.core.ServerComputer;
|
||||
import dan200.computercraft.shared.util.NamedTileEntityType;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.command.ICommandSource;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.Vec2f;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
@ -30,11 +28,6 @@ import java.util.Map;
|
||||
|
||||
public class TileCommandComputer extends TileComputer
|
||||
{
|
||||
public static final NamedTileEntityType<TileCommandComputer> FACTORY = NamedTileEntityType.create(
|
||||
new ResourceLocation( ComputerCraft.MOD_ID, "command_computer" ),
|
||||
f -> new TileCommandComputer( ComputerFamily.COMMAND, f )
|
||||
);
|
||||
|
||||
public class CommandReceiver implements ICommandSource
|
||||
{
|
||||
private final Map<Integer, String> output = new HashMap<>();
|
||||
|
@ -13,14 +13,12 @@ import dan200.computercraft.shared.computer.core.ComputerState;
|
||||
import dan200.computercraft.shared.computer.core.ServerComputer;
|
||||
import dan200.computercraft.shared.computer.inventory.ContainerComputer;
|
||||
import dan200.computercraft.shared.util.CapabilityUtil;
|
||||
import dan200.computercraft.shared.util.NamedTileEntityType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
|
||||
@ -31,16 +29,6 @@ import static dan200.computercraft.shared.Capabilities.CAPABILITY_PERIPHERAL;
|
||||
|
||||
public class TileComputer extends TileComputerBase
|
||||
{
|
||||
public static final NamedTileEntityType<TileComputer> FACTORY_NORMAL = NamedTileEntityType.create(
|
||||
new ResourceLocation( ComputerCraft.MOD_ID, "computer_normal" ),
|
||||
f -> new TileComputer( ComputerFamily.NORMAL, f )
|
||||
);
|
||||
|
||||
public static final NamedTileEntityType<TileComputer> FACTORY_ADVANCED = NamedTileEntityType.create(
|
||||
new ResourceLocation( ComputerCraft.MOD_ID, "computer_advanced" ),
|
||||
f -> new TileComputer( ComputerFamily.ADVANCED, f )
|
||||
);
|
||||
|
||||
private ComputerProxy proxy;
|
||||
private LazyOptional<IPeripheral> peripheral;
|
||||
|
||||
|
@ -178,7 +178,7 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompoundNBT write( CompoundNBT nbt )
|
||||
public CompoundNBT write( @Nonnull CompoundNBT nbt )
|
||||
{
|
||||
// Save ID, label and power state
|
||||
if( m_computerID >= 0 ) nbt.putInt( NBT_ID, m_computerID );
|
||||
@ -189,7 +189,7 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read( CompoundNBT nbt )
|
||||
public void read( @Nonnull CompoundNBT nbt )
|
||||
{
|
||||
super.read( nbt );
|
||||
|
||||
|
@ -5,23 +5,20 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.computer.inventory;
|
||||
|
||||
import dan200.computercraft.shared.Registry;
|
||||
import dan200.computercraft.shared.computer.blocks.TileComputer;
|
||||
import dan200.computercraft.shared.network.container.ComputerContainerData;
|
||||
import dan200.computercraft.shared.network.container.ContainerData;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
|
||||
public class ContainerComputer extends ContainerComputerBase
|
||||
{
|
||||
public static final ContainerType<ContainerComputer> TYPE = ContainerData.toType( ComputerContainerData::new, ContainerComputer::new );
|
||||
|
||||
public ContainerComputer( int id, TileComputer tile )
|
||||
{
|
||||
super( TYPE, id, tile::isUsableByPlayer, tile.createServerComputer(), tile.getFamily() );
|
||||
super( Registry.ModContainers.COMPUTER.get(), id, tile::isUsableByPlayer, tile.createServerComputer(), tile.getFamily() );
|
||||
}
|
||||
|
||||
private ContainerComputer( int id, PlayerInventory player, ComputerContainerData data )
|
||||
public ContainerComputer( int id, PlayerInventory player, ComputerContainerData data )
|
||||
{
|
||||
super( TYPE, id, player, data );
|
||||
super( Registry.ModContainers.COMPUTER.get(), id, player, data );
|
||||
}
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ public class ContainerComputerBase extends Container implements IContainerComput
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed( PlayerEntity player )
|
||||
public void onContainerClosed( @Nonnull PlayerEntity player )
|
||||
{
|
||||
super.onContainerClosed( player );
|
||||
input.close();
|
||||
|
@ -6,34 +6,31 @@
|
||||
package dan200.computercraft.shared.computer.inventory;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.shared.Registry;
|
||||
import dan200.computercraft.shared.computer.blocks.TileCommandComputer;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.computer.core.IContainerComputer;
|
||||
import dan200.computercraft.shared.computer.core.ServerComputer;
|
||||
import dan200.computercraft.shared.network.container.ContainerData;
|
||||
import dan200.computercraft.shared.network.container.ViewComputerContainerData;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class ContainerViewComputer extends ContainerComputerBase implements IContainerComputer
|
||||
{
|
||||
public static final ContainerType<ContainerViewComputer> TYPE = ContainerData.toType( ViewComputerContainerData::new, ContainerViewComputer::new );
|
||||
|
||||
private final int width;
|
||||
private final int height;
|
||||
|
||||
public ContainerViewComputer( int id, ServerComputer computer )
|
||||
{
|
||||
super( TYPE, id, player -> canInteractWith( computer, player ), computer, computer.getFamily() );
|
||||
super( Registry.ModContainers.VIEW_COMPUTER.get(), id, player -> canInteractWith( computer, player ), computer, computer.getFamily() );
|
||||
this.width = this.height = 0;
|
||||
}
|
||||
|
||||
public ContainerViewComputer( int id, PlayerInventory player, ViewComputerContainerData data )
|
||||
{
|
||||
super( TYPE, id, player, data );
|
||||
super( Registry.ModContainers.VIEW_COMPUTER.get(), id, player, data );
|
||||
this.width = data.getWidth();
|
||||
this.height = data.getHeight();
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.computer.items;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.shared.Registry;
|
||||
import dan200.computercraft.shared.computer.blocks.TileComputer;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@ -28,11 +28,11 @@ public final class ComputerItemFactory
|
||||
switch( family )
|
||||
{
|
||||
case NORMAL:
|
||||
return ComputerCraft.Items.computerNormal.create( id, label );
|
||||
return Registry.ModItems.COMPUTER_NORMAL.get().create( id, label );
|
||||
case ADVANCED:
|
||||
return ComputerCraft.Items.computerAdvanced.create( id, label );
|
||||
return Registry.ModItems.COMPUTER_ADVANCED.get().create( id, label );
|
||||
case COMMAND:
|
||||
return ComputerCraft.Items.computerCommand.create( id, label );
|
||||
return Registry.ModItems.COMPUTER_COMMAND.get().create( id, label );
|
||||
default:
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import dan200.computercraft.api.pocket.IPocketUpgrade;
|
||||
import dan200.computercraft.api.turtle.ITurtleUpgrade;
|
||||
import dan200.computercraft.api.turtle.TurtleSide;
|
||||
import dan200.computercraft.shared.PocketUpgrades;
|
||||
import dan200.computercraft.shared.Registry;
|
||||
import dan200.computercraft.shared.TurtleUpgrades;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.media.items.ItemDisk;
|
||||
@ -51,13 +52,13 @@ public class JEIComputerCraft implements IModPlugin
|
||||
@Override
|
||||
public void registerItemSubtypes( ISubtypeRegistration subtypeRegistry )
|
||||
{
|
||||
subtypeRegistry.registerSubtypeInterpreter( ComputerCraft.Items.turtleNormal, turtleSubtype );
|
||||
subtypeRegistry.registerSubtypeInterpreter( ComputerCraft.Items.turtleAdvanced, turtleSubtype );
|
||||
subtypeRegistry.registerSubtypeInterpreter( Registry.ModItems.TURTLE_NORMAL.get(), turtleSubtype );
|
||||
subtypeRegistry.registerSubtypeInterpreter( Registry.ModItems.TURTLE_ADVANCED.get(), turtleSubtype );
|
||||
|
||||
subtypeRegistry.registerSubtypeInterpreter( ComputerCraft.Items.pocketComputerNormal, pocketSubtype );
|
||||
subtypeRegistry.registerSubtypeInterpreter( ComputerCraft.Items.pocketComputerAdvanced, pocketSubtype );
|
||||
subtypeRegistry.registerSubtypeInterpreter( Registry.ModItems.POCKET_COMPUTER_NORMAL.get(), pocketSubtype );
|
||||
subtypeRegistry.registerSubtypeInterpreter( Registry.ModItems.POCKET_COMPUTER_ADVANCED.get(), pocketSubtype );
|
||||
|
||||
subtypeRegistry.registerSubtypeInterpreter( ComputerCraft.Items.disk, diskSubtype );
|
||||
subtypeRegistry.registerSubtypeInterpreter( Registry.ModItems.DISK.get(), diskSubtype );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -9,6 +9,7 @@ import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.filesystem.IMount;
|
||||
import dan200.computercraft.api.media.IMedia;
|
||||
import dan200.computercraft.shared.Registry;
|
||||
import dan200.computercraft.shared.common.IColouredItem;
|
||||
import dan200.computercraft.shared.util.Colour;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
@ -42,9 +43,9 @@ public class ItemDisk extends Item implements IMedia, IColouredItem
|
||||
@Nonnull
|
||||
public static ItemStack createFromIDAndColour( int id, String label, int colour )
|
||||
{
|
||||
ItemStack stack = new ItemStack( ComputerCraft.Items.disk );
|
||||
ItemStack stack = new ItemStack( Registry.ModItems.DISK.get() );
|
||||
setDiskID( stack, id );
|
||||
ComputerCraft.Items.disk.setLabel( stack, label );
|
||||
Registry.ModItems.DISK.get().setLabel( stack, label );
|
||||
IColouredItem.setColourBasic( stack, colour );
|
||||
return stack;
|
||||
}
|
||||
@ -60,7 +61,7 @@ public class ItemDisk extends Item implements IMedia, IColouredItem
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation( ItemStack stack, @Nullable World world, List<ITextComponent> list, ITooltipFlag options )
|
||||
public void addInformation( @Nonnull ItemStack stack, @Nullable World world, @Nonnull List<ITextComponent> list, ITooltipFlag options )
|
||||
{
|
||||
if( options.isAdvanced() )
|
||||
{
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.media.items;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.shared.Registry;
|
||||
import dan200.computercraft.shared.common.ContainerHeldItem;
|
||||
import dan200.computercraft.shared.network.container.HeldItemContainerData;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
@ -50,7 +50,7 @@ public class ItemPrintout extends Item
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation( @Nonnull ItemStack stack, World world, List<ITextComponent> list, ITooltipFlag options )
|
||||
public void addInformation( @Nonnull ItemStack stack, World world, @Nonnull List<ITextComponent> list, @Nonnull ITooltipFlag options )
|
||||
{
|
||||
String title = getTitle( stack );
|
||||
if( title != null && !title.isEmpty() ) list.add( new StringTextComponent( title ) );
|
||||
@ -58,12 +58,12 @@ public class ItemPrintout extends Item
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick( World world, PlayerEntity player, @Nonnull Hand hand )
|
||||
public ActionResult<ItemStack> onItemRightClick( World world, @Nonnull PlayerEntity player, @Nonnull Hand hand )
|
||||
{
|
||||
if( !world.isRemote )
|
||||
{
|
||||
new HeldItemContainerData( hand )
|
||||
.open( player, new ContainerHeldItem.Factory( ContainerHeldItem.PRINTOUT_TYPE, player.getHeldItem( hand ), hand ) );
|
||||
.open( player, new ContainerHeldItem.Factory( Registry.ModContainers.PRINTOUT.get(), player.getHeldItem( hand ), hand ) );
|
||||
}
|
||||
return new ActionResult<>( ActionResultType.SUCCESS, player.getHeldItem( hand ) );
|
||||
}
|
||||
@ -100,19 +100,19 @@ public class ItemPrintout extends Item
|
||||
@Nonnull
|
||||
public static ItemStack createSingleFromTitleAndText( String title, String[] text, String[] colours )
|
||||
{
|
||||
return ComputerCraft.Items.printedPage.createFromTitleAndText( title, text, colours );
|
||||
return Registry.ModItems.PRINTED_PAGE.get().createFromTitleAndText( title, text, colours );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static ItemStack createMultipleFromTitleAndText( String title, String[] text, String[] colours )
|
||||
{
|
||||
return ComputerCraft.Items.printedPages.createFromTitleAndText( title, text, colours );
|
||||
return Registry.ModItems.PRINTED_PAGES.get().createFromTitleAndText( title, text, colours );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static ItemStack createBookFromTitleAndText( String title, String[] text, String[] colours )
|
||||
{
|
||||
return ComputerCraft.Items.printedBook.createFromTitleAndText( title, text, colours );
|
||||
return Registry.ModItems.PRINTED_BOOK.get().createFromTitleAndText( title, text, colours );
|
||||
}
|
||||
|
||||
public Type getType()
|
||||
|
@ -5,11 +5,11 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.media.items;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.filesystem.IMount;
|
||||
import dan200.computercraft.api.media.IMedia;
|
||||
import dan200.computercraft.core.filesystem.SubMount;
|
||||
import dan200.computercraft.shared.Registry;
|
||||
import dan200.computercraft.shared.util.Colour;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@ -46,7 +46,7 @@ public class ItemTreasureDisk extends Item implements IMedia
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation( ItemStack stack, @Nullable World world, List<ITextComponent> list, ITooltipFlag tooltipOptions )
|
||||
public void addInformation( @Nonnull ItemStack stack, @Nullable World world, @Nonnull List<ITextComponent> list, @Nonnull ITooltipFlag tooltipOptions )
|
||||
{
|
||||
String label = getTitle( stack );
|
||||
if( !label.isEmpty() ) list.add( new StringTextComponent( label ) );
|
||||
@ -92,7 +92,7 @@ public class ItemTreasureDisk extends Item implements IMedia
|
||||
|
||||
public static ItemStack create( String subPath, int colourIndex )
|
||||
{
|
||||
ItemStack result = new ItemStack( ComputerCraft.Items.treasureDisk );
|
||||
ItemStack result = new ItemStack( Registry.ModItems.TREASURE_DISK.get() );
|
||||
CompoundNBT nbt = result.getOrCreateTag();
|
||||
nbt.putString( NBT_SUB_PATH, subPath );
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.peripheral.diskdrive;
|
||||
|
||||
import dan200.computercraft.shared.Registry;
|
||||
import dan200.computercraft.shared.common.BlockGeneric;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
@ -33,7 +34,7 @@ public class BlockDiskDrive extends BlockGeneric
|
||||
|
||||
public BlockDiskDrive( Properties settings )
|
||||
{
|
||||
super( settings, TileDiskDrive.FACTORY );
|
||||
super( settings, Registry.ModTiles.DISK_DRIVE );
|
||||
setDefaultState( getStateContainer().getBaseState()
|
||||
.with( FACING, Direction.NORTH )
|
||||
.with( STATE, DiskDriveState.EMPTY ) );
|
||||
@ -54,7 +55,7 @@ public class BlockDiskDrive extends BlockGeneric
|
||||
}
|
||||
|
||||
@Override
|
||||
public void harvestBlock( @Nonnull World world, PlayerEntity player, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nullable TileEntity te, ItemStack stack )
|
||||
public void harvestBlock( @Nonnull World world, @Nonnull PlayerEntity player, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nullable TileEntity te, @Nonnull ItemStack stack )
|
||||
{
|
||||
if( te instanceof INameable && ((INameable) te).hasCustomName() )
|
||||
{
|
||||
@ -72,7 +73,7 @@ public class BlockDiskDrive extends BlockGeneric
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy( World world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack )
|
||||
public void onBlockPlacedBy( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull BlockState state, LivingEntity placer, ItemStack stack )
|
||||
{
|
||||
if( stack.hasDisplayName() )
|
||||
{
|
||||
|
@ -5,12 +5,12 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.peripheral.diskdrive;
|
||||
|
||||
import dan200.computercraft.shared.Registry;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@ -18,13 +18,11 @@ import javax.annotation.Nonnull;
|
||||
|
||||
public class ContainerDiskDrive extends Container
|
||||
{
|
||||
public static final ContainerType<ContainerDiskDrive> TYPE = new ContainerType<>( ContainerDiskDrive::new );
|
||||
|
||||
private final IInventory inventory;
|
||||
|
||||
public ContainerDiskDrive( int id, PlayerInventory player, IInventory inventory )
|
||||
{
|
||||
super( TYPE, id );
|
||||
super( Registry.ModContainers.DISK_DRIVE.get(), id );
|
||||
|
||||
this.inventory = inventory;
|
||||
|
||||
@ -44,7 +42,7 @@ public class ContainerDiskDrive extends Container
|
||||
}
|
||||
}
|
||||
|
||||
private ContainerDiskDrive( int id, PlayerInventory player )
|
||||
public ContainerDiskDrive( int id, PlayerInventory player )
|
||||
{
|
||||
this( id, player, new Inventory( 1 ) );
|
||||
}
|
||||
@ -57,7 +55,7 @@ public class ContainerDiskDrive extends Container
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack transferStackInSlot( PlayerEntity player, int slotIndex )
|
||||
public ItemStack transferStackInSlot( @Nonnull PlayerEntity player, int slotIndex )
|
||||
{
|
||||
Slot slot = inventorySlots.get( slotIndex );
|
||||
if( slot == null || !slot.getHasStack() ) return ItemStack.EMPTY;
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.peripheral.diskdrive;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.filesystem.IMount;
|
||||
import dan200.computercraft.api.filesystem.IWritableMount;
|
||||
import dan200.computercraft.api.media.IMedia;
|
||||
@ -13,7 +12,10 @@ import dan200.computercraft.api.peripheral.IComputerAccess;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.shared.MediaProviders;
|
||||
import dan200.computercraft.shared.common.TileGeneric;
|
||||
import dan200.computercraft.shared.util.*;
|
||||
import dan200.computercraft.shared.util.CapabilityUtil;
|
||||
import dan200.computercraft.shared.util.DefaultInventory;
|
||||
import dan200.computercraft.shared.util.InventoryUtil;
|
||||
import dan200.computercraft.shared.util.RecordUtil;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.item.ItemEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@ -24,6 +26,7 @@ import net.minecraft.inventory.container.INamedContainerProvider;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.ITickableTileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
@ -49,11 +52,6 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory
|
||||
private static final String NBT_NAME = "CustomName";
|
||||
private static final String NBT_ITEM = "Item";
|
||||
|
||||
public static final NamedTileEntityType<TileDiskDrive> FACTORY = NamedTileEntityType.create(
|
||||
new ResourceLocation( ComputerCraft.MOD_ID, "disk_drive" ),
|
||||
TileDiskDrive::new
|
||||
);
|
||||
|
||||
private static class MountInfo
|
||||
{
|
||||
String mountPath;
|
||||
@ -74,9 +72,9 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory
|
||||
private boolean m_restartRecord = false;
|
||||
private boolean m_ejectQueued;
|
||||
|
||||
private TileDiskDrive()
|
||||
public TileDiskDrive( TileEntityType<TileDiskDrive> type )
|
||||
{
|
||||
super( FACTORY );
|
||||
super( type );
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -124,7 +122,7 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read( CompoundNBT nbt )
|
||||
public void read( @Nonnull CompoundNBT nbt )
|
||||
{
|
||||
super.read( nbt );
|
||||
customName = nbt.contains( NBT_NAME ) ? ITextComponent.Serializer.fromJson( nbt.getString( NBT_NAME ) ) : null;
|
||||
@ -138,7 +136,7 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompoundNBT write( CompoundNBT nbt )
|
||||
public CompoundNBT write( @Nonnull CompoundNBT nbt )
|
||||
{
|
||||
if( customName != null ) nbt.putString( NBT_NAME, ITextComponent.Serializer.toJson( customName ) );
|
||||
|
||||
|
@ -6,8 +6,8 @@
|
||||
package dan200.computercraft.shared.peripheral.modem.wired;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.shared.Registry;
|
||||
import dan200.computercraft.shared.common.BlockGeneric;
|
||||
import dan200.computercraft.shared.util.WorldUtil;
|
||||
import net.minecraft.block.Block;
|
||||
@ -61,7 +61,7 @@ public class BlockCable extends BlockGeneric implements IWaterLoggable
|
||||
|
||||
public BlockCable( Properties settings )
|
||||
{
|
||||
super( settings, TileCable.FACTORY );
|
||||
super( settings, Registry.ModTiles.CABLE );
|
||||
|
||||
setDefaultState( getStateContainer().getBaseState()
|
||||
.with( MODEM, CableModemVariant.None )
|
||||
@ -94,7 +94,7 @@ public class BlockCable extends BlockGeneric implements IWaterLoggable
|
||||
@Nonnull
|
||||
@Override
|
||||
@Deprecated
|
||||
public VoxelShape getShape( BlockState state, IBlockReader world, BlockPos pos, ISelectionContext context )
|
||||
public VoxelShape getShape( @Nonnull BlockState state, @Nonnull IBlockReader world, @Nonnull BlockPos pos, @Nonnull ISelectionContext context )
|
||||
{
|
||||
return CableShapes.getShape( state );
|
||||
}
|
||||
@ -121,12 +121,12 @@ public class BlockCable extends BlockGeneric implements IWaterLoggable
|
||||
if( WorldUtil.isVecInside( CableShapes.getModemShape( state ), hit.getHitVec().subtract( pos.getX(), pos.getY(), pos.getZ() ) ) )
|
||||
{
|
||||
newState = state.with( MODEM, CableModemVariant.None );
|
||||
item = new ItemStack( ComputerCraft.Items.wiredModem );
|
||||
item = new ItemStack( Registry.ModItems.WIRED_MODEM.get() );
|
||||
}
|
||||
else
|
||||
{
|
||||
newState = state.with( CABLE, false );
|
||||
item = new ItemStack( ComputerCraft.Items.cable );
|
||||
item = new ItemStack( Registry.ModItems.CABLE.get() );
|
||||
}
|
||||
|
||||
world.setBlockState( pos, correctConnections( world, pos, newState ), 3 );
|
||||
@ -154,18 +154,18 @@ public class BlockCable extends BlockGeneric implements IWaterLoggable
|
||||
boolean cable = state.get( CABLE );
|
||||
|
||||
// If we've only got one, just use that.
|
||||
if( !cable ) return new ItemStack( ComputerCraft.Items.wiredModem );
|
||||
if( modem == null ) return new ItemStack( ComputerCraft.Items.cable );
|
||||
if( !cable ) return new ItemStack( Registry.ModItems.WIRED_MODEM.get() );
|
||||
if( modem == null ) return new ItemStack( Registry.ModItems.CABLE.get() );
|
||||
|
||||
// We've a modem and cable, so try to work out which one we're interacting with
|
||||
return hit != null && WorldUtil.isVecInside( CableShapes.getModemShape( state ), hit.getHitVec().subtract( pos.getX(), pos.getY(), pos.getZ() ) )
|
||||
? new ItemStack( ComputerCraft.Items.wiredModem )
|
||||
: new ItemStack( ComputerCraft.Items.cable );
|
||||
? new ItemStack( Registry.ModItems.WIRED_MODEM.get() )
|
||||
: new ItemStack( Registry.ModItems.CABLE.get() );
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy( World world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack )
|
||||
public void onBlockPlacedBy( World world, @Nonnull BlockPos pos, @Nonnull BlockState state, LivingEntity placer, @Nonnull ItemStack stack )
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
if( tile instanceof TileCable )
|
||||
@ -180,7 +180,7 @@ public class BlockCable extends BlockGeneric implements IWaterLoggable
|
||||
@Nonnull
|
||||
@Override
|
||||
@Deprecated
|
||||
public IFluidState getFluidState( BlockState state )
|
||||
public IFluidState getFluidState( @Nonnull BlockState state )
|
||||
{
|
||||
return getWaterloggedFluidState( state );
|
||||
}
|
||||
@ -188,7 +188,7 @@ public class BlockCable extends BlockGeneric implements IWaterLoggable
|
||||
@Nonnull
|
||||
@Override
|
||||
@Deprecated
|
||||
public BlockState updatePostPlacement( @Nonnull BlockState state, Direction side, BlockState otherState, IWorld world, BlockPos pos, BlockPos otherPos )
|
||||
public BlockState updatePostPlacement( @Nonnull BlockState state, @Nonnull Direction side, @Nonnull BlockState otherState, @Nonnull IWorld world, @Nonnull BlockPos pos, @Nonnull BlockPos otherPos )
|
||||
{
|
||||
updateWaterloggedPostPlacement( state, world, pos );
|
||||
// Should never happen, but handle the case where we've no modem or cable.
|
||||
@ -202,7 +202,7 @@ public class BlockCable extends BlockGeneric implements IWaterLoggable
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean isValidPosition( BlockState state, IWorldReader world, BlockPos pos )
|
||||
public boolean isValidPosition( BlockState state, @Nonnull IWorldReader world, @Nonnull BlockPos pos )
|
||||
{
|
||||
Direction facing = state.get( MODEM ).getFacing();
|
||||
if( facing == null ) return true;
|
||||
@ -214,7 +214,7 @@ public class BlockCable extends BlockGeneric implements IWaterLoggable
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockState getStateForPlacement( BlockItemUseContext context )
|
||||
public BlockState getStateForPlacement( @Nonnull BlockItemUseContext context )
|
||||
{
|
||||
BlockState state = getDefaultState()
|
||||
.with( WATERLOGGED, getWaterloggedStateForPlacement( context ) );
|
||||
|
@ -5,6 +5,7 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.peripheral.modem.wired;
|
||||
|
||||
import dan200.computercraft.shared.Registry;
|
||||
import dan200.computercraft.shared.common.BlockGeneric;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
@ -18,7 +19,7 @@ public class BlockWiredModemFull extends BlockGeneric
|
||||
|
||||
public BlockWiredModemFull( Properties settings )
|
||||
{
|
||||
super( settings, TileWiredModemFull.FACTORY );
|
||||
super( settings, Registry.ModTiles.WIRED_MODEM_FULL );
|
||||
setDefaultState( getStateContainer().getBaseState()
|
||||
.with( MODEM_ON, false )
|
||||
.with( PERIPHERAL_ON, false )
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.peripheral.modem.wired;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.shared.Registry;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@ -93,7 +93,7 @@ public abstract class ItemBlockCable extends BlockItem
|
||||
BlockState existingState = world.getBlockState( pos );
|
||||
|
||||
// Try to add a modem to a cable
|
||||
if( existingState.getBlock() == ComputerCraft.Blocks.cable && existingState.get( MODEM ) == CableModemVariant.None )
|
||||
if( existingState.getBlock() == Registry.ModBlocks.CABLE.get() && existingState.get( MODEM ) == CableModemVariant.None )
|
||||
{
|
||||
Direction side = context.getFace().getOpposite();
|
||||
BlockState newState = existingState
|
||||
@ -130,7 +130,7 @@ public abstract class ItemBlockCable extends BlockItem
|
||||
// Try to add a cable to a modem inside the block we're clicking on.
|
||||
BlockPos insidePos = pos.offset( context.getFace().getOpposite() );
|
||||
BlockState insideState = world.getBlockState( insidePos );
|
||||
if( insideState.getBlock() == ComputerCraft.Blocks.cable && !insideState.get( BlockCable.CABLE )
|
||||
if( insideState.getBlock() == Registry.ModBlocks.CABLE.get() && !insideState.get( BlockCable.CABLE )
|
||||
&& placeAtCorrected( world, insidePos, insideState.with( BlockCable.CABLE, true ) ) )
|
||||
{
|
||||
stack.shrink( 1 );
|
||||
@ -139,7 +139,7 @@ public abstract class ItemBlockCable extends BlockItem
|
||||
|
||||
// Try to add a cable to a modem adjacent to this block
|
||||
BlockState existingState = world.getBlockState( pos );
|
||||
if( existingState.getBlock() == ComputerCraft.Blocks.cable && !existingState.get( BlockCable.CABLE )
|
||||
if( existingState.getBlock() == Registry.ModBlocks.CABLE.get() && !existingState.get( BlockCable.CABLE )
|
||||
&& placeAtCorrected( world, pos, existingState.with( BlockCable.CABLE, true ) ) )
|
||||
{
|
||||
stack.shrink( 1 );
|
||||
|
@ -6,27 +6,26 @@
|
||||
package dan200.computercraft.shared.peripheral.modem.wired;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.network.wired.IWiredElement;
|
||||
import dan200.computercraft.api.network.wired.IWiredNode;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.shared.Registry;
|
||||
import dan200.computercraft.shared.command.CommandCopy;
|
||||
import dan200.computercraft.shared.common.TileGeneric;
|
||||
import dan200.computercraft.shared.peripheral.modem.ModemState;
|
||||
import dan200.computercraft.shared.util.CapabilityUtil;
|
||||
import dan200.computercraft.shared.util.DirectionUtil;
|
||||
import dan200.computercraft.shared.util.NamedTileEntityType;
|
||||
import dan200.computercraft.shared.util.TickScheduler;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
@ -46,11 +45,6 @@ import static dan200.computercraft.shared.Capabilities.CAPABILITY_WIRED_ELEMENT;
|
||||
|
||||
public class TileCable extends TileGeneric
|
||||
{
|
||||
public static final NamedTileEntityType<TileCable> FACTORY = NamedTileEntityType.create(
|
||||
new ResourceLocation( ComputerCraft.MOD_ID, "cable" ),
|
||||
TileCable::new
|
||||
);
|
||||
|
||||
private static final String NBT_PERIPHERAL_ENABLED = "PeirpheralAccess";
|
||||
|
||||
private class CableElement extends WiredModemElement
|
||||
@ -126,9 +120,9 @@ public class TileCable extends TileGeneric
|
||||
|
||||
private final NonNullConsumer<LazyOptional<IWiredElement>> connectedNodeChanged = x -> connectionsChanged();
|
||||
|
||||
public TileCable()
|
||||
public TileCable( TileEntityType<? extends TileCable> type )
|
||||
{
|
||||
super( FACTORY );
|
||||
super( type );
|
||||
}
|
||||
|
||||
private void onRemove()
|
||||
@ -219,7 +213,7 @@ public class TileCable extends TileGeneric
|
||||
if( hasCable() )
|
||||
{
|
||||
// Drop the modem and convert to cable
|
||||
Block.spawnAsEntity( getWorld(), getPos(), new ItemStack( ComputerCraft.Items.wiredModem ) );
|
||||
Block.spawnAsEntity( getWorld(), getPos(), new ItemStack( Registry.ModItems.WIRED_MODEM.get() ) );
|
||||
getWorld().setBlockState( getPos(), getBlockState().with( BlockCable.MODEM, CableModemVariant.None ) );
|
||||
modemChanged();
|
||||
connectionsChanged();
|
||||
@ -227,7 +221,7 @@ public class TileCable extends TileGeneric
|
||||
else
|
||||
{
|
||||
// Drop everything and remove block
|
||||
Block.spawnAsEntity( getWorld(), getPos(), new ItemStack( ComputerCraft.Items.wiredModem ) );
|
||||
Block.spawnAsEntity( getWorld(), getPos(), new ItemStack( Registry.ModItems.WIRED_MODEM.get() ) );
|
||||
getWorld().removeBlock( getPos(), false );
|
||||
// This'll call #destroy(), so we don't need to reset the network here.
|
||||
}
|
||||
@ -287,7 +281,7 @@ public class TileCable extends TileGeneric
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read( CompoundNBT nbt )
|
||||
public void read( @Nonnull CompoundNBT nbt )
|
||||
{
|
||||
super.read( nbt );
|
||||
m_peripheralAccessAllowed = nbt.getBoolean( NBT_PERIPHERAL_ENABLED );
|
||||
|
@ -6,7 +6,6 @@
|
||||
package dan200.computercraft.shared.peripheral.modem.wired;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.network.wired.IWiredElement;
|
||||
import dan200.computercraft.api.network.wired.IWiredNode;
|
||||
@ -14,14 +13,17 @@ import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.shared.command.CommandCopy;
|
||||
import dan200.computercraft.shared.common.TileGeneric;
|
||||
import dan200.computercraft.shared.peripheral.modem.ModemState;
|
||||
import dan200.computercraft.shared.util.*;
|
||||
import dan200.computercraft.shared.util.CapabilityUtil;
|
||||
import dan200.computercraft.shared.util.DirectionUtil;
|
||||
import dan200.computercraft.shared.util.SidedCaps;
|
||||
import dan200.computercraft.shared.util.TickScheduler;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
@ -43,11 +45,6 @@ import static dan200.computercraft.shared.peripheral.modem.wired.BlockWiredModem
|
||||
|
||||
public class TileWiredModemFull extends TileGeneric
|
||||
{
|
||||
public static final NamedTileEntityType<TileWiredModemFull> FACTORY = NamedTileEntityType.create(
|
||||
new ResourceLocation( ComputerCraft.MOD_ID, "wired_modem_full" ),
|
||||
TileWiredModemFull::new
|
||||
);
|
||||
|
||||
private static final String NBT_PERIPHERAL_ENABLED = "PeripheralAccess";
|
||||
|
||||
private static final class FullElement extends WiredModemElement
|
||||
@ -111,9 +108,9 @@ public class TileWiredModemFull extends TileGeneric
|
||||
|
||||
private final NonNullConsumer<LazyOptional<IWiredElement>> connectedNodeChanged = x -> connectionsChanged();
|
||||
|
||||
public TileWiredModemFull()
|
||||
public TileWiredModemFull( TileEntityType<TileWiredModemFull> type )
|
||||
{
|
||||
super( FACTORY );
|
||||
super( type );
|
||||
for( int i = 0; i < m_peripherals.length; i++ )
|
||||
{
|
||||
Direction facing = Direction.byIndex( i );
|
||||
|
@ -5,9 +5,9 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.peripheral.modem.wired;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.shared.Peripherals;
|
||||
import dan200.computercraft.shared.Registry;
|
||||
import dan200.computercraft.shared.util.IDAssigner;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
@ -144,7 +144,7 @@ public final class WiredModemLocalPeripheral
|
||||
BlockPos offset = pos.offset( direction );
|
||||
|
||||
Block block = world.getBlockState( offset ).getBlock();
|
||||
if( block == ComputerCraft.Blocks.wiredModemFull || block == ComputerCraft.Blocks.cable ) return null;
|
||||
if( block == Registry.ModBlocks.WIRED_MODEM_FULL.get() || block == Registry.ModBlocks.CABLE.get() ) return null;
|
||||
|
||||
IPeripheral peripheral = Peripherals.getPeripheral( world, offset, direction.getOpposite(), invalidate );
|
||||
return peripheral instanceof WiredModemPeripheral ? null : peripheral;
|
||||
|
@ -7,7 +7,6 @@ package dan200.computercraft.shared.peripheral.modem.wireless;
|
||||
|
||||
import dan200.computercraft.shared.common.BlockGeneric;
|
||||
import dan200.computercraft.shared.peripheral.modem.ModemShapes;
|
||||
import dan200.computercraft.shared.util.NamedTileEntityType;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.IWaterLoggable;
|
||||
@ -17,6 +16,7 @@ import net.minecraft.state.BooleanProperty;
|
||||
import net.minecraft.state.DirectionProperty;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
@ -24,6 +24,7 @@ import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
import net.minecraftforge.fml.RegistryObject;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
@ -35,7 +36,7 @@ public class BlockWirelessModem extends BlockGeneric implements IWaterLoggable
|
||||
public static final DirectionProperty FACING = BlockStateProperties.FACING;
|
||||
public static final BooleanProperty ON = BooleanProperty.create( "on" );
|
||||
|
||||
public BlockWirelessModem( Properties settings, NamedTileEntityType<? extends TileWirelessModem> type )
|
||||
public BlockWirelessModem( Properties settings, RegistryObject<? extends TileEntityType<? extends TileWirelessModem>> type )
|
||||
{
|
||||
super( settings, type );
|
||||
setDefaultState( getStateContainer().getBaseState()
|
||||
@ -53,7 +54,7 @@ public class BlockWirelessModem extends BlockGeneric implements IWaterLoggable
|
||||
@Nonnull
|
||||
@Override
|
||||
@Deprecated
|
||||
public VoxelShape getShape( BlockState blockState, IBlockReader blockView, BlockPos blockPos, ISelectionContext context )
|
||||
public VoxelShape getShape( BlockState blockState, @Nonnull IBlockReader blockView, @Nonnull BlockPos blockPos, @Nonnull ISelectionContext context )
|
||||
{
|
||||
return ModemShapes.getBounds( blockState.get( FACING ) );
|
||||
}
|
||||
@ -61,7 +62,7 @@ public class BlockWirelessModem extends BlockGeneric implements IWaterLoggable
|
||||
@Nonnull
|
||||
@Override
|
||||
@Deprecated
|
||||
public IFluidState getFluidState( BlockState state )
|
||||
public IFluidState getFluidState( @Nonnull BlockState state )
|
||||
{
|
||||
return getWaterloggedFluidState( state );
|
||||
}
|
||||
@ -69,7 +70,7 @@ public class BlockWirelessModem extends BlockGeneric implements IWaterLoggable
|
||||
@Nonnull
|
||||
@Override
|
||||
@Deprecated
|
||||
public BlockState updatePostPlacement( @Nonnull BlockState state, Direction side, BlockState otherState, IWorld world, BlockPos pos, BlockPos otherPos )
|
||||
public BlockState updatePostPlacement( @Nonnull BlockState state, @Nonnull Direction side, @Nonnull BlockState otherState, @Nonnull IWorld world, @Nonnull BlockPos pos, @Nonnull BlockPos otherPos )
|
||||
{
|
||||
updateWaterloggedPostPlacement( state, world, pos );
|
||||
return side == state.get( FACING ) && !state.isValidPosition( world, pos )
|
||||
|
@ -5,18 +5,15 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.peripheral.modem.wireless;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.shared.common.TileGeneric;
|
||||
import dan200.computercraft.shared.peripheral.modem.ModemPeripheral;
|
||||
import dan200.computercraft.shared.peripheral.modem.ModemState;
|
||||
import dan200.computercraft.shared.util.CapabilityUtil;
|
||||
import dan200.computercraft.shared.util.NamedTileEntityType;
|
||||
import dan200.computercraft.shared.util.TickScheduler;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
@ -30,16 +27,6 @@ import static dan200.computercraft.shared.Capabilities.CAPABILITY_PERIPHERAL;
|
||||
|
||||
public class TileWirelessModem extends TileGeneric
|
||||
{
|
||||
public static final NamedTileEntityType<TileWirelessModem> FACTORY_NORMAL = NamedTileEntityType.create(
|
||||
new ResourceLocation( ComputerCraft.MOD_ID, "wireless_modem_normal" ),
|
||||
f -> new TileWirelessModem( f, false )
|
||||
);
|
||||
|
||||
public static final NamedTileEntityType<TileWirelessModem> FACTORY_ADVANCED = NamedTileEntityType.create(
|
||||
new ResourceLocation( ComputerCraft.MOD_ID, "wireless_modem_advanced" ),
|
||||
f -> new TileWirelessModem( f, true )
|
||||
);
|
||||
|
||||
private static class Peripheral extends WirelessModemPeripheral
|
||||
{
|
||||
private final TileWirelessModem entity;
|
||||
|
@ -6,8 +6,6 @@
|
||||
package dan200.computercraft.shared.peripheral.monitor;
|
||||
|
||||
import dan200.computercraft.shared.common.BlockGeneric;
|
||||
import dan200.computercraft.shared.common.TileGeneric;
|
||||
import dan200.computercraft.shared.util.NamedTileEntityType;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
@ -18,10 +16,13 @@ import net.minecraft.state.EnumProperty;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.RegistryObject;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class BlockMonitor extends BlockGeneric
|
||||
@ -33,7 +34,7 @@ public class BlockMonitor extends BlockGeneric
|
||||
|
||||
static final EnumProperty<MonitorEdgeState> STATE = EnumProperty.create( "state", MonitorEdgeState.class );
|
||||
|
||||
public BlockMonitor( Properties settings, NamedTileEntityType<? extends TileGeneric> type )
|
||||
public BlockMonitor( Properties settings, RegistryObject<? extends TileEntityType<? extends TileMonitor>> type )
|
||||
{
|
||||
super( settings, type );
|
||||
// TODO: Test underwater - do we need isSolid at all?
|
||||
@ -76,7 +77,7 @@ public class BlockMonitor extends BlockGeneric
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy( World world, BlockPos pos, BlockState blockState, @Nullable LivingEntity livingEntity, ItemStack itemStack )
|
||||
public void onBlockPlacedBy( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull BlockState blockState, @Nullable LivingEntity livingEntity, @Nonnull ItemStack itemStack )
|
||||
{
|
||||
super.onBlockPlacedBy( world, pos, blockState, livingEntity, itemStack );
|
||||
|
||||
|
@ -13,7 +13,6 @@ import dan200.computercraft.shared.common.ServerTerminal;
|
||||
import dan200.computercraft.shared.common.TileGeneric;
|
||||
import dan200.computercraft.shared.network.client.TerminalState;
|
||||
import dan200.computercraft.shared.util.CapabilityUtil;
|
||||
import dan200.computercraft.shared.util.NamedTileEntityType;
|
||||
import dan200.computercraft.shared.util.TickScheduler;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
@ -22,7 +21,6 @@ import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
@ -39,16 +37,6 @@ import static dan200.computercraft.shared.Capabilities.CAPABILITY_PERIPHERAL;
|
||||
|
||||
public class TileMonitor extends TileGeneric
|
||||
{
|
||||
public static final NamedTileEntityType<TileMonitor> FACTORY_NORMAL = NamedTileEntityType.create(
|
||||
new ResourceLocation( ComputerCraft.MOD_ID, "monitor_normal" ),
|
||||
f -> new TileMonitor( f, false )
|
||||
);
|
||||
|
||||
public static final NamedTileEntityType<TileMonitor> FACTORY_ADVANCED = NamedTileEntityType.create(
|
||||
new ResourceLocation( ComputerCraft.MOD_ID, "monitor_advanced" ),
|
||||
f -> new TileMonitor( f, true )
|
||||
);
|
||||
|
||||
public static final double RENDER_BORDER = 2.0 / 16.0;
|
||||
public static final double RENDER_MARGIN = 0.5 / 16.0;
|
||||
public static final double RENDER_PIXEL_SCALE = 1.0 / 64.0;
|
||||
@ -149,7 +137,7 @@ public class TileMonitor extends TileGeneric
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read( CompoundNBT tag )
|
||||
public void read( @Nonnull CompoundNBT tag )
|
||||
{
|
||||
super.read( tag );
|
||||
m_xIndex = tag.getInt( NBT_X );
|
||||
|
@ -5,6 +5,7 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.peripheral.printer;
|
||||
|
||||
import dan200.computercraft.shared.Registry;
|
||||
import dan200.computercraft.shared.common.BlockGeneric;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
@ -34,7 +35,7 @@ public class BlockPrinter extends BlockGeneric
|
||||
|
||||
public BlockPrinter( Properties settings )
|
||||
{
|
||||
super( settings, TilePrinter.FACTORY );
|
||||
super( settings, Registry.ModTiles.PRINTER );
|
||||
setDefaultState( getStateContainer().getBaseState()
|
||||
.with( FACING, Direction.NORTH )
|
||||
.with( TOP, false )
|
||||
@ -55,7 +56,7 @@ public class BlockPrinter extends BlockGeneric
|
||||
}
|
||||
|
||||
@Override
|
||||
public void harvestBlock( @Nonnull World world, PlayerEntity player, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nullable TileEntity te, ItemStack stack )
|
||||
public void harvestBlock( @Nonnull World world, @Nonnull PlayerEntity player, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nullable TileEntity te, @Nonnull ItemStack stack )
|
||||
{
|
||||
if( te instanceof INameable && ((INameable) te).hasCustomName() )
|
||||
{
|
||||
@ -73,7 +74,7 @@ public class BlockPrinter extends BlockGeneric
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy( World world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack )
|
||||
public void onBlockPlacedBy( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull BlockState state, LivingEntity placer, ItemStack stack )
|
||||
{
|
||||
if( stack.hasDisplayName() )
|
||||
{
|
||||
|
@ -5,13 +5,13 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.peripheral.printer;
|
||||
|
||||
import dan200.computercraft.shared.Registry;
|
||||
import dan200.computercraft.shared.util.SingleIntArray;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.item.DyeItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@ -22,14 +22,12 @@ import javax.annotation.Nonnull;
|
||||
|
||||
public class ContainerPrinter extends Container
|
||||
{
|
||||
public static final ContainerType<ContainerPrinter> TYPE = new ContainerType<>( ContainerPrinter::new );
|
||||
|
||||
private final IInventory inventory;
|
||||
private final IIntArray properties;
|
||||
|
||||
private ContainerPrinter( int id, PlayerInventory player, IInventory inventory, IIntArray properties )
|
||||
{
|
||||
super( TYPE, id );
|
||||
super( Registry.ModContainers.PRINTER.get(), id );
|
||||
this.properties = properties;
|
||||
this.inventory = inventory;
|
||||
|
||||
@ -60,7 +58,7 @@ public class ContainerPrinter extends Container
|
||||
}
|
||||
}
|
||||
|
||||
private ContainerPrinter( int id, PlayerInventory player )
|
||||
public ContainerPrinter( int id, PlayerInventory player )
|
||||
{
|
||||
this( id, player, new Inventory( TilePrinter.SLOTS ), new IntArray( 1 ) );
|
||||
}
|
||||
@ -83,7 +81,7 @@ public class ContainerPrinter extends Container
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack transferStackInSlot( PlayerEntity player, int index )
|
||||
public ItemStack transferStackInSlot( @Nonnull PlayerEntity player, int index )
|
||||
{
|
||||
Slot slot = inventorySlots.get( index );
|
||||
if( slot == null || !slot.getHasStack() ) return ItemStack.EMPTY;
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.peripheral.printer;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.core.terminal.Terminal;
|
||||
import dan200.computercraft.shared.common.TileGeneric;
|
||||
@ -20,6 +19,7 @@ import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.inventory.container.INamedContainerProvider;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
@ -40,11 +40,6 @@ import static net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABI
|
||||
|
||||
public final class TilePrinter extends TileGeneric implements DefaultSidedInventory, INameable, INamedContainerProvider
|
||||
{
|
||||
public static final NamedTileEntityType<TilePrinter> FACTORY = NamedTileEntityType.create(
|
||||
new ResourceLocation( ComputerCraft.MOD_ID, "printer" ),
|
||||
TilePrinter::new
|
||||
);
|
||||
|
||||
private static final String NBT_NAME = "CustomName";
|
||||
private static final String NBT_PRINTING = "Printing";
|
||||
private static final String NBT_PAGE_TITLE = "PageTitle";
|
||||
@ -66,9 +61,9 @@ public final class TilePrinter extends TileGeneric implements DefaultSidedInvent
|
||||
private String m_pageTitle = "";
|
||||
private boolean m_printing = false;
|
||||
|
||||
private TilePrinter()
|
||||
public TilePrinter( TileEntityType<TilePrinter> type )
|
||||
{
|
||||
super( FACTORY );
|
||||
super( type );
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -96,7 +91,7 @@ public final class TilePrinter extends TileGeneric implements DefaultSidedInvent
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read( CompoundNBT nbt )
|
||||
public void read( @Nonnull CompoundNBT nbt )
|
||||
{
|
||||
super.read( nbt );
|
||||
|
||||
@ -116,7 +111,7 @@ public final class TilePrinter extends TileGeneric implements DefaultSidedInvent
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompoundNBT write( CompoundNBT nbt )
|
||||
public CompoundNBT write( @Nonnull CompoundNBT nbt )
|
||||
{
|
||||
if( customName != null ) nbt.putString( NBT_NAME, ITextComponent.Serializer.toJson( customName ) );
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.peripheral.speaker;
|
||||
|
||||
import dan200.computercraft.shared.Registry;
|
||||
import dan200.computercraft.shared.common.BlockGeneric;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
@ -22,7 +23,7 @@ public class BlockSpeaker extends BlockGeneric
|
||||
|
||||
public BlockSpeaker( Properties settings )
|
||||
{
|
||||
super( settings, TileSpeaker.FACTORY );
|
||||
super( settings, Registry.ModTiles.SPEAKER );
|
||||
setDefaultState( getStateContainer().getBaseState()
|
||||
.with( FACING, Direction.NORTH ) );
|
||||
}
|
||||
|
@ -5,14 +5,12 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.peripheral.speaker;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.shared.common.TileGeneric;
|
||||
import dan200.computercraft.shared.util.CapabilityUtil;
|
||||
import dan200.computercraft.shared.util.NamedTileEntityType;
|
||||
import net.minecraft.tileentity.ITickableTileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
@ -28,17 +26,12 @@ public class TileSpeaker extends TileGeneric implements ITickableTileEntity
|
||||
{
|
||||
public static final int MIN_TICKS_BETWEEN_SOUNDS = 1;
|
||||
|
||||
public static final NamedTileEntityType<TileSpeaker> FACTORY = NamedTileEntityType.create(
|
||||
new ResourceLocation( ComputerCraft.MOD_ID, "speaker" ),
|
||||
TileSpeaker::new
|
||||
);
|
||||
|
||||
private final SpeakerPeripheral peripheral;
|
||||
private LazyOptional<IPeripheral> peripheralCap;
|
||||
|
||||
public TileSpeaker()
|
||||
public TileSpeaker( TileEntityType<TileSpeaker> type )
|
||||
{
|
||||
super( FACTORY );
|
||||
super( type );
|
||||
peripheral = new Peripheral( this );
|
||||
}
|
||||
|
||||
|
@ -5,15 +5,14 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.pocket.inventory;
|
||||
|
||||
import dan200.computercraft.shared.Registry;
|
||||
import dan200.computercraft.shared.computer.core.ServerComputer;
|
||||
import dan200.computercraft.shared.computer.inventory.ContainerComputerBase;
|
||||
import dan200.computercraft.shared.network.container.ComputerContainerData;
|
||||
import dan200.computercraft.shared.network.container.ContainerData;
|
||||
import dan200.computercraft.shared.pocket.items.ItemPocketComputer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.inventory.container.INamedContainerProvider;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Hand;
|
||||
@ -24,24 +23,21 @@ import javax.annotation.Nullable;
|
||||
|
||||
public final class ContainerPocketComputer extends ContainerComputerBase
|
||||
{
|
||||
public static final ContainerType<ContainerPocketComputer> TYPE = ContainerData.toType( ComputerContainerData::new, ContainerPocketComputer::new );
|
||||
|
||||
private ContainerPocketComputer( int id, ServerComputer computer, ItemPocketComputer item, Hand hand )
|
||||
{
|
||||
super( TYPE, id, p -> {
|
||||
super( Registry.ModContainers.POCKET_COMPUTER.get(), id, p -> {
|
||||
ItemStack stack = p.getHeldItem( hand );
|
||||
return stack.getItem() == item && ItemPocketComputer.getServerComputer( stack ) == computer;
|
||||
}, computer, item.getFamily() );
|
||||
}
|
||||
|
||||
private ContainerPocketComputer( int id, PlayerInventory player, ComputerContainerData data )
|
||||
public ContainerPocketComputer( int id, PlayerInventory player, ComputerContainerData data )
|
||||
{
|
||||
super( TYPE, id, player, data );
|
||||
super( Registry.ModContainers.POCKET_COMPUTER.get(), id, player, data );
|
||||
}
|
||||
|
||||
public static class Factory implements INamedContainerProvider
|
||||
{
|
||||
|
||||
private final ServerComputer computer;
|
||||
private final ITextComponent name;
|
||||
private final ItemPocketComputer item;
|
||||
|
@ -86,7 +86,7 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inventoryTick( ItemStack stack, World world, Entity entity, int slotNum, boolean selected )
|
||||
public void inventoryTick( @Nonnull ItemStack stack, World world, @Nonnull Entity entity, int slotNum, boolean selected )
|
||||
{
|
||||
if( !world.isRemote )
|
||||
{
|
||||
@ -182,7 +182,7 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I
|
||||
|
||||
|
||||
@Override
|
||||
public void addInformation( @Nonnull ItemStack stack, @Nullable World world, List<ITextComponent> list, ITooltipFlag flag )
|
||||
public void addInformation( @Nonnull ItemStack stack, @Nullable World world, @Nonnull List<ITextComponent> list, ITooltipFlag flag )
|
||||
{
|
||||
if( flag.isAdvanced() || getLabel( stack ) == null )
|
||||
{
|
||||
|
@ -5,8 +5,8 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.pocket.items;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.pocket.IPocketUpgrade;
|
||||
import dan200.computercraft.shared.Registry;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@ -22,9 +22,9 @@ public final class PocketComputerItemFactory
|
||||
switch( family )
|
||||
{
|
||||
case NORMAL:
|
||||
return ComputerCraft.Items.pocketComputerNormal.create( id, label, colour, upgrade );
|
||||
return Registry.ModItems.POCKET_COMPUTER_NORMAL.get().create( id, label, colour, upgrade );
|
||||
case ADVANCED:
|
||||
return ComputerCraft.Items.pocketComputerAdvanced.create( id, label, colour, upgrade );
|
||||
return Registry.ModItems.POCKET_COMPUTER_ADVANCED.get().create( id, label, colour, upgrade );
|
||||
default:
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
@ -5,10 +5,10 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.pocket.peripherals;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.api.pocket.AbstractPocketUpgrade;
|
||||
import dan200.computercraft.api.pocket.IPocketAccess;
|
||||
import dan200.computercraft.shared.Registry;
|
||||
import dan200.computercraft.shared.peripheral.modem.ModemState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
@ -25,8 +25,8 @@ public class PocketModem extends AbstractPocketUpgrade
|
||||
super(
|
||||
new ResourceLocation( "computercraft", advanced ? "wireless_modem_advanced" : "wireless_modem_normal" ),
|
||||
advanced
|
||||
? ComputerCraft.Blocks.wirelessModemAdvanced
|
||||
: ComputerCraft.Blocks.wirelessModemNormal
|
||||
? Registry.ModBlocks.WIRELESS_MODEM_ADVANCED
|
||||
: Registry.ModBlocks.WIRELESS_MODEM_NORMAL
|
||||
);
|
||||
this.advanced = advanced;
|
||||
}
|
||||
|
@ -5,10 +5,10 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.pocket.peripherals;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.api.pocket.AbstractPocketUpgrade;
|
||||
import dan200.computercraft.api.pocket.IPocketAccess;
|
||||
import dan200.computercraft.shared.Registry;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
@ -19,7 +19,7 @@ public class PocketSpeaker extends AbstractPocketUpgrade
|
||||
{
|
||||
public PocketSpeaker()
|
||||
{
|
||||
super( new ResourceLocation( "computercraft", "speaker" ), ComputerCraft.Blocks.speaker );
|
||||
super( new ResourceLocation( "computercraft", "speaker" ), Registry.ModBlocks.SPEAKER );
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -12,7 +12,6 @@ import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.turtle.core.TurtleBrain;
|
||||
import dan200.computercraft.shared.turtle.items.ITurtleItem;
|
||||
import dan200.computercraft.shared.turtle.items.TurtleItemFactory;
|
||||
import dan200.computercraft.shared.util.NamedTileEntityType;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
@ -28,6 +27,7 @@ import net.minecraft.state.DirectionProperty;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@ -36,6 +36,7 @@ import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.util.math.shapes.VoxelShapes;
|
||||
import net.minecraft.world.*;
|
||||
import net.minecraftforge.fml.RegistryObject;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
@ -52,7 +53,7 @@ public class BlockTurtle extends BlockComputerBase<TileTurtle> implements IWater
|
||||
0.875, 0.875, 0.875
|
||||
);
|
||||
|
||||
public BlockTurtle( Properties settings, ComputerFamily family, NamedTileEntityType<TileTurtle> type )
|
||||
public BlockTurtle( Properties settings, ComputerFamily family, RegistryObject<? extends TileEntityType<? extends TileTurtle>> type )
|
||||
{
|
||||
super( settings, family, type );
|
||||
setDefaultState( getStateContainer().getBaseState()
|
||||
@ -70,7 +71,7 @@ public class BlockTurtle extends BlockComputerBase<TileTurtle> implements IWater
|
||||
@Nonnull
|
||||
@Override
|
||||
@Deprecated
|
||||
public BlockRenderType getRenderType( BlockState state )
|
||||
public BlockRenderType getRenderType( @Nonnull BlockState state )
|
||||
{
|
||||
return BlockRenderType.ENTITYBLOCK_ANIMATED;
|
||||
}
|
||||
@ -78,7 +79,7 @@ public class BlockTurtle extends BlockComputerBase<TileTurtle> implements IWater
|
||||
@Nonnull
|
||||
@Override
|
||||
@Deprecated
|
||||
public VoxelShape getShape( BlockState state, IBlockReader world, BlockPos pos, ISelectionContext context )
|
||||
public VoxelShape getShape( @Nonnull BlockState state, IBlockReader world, @Nonnull BlockPos pos, @Nonnull ISelectionContext context )
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
Vec3d offset = tile instanceof TileTurtle ? ((TileTurtle) tile).getRenderOffset( 1.0f ) : Vec3d.ZERO;
|
||||
@ -97,7 +98,7 @@ public class BlockTurtle extends BlockComputerBase<TileTurtle> implements IWater
|
||||
@Nonnull
|
||||
@Override
|
||||
@Deprecated
|
||||
public IFluidState getFluidState( BlockState state )
|
||||
public IFluidState getFluidState( @Nonnull BlockState state )
|
||||
{
|
||||
return getWaterloggedFluidState( state );
|
||||
}
|
||||
@ -105,14 +106,14 @@ public class BlockTurtle extends BlockComputerBase<TileTurtle> implements IWater
|
||||
@Nonnull
|
||||
@Override
|
||||
@Deprecated
|
||||
public BlockState updatePostPlacement( @Nonnull BlockState state, Direction side, BlockState otherState, IWorld world, BlockPos pos, BlockPos otherPos )
|
||||
public BlockState updatePostPlacement( @Nonnull BlockState state, @Nonnull Direction side, @Nonnull BlockState otherState, @Nonnull IWorld world, @Nonnull BlockPos pos, @Nonnull BlockPos otherPos )
|
||||
{
|
||||
updateWaterloggedPostPlacement( state, world, pos );
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy( World world, BlockPos pos, BlockState state, @Nullable LivingEntity player, @Nonnull ItemStack stack )
|
||||
public void onBlockPlacedBy( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nullable LivingEntity player, @Nonnull ItemStack stack )
|
||||
{
|
||||
super.onBlockPlacedBy( world, pos, state, player, stack );
|
||||
|
||||
|
@ -56,16 +56,6 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
|
||||
public static final int INVENTORY_WIDTH = 4;
|
||||
public static final int INVENTORY_HEIGHT = 4;
|
||||
|
||||
public static final NamedTileEntityType<TileTurtle> FACTORY_NORMAL = NamedTileEntityType.create(
|
||||
new ResourceLocation( ComputerCraft.MOD_ID, "turtle_normal" ),
|
||||
type -> new TileTurtle( type, ComputerFamily.NORMAL )
|
||||
);
|
||||
|
||||
public static final NamedTileEntityType<TileTurtle> FACTORY_ADVANCED = NamedTileEntityType.create(
|
||||
new ResourceLocation( ComputerCraft.MOD_ID, "turtle_advanced" ),
|
||||
type -> new TileTurtle( type, ComputerFamily.ADVANCED )
|
||||
);
|
||||
|
||||
enum MoveState
|
||||
{
|
||||
NOT_MOVED,
|
||||
@ -266,7 +256,7 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read( CompoundNBT nbt )
|
||||
public void read( @Nonnull CompoundNBT nbt )
|
||||
{
|
||||
super.read( nbt );
|
||||
|
||||
@ -291,7 +281,7 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompoundNBT write( CompoundNBT nbt )
|
||||
public CompoundNBT write( @Nonnull CompoundNBT nbt )
|
||||
{
|
||||
// Write inventory
|
||||
ListNBT nbttaglist = new ListNBT();
|
||||
|
@ -8,10 +8,14 @@ package dan200.computercraft.shared.turtle.core;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.turtle.ITurtleAccess;
|
||||
import dan200.computercraft.shared.Registry;
|
||||
import dan200.computercraft.shared.util.FakeNetHandler;
|
||||
import dan200.computercraft.shared.util.InventoryUtil;
|
||||
import dan200.computercraft.shared.util.WorldUtil;
|
||||
import net.minecraft.entity.*;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntitySize;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.Pose;
|
||||
import net.minecraft.entity.passive.horse.AbstractHorseEntity;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.container.INamedContainerProvider;
|
||||
@ -37,12 +41,6 @@ public final class TurtlePlayer extends FakePlayer
|
||||
"[ComputerCraft]"
|
||||
);
|
||||
|
||||
public static final EntityType<TurtlePlayer> TYPE = EntityType.Builder.<TurtlePlayer>create( EntityClassification.MISC )
|
||||
.disableSerialization()
|
||||
.disableSummoning()
|
||||
.size( 0, 0 )
|
||||
.build( ComputerCraft.MOD_ID + ":turtle_player" );
|
||||
|
||||
private TurtlePlayer( ITurtleAccess turtle )
|
||||
{
|
||||
super( (ServerWorld) turtle.getWorld(), getProfile( turtle.getOwningPlayer() ) );
|
||||
@ -129,7 +127,7 @@ public final class TurtlePlayer extends FakePlayer
|
||||
@Override
|
||||
public EntityType<?> getType()
|
||||
{
|
||||
return TYPE;
|
||||
return Registry.ModEntities.TURTLE_PLAYER.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -145,7 +143,7 @@ public final class TurtlePlayer extends FakePlayer
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getStandingEyeHeight( Pose pose, EntitySize size )
|
||||
public float getStandingEyeHeight( @Nonnull Pose pose, @Nonnull EntitySize size )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -180,17 +178,17 @@ public final class TurtlePlayer extends FakePlayer
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openSignEditor( SignTileEntity signTile )
|
||||
public void openSignEditor( @Nonnull SignTileEntity signTile )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openHorseInventory( AbstractHorseEntity horse, IInventory inventory )
|
||||
public void openHorseInventory( @Nonnull AbstractHorseEntity horse, @Nonnull IInventory inventory )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openBook( ItemStack stack, @Nonnull Hand hand )
|
||||
public void openBook( @Nonnull ItemStack stack, @Nonnull Hand hand )
|
||||
{
|
||||
}
|
||||
|
||||
@ -205,17 +203,17 @@ public final class TurtlePlayer extends FakePlayer
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNewPotionEffect( EffectInstance id )
|
||||
protected void onNewPotionEffect( @Nonnull EffectInstance id )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onChangedPotionEffect( EffectInstance id, boolean apply )
|
||||
protected void onChangedPotionEffect( @Nonnull EffectInstance id, boolean apply )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishedPotionEffect( EffectInstance effect )
|
||||
protected void onFinishedPotionEffect( @Nonnull EffectInstance effect )
|
||||
{
|
||||
}
|
||||
//endregion
|
||||
|
@ -5,11 +5,11 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.turtle.inventory;
|
||||
|
||||
import dan200.computercraft.shared.Registry;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.computer.core.IComputer;
|
||||
import dan200.computercraft.shared.computer.inventory.ContainerComputerBase;
|
||||
import dan200.computercraft.shared.network.container.ComputerContainerData;
|
||||
import dan200.computercraft.shared.network.container.ContainerData;
|
||||
import dan200.computercraft.shared.turtle.blocks.TileTurtle;
|
||||
import dan200.computercraft.shared.turtle.core.TurtleBrain;
|
||||
import dan200.computercraft.shared.util.SingleIntArray;
|
||||
@ -17,7 +17,6 @@ import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIntArray;
|
||||
@ -28,8 +27,6 @@ import java.util.function.Predicate;
|
||||
|
||||
public class ContainerTurtle extends ContainerComputerBase
|
||||
{
|
||||
public static final ContainerType<ContainerTurtle> TYPE = ContainerData.toType( ComputerContainerData::new, ContainerTurtle::new );
|
||||
|
||||
public static final int PLAYER_START_Y = 134;
|
||||
public static final int TURTLE_START_X = 175;
|
||||
|
||||
@ -40,7 +37,7 @@ public class ContainerTurtle extends ContainerComputerBase
|
||||
PlayerInventory playerInventory, IInventory inventory, IIntArray properties
|
||||
)
|
||||
{
|
||||
super( TYPE, id, canUse, computer, family );
|
||||
super( Registry.ModContainers.TURTLE.get(), id, canUse, computer, family );
|
||||
this.properties = properties;
|
||||
|
||||
trackIntArray( properties );
|
||||
@ -78,7 +75,7 @@ public class ContainerTurtle extends ContainerComputerBase
|
||||
);
|
||||
}
|
||||
|
||||
private ContainerTurtle( int id, PlayerInventory player, ComputerContainerData data )
|
||||
public ContainerTurtle( int id, PlayerInventory player, ComputerContainerData data )
|
||||
{
|
||||
this(
|
||||
id, x -> true, getComputer( player, data ), data.getFamily(),
|
||||
@ -128,7 +125,7 @@ public class ContainerTurtle extends ContainerComputerBase
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack transferStackInSlot( PlayerEntity player, int slotNum )
|
||||
public ItemStack transferStackInSlot( @Nonnull PlayerEntity player, int slotNum )
|
||||
{
|
||||
if( slotNum >= 0 && slotNum < 16 )
|
||||
{
|
||||
|
@ -5,10 +5,10 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.turtle.items;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.turtle.ITurtleAccess;
|
||||
import dan200.computercraft.api.turtle.ITurtleUpgrade;
|
||||
import dan200.computercraft.api.turtle.TurtleSide;
|
||||
import dan200.computercraft.shared.Registry;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.turtle.blocks.ITurtleTile;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@ -38,9 +38,9 @@ public final class TurtleItemFactory
|
||||
switch( family )
|
||||
{
|
||||
case NORMAL:
|
||||
return ComputerCraft.Items.turtleNormal.create( id, label, colour, leftUpgrade, rightUpgrade, fuelLevel, overlay );
|
||||
return Registry.ModItems.TURTLE_NORMAL.get().create( id, label, colour, leftUpgrade, rightUpgrade, fuelLevel, overlay );
|
||||
case ADVANCED:
|
||||
return ComputerCraft.Items.turtleAdvanced.create( id, label, colour, leftUpgrade, rightUpgrade, fuelLevel, overlay );
|
||||
return Registry.ModItems.TURTLE_ADVANCED.get().create( id, label, colour, leftUpgrade, rightUpgrade, fuelLevel, overlay );
|
||||
default:
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ public class TurtleInventoryCrafting extends CraftingInventory
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUsableByPlayer( PlayerEntity player )
|
||||
public boolean isUsableByPlayer( @Nonnull PlayerEntity player )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -5,10 +5,10 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.turtle.upgrades;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.client.TransformedModel;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.api.turtle.*;
|
||||
import dan200.computercraft.shared.Registry;
|
||||
import dan200.computercraft.shared.peripheral.modem.ModemState;
|
||||
import dan200.computercraft.shared.peripheral.modem.wireless.WirelessModemPeripheral;
|
||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||
@ -61,7 +61,7 @@ public class TurtleModem extends AbstractTurtleUpgrade
|
||||
}
|
||||
}
|
||||
|
||||
private boolean advanced;
|
||||
private final boolean advanced;
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
private ModelResourceLocation m_leftOffModel;
|
||||
@ -80,8 +80,8 @@ public class TurtleModem extends AbstractTurtleUpgrade
|
||||
super(
|
||||
id, TurtleUpgradeType.PERIPHERAL,
|
||||
advanced
|
||||
? ComputerCraft.Blocks.wirelessModemAdvanced
|
||||
: ComputerCraft.Blocks.wirelessModemNormal
|
||||
? Registry.ModBlocks.WIRELESS_MODEM_ADVANCED
|
||||
: Registry.ModBlocks.WIRELESS_MODEM_NORMAL
|
||||
);
|
||||
this.advanced = advanced;
|
||||
}
|
||||
|
@ -6,13 +6,13 @@
|
||||
|
||||
package dan200.computercraft.shared.turtle.upgrades;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.client.TransformedModel;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.api.turtle.AbstractTurtleUpgrade;
|
||||
import dan200.computercraft.api.turtle.ITurtleAccess;
|
||||
import dan200.computercraft.api.turtle.TurtleSide;
|
||||
import dan200.computercraft.api.turtle.TurtleUpgradeType;
|
||||
import dan200.computercraft.shared.Registry;
|
||||
import dan200.computercraft.shared.peripheral.speaker.SpeakerPeripheral;
|
||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
@ -63,7 +63,7 @@ public class TurtleSpeaker extends AbstractTurtleUpgrade
|
||||
|
||||
public TurtleSpeaker( ResourceLocation id )
|
||||
{
|
||||
super( id, TurtleUpgradeType.PERIPHERAL, ComputerCraft.Blocks.speaker );
|
||||
super( id, TurtleUpgradeType.PERIPHERAL, Registry.ModBlocks.SPEAKER );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -6,6 +6,7 @@
|
||||
package dan200.computercraft.shared.util;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.shared.Registry;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
@ -25,6 +26,6 @@ public class CreativeTabMain extends ItemGroup
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public ItemStack createIcon()
|
||||
{
|
||||
return new ItemStack( ComputerCraft.Blocks.computerNormal );
|
||||
return new ItemStack( Registry.ModBlocks.COMPUTER_NORMAL.get() );
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ public class FakeNetHandler extends ServerPlayNetHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisconnect( ITextComponent reason )
|
||||
public void onDisconnect( @Nonnull ITextComponent reason )
|
||||
{
|
||||
}
|
||||
|
||||
@ -51,32 +51,32 @@ public class FakeNetHandler extends ServerPlayNetHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processInput( CInputPacket packet )
|
||||
public void processInput( @Nonnull CInputPacket packet )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processVehicleMove( CMoveVehiclePacket packet )
|
||||
public void processVehicleMove( @Nonnull CMoveVehiclePacket packet )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processConfirmTeleport( CConfirmTeleportPacket packet )
|
||||
public void processConfirmTeleport( @Nonnull CConfirmTeleportPacket packet )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleRecipeBookUpdate( CRecipeInfoPacket packet )
|
||||
public void handleRecipeBookUpdate( @Nonnull CRecipeInfoPacket packet )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSeenAdvancements( CSeenAdvancementsPacket packet )
|
||||
public void handleSeenAdvancements( @Nonnull CSeenAdvancementsPacket packet )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processTabComplete( CTabCompletePacket packet )
|
||||
public void processTabComplete( @Nonnull CTabCompletePacket packet )
|
||||
{
|
||||
}
|
||||
|
||||
@ -91,7 +91,7 @@ public class FakeNetHandler extends ServerPlayNetHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processPickItem( CPickItemPacket packet )
|
||||
public void processPickItem( @Nonnull CPickItemPacket packet )
|
||||
{
|
||||
}
|
||||
|
||||
@ -116,12 +116,12 @@ public class FakeNetHandler extends ServerPlayNetHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processSelectTrade( CSelectTradePacket packet )
|
||||
public void processSelectTrade( @Nonnull CSelectTradePacket packet )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processEditBook( CEditBookPacket packet )
|
||||
public void processEditBook( @Nonnull CEditBookPacket packet )
|
||||
{
|
||||
}
|
||||
|
||||
@ -136,22 +136,22 @@ public class FakeNetHandler extends ServerPlayNetHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processPlayer( CPlayerPacket packet )
|
||||
public void processPlayer( @Nonnull CPlayerPacket packet )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processPlayerDigging( CPlayerDiggingPacket packet )
|
||||
public void processPlayerDigging( @Nonnull CPlayerDiggingPacket packet )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processTryUseItemOnBlock( CPlayerTryUseItemOnBlockPacket packet )
|
||||
public void processTryUseItemOnBlock( @Nonnull CPlayerTryUseItemOnBlockPacket packet )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processTryUseItem( CPlayerTryUseItemPacket packet )
|
||||
public void processTryUseItem( @Nonnull CPlayerTryUseItemPacket packet )
|
||||
{
|
||||
}
|
||||
|
||||
@ -161,7 +161,7 @@ public class FakeNetHandler extends ServerPlayNetHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleResourcePackStatus( CResourcePackStatusPacket packet )
|
||||
public void handleResourcePackStatus( @Nonnull CResourcePackStatusPacket packet )
|
||||
{
|
||||
}
|
||||
|
||||
@ -171,7 +171,7 @@ public class FakeNetHandler extends ServerPlayNetHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processHeldItemChange( CHeldItemChangePacket packet )
|
||||
public void processHeldItemChange( @Nonnull CHeldItemChangePacket packet )
|
||||
{
|
||||
}
|
||||
|
||||
@ -181,22 +181,22 @@ public class FakeNetHandler extends ServerPlayNetHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleAnimation( CAnimateHandPacket packet )
|
||||
public void handleAnimation( @Nonnull CAnimateHandPacket packet )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processEntityAction( CEntityActionPacket packet )
|
||||
public void processEntityAction( @Nonnull CEntityActionPacket packet )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processUseEntity( CUseEntityPacket packet )
|
||||
public void processUseEntity( @Nonnull CUseEntityPacket packet )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processClientStatus( CClientStatusPacket packet )
|
||||
public void processClientStatus( @Nonnull CClientStatusPacket packet )
|
||||
{
|
||||
}
|
||||
|
||||
@ -206,7 +206,7 @@ public class FakeNetHandler extends ServerPlayNetHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processClickWindow( CClickWindowPacket packet )
|
||||
public void processClickWindow( @Nonnull CClickWindowPacket packet )
|
||||
{
|
||||
}
|
||||
|
||||
@ -216,7 +216,7 @@ public class FakeNetHandler extends ServerPlayNetHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processEnchantItem( CEnchantItemPacket packet )
|
||||
public void processEnchantItem( @Nonnull CEnchantItemPacket packet )
|
||||
{
|
||||
}
|
||||
|
||||
@ -226,12 +226,12 @@ public class FakeNetHandler extends ServerPlayNetHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processConfirmTransaction( CConfirmTransactionPacket packet )
|
||||
public void processConfirmTransaction( @Nonnull CConfirmTransactionPacket packet )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processUpdateSign( CUpdateSignPacket packet )
|
||||
public void processUpdateSign( @Nonnull CUpdateSignPacket packet )
|
||||
{
|
||||
}
|
||||
|
||||
@ -241,7 +241,7 @@ public class FakeNetHandler extends ServerPlayNetHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processPlayerAbilities( CPlayerAbilitiesPacket packet )
|
||||
public void processPlayerAbilities( @Nonnull CPlayerAbilitiesPacket packet )
|
||||
{
|
||||
}
|
||||
|
||||
@ -251,7 +251,7 @@ public class FakeNetHandler extends ServerPlayNetHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processCustomPayload( CCustomPayloadPacket packet )
|
||||
public void processCustomPayload( @Nonnull CCustomPayloadPacket packet )
|
||||
{
|
||||
}
|
||||
|
||||
@ -276,7 +276,7 @@ public class FakeNetHandler extends ServerPlayNetHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelActive( ChannelHandlerContext context )
|
||||
public void channelActive( @Nonnull ChannelHandlerContext context )
|
||||
{
|
||||
}
|
||||
|
||||
@ -286,22 +286,22 @@ public class FakeNetHandler extends ServerPlayNetHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelInactive( ChannelHandlerContext context )
|
||||
public void channelInactive( @Nonnull ChannelHandlerContext context )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exceptionCaught( ChannelHandlerContext context, @Nonnull Throwable err )
|
||||
public void exceptionCaught( @Nonnull ChannelHandlerContext context, @Nonnull Throwable err )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void channelRead0( ChannelHandlerContext context, @Nonnull IPacket<?> packet )
|
||||
protected void channelRead0( @Nonnull ChannelHandlerContext context, @Nonnull IPacket<?> packet )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNetHandler( INetHandler handler )
|
||||
public void setNetHandler( @Nonnull INetHandler handler )
|
||||
{
|
||||
this.handler = handler;
|
||||
}
|
||||
@ -328,7 +328,7 @@ public class FakeNetHandler extends ServerPlayNetHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enableEncryption( SecretKey key )
|
||||
public void enableEncryption( @Nonnull SecretKey key )
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
package dan200.computercraft.shared.util;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collections;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* A {@link TileEntityType} whose supplier uses itself as an argument.
|
||||
*
|
||||
* @param <T> The type of the produced tile entity.
|
||||
*/
|
||||
public final class FixedPointTileEntityType<T extends TileEntity> extends TileEntityType<T>
|
||||
{
|
||||
private final Supplier<? extends Block> block;
|
||||
|
||||
private FixedPointTileEntityType( Supplier<? extends Block> block, Supplier<T> builder )
|
||||
{
|
||||
super( builder, Collections.emptySet(), null );
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
public static <T extends TileEntity> FixedPointTileEntityType<T> create( Supplier<? extends Block> block, Function<TileEntityType<T>, T> builder )
|
||||
{
|
||||
return new FixedPointSupplier<>( block, builder ).factory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidBlock( @Nonnull Block block )
|
||||
{
|
||||
return block == this.block.get();
|
||||
}
|
||||
|
||||
private static final class FixedPointSupplier<T extends TileEntity> implements Supplier<T>
|
||||
{
|
||||
final FixedPointTileEntityType<T> factory;
|
||||
private final Function<TileEntityType<T>, T> builder;
|
||||
|
||||
private FixedPointSupplier( Supplier<? extends Block> block, Function<TileEntityType<T>, T> builder )
|
||||
{
|
||||
factory = new FixedPointTileEntityType<>( block, this );
|
||||
this.builder = builder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get()
|
||||
{
|
||||
return builder.apply( factory );
|
||||
}
|
||||
}
|
||||
}
|
@ -38,7 +38,7 @@ public final class ImpostorRecipe extends ShapedRecipe
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches( @Nonnull CraftingInventory inv, World world )
|
||||
public boolean matches( @Nonnull CraftingInventory inv, @Nonnull World world )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -40,14 +40,14 @@ public final class ImpostorShapelessRecipe extends ShapelessRecipe
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches( CraftingInventory inv, World world )
|
||||
public boolean matches( @Nonnull CraftingInventory inv, @Nonnull World world )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack getCraftingResult( CraftingInventory inventory )
|
||||
public ItemStack getCraftingResult( @Nonnull CraftingInventory inventory )
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ public interface InventoryDelegate extends IInventory
|
||||
}
|
||||
|
||||
@Override
|
||||
default void setInventorySlotContents( int slot, ItemStack stack )
|
||||
default void setInventorySlotContents( int slot, @Nonnull ItemStack stack )
|
||||
{
|
||||
getInventory().setInventorySlotContents( slot, stack );
|
||||
}
|
||||
|
@ -1,75 +0,0 @@
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
package dan200.computercraft.shared.util;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collections;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public final class NamedTileEntityType<T extends TileEntity> extends TileEntityType<T>
|
||||
{
|
||||
private final ResourceLocation identifier;
|
||||
private Block block;
|
||||
|
||||
private NamedTileEntityType( ResourceLocation identifier, Supplier<? extends T> supplier )
|
||||
{
|
||||
super( supplier, Collections.emptySet(), null );
|
||||
this.identifier = identifier;
|
||||
setRegistryName( identifier );
|
||||
}
|
||||
|
||||
public static <T extends TileEntity> NamedTileEntityType<T> create( ResourceLocation identifier, Supplier<? extends T> supplier )
|
||||
{
|
||||
return new NamedTileEntityType<>( identifier, supplier );
|
||||
}
|
||||
|
||||
public static <T extends TileEntity> NamedTileEntityType<T> create( ResourceLocation identifier, Function<NamedTileEntityType<T>, ? extends T> builder )
|
||||
{
|
||||
return new FixedPointSupplier<>( identifier, builder ).factory;
|
||||
}
|
||||
|
||||
public void setBlock( @Nonnull Block block )
|
||||
{
|
||||
if( this.block != null ) throw new IllegalStateException( "Cannot change block once set" );
|
||||
this.block = Objects.requireNonNull( block, "block cannot be null" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidBlock( @Nonnull Block block )
|
||||
{
|
||||
return block == this.block;
|
||||
}
|
||||
|
||||
public ResourceLocation getId()
|
||||
{
|
||||
return identifier;
|
||||
}
|
||||
|
||||
private static final class FixedPointSupplier<T extends TileEntity> implements Supplier<T>
|
||||
{
|
||||
final NamedTileEntityType<T> factory;
|
||||
private final Function<NamedTileEntityType<T>, ? extends T> builder;
|
||||
|
||||
private FixedPointSupplier( ResourceLocation identifier, Function<NamedTileEntityType<T>, ? extends T> builder )
|
||||
{
|
||||
factory = create( identifier, this );
|
||||
this.builder = builder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get()
|
||||
{
|
||||
return builder.apply( factory );
|
||||
}
|
||||
}
|
||||
}
|
@ -9,6 +9,8 @@ import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class ValidatingSlot extends Slot
|
||||
{
|
||||
public ValidatingSlot( IInventory inventoryIn, int index, int xPosition, int yPosition )
|
||||
@ -17,7 +19,7 @@ public class ValidatingSlot extends Slot
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid( ItemStack stack )
|
||||
public boolean isItemValid( @Nonnull ItemStack stack )
|
||||
{
|
||||
return true; // inventory.isItemValidForSlot( slotNumber, stack );
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ public final class WorldUtil
|
||||
{
|
||||
@Nonnull
|
||||
@Override
|
||||
public EntitySize getSize( Pose pose )
|
||||
public EntitySize getSize( @Nonnull Pose pose )
|
||||
{
|
||||
return EntitySize.fixed( 0, 0 );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user