mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-09-10 14:25:59 +00:00
Update to Minecraft 1.14.4
This commit is contained in:
@@ -53,8 +53,8 @@ configurations {
|
|||||||
dependencies {
|
dependencies {
|
||||||
minecraft "com.mojang:minecraft:${mc_version}"
|
minecraft "com.mojang:minecraft:${mc_version}"
|
||||||
mappings "net.fabricmc:yarn:${mc_version}+build.${mappings_version}"
|
mappings "net.fabricmc:yarn:${mc_version}+build.${mappings_version}"
|
||||||
modCompile "net.fabricmc:fabric-loader:0.4.8+build.153"
|
modCompile "net.fabricmc:fabric-loader:0.4.8+build.159"
|
||||||
modCompile "net.fabricmc.fabric-api:fabric-api:0.3.0+build.175"
|
modCompile "net.fabricmc.fabric-api:fabric-api:0.3.1+build.208"
|
||||||
|
|
||||||
implementation 'com.google.code.findbugs:jsr305:3.0.2'
|
implementation 'com.google.code.findbugs:jsr305:3.0.2'
|
||||||
|
|
||||||
|
@@ -2,5 +2,5 @@
|
|||||||
mod_version=1.83.1
|
mod_version=1.83.1
|
||||||
|
|
||||||
# Minecraft properties
|
# Minecraft properties
|
||||||
mc_version=1.14.2
|
mc_version=1.14.4
|
||||||
mappings_version=2
|
mappings_version=9
|
||||||
|
@@ -22,11 +22,10 @@ import net.minecraft.entity.passive.HorseBaseEntity;
|
|||||||
import net.minecraft.inventory.Inventory;
|
import net.minecraft.inventory.Inventory;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.network.ClientConnection;
|
import net.minecraft.network.ClientConnection;
|
||||||
|
import net.minecraft.network.MessageType;
|
||||||
import net.minecraft.network.NetworkSide;
|
import net.minecraft.network.NetworkSide;
|
||||||
import net.minecraft.network.NetworkState;
|
import net.minecraft.network.NetworkState;
|
||||||
import net.minecraft.network.Packet;
|
import net.minecraft.network.Packet;
|
||||||
import net.minecraft.network.chat.ChatMessageType;
|
|
||||||
import net.minecraft.network.chat.Component;
|
|
||||||
import net.minecraft.recipe.Recipe;
|
import net.minecraft.recipe.Recipe;
|
||||||
import net.minecraft.server.network.ServerPlayNetworkHandler;
|
import net.minecraft.server.network.ServerPlayNetworkHandler;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
@@ -36,6 +35,7 @@ import net.minecraft.server.network.packet.VehicleMoveC2SPacket;
|
|||||||
import net.minecraft.server.world.ServerWorld;
|
import net.minecraft.server.world.ServerWorld;
|
||||||
import net.minecraft.sound.SoundCategory;
|
import net.minecraft.sound.SoundCategory;
|
||||||
import net.minecraft.sound.SoundEvent;
|
import net.minecraft.sound.SoundEvent;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.DefaultedList;
|
import net.minecraft.util.DefaultedList;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.math.ChunkPos;
|
import net.minecraft.util.math.ChunkPos;
|
||||||
@@ -108,7 +108,7 @@ public class FakePlayer extends ServerPlayerEntity
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendTradeOffers( int id, TraderOfferList list, int level, int experience, boolean levelled ) { }
|
public void sendTradeOffers( int id, TraderOfferList list, int level, int experience, boolean levelled, boolean refreshable ) { }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void openHorseInventory( HorseBaseEntity horse, Inventory inventory ) { }
|
public void openHorseInventory( HorseBaseEntity horse, Inventory inventory ) { }
|
||||||
@@ -135,7 +135,7 @@ public class FakePlayer extends ServerPlayerEntity
|
|||||||
public void method_14241() { }
|
public void method_14241() { }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addChatMessage( Component textComponent, boolean status ) { }
|
public void addChatMessage( Text textComponent, boolean status ) { }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void method_6040() { }
|
protected void method_6040() { }
|
||||||
@@ -162,7 +162,7 @@ public class FakePlayer extends ServerPlayerEntity
|
|||||||
public void setGameMode( GameMode gameMode ) { }
|
public void setGameMode( GameMode gameMode ) { }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendChatMessage( Component textComponent, ChatMessageType chatMessageType ) { }
|
public void sendChatMessage( Text textComponent, MessageType chatMessageType ) { }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getServerBrand()
|
public String getServerBrand()
|
||||||
@@ -214,7 +214,7 @@ public class FakePlayer extends ServerPlayerEntity
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disconnect( Component message ) { }
|
public void disconnect( Text message ) { }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRequestCommandCompletions( RequestCommandCompletionsC2SPacket packet ) { }
|
public void onRequestCommandCompletions( RequestCommandCompletionsC2SPacket packet ) { }
|
||||||
@@ -244,7 +244,7 @@ public class FakePlayer extends ServerPlayerEntity
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disconnect( Component message )
|
public void disconnect( Text message )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -10,12 +10,12 @@ import dan200.computercraft.shared.command.text.ChatHelpers;
|
|||||||
import dan200.computercraft.shared.command.text.TableBuilder;
|
import dan200.computercraft.shared.command.text.TableBuilder;
|
||||||
import dan200.computercraft.shared.command.text.TableFormatter;
|
import dan200.computercraft.shared.command.text.TableFormatter;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
||||||
import net.minecraft.ChatFormat;
|
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.font.TextRenderer;
|
import net.minecraft.client.font.TextRenderer;
|
||||||
import net.minecraft.client.gui.hud.ChatHud;
|
import net.minecraft.client.gui.hud.ChatHud;
|
||||||
import net.minecraft.client.util.TextComponentUtil;
|
import net.minecraft.client.util.TextComponentUtil;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.text.Text;
|
||||||
|
import net.minecraft.util.Formatting;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ public class ClientTableFormatter implements TableFormatter
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public Component getPadding( Component component, int width )
|
public Text getPadding( Text component, int width )
|
||||||
{
|
{
|
||||||
int extraWidth = width - getWidth( component );
|
int extraWidth = width - getWidth( component );
|
||||||
if( extraWidth <= 0 ) return null;
|
if( extraWidth <= 0 ) return null;
|
||||||
@@ -46,7 +46,7 @@ public class ClientTableFormatter implements TableFormatter
|
|||||||
int spaces = MathHelper.floor( extraWidth / spaceWidth );
|
int spaces = MathHelper.floor( extraWidth / spaceWidth );
|
||||||
int extra = extraWidth - (int) (spaces * spaceWidth);
|
int extra = extraWidth - (int) (spaces * spaceWidth);
|
||||||
|
|
||||||
return ChatHelpers.coloured( StringUtils.repeat( ' ', spaces ) + StringUtils.repeat( (char) 712, extra ), ChatFormat.GRAY );
|
return ChatHelpers.coloured( StringUtils.repeat( ' ', spaces ) + StringUtils.repeat( (char) 712, extra ), Formatting.GRAY );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -56,20 +56,20 @@ public class ClientTableFormatter implements TableFormatter
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getWidth( Component component )
|
public int getWidth( Text component )
|
||||||
{
|
{
|
||||||
return renderer().getStringWidth( component.getFormattedText() );
|
return renderer().getStringWidth( component.asFormattedString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeLine( int id, Component component )
|
public void writeLine( int id, Text component )
|
||||||
{
|
{
|
||||||
MinecraftClient mc = MinecraftClient.getInstance();
|
MinecraftClient mc = MinecraftClient.getInstance();
|
||||||
ChatHud chat = mc.inGameHud.getChatHud();
|
ChatHud chat = mc.inGameHud.getChatHud();
|
||||||
|
|
||||||
// Trim the text if it goes over the allowed length
|
// Trim the text if it goes over the allowed length
|
||||||
int maxWidth = MathHelper.floor( chat.getWidth() / chat.getScale() );
|
int maxWidth = MathHelper.floor( chat.getWidth() / chat.getChatScale() );
|
||||||
List<Component> list = TextComponentUtil.wrapLines( component, maxWidth, mc.textRenderer, false, false );
|
List<Text> list = TextComponentUtil.wrapLines( component, maxWidth, mc.textRenderer, false, false );
|
||||||
if( !list.isEmpty() ) chat.addMessage( list.get( 0 ), id );
|
if( !list.isEmpty() ) chat.addMessage( list.get( 0 ), id );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -17,7 +17,7 @@ import dan200.computercraft.shared.computer.inventory.ContainerComputer;
|
|||||||
import net.minecraft.client.gui.screen.ingame.AbstractContainerScreen;
|
import net.minecraft.client.gui.screen.ingame.AbstractContainerScreen;
|
||||||
import net.minecraft.container.Container;
|
import net.minecraft.container.Container;
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
import net.minecraft.network.chat.TextComponent;
|
import net.minecraft.text.LiteralText;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import org.lwjgl.glfw.GLFW;
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ public class GuiComputer<T extends Container> extends AbstractContainerScreen<T>
|
|||||||
|
|
||||||
public GuiComputer( T container, PlayerInventory player, ComputerFamily family, ClientComputer computer, int termWidth, int termHeight )
|
public GuiComputer( T container, PlayerInventory player, ComputerFamily family, ClientComputer computer, int termWidth, int termHeight )
|
||||||
{
|
{
|
||||||
super( container, player, new TextComponent( "" ) );
|
super( container, player, new LiteralText( "" ) );
|
||||||
|
|
||||||
m_family = family;
|
m_family = family;
|
||||||
m_computer = computer;
|
m_computer = computer;
|
||||||
|
@@ -20,13 +20,13 @@ public class GuiDiskDrive extends AbstractContainerScreen<ContainerDiskDrive>
|
|||||||
|
|
||||||
public GuiDiskDrive( ContainerDiskDrive container, PlayerInventory inventory )
|
public GuiDiskDrive( ContainerDiskDrive container, PlayerInventory inventory )
|
||||||
{
|
{
|
||||||
super( container, inventory, ComputerCraft.Blocks.diskDrive.getTextComponent() );
|
super( container, inventory, ComputerCraft.Blocks.diskDrive.getName() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void drawForeground( int par1, int par2 )
|
protected void drawForeground( int par1, int par2 )
|
||||||
{
|
{
|
||||||
String title = getTitle().getFormattedText();
|
String title = getTitle().asFormattedString();
|
||||||
font.draw( title, (containerWidth - font.getStringWidth( title )) / 2.0f, 6, 0x404040 );
|
font.draw( title, (containerWidth - font.getStringWidth( title )) / 2.0f, 6, 0x404040 );
|
||||||
font.draw( I18n.translate( "container.inventory" ), 8, (containerHeight - 96) + 2, 0x404040 );
|
font.draw( I18n.translate( "container.inventory" ), 8, (containerHeight - 96) + 2, 0x404040 );
|
||||||
}
|
}
|
||||||
|
@@ -20,13 +20,13 @@ public class GuiPrinter extends AbstractContainerScreen<ContainerPrinter>
|
|||||||
|
|
||||||
public GuiPrinter( ContainerPrinter container, PlayerInventory player )
|
public GuiPrinter( ContainerPrinter container, PlayerInventory player )
|
||||||
{
|
{
|
||||||
super( container, player, ComputerCraft.Blocks.printer.getTextComponent() );
|
super( container, player, ComputerCraft.Blocks.printer.getName() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void drawForeground( int mouseX, int mouseY )
|
protected void drawForeground( int mouseX, int mouseY )
|
||||||
{
|
{
|
||||||
String title = getTitle().getFormattedText();
|
String title = getTitle().asFormattedString();
|
||||||
font.draw( title, (containerWidth - font.getStringWidth( title )) / 2.0f, 6, 0x404040 );
|
font.draw( title, (containerWidth - font.getStringWidth( title )) / 2.0f, 6, 0x404040 );
|
||||||
font.draw( I18n.translate( "container.inventory" ), 8, containerHeight - 96 + 2, 0x404040 );
|
font.draw( I18n.translate( "container.inventory" ), 8, containerHeight - 96 + 2, 0x404040 );
|
||||||
}
|
}
|
||||||
|
@@ -26,7 +26,7 @@ public class GuiPrintout extends AbstractContainerScreen<ContainerHeldItem>
|
|||||||
|
|
||||||
public GuiPrintout( ContainerHeldItem container, PlayerInventory player )
|
public GuiPrintout( ContainerHeldItem container, PlayerInventory player )
|
||||||
{
|
{
|
||||||
super( container, player, container.getStack().getDisplayName() );
|
super( container, player, container.getStack().getName() );
|
||||||
|
|
||||||
containerHeight = Y_SIZE;
|
containerHeight = Y_SIZE;
|
||||||
|
|
||||||
|
@@ -26,6 +26,7 @@ import net.fabricmc.fabric.api.client.model.ModelLoadingRegistry;
|
|||||||
import net.fabricmc.fabric.api.client.render.BlockEntityRendererRegistry;
|
import net.fabricmc.fabric.api.client.render.BlockEntityRendererRegistry;
|
||||||
import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback;
|
import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback;
|
||||||
import net.fabricmc.fabric.api.event.client.ClientTickCallback;
|
import net.fabricmc.fabric.api.event.client.ClientTickCallback;
|
||||||
|
import net.minecraft.client.texture.SpriteAtlasTexture;
|
||||||
import net.minecraft.container.ArrayPropertyDelegate;
|
import net.minecraft.container.ArrayPropertyDelegate;
|
||||||
import net.minecraft.inventory.BasicInventory;
|
import net.minecraft.inventory.BasicInventory;
|
||||||
|
|
||||||
@@ -41,7 +42,7 @@ public final class ComputerCraftProxyClient
|
|||||||
BlockEntityRendererRegistry.INSTANCE.register( TileTurtle.class, new TileEntityTurtleRenderer() );
|
BlockEntityRendererRegistry.INSTANCE.register( TileTurtle.class, new TileEntityTurtleRenderer() );
|
||||||
|
|
||||||
ClientRegistry.onItemColours();
|
ClientRegistry.onItemColours();
|
||||||
ClientSpriteRegistryCallback.registerBlockAtlas( ClientRegistry::onTextureStitchEvent );
|
ClientSpriteRegistryCallback.event( SpriteAtlasTexture.BLOCK_ATLAS_TEX ).register( ClientRegistry::onTextureStitchEvent );
|
||||||
ModelLoadingRegistry.INSTANCE.registerAppender( ClientRegistry::onModelBakeEvent );
|
ModelLoadingRegistry.INSTANCE.registerAppender( ClientRegistry::onModelBakeEvent );
|
||||||
ModelLoadingRegistry.INSTANCE.registerResourceProvider( loader -> ( name, context ) ->
|
ModelLoadingRegistry.INSTANCE.registerResourceProvider( loader -> ( name, context ) ->
|
||||||
TurtleModelLoader.INSTANCE.accepts( name ) ? TurtleModelLoader.INSTANCE.loadModel( name ) : null
|
TurtleModelLoader.INSTANCE.accepts( name ) ? TurtleModelLoader.INSTANCE.loadModel( name ) : null
|
||||||
|
@@ -12,7 +12,7 @@ import net.minecraft.client.MinecraftClient;
|
|||||||
import net.minecraft.client.render.FirstPersonRenderer;
|
import net.minecraft.client.render.FirstPersonRenderer;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.AbsoluteHand;
|
import net.minecraft.util.Arm;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ public abstract class ItemMapLikeRenderer
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
renderItemFirstPersonSide(
|
renderItemFirstPersonSide(
|
||||||
hand == Hand.MAIN_HAND ? player.getMainHand() : player.getMainHand().getOpposite(),
|
hand == Hand.MAIN_HAND ? player.getMainArm() : player.getMainArm().getOpposite(),
|
||||||
equipProgress, swingProgress, stack
|
equipProgress, swingProgress, stack
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -52,12 +52,12 @@ public abstract class ItemMapLikeRenderer
|
|||||||
* @param equipProgress The equip progress of this item
|
* @param equipProgress The equip progress of this item
|
||||||
* @param swingProgress The swing progress of this item
|
* @param swingProgress The swing progress of this item
|
||||||
* @param stack The stack to render
|
* @param stack The stack to render
|
||||||
* @see FirstPersonRenderer#method_3222(float, AbsoluteHand, float, ItemStack) // renderMapFirstPersonSide
|
* @see FirstPersonRenderer#method_3222(float, Arm, float, ItemStack) // renderMapFirstPersonSide
|
||||||
*/
|
*/
|
||||||
private void renderItemFirstPersonSide( AbsoluteHand side, float equipProgress, float swingProgress, ItemStack stack )
|
private void renderItemFirstPersonSide( Arm side, float equipProgress, float swingProgress, ItemStack stack )
|
||||||
{
|
{
|
||||||
MinecraftClient minecraft = MinecraftClient.getInstance();
|
MinecraftClient minecraft = MinecraftClient.getInstance();
|
||||||
float offset = side == AbsoluteHand.RIGHT ? 1f : -1f;
|
float offset = side == Arm.RIGHT ? 1f : -1f;
|
||||||
GlStateManager.translatef( offset * 0.125f, -0.125f, 0f );
|
GlStateManager.translatef( offset * 0.125f, -0.125f, 0f );
|
||||||
|
|
||||||
// If the player is not invisible then render a single arm
|
// If the player is not invisible then render a single arm
|
||||||
|
@@ -184,7 +184,7 @@ public final class Registry
|
|||||||
|
|
||||||
private static Item.Settings defaultItem()
|
private static Item.Settings defaultItem()
|
||||||
{
|
{
|
||||||
return new Item.Settings().itemGroup( mainItemGroup );
|
return new Item.Settings().group( mainItemGroup );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerItems( MutableRegistry<Item> registry )
|
public static void registerItems( MutableRegistry<Item> registry )
|
||||||
@@ -206,23 +206,23 @@ public final class Registry
|
|||||||
registerItemBlock( registry, ComputerCraft.Items.turtleAdvanced );
|
registerItemBlock( registry, ComputerCraft.Items.turtleAdvanced );
|
||||||
|
|
||||||
// Pocket computer
|
// Pocket computer
|
||||||
ComputerCraft.Items.pocketComputerNormal = new ItemPocketComputer( defaultItem().stackSize( 1 ), ComputerFamily.Normal );
|
ComputerCraft.Items.pocketComputerNormal = new ItemPocketComputer( defaultItem().maxCount( 1 ), ComputerFamily.Normal );
|
||||||
ComputerCraft.Items.pocketComputerAdvanced = new ItemPocketComputer( defaultItem().stackSize( 1 ), ComputerFamily.Advanced );
|
ComputerCraft.Items.pocketComputerAdvanced = new ItemPocketComputer( defaultItem().maxCount( 1 ), ComputerFamily.Advanced );
|
||||||
|
|
||||||
registry.add( new Identifier( ComputerCraft.MOD_ID, "pocket_computer_normal" ), ComputerCraft.Items.pocketComputerNormal );
|
registry.add( new Identifier( ComputerCraft.MOD_ID, "pocket_computer_normal" ), ComputerCraft.Items.pocketComputerNormal );
|
||||||
registry.add( new Identifier( ComputerCraft.MOD_ID, "pocket_computer_advanced" ), ComputerCraft.Items.pocketComputerAdvanced );
|
registry.add( new Identifier( ComputerCraft.MOD_ID, "pocket_computer_advanced" ), ComputerCraft.Items.pocketComputerAdvanced );
|
||||||
|
|
||||||
// Floppy disk
|
// Floppy disk
|
||||||
ComputerCraft.Items.disk = new ItemDisk( defaultItem().stackSize( 1 ) );
|
ComputerCraft.Items.disk = new ItemDisk( defaultItem().maxCount( 1 ) );
|
||||||
ComputerCraft.Items.treasureDisk = new ItemTreasureDisk( defaultItem().stackSize( 1 ) );
|
ComputerCraft.Items.treasureDisk = new ItemTreasureDisk( defaultItem().maxCount( 1 ) );
|
||||||
|
|
||||||
registry.add( new Identifier( ComputerCraft.MOD_ID, "disk" ), ComputerCraft.Items.disk );
|
registry.add( new Identifier( ComputerCraft.MOD_ID, "disk" ), ComputerCraft.Items.disk );
|
||||||
registry.add( new Identifier( ComputerCraft.MOD_ID, "treasure_disk" ), ComputerCraft.Items.treasureDisk );
|
registry.add( new Identifier( ComputerCraft.MOD_ID, "treasure_disk" ), ComputerCraft.Items.treasureDisk );
|
||||||
|
|
||||||
// Printouts
|
// Printouts
|
||||||
ComputerCraft.Items.printedPage = new ItemPrintout( defaultItem().stackSize( 1 ), ItemPrintout.Type.PAGE );
|
ComputerCraft.Items.printedPage = new ItemPrintout( defaultItem().maxCount( 1 ), ItemPrintout.Type.PAGE );
|
||||||
ComputerCraft.Items.printedPages = new ItemPrintout( defaultItem().stackSize( 1 ), ItemPrintout.Type.PAGES );
|
ComputerCraft.Items.printedPages = new ItemPrintout( defaultItem().maxCount( 1 ), ItemPrintout.Type.PAGES );
|
||||||
ComputerCraft.Items.printedBook = new ItemPrintout( defaultItem().stackSize( 1 ), ItemPrintout.Type.BOOK );
|
ComputerCraft.Items.printedBook = new ItemPrintout( defaultItem().maxCount( 1 ), ItemPrintout.Type.BOOK );
|
||||||
|
|
||||||
registry.add( new Identifier( ComputerCraft.MOD_ID, "printed_page" ), ComputerCraft.Items.printedPage );
|
registry.add( new Identifier( ComputerCraft.MOD_ID, "printed_page" ), ComputerCraft.Items.printedPage );
|
||||||
registry.add( new Identifier( ComputerCraft.MOD_ID, "printed_pages" ), ComputerCraft.Items.printedPages );
|
registry.add( new Identifier( ComputerCraft.MOD_ID, "printed_pages" ), ComputerCraft.Items.printedPages );
|
||||||
|
@@ -23,8 +23,8 @@ import dan200.computercraft.shared.computer.core.ServerComputer;
|
|||||||
import dan200.computercraft.shared.network.Containers;
|
import dan200.computercraft.shared.network.Containers;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.text.LiteralText;
|
||||||
import net.minecraft.network.chat.TextComponent;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
import net.minecraft.server.world.ServerWorld;
|
||||||
@@ -256,9 +256,9 @@ public final class CommandComputerCraft
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Component linkComputer( ServerCommandSource source, ServerComputer serverComputer, int computerId )
|
private static Text linkComputer( ServerCommandSource source, ServerComputer serverComputer, int computerId )
|
||||||
{
|
{
|
||||||
TextComponent out = new TextComponent( "" );
|
LiteralText out = new LiteralText( "" );
|
||||||
|
|
||||||
// Append the computer instance
|
// Append the computer instance
|
||||||
if( serverComputer == null )
|
if( serverComputer == null )
|
||||||
@@ -298,7 +298,7 @@ public final class CommandComputerCraft
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Component linkPosition( ServerCommandSource context, ServerComputer computer )
|
private static Text linkPosition( ServerCommandSource context, ServerComputer computer )
|
||||||
{
|
{
|
||||||
if( UserLevel.OP.test( context ) )
|
if( UserLevel.OP.test( context ) )
|
||||||
{
|
{
|
||||||
@@ -344,7 +344,7 @@ public final class CommandComputerCraft
|
|||||||
|
|
||||||
timings.sort( Comparator.<ComputerTracker, Long>comparing( x -> x.get( sortField ) ).reversed() );
|
timings.sort( Comparator.<ComputerTracker, Long>comparing( x -> x.get( sortField ) ).reversed() );
|
||||||
|
|
||||||
Component[] headers = new Component[1 + fields.size()];
|
Text[] headers = new Text[1 + fields.size()];
|
||||||
headers[0] = translate( "commands.computercraft.track.dump.computer" );
|
headers[0] = translate( "commands.computercraft.track.dump.computer" );
|
||||||
for( int i = 0; i < fields.size(); i++ ) headers[i + 1] = translate( fields.get( i ).translationKey() );
|
for( int i = 0; i < fields.size(); i++ ) headers[i + 1] = translate( fields.get( i ).translationKey() );
|
||||||
TableBuilder table = new TableBuilder( TRACK_ID, headers );
|
TableBuilder table = new TableBuilder( TRACK_ID, headers );
|
||||||
@@ -354,9 +354,9 @@ public final class CommandComputerCraft
|
|||||||
Computer computer = entry.getComputer();
|
Computer computer = entry.getComputer();
|
||||||
ServerComputer serverComputer = computer == null ? null : lookup.get( computer );
|
ServerComputer serverComputer = computer == null ? null : lookup.get( computer );
|
||||||
|
|
||||||
Component computerComponent = linkComputer( source, serverComputer, entry.getComputerId() );
|
Text computerComponent = linkComputer( source, serverComputer, entry.getComputerId() );
|
||||||
|
|
||||||
Component[] row = new Component[1 + fields.size()];
|
Text[] row = new Text[1 + fields.size()];
|
||||||
row[0] = computerComponent;
|
row[0] = computerComponent;
|
||||||
for( int i = 0; i < fields.size(); i++ ) row[i + 1] = text( entry.getFormatted( fields.get( i ) ) );
|
for( int i = 0; i < fields.size(); i++ ) row[i + 1] = text( entry.getFormatted( fields.get( i ) ) );
|
||||||
table.row( row );
|
table.row( row );
|
||||||
|
@@ -9,10 +9,10 @@ package dan200.computercraft.shared.command;
|
|||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.network.chat.ClickEvent;
|
import net.minecraft.text.ClickEvent;
|
||||||
import net.minecraft.network.chat.HoverEvent;
|
import net.minecraft.text.HoverEvent;
|
||||||
import net.minecraft.network.chat.TextComponent;
|
import net.minecraft.text.LiteralText;
|
||||||
import net.minecraft.network.chat.TranslatableComponent;
|
import net.minecraft.text.TranslatableText;
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
|
|
||||||
import static net.minecraft.server.command.CommandManager.argument;
|
import static net.minecraft.server.command.CommandManager.argument;
|
||||||
@@ -50,12 +50,12 @@ public final class CommandCopy
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TextComponent createCopyText( String text )
|
public static LiteralText createCopyText( String text )
|
||||||
{
|
{
|
||||||
TextComponent name = new TextComponent( text );
|
LiteralText name = new LiteralText( text );
|
||||||
name.getStyle()
|
name.getStyle()
|
||||||
.setClickEvent( new ClickEvent( ClickEvent.Action.RUN_COMMAND, PREFIX + text ) )
|
.setClickEvent( new ClickEvent( ClickEvent.Action.RUN_COMMAND, PREFIX + text ) )
|
||||||
.setHoverEvent( new HoverEvent( HoverEvent.Action.SHOW_TEXT, new TranslatableComponent( "gui.computercraft.tooltip.copy" ) ) );
|
.setHoverEvent( new HoverEvent( HoverEvent.Action.SHOW_TEXT, new TranslatableText( "gui.computercraft.tooltip.copy" ) ) );
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -9,7 +9,7 @@ package dan200.computercraft.shared.command;
|
|||||||
import com.mojang.brigadier.exceptions.Dynamic2CommandExceptionType;
|
import com.mojang.brigadier.exceptions.Dynamic2CommandExceptionType;
|
||||||
import com.mojang.brigadier.exceptions.DynamicCommandExceptionType;
|
import com.mojang.brigadier.exceptions.DynamicCommandExceptionType;
|
||||||
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
|
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
|
||||||
import net.minecraft.network.chat.TranslatableComponent;
|
import net.minecraft.text.TranslatableText;
|
||||||
|
|
||||||
public final class Exceptions
|
public final class Exceptions
|
||||||
{
|
{
|
||||||
@@ -28,16 +28,16 @@ public final class Exceptions
|
|||||||
|
|
||||||
private static SimpleCommandExceptionType translated( String key )
|
private static SimpleCommandExceptionType translated( String key )
|
||||||
{
|
{
|
||||||
return new SimpleCommandExceptionType( new TranslatableComponent( key ) );
|
return new SimpleCommandExceptionType( new TranslatableText( key ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
private static DynamicCommandExceptionType translated1( String key )
|
private static DynamicCommandExceptionType translated1( String key )
|
||||||
{
|
{
|
||||||
return new DynamicCommandExceptionType( x -> new TranslatableComponent( key, x ) );
|
return new DynamicCommandExceptionType( x -> new TranslatableText( key, x ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Dynamic2CommandExceptionType translated2( String key )
|
private static Dynamic2CommandExceptionType translated2( String key )
|
||||||
{
|
{
|
||||||
return new Dynamic2CommandExceptionType( ( x, y ) -> new TranslatableComponent( key, x, y ) );
|
return new Dynamic2CommandExceptionType( ( x, y ) -> new TranslatableText( key, x, y ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -17,8 +17,8 @@ import com.mojang.brigadier.suggestion.Suggestions;
|
|||||||
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
|
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
|
||||||
import net.minecraft.command.arguments.ArgumentTypes;
|
import net.minecraft.command.arguments.ArgumentTypes;
|
||||||
import net.minecraft.command.arguments.serialize.ArgumentSerializer;
|
import net.minecraft.command.arguments.serialize.ArgumentSerializer;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.text.LiteralText;
|
||||||
import net.minecraft.network.chat.TextComponent;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.PacketByteBuf;
|
import net.minecraft.util.PacketByteBuf;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
@@ -133,7 +133,7 @@ public final class RepeatArgumentType<T, U> implements ArgumentType<List<T>>
|
|||||||
{
|
{
|
||||||
buf.writeBoolean( arg.flatten );
|
buf.writeBoolean( arg.flatten );
|
||||||
ArgumentTypes.toPacket( buf, arg.child );
|
ArgumentTypes.toPacket( buf, arg.child );
|
||||||
buf.writeTextComponent( getMessage( arg ) );
|
buf.writeText( getMessage( arg ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@@ -143,7 +143,7 @@ public final class RepeatArgumentType<T, U> implements ArgumentType<List<T>>
|
|||||||
{
|
{
|
||||||
boolean isList = buf.readBoolean();
|
boolean isList = buf.readBoolean();
|
||||||
ArgumentType<?> child = ArgumentTypes.fromPacket( buf );
|
ArgumentType<?> child = ArgumentTypes.fromPacket( buf );
|
||||||
Component message = buf.readTextComponent();
|
Text message = buf.readText();
|
||||||
BiConsumer<List<Object>, ?> appender = isList ? ( list, x ) -> list.addAll( (Collection) x ) : List::add;
|
BiConsumer<List<Object>, ?> appender = isList ? ( list, x ) -> list.addAll( (Collection) x ) : List::add;
|
||||||
return new RepeatArgumentType( child, appender, isList, new SimpleCommandExceptionType( message ) );
|
return new RepeatArgumentType( child, appender, isList, new SimpleCommandExceptionType( message ) );
|
||||||
}
|
}
|
||||||
@@ -153,14 +153,14 @@ public final class RepeatArgumentType<T, U> implements ArgumentType<List<T>>
|
|||||||
{
|
{
|
||||||
json.addProperty( "flatten", arg.flatten );
|
json.addProperty( "flatten", arg.flatten );
|
||||||
json.addProperty( "child", "<<cannot serialize>>" ); // TODO: Potentially serialize this using reflection.
|
json.addProperty( "child", "<<cannot serialize>>" ); // TODO: Potentially serialize this using reflection.
|
||||||
json.addProperty( "error", TextComponent.Serializer.toJsonString( getMessage( arg ) ) );
|
json.addProperty( "error", LiteralText.Serializer.toJson( getMessage( arg ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
private static TextComponent getMessage( RepeatArgumentType<?, ?> arg )
|
private static LiteralText getMessage( RepeatArgumentType<?, ?> arg )
|
||||||
{
|
{
|
||||||
Message message = arg.some.create().getRawMessage();
|
Message message = arg.some.create().getRawMessage();
|
||||||
if( message instanceof TextComponent ) return (TextComponent) message;
|
if( message instanceof LiteralText ) return (LiteralText) message;
|
||||||
return new TextComponent( message.getString() );
|
return new LiteralText( message.getString() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -13,10 +13,10 @@ import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
|||||||
import com.mojang.brigadier.context.CommandContext;
|
import com.mojang.brigadier.context.CommandContext;
|
||||||
import com.mojang.brigadier.tree.CommandNode;
|
import com.mojang.brigadier.tree.CommandNode;
|
||||||
import com.mojang.brigadier.tree.LiteralCommandNode;
|
import com.mojang.brigadier.tree.LiteralCommandNode;
|
||||||
import net.minecraft.ChatFormat;
|
import net.minecraft.text.ClickEvent;
|
||||||
import net.minecraft.network.chat.ClickEvent;
|
import net.minecraft.text.LiteralText;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.network.chat.TextComponent;
|
import net.minecraft.util.Formatting;
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
@@ -133,9 +133,9 @@ public final class HelpingArgumentBuilder extends LiteralArgumentBuilder<ServerC
|
|||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final ChatFormat HEADER = ChatFormat.LIGHT_PURPLE;
|
private static final Formatting HEADER = Formatting.LIGHT_PURPLE;
|
||||||
private static final ChatFormat SYNOPSIS = ChatFormat.AQUA;
|
private static final Formatting SYNOPSIS = Formatting.AQUA;
|
||||||
private static final ChatFormat NAME = ChatFormat.GREEN;
|
private static final Formatting NAME = Formatting.GREEN;
|
||||||
|
|
||||||
private static final class HelpCommand implements Command<ServerCommandSource>
|
private static final class HelpCommand implements Command<ServerCommandSource>
|
||||||
{
|
{
|
||||||
@@ -165,7 +165,7 @@ public final class HelpingArgumentBuilder extends LiteralArgumentBuilder<ServerC
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Component getHelp( CommandContext<ServerCommandSource> context, CommandNode<ServerCommandSource> node, String id, String command )
|
private static Text getHelp( CommandContext<ServerCommandSource> context, CommandNode<ServerCommandSource> node, String id, String command )
|
||||||
{
|
{
|
||||||
// An ugly hack to extract usage information from the dispatcher. We generate a temporary node, generate
|
// An ugly hack to extract usage information from the dispatcher. We generate a temporary node, generate
|
||||||
// the shorthand usage, and emit that.
|
// the shorthand usage, and emit that.
|
||||||
@@ -174,7 +174,7 @@ public final class HelpingArgumentBuilder extends LiteralArgumentBuilder<ServerC
|
|||||||
temp.addChild( node );
|
temp.addChild( node );
|
||||||
String usage = dispatcher.getSmartUsage( temp, context.getSource() ).get( node ).substring( node.getName().length() );
|
String usage = dispatcher.getSmartUsage( temp, context.getSource() ).get( node ).substring( node.getName().length() );
|
||||||
|
|
||||||
Component output = new TextComponent( "" )
|
Text output = new LiteralText( "" )
|
||||||
.append( coloured( "/" + command + usage, HEADER ) )
|
.append( coloured( "/" + command + usage, HEADER ) )
|
||||||
.append( " " )
|
.append( " " )
|
||||||
.append( coloured( translate( "commands." + id + ".synopsis" ), SYNOPSIS ) )
|
.append( coloured( translate( "commands." + id + ".synopsis" ), SYNOPSIS ) )
|
||||||
@@ -190,7 +190,7 @@ public final class HelpingArgumentBuilder extends LiteralArgumentBuilder<ServerC
|
|||||||
|
|
||||||
output.append( "\n" );
|
output.append( "\n" );
|
||||||
|
|
||||||
Component component = coloured( child.getName(), NAME );
|
Text component = coloured( child.getName(), NAME );
|
||||||
component.getStyle().setClickEvent( new ClickEvent(
|
component.getStyle().setClickEvent( new ClickEvent(
|
||||||
ClickEvent.Action.SUGGEST_COMMAND,
|
ClickEvent.Action.SUGGEST_COMMAND,
|
||||||
"/" + command + " " + child.getName()
|
"/" + command + " " + child.getName()
|
||||||
|
@@ -6,8 +6,8 @@
|
|||||||
|
|
||||||
package dan200.computercraft.shared.command.text;
|
package dan200.computercraft.shared.command.text;
|
||||||
|
|
||||||
import net.minecraft.ChatFormat;
|
import net.minecraft.text.*;
|
||||||
import net.minecraft.network.chat.*;
|
import net.minecraft.util.Formatting;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -15,73 +15,73 @@ import net.minecraft.util.math.BlockPos;
|
|||||||
*/
|
*/
|
||||||
public final class ChatHelpers
|
public final class ChatHelpers
|
||||||
{
|
{
|
||||||
private static final ChatFormat HEADER = ChatFormat.LIGHT_PURPLE;
|
private static final Formatting HEADER = Formatting.LIGHT_PURPLE;
|
||||||
|
|
||||||
private ChatHelpers() {}
|
private ChatHelpers() {}
|
||||||
|
|
||||||
public static Component coloured( String text, ChatFormat colour )
|
public static Text coloured( String text, Formatting colour )
|
||||||
{
|
{
|
||||||
TextComponent component = new TextComponent( text == null ? "" : text );
|
LiteralText component = new LiteralText( text == null ? "" : text );
|
||||||
component.getStyle().setColor( colour );
|
component.getStyle().setColor( colour );
|
||||||
return component;
|
return component;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T extends Component> T coloured( T component, ChatFormat colour )
|
public static <T extends Text> T coloured( T component, Formatting colour )
|
||||||
{
|
{
|
||||||
component.getStyle().setColor( colour );
|
component.getStyle().setColor( colour );
|
||||||
return component;
|
return component;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Component text( String text )
|
public static Text text( String text )
|
||||||
{
|
{
|
||||||
return new TextComponent( text == null ? "" : text );
|
return new LiteralText( text == null ? "" : text );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Component translate( String text )
|
public static Text translate( String text )
|
||||||
{
|
{
|
||||||
return new TranslatableComponent( text == null ? "" : text );
|
return new TranslatableText( text == null ? "" : text );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Component translate( String text, Object... args )
|
public static Text translate( String text, Object... args )
|
||||||
{
|
{
|
||||||
return new TranslatableComponent( text == null ? "" : text, args );
|
return new TranslatableText( text == null ? "" : text, args );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Component list( Component... children )
|
public static Text list( Text... children )
|
||||||
{
|
{
|
||||||
Component component = new TextComponent( "" );
|
Text component = new LiteralText( "" );
|
||||||
for( Component child : children )
|
for( Text child : children )
|
||||||
{
|
{
|
||||||
component.append( child );
|
component.append( child );
|
||||||
}
|
}
|
||||||
return component;
|
return component;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Component position( BlockPos pos )
|
public static Text position( BlockPos pos )
|
||||||
{
|
{
|
||||||
if( pos == null ) return translate( "commands.computercraft.generic.no_position" );
|
if( pos == null ) return translate( "commands.computercraft.generic.no_position" );
|
||||||
return translate( "commands.computercraft.generic.position", pos.getX(), pos.getY(), pos.getZ() );
|
return translate( "commands.computercraft.generic.position", pos.getX(), pos.getY(), pos.getZ() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Component bool( boolean value )
|
public static Text bool( boolean value )
|
||||||
{
|
{
|
||||||
return value
|
return value
|
||||||
? coloured( translate( "commands.computercraft.generic.yes" ), ChatFormat.GREEN )
|
? coloured( translate( "commands.computercraft.generic.yes" ), Formatting.GREEN )
|
||||||
: coloured( translate( "commands.computercraft.generic.no" ), ChatFormat.RED );
|
: coloured( translate( "commands.computercraft.generic.no" ), Formatting.RED );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Component link( Component component, String command, Component toolTip )
|
public static Text link( Text component, String command, Text toolTip )
|
||||||
{
|
{
|
||||||
Style style = component.getStyle();
|
Style style = component.getStyle();
|
||||||
|
|
||||||
if( style.getColor() == null ) style.setColor( ChatFormat.YELLOW );
|
if( style.getColor() == null ) style.setColor( Formatting.YELLOW );
|
||||||
style.setClickEvent( new ClickEvent( ClickEvent.Action.RUN_COMMAND, command ) );
|
style.setClickEvent( new ClickEvent( ClickEvent.Action.RUN_COMMAND, command ) );
|
||||||
style.setHoverEvent( new HoverEvent( HoverEvent.Action.SHOW_TEXT, toolTip ) );
|
style.setHoverEvent( new HoverEvent( HoverEvent.Action.SHOW_TEXT, toolTip ) );
|
||||||
|
|
||||||
return component;
|
return component;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Component header( String text )
|
public static Text header( String text )
|
||||||
{
|
{
|
||||||
return coloured( text, HEADER );
|
return coloured( text, HEADER );
|
||||||
}
|
}
|
||||||
|
@@ -6,9 +6,9 @@
|
|||||||
|
|
||||||
package dan200.computercraft.shared.command.text;
|
package dan200.computercraft.shared.command.text;
|
||||||
|
|
||||||
import net.minecraft.network.chat.Component;
|
|
||||||
import net.minecraft.network.chat.TextComponent;
|
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
|
import net.minecraft.text.LiteralText;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@@ -24,11 +24,11 @@ public class ServerTableFormatter implements TableFormatter
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public Component getPadding( Component component, int width )
|
public Text getPadding( Text component, int width )
|
||||||
{
|
{
|
||||||
int extraWidth = width - getWidth( component );
|
int extraWidth = width - getWidth( component );
|
||||||
if( extraWidth <= 0 ) return null;
|
if( extraWidth <= 0 ) return null;
|
||||||
return new TextComponent( StringUtils.repeat( ' ', extraWidth ) );
|
return new LiteralText( StringUtils.repeat( ' ', extraWidth ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -38,13 +38,13 @@ public class ServerTableFormatter implements TableFormatter
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getWidth( Component component )
|
public int getWidth( Text component )
|
||||||
{
|
{
|
||||||
return component.getText().length();
|
return component.asString().length();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeLine( int id, Component component )
|
public void writeLine( int id, Text component )
|
||||||
{
|
{
|
||||||
source.sendFeedback( component, false );
|
source.sendFeedback( component, false );
|
||||||
}
|
}
|
||||||
|
@@ -9,9 +9,9 @@ package dan200.computercraft.shared.command.text;
|
|||||||
import dan200.computercraft.shared.command.CommandUtils;
|
import dan200.computercraft.shared.command.CommandUtils;
|
||||||
import dan200.computercraft.shared.network.NetworkHandler;
|
import dan200.computercraft.shared.network.NetworkHandler;
|
||||||
import dan200.computercraft.shared.network.client.ChatTableClientMessage;
|
import dan200.computercraft.shared.network.client.ChatTableClientMessage;
|
||||||
import net.minecraft.network.chat.Component;
|
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@@ -22,11 +22,11 @@ public class TableBuilder
|
|||||||
{
|
{
|
||||||
private final int id;
|
private final int id;
|
||||||
private int columns = -1;
|
private int columns = -1;
|
||||||
private final Component[] headers;
|
private final Text[] headers;
|
||||||
private final ArrayList<Component[]> rows = new ArrayList<>();
|
private final ArrayList<Text[]> rows = new ArrayList<>();
|
||||||
private int additional;
|
private int additional;
|
||||||
|
|
||||||
public TableBuilder( int id, @Nonnull Component... headers )
|
public TableBuilder( int id, @Nonnull Text... headers )
|
||||||
{
|
{
|
||||||
if( id < 0 ) throw new IllegalArgumentException( "ID must be positive" );
|
if( id < 0 ) throw new IllegalArgumentException( "ID must be positive" );
|
||||||
this.id = id;
|
this.id = id;
|
||||||
@@ -45,13 +45,13 @@ public class TableBuilder
|
|||||||
{
|
{
|
||||||
if( id < 0 ) throw new IllegalArgumentException( "ID must be positive" );
|
if( id < 0 ) throw new IllegalArgumentException( "ID must be positive" );
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.headers = new Component[headers.length];
|
this.headers = new Text[headers.length];
|
||||||
columns = headers.length;
|
columns = headers.length;
|
||||||
|
|
||||||
for( int i = 0; i < headers.length; i++ ) this.headers[i] = ChatHelpers.header( headers[i] );
|
for( int i = 0; i < headers.length; i++ ) this.headers[i] = ChatHelpers.header( headers[i] );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void row( @Nonnull Component... row )
|
public void row( @Nonnull Text... row )
|
||||||
{
|
{
|
||||||
if( columns == -1 ) columns = row.length;
|
if( columns == -1 ) columns = row.length;
|
||||||
if( row.length != columns ) throw new IllegalArgumentException( "Row is the incorrect length" );
|
if( row.length != columns ) throw new IllegalArgumentException( "Row is the incorrect length" );
|
||||||
@@ -85,13 +85,13 @@ public class TableBuilder
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public Component[] getHeaders()
|
public Text[] getHeaders()
|
||||||
{
|
{
|
||||||
return headers;
|
return headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public List<Component[]> getRows()
|
public List<Text[]> getRows()
|
||||||
{
|
{
|
||||||
return rows;
|
return rows;
|
||||||
}
|
}
|
||||||
|
@@ -6,9 +6,9 @@
|
|||||||
|
|
||||||
package dan200.computercraft.shared.command.text;
|
package dan200.computercraft.shared.command.text;
|
||||||
|
|
||||||
import net.minecraft.ChatFormat;
|
import net.minecraft.text.LiteralText;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.network.chat.TextComponent;
|
import net.minecraft.util.Formatting;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@@ -18,8 +18,8 @@ import static dan200.computercraft.shared.command.text.ChatHelpers.translate;
|
|||||||
|
|
||||||
public interface TableFormatter
|
public interface TableFormatter
|
||||||
{
|
{
|
||||||
Component SEPARATOR = coloured( "| ", ChatFormat.GRAY );
|
Text SEPARATOR = coloured( "| ", Formatting.GRAY );
|
||||||
Component HEADER = coloured( "=", ChatFormat.GRAY );
|
Text HEADER = coloured( "=", Formatting.GRAY );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get additional padding for the component
|
* Get additional padding for the component
|
||||||
@@ -29,7 +29,7 @@ public interface TableFormatter
|
|||||||
* @return The padding for this component, or {@code null} if none is needed.
|
* @return The padding for this component, or {@code null} if none is needed.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
Component getPadding( Component component, int width );
|
Text getPadding( Text component, int width );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the minimum padding between each column
|
* Get the minimum padding between each column
|
||||||
@@ -38,9 +38,9 @@ public interface TableFormatter
|
|||||||
*/
|
*/
|
||||||
int getColumnPadding();
|
int getColumnPadding();
|
||||||
|
|
||||||
int getWidth( Component component );
|
int getWidth( Text component );
|
||||||
|
|
||||||
void writeLine( int id, Component component );
|
void writeLine( int id, Text component );
|
||||||
|
|
||||||
default int display( TableBuilder table )
|
default int display( TableBuilder table )
|
||||||
{
|
{
|
||||||
@@ -50,13 +50,13 @@ public interface TableFormatter
|
|||||||
int columns = table.getColumns();
|
int columns = table.getColumns();
|
||||||
int[] maxWidths = new int[columns];
|
int[] maxWidths = new int[columns];
|
||||||
|
|
||||||
Component[] headers = table.getHeaders();
|
Text[] headers = table.getHeaders();
|
||||||
if( headers != null )
|
if( headers != null )
|
||||||
{
|
{
|
||||||
for( int i = 0; i < columns; i++ ) maxWidths[i] = getWidth( headers[i] );
|
for( int i = 0; i < columns; i++ ) maxWidths[i] = getWidth( headers[i] );
|
||||||
}
|
}
|
||||||
|
|
||||||
for( Component[] row : table.getRows() )
|
for( Text[] row : table.getRows() )
|
||||||
{
|
{
|
||||||
for( int i = 0; i < row.length; i++ )
|
for( int i = 0; i < row.length; i++ )
|
||||||
{
|
{
|
||||||
@@ -77,11 +77,11 @@ public interface TableFormatter
|
|||||||
|
|
||||||
if( headers != null )
|
if( headers != null )
|
||||||
{
|
{
|
||||||
TextComponent line = new TextComponent( "" );
|
LiteralText line = new LiteralText( "" );
|
||||||
for( int i = 0; i < columns - 1; i++ )
|
for( int i = 0; i < columns - 1; i++ )
|
||||||
{
|
{
|
||||||
line.append( headers[i] );
|
line.append( headers[i] );
|
||||||
Component padding = getPadding( headers[i], maxWidths[i] );
|
Text padding = getPadding( headers[i], maxWidths[i] );
|
||||||
if( padding != null ) line.append( padding );
|
if( padding != null ) line.append( padding );
|
||||||
line.append( SEPARATOR );
|
line.append( SEPARATOR );
|
||||||
}
|
}
|
||||||
@@ -93,16 +93,16 @@ public interface TableFormatter
|
|||||||
// it a tad prettier.
|
// it a tad prettier.
|
||||||
int rowCharWidth = getWidth( HEADER );
|
int rowCharWidth = getWidth( HEADER );
|
||||||
int rowWidth = totalWidth / rowCharWidth + (totalWidth % rowCharWidth == 0 ? 0 : 1);
|
int rowWidth = totalWidth / rowCharWidth + (totalWidth % rowCharWidth == 0 ? 0 : 1);
|
||||||
writeLine( rowId++, coloured( StringUtils.repeat( HEADER.getText(), rowWidth ), ChatFormat.GRAY ) );
|
writeLine( rowId++, coloured( StringUtils.repeat( HEADER.asString(), rowWidth ), Formatting.GRAY ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
for( Component[] row : table.getRows() )
|
for( Text[] row : table.getRows() )
|
||||||
{
|
{
|
||||||
TextComponent line = new TextComponent( "" );
|
LiteralText line = new LiteralText( "" );
|
||||||
for( int i = 0; i < columns - 1; i++ )
|
for( int i = 0; i < columns - 1; i++ )
|
||||||
{
|
{
|
||||||
line.append( row[i] );
|
line.append( row[i] );
|
||||||
Component padding = getPadding( row[i], maxWidths[i] );
|
Text padding = getPadding( row[i], maxWidths[i] );
|
||||||
if( padding != null ) line.append( padding );
|
if( padding != null ) line.append( padding );
|
||||||
line.append( SEPARATOR );
|
line.append( SEPARATOR );
|
||||||
}
|
}
|
||||||
@@ -112,7 +112,7 @@ public interface TableFormatter
|
|||||||
|
|
||||||
if( table.getAdditional() > 0 )
|
if( table.getAdditional() > 0 )
|
||||||
{
|
{
|
||||||
writeLine( rowId++, coloured( translate( "commands.computercraft.generic.additional_rows", table.getAdditional() ), ChatFormat.AQUA ) );
|
writeLine( rowId++, coloured( translate( "commands.computercraft.generic.additional_rows", table.getAdditional() ), Formatting.AQUA ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return rowId - table.getId();
|
return rowId - table.getId();
|
||||||
|
@@ -34,7 +34,6 @@ public abstract class TileGeneric extends BlockEntity implements BlockEntityClie
|
|||||||
markDirty();
|
markDirty();
|
||||||
BlockPos pos = getPos();
|
BlockPos pos = getPos();
|
||||||
BlockState state = getCachedState();
|
BlockState state = getCachedState();
|
||||||
getWorld().scheduleBlockRender( pos );
|
|
||||||
getWorld().updateListeners( pos, state, state, 3 );
|
getWorld().updateListeners( pos, state, state, 3 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -123,7 +123,7 @@ public class CommandAPI implements ILuaAPI
|
|||||||
private static Object getPropertyValue( Property property, Comparable value )
|
private static Object getPropertyValue( Property property, Comparable value )
|
||||||
{
|
{
|
||||||
if( value instanceof String || value instanceof Number || value instanceof Boolean ) return value;
|
if( value instanceof String || value instanceof Number || value instanceof Boolean ) return value;
|
||||||
return property.getValueAsString( value );
|
return property.getName( value );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -25,8 +25,8 @@ import javax.annotation.Nullable;
|
|||||||
|
|
||||||
public class BlockComputer extends BlockComputerBase<TileComputer>
|
public class BlockComputer extends BlockComputerBase<TileComputer>
|
||||||
{
|
{
|
||||||
public static final EnumProperty<ComputerState> STATE = EnumProperty.create( "state", ComputerState.class );
|
public static final EnumProperty<ComputerState> STATE = EnumProperty.of( "state", ComputerState.class );
|
||||||
public static final DirectionProperty FACING = Properties.FACING_HORIZONTAL;
|
public static final DirectionProperty FACING = Properties.HORIZONTAL_FACING;
|
||||||
|
|
||||||
public BlockComputer( Settings settings, ComputerFamily family, NamedBlockEntityType<? extends TileComputer> type )
|
public BlockComputer( Settings settings, ComputerFamily family, NamedBlockEntityType<? extends TileComputer> type )
|
||||||
{
|
{
|
||||||
@@ -47,7 +47,7 @@ public class BlockComputer extends BlockComputerBase<TileComputer>
|
|||||||
@Override
|
@Override
|
||||||
public BlockState getPlacementState( ItemPlacementContext placement )
|
public BlockState getPlacementState( ItemPlacementContext placement )
|
||||||
{
|
{
|
||||||
return getDefaultState().with( FACING, placement.getPlayerHorizontalFacing().getOpposite() );
|
return getDefaultState().with( FACING, placement.getPlayerFacing().getOpposite() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
@@ -13,16 +13,17 @@ import dan200.computercraft.shared.computer.core.ServerComputer;
|
|||||||
import dan200.computercraft.shared.util.NamedBlockEntityType;
|
import dan200.computercraft.shared.util.NamedBlockEntityType;
|
||||||
import net.minecraft.block.entity.BlockEntityType;
|
import net.minecraft.block.entity.BlockEntityType;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.network.chat.Component;
|
|
||||||
import net.minecraft.network.chat.TextComponent;
|
|
||||||
import net.minecraft.network.chat.TranslatableComponent;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.command.CommandOutput;
|
import net.minecraft.server.command.CommandOutput;
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
import net.minecraft.server.world.ServerWorld;
|
||||||
|
import net.minecraft.text.LiteralText;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
|
import net.minecraft.text.TranslatableText;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.math.Vec2f;
|
import net.minecraft.util.math.Vec2f;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
import net.minecraft.world.GameRules;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -54,15 +55,15 @@ public class TileCommandComputer extends TileComputer
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendMessage( Component textComponent )
|
public void sendMessage( Text textComponent )
|
||||||
{
|
{
|
||||||
output.put( output.size() + 1, textComponent.getText() );
|
output.put( output.size() + 1, textComponent.asString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean sendCommandFeedback()
|
public boolean sendCommandFeedback()
|
||||||
{
|
{
|
||||||
return getWorld().getGameRules().getBoolean( "sendCommandFeedback" );
|
return getWorld().getGameRules().getBoolean( GameRules.SEND_COMMAND_FEEDBACK );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -74,7 +75,7 @@ public class TileCommandComputer extends TileComputer
|
|||||||
@Override
|
@Override
|
||||||
public boolean shouldBroadcastConsoleToOps()
|
public boolean shouldBroadcastConsoleToOps()
|
||||||
{
|
{
|
||||||
return getWorld().getGameRules().getBoolean( "commandBlockOutput" );
|
return getWorld().getGameRules().getBoolean( GameRules.COMMAND_BLOCK_OUTPUT );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +105,7 @@ public class TileCommandComputer extends TileComputer
|
|||||||
return new ServerCommandSource( receiver,
|
return new ServerCommandSource( receiver,
|
||||||
new Vec3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 ), Vec2f.ZERO,
|
new Vec3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 ), Vec2f.ZERO,
|
||||||
(ServerWorld) getWorld(), 2,
|
(ServerWorld) getWorld(), 2,
|
||||||
name, new TextComponent( name ),
|
name, new LiteralText( name ),
|
||||||
getWorld().getServer(), null
|
getWorld().getServer(), null
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -123,12 +124,12 @@ public class TileCommandComputer extends TileComputer
|
|||||||
MinecraftServer server = player.getServer();
|
MinecraftServer server = player.getServer();
|
||||||
if( server == null || !server.areCommandBlocksEnabled() )
|
if( server == null || !server.areCommandBlocksEnabled() )
|
||||||
{
|
{
|
||||||
player.addChatMessage( new TranslatableComponent( "advMode.notEnabled" ), true );
|
player.addChatMessage( new TranslatableText( "advMode.notEnabled" ), true );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if( !player.isCreativeLevelTwoOp() )
|
else if( !player.isCreativeLevelTwoOp() )
|
||||||
{
|
{
|
||||||
player.addChatMessage( new TranslatableComponent( "advMode.notAllowed" ), true );
|
player.addChatMessage( new TranslatableText( "advMode.notAllowed" ), true );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@@ -28,8 +28,8 @@ import net.minecraft.entity.player.PlayerEntity;
|
|||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.Items;
|
import net.minecraft.item.Items;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.text.LiteralText;
|
||||||
import net.minecraft.network.chat.TextComponent;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.Nameable;
|
import net.minecraft.util.Nameable;
|
||||||
import net.minecraft.util.Tickable;
|
import net.minecraft.util.Tickable;
|
||||||
@@ -109,13 +109,13 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
|
|||||||
public boolean onActivate( PlayerEntity player, Hand hand, BlockHitResult hit )
|
public boolean onActivate( PlayerEntity player, Hand hand, BlockHitResult hit )
|
||||||
{
|
{
|
||||||
ItemStack currentItem = player.getStackInHand( hand );
|
ItemStack currentItem = player.getStackInHand( hand );
|
||||||
if( !currentItem.isEmpty() && currentItem.getItem() == Items.NAME_TAG && canNameWithTag( player ) && currentItem.hasDisplayName() )
|
if( !currentItem.isEmpty() && currentItem.getItem() == Items.NAME_TAG && canNameWithTag( player ) && currentItem.hasCustomName() )
|
||||||
{
|
{
|
||||||
// Label to rename computer
|
// Label to rename computer
|
||||||
if( !getWorld().isClient )
|
if( !getWorld().isClient )
|
||||||
{
|
{
|
||||||
setLabel( currentItem.getDisplayName().getText() );
|
setLabel( currentItem.getName().asString() );
|
||||||
currentItem.subtractAmount( 1 );
|
currentItem.decrement( 1 );
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -439,9 +439,9 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
|
|||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public Component getName()
|
public Text getName()
|
||||||
{
|
{
|
||||||
return hasCustomName() ? new TextComponent( m_label ) : getCachedState().getBlock().getTextComponent();
|
return hasCustomName() ? new LiteralText( m_label ) : getCachedState().getBlock().getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -452,8 +452,8 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public Component getCustomName()
|
public Text getCustomName()
|
||||||
{
|
{
|
||||||
return hasCustomName() ? new TextComponent( m_label ) : null;
|
return hasCustomName() ? new LiteralText( m_label ) : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,8 +10,8 @@ import dan200.computercraft.ComputerCraft;
|
|||||||
import dan200.computercraft.shared.computer.core.*;
|
import dan200.computercraft.shared.computer.core.*;
|
||||||
import net.minecraft.container.Container;
|
import net.minecraft.container.Container;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.network.chat.TranslatableComponent;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
import net.minecraft.text.TranslatableText;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@@ -53,12 +53,12 @@ public class ContainerViewComputer extends Container implements IContainerComput
|
|||||||
MinecraftServer server = player.getServer();
|
MinecraftServer server = player.getServer();
|
||||||
if( server == null || !server.areCommandBlocksEnabled() )
|
if( server == null || !server.areCommandBlocksEnabled() )
|
||||||
{
|
{
|
||||||
player.addChatMessage( new TranslatableComponent( "advMode.notEnabled" ), false );
|
player.addChatMessage( new TranslatableText( "advMode.notEnabled" ), false );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if( !player.isCreativeLevelTwoOp() )
|
else if( !player.isCreativeLevelTwoOp() )
|
||||||
{
|
{
|
||||||
player.addChatMessage( new TranslatableComponent( "advMode.notAllowed" ), false );
|
player.addChatMessage( new TranslatableText( "advMode.notAllowed" ), false );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -24,7 +24,7 @@ public interface IComputerItem
|
|||||||
|
|
||||||
default String getLabel( @Nonnull ItemStack stack )
|
default String getLabel( @Nonnull ItemStack stack )
|
||||||
{
|
{
|
||||||
return stack.hasDisplayName() ? stack.getDisplayName().getString() : null;
|
return stack.hasCustomName() ? stack.getName().getString() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
ComputerFamily getFamily();
|
ComputerFamily getFamily();
|
||||||
|
@@ -9,7 +9,7 @@ package dan200.computercraft.shared.computer.items;
|
|||||||
import dan200.computercraft.shared.computer.blocks.BlockComputer;
|
import dan200.computercraft.shared.computer.blocks.BlockComputer;
|
||||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.network.chat.TextComponent;
|
import net.minecraft.text.LiteralText;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@ public class ItemComputer extends ItemComputerBase
|
|||||||
{
|
{
|
||||||
ItemStack result = new ItemStack( this );
|
ItemStack result = new ItemStack( this );
|
||||||
if( id >= 0 ) result.getOrCreateTag().putInt( NBT_ID, id );
|
if( id >= 0 ) result.getOrCreateTag().putInt( NBT_ID, id );
|
||||||
if( label != null ) result.setDisplayName( new TextComponent( label ) );
|
if( label != null ) result.setCustomName( new LiteralText( label ) );
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@ public class ItemComputer extends ItemComputerBase
|
|||||||
public ItemStack withFamily( @Nonnull ItemStack stack, @Nonnull ComputerFamily family )
|
public ItemStack withFamily( @Nonnull ItemStack stack, @Nonnull ComputerFamily family )
|
||||||
{
|
{
|
||||||
ItemStack result = ComputerItemFactory.create( getComputerID( stack ), null, family );
|
ItemStack result = ComputerItemFactory.create( getComputerID( stack ), null, family );
|
||||||
if( stack.hasDisplayName() ) result.setDisplayName( stack.getDisplayName() );
|
if( stack.hasCustomName() ) result.setCustomName( stack.getName() );
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -12,13 +12,13 @@ import dan200.computercraft.api.filesystem.IMount;
|
|||||||
import dan200.computercraft.api.media.IMedia;
|
import dan200.computercraft.api.media.IMedia;
|
||||||
import dan200.computercraft.shared.computer.blocks.BlockComputerBase;
|
import dan200.computercraft.shared.computer.blocks.BlockComputerBase;
|
||||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||||
import net.minecraft.ChatFormat;
|
|
||||||
import net.minecraft.client.item.TooltipContext;
|
import net.minecraft.client.item.TooltipContext;
|
||||||
import net.minecraft.item.BlockItem;
|
import net.minecraft.item.BlockItem;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.text.LiteralText;
|
||||||
import net.minecraft.network.chat.TextComponent;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.network.chat.TranslatableComponent;
|
import net.minecraft.text.TranslatableText;
|
||||||
|
import net.minecraft.util.Formatting;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
@@ -36,15 +36,15 @@ public abstract class ItemComputerBase extends BlockItem implements IComputerIte
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void buildTooltip( @Nonnull ItemStack stack, @Nullable World world, @Nonnull List<Component> list, @Nonnull TooltipContext options )
|
public void appendTooltip( @Nonnull ItemStack stack, @Nullable World world, @Nonnull List<Text> list, @Nonnull TooltipContext options )
|
||||||
{
|
{
|
||||||
if( options.isAdvanced() )
|
if( options.isAdvanced() )
|
||||||
{
|
{
|
||||||
int id = getComputerID( stack );
|
int id = getComputerID( stack );
|
||||||
if( id >= 0 )
|
if( id >= 0 )
|
||||||
{
|
{
|
||||||
list.add( new TranslatableComponent( "gui.computercraft.tooltip.computer_id", id )
|
list.add( new TranslatableText( "gui.computercraft.tooltip.computer_id", id )
|
||||||
.applyFormat( ChatFormat.GRAY ) );
|
.formatted( Formatting.GRAY ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -52,7 +52,7 @@ public abstract class ItemComputerBase extends BlockItem implements IComputerIte
|
|||||||
@Override
|
@Override
|
||||||
public String getLabel( @Nonnull ItemStack stack )
|
public String getLabel( @Nonnull ItemStack stack )
|
||||||
{
|
{
|
||||||
return stack.hasDisplayName() ? stack.getDisplayName().getString() : null;
|
return stack.hasCustomName() ? stack.getName().getString() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -68,11 +68,11 @@ public abstract class ItemComputerBase extends BlockItem implements IComputerIte
|
|||||||
{
|
{
|
||||||
if( label != null )
|
if( label != null )
|
||||||
{
|
{
|
||||||
stack.setDisplayName( new TextComponent( label ) );
|
stack.setCustomName( new LiteralText( label ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
stack.removeDisplayName();
|
stack.removeCustomName();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -60,7 +60,7 @@ public abstract class ComputerFamilyRecipe extends ComputerConvertRecipe
|
|||||||
int height = buf.readVarInt();
|
int height = buf.readVarInt();
|
||||||
String group = buf.readString( Short.MAX_VALUE );
|
String group = buf.readString( Short.MAX_VALUE );
|
||||||
|
|
||||||
DefaultedList<Ingredient> ingredients = DefaultedList.create( width * height, Ingredient.EMPTY );
|
DefaultedList<Ingredient> ingredients = DefaultedList.ofSize( width * height, Ingredient.EMPTY );
|
||||||
for( int i = 0; i < ingredients.size(); i++ ) ingredients.set( i, Ingredient.fromPacket( buf ) );
|
for( int i = 0; i < ingredients.size(); i++ ) ingredients.set( i, Ingredient.fromPacket( buf ) );
|
||||||
|
|
||||||
ItemStack result = buf.readItemStack();
|
ItemStack result = buf.readItemStack();
|
||||||
|
@@ -12,16 +12,16 @@ import dan200.computercraft.api.filesystem.IMount;
|
|||||||
import dan200.computercraft.api.media.IMedia;
|
import dan200.computercraft.api.media.IMedia;
|
||||||
import dan200.computercraft.shared.common.IColouredItem;
|
import dan200.computercraft.shared.common.IColouredItem;
|
||||||
import dan200.computercraft.shared.util.Colour;
|
import dan200.computercraft.shared.util.Colour;
|
||||||
import net.minecraft.ChatFormat;
|
|
||||||
import net.minecraft.client.item.TooltipContext;
|
import net.minecraft.client.item.TooltipContext;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemGroup;
|
import net.minecraft.item.ItemGroup;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.text.LiteralText;
|
||||||
import net.minecraft.network.chat.TextComponent;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.network.chat.TranslatableComponent;
|
import net.minecraft.text.TranslatableText;
|
||||||
import net.minecraft.util.DefaultedList;
|
import net.minecraft.util.DefaultedList;
|
||||||
|
import net.minecraft.util.Formatting;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
@@ -48,9 +48,9 @@ public class ItemDisk extends Item implements IMedia, IColouredItem
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void appendItemsForGroup( @Nonnull ItemGroup tabs, @Nonnull DefaultedList<ItemStack> list )
|
public void appendStacks( @Nonnull ItemGroup tabs, @Nonnull DefaultedList<ItemStack> list )
|
||||||
{
|
{
|
||||||
if( !isInItemGroup( tabs ) ) return;
|
if( !isIn( tabs ) ) return;
|
||||||
for( int colour = 0; colour < 16; colour++ )
|
for( int colour = 0; colour < 16; colour++ )
|
||||||
{
|
{
|
||||||
list.add( createFromIDAndColour( -1, null, Colour.VALUES[colour].getHex() ) );
|
list.add( createFromIDAndColour( -1, null, Colour.VALUES[colour].getHex() ) );
|
||||||
@@ -58,15 +58,15 @@ public class ItemDisk extends Item implements IMedia, IColouredItem
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void buildTooltip( ItemStack stack, @Nullable World world, List<Component> list, TooltipContext options )
|
public void appendTooltip( ItemStack stack, @Nullable World world, List<Text> list, TooltipContext options )
|
||||||
{
|
{
|
||||||
if( options.isAdvanced() )
|
if( options.isAdvanced() )
|
||||||
{
|
{
|
||||||
int id = getDiskID( stack );
|
int id = getDiskID( stack );
|
||||||
if( id >= 0 )
|
if( id >= 0 )
|
||||||
{
|
{
|
||||||
list.add( new TranslatableComponent( "gui.computercraft.tooltip.disk_id", id )
|
list.add( new TranslatableText( "gui.computercraft.tooltip.disk_id", id )
|
||||||
.applyFormat( ChatFormat.GRAY ) );
|
.formatted( Formatting.GRAY ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -74,7 +74,7 @@ public class ItemDisk extends Item implements IMedia, IColouredItem
|
|||||||
@Override
|
@Override
|
||||||
public String getLabel( @Nonnull ItemStack stack )
|
public String getLabel( @Nonnull ItemStack stack )
|
||||||
{
|
{
|
||||||
return stack.hasDisplayName() ? stack.getDisplayName().getString() : null;
|
return stack.hasCustomName() ? stack.getName().getString() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -82,11 +82,11 @@ public class ItemDisk extends Item implements IMedia, IColouredItem
|
|||||||
{
|
{
|
||||||
if( label != null )
|
if( label != null )
|
||||||
{
|
{
|
||||||
stack.setDisplayName( new TextComponent( label ) );
|
stack.setCustomName( new LiteralText( label ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
stack.removeDisplayName();
|
stack.removeCustomName();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -13,8 +13,8 @@ import net.minecraft.entity.player.PlayerEntity;
|
|||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.text.LiteralText;
|
||||||
import net.minecraft.network.chat.TextComponent;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.ActionResult;
|
import net.minecraft.util.ActionResult;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.TypedActionResult;
|
import net.minecraft.util.TypedActionResult;
|
||||||
@@ -50,10 +50,10 @@ public class ItemPrintout extends Item
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void buildTooltip( @Nonnull ItemStack stack, World world, List<Component> list, TooltipContext options )
|
public void appendTooltip( @Nonnull ItemStack stack, World world, List<Text> list, TooltipContext options )
|
||||||
{
|
{
|
||||||
String title = getTitle( stack );
|
String title = getTitle( stack );
|
||||||
if( title != null && !title.isEmpty() ) list.add( new TextComponent( title ) );
|
if( title != null && !title.isEmpty() ) list.add( new LiteralText( title ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -17,11 +17,10 @@ import net.minecraft.item.Item;
|
|||||||
import net.minecraft.item.ItemGroup;
|
import net.minecraft.item.ItemGroup;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.text.LiteralText;
|
||||||
import net.minecraft.network.chat.TextComponent;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.DefaultedList;
|
import net.minecraft.util.DefaultedList;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -39,15 +38,15 @@ public class ItemTreasureDisk extends Item implements IMedia
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void appendItemsForGroup( @Nonnull ItemGroup group, @Nonnull DefaultedList<ItemStack> stacks )
|
public void appendStacks( @Nonnull ItemGroup group, @Nonnull DefaultedList<ItemStack> stacks )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void buildTooltip( ItemStack stack, @Nullable World world, List<Component> list, TooltipContext context )
|
public void appendTooltip( ItemStack stack, @Nullable World world, List<Text> list, TooltipContext context )
|
||||||
{
|
{
|
||||||
String label = getTitle( stack );
|
String label = getTitle( stack );
|
||||||
if( !label.isEmpty() ) list.add( new TextComponent( label ) );
|
if( !label.isEmpty() ) list.add( new LiteralText( label ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -6,13 +6,13 @@
|
|||||||
|
|
||||||
package dan200.computercraft.shared.mixed;
|
package dan200.computercraft.shared.mixed;
|
||||||
|
|
||||||
import net.minecraft.util.AbsoluteHand;
|
import net.minecraft.util.Arm;
|
||||||
|
|
||||||
public interface MixedFirstPersonRenderer
|
public interface MixedFirstPersonRenderer
|
||||||
{
|
{
|
||||||
void renderArms_CC();
|
void renderArms_CC();
|
||||||
|
|
||||||
void renderArmFirstPerson_CC( float equip, float swing, AbsoluteHand hand );
|
void renderArmFirstPerson_CC( float equip, float swing, Arm hand );
|
||||||
|
|
||||||
float getMapAngleFromPitch_CC( float pitch );
|
float getMapAngleFromPitch_CC( float pitch );
|
||||||
}
|
}
|
||||||
|
@@ -14,7 +14,7 @@ import dan200.computercraft.shared.pocket.items.ItemPocketComputer;
|
|||||||
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
||||||
import net.minecraft.client.render.FirstPersonRenderer;
|
import net.minecraft.client.render.FirstPersonRenderer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.AbsoluteHand;
|
import net.minecraft.util.Arm;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
@@ -37,7 +37,7 @@ public class MixinFirstPersonRenderer implements MixedFirstPersonRenderer
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Shadow
|
@Shadow
|
||||||
private void renderArmHoldingItem( float equip, float swing, AbsoluteHand hand )
|
private void renderArmHoldingItem( float equip, float swing, Arm hand )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ public class MixinFirstPersonRenderer implements MixedFirstPersonRenderer
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderArmFirstPerson_CC( float equip, float swing, AbsoluteHand hand )
|
public void renderArmFirstPerson_CC( float equip, float swing, Arm hand )
|
||||||
{
|
{
|
||||||
renderArmHoldingItem( equip, swing, hand );
|
renderArmHoldingItem( equip, swing, hand );
|
||||||
}
|
}
|
||||||
|
@@ -12,7 +12,7 @@ import dan200.computercraft.shared.network.NetworkMessage;
|
|||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.fabricmc.fabric.api.network.PacketContext;
|
import net.fabricmc.fabric.api.network.PacketContext;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.PacketByteBuf;
|
import net.minecraft.util.PacketByteBuf;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
@@ -39,13 +39,13 @@ public class ChatTableClientMessage implements NetworkMessage
|
|||||||
buf.writeBoolean( table.getHeaders() != null );
|
buf.writeBoolean( table.getHeaders() != null );
|
||||||
if( table.getHeaders() != null )
|
if( table.getHeaders() != null )
|
||||||
{
|
{
|
||||||
for( Component header : table.getHeaders() ) buf.writeTextComponent( header );
|
for( Text header : table.getHeaders() ) buf.writeText( header );
|
||||||
}
|
}
|
||||||
|
|
||||||
buf.writeVarInt( table.getRows().size() );
|
buf.writeVarInt( table.getRows().size() );
|
||||||
for( Component[] row : table.getRows() )
|
for( Text[] row : table.getRows() )
|
||||||
{
|
{
|
||||||
for( Component column : row ) buf.writeTextComponent( column );
|
for( Text column : row ) buf.writeText( column );
|
||||||
}
|
}
|
||||||
|
|
||||||
buf.writeVarInt( table.getAdditional() );
|
buf.writeVarInt( table.getAdditional() );
|
||||||
@@ -59,8 +59,8 @@ public class ChatTableClientMessage implements NetworkMessage
|
|||||||
TableBuilder table;
|
TableBuilder table;
|
||||||
if( buf.readBoolean() )
|
if( buf.readBoolean() )
|
||||||
{
|
{
|
||||||
Component[] headers = new Component[columns];
|
Text[] headers = new Text[columns];
|
||||||
for( int i = 0; i < columns; i++ ) headers[i] = buf.readTextComponent();
|
for( int i = 0; i < columns; i++ ) headers[i] = buf.readText();
|
||||||
table = new TableBuilder( id, headers );
|
table = new TableBuilder( id, headers );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -71,8 +71,8 @@ public class ChatTableClientMessage implements NetworkMessage
|
|||||||
int rows = buf.readVarInt();
|
int rows = buf.readVarInt();
|
||||||
for( int i = 0; i < rows; i++ )
|
for( int i = 0; i < rows; i++ )
|
||||||
{
|
{
|
||||||
Component[] row = new Component[columns];
|
Text[] row = new Text[columns];
|
||||||
for( int j = 0; j < columns; j++ ) row[j] = buf.readTextComponent();
|
for( int j = 0; j < columns; j++ ) row[j] = buf.readText();
|
||||||
table.row( row );
|
table.row( row );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -25,8 +25,8 @@ import javax.annotation.Nullable;
|
|||||||
|
|
||||||
public class BlockDiskDrive extends BlockGeneric
|
public class BlockDiskDrive extends BlockGeneric
|
||||||
{
|
{
|
||||||
static final DirectionProperty FACING = Properties.FACING_HORIZONTAL;
|
static final DirectionProperty FACING = Properties.HORIZONTAL_FACING;
|
||||||
static final EnumProperty<DiskDriveState> STATE = EnumProperty.create( "state", DiskDriveState.class );
|
static final EnumProperty<DiskDriveState> STATE = EnumProperty.of( "state", DiskDriveState.class );
|
||||||
|
|
||||||
public BlockDiskDrive( Settings settings )
|
public BlockDiskDrive( Settings settings )
|
||||||
{
|
{
|
||||||
@@ -46,16 +46,16 @@ public class BlockDiskDrive extends BlockGeneric
|
|||||||
@Override
|
@Override
|
||||||
public BlockState getPlacementState( ItemPlacementContext placement )
|
public BlockState getPlacementState( ItemPlacementContext placement )
|
||||||
{
|
{
|
||||||
return getDefaultState().with( FACING, placement.getPlayerHorizontalFacing().getOpposite() );
|
return getDefaultState().with( FACING, placement.getPlayerFacing().getOpposite() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlaced( World world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack )
|
public void onPlaced( World world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack )
|
||||||
{
|
{
|
||||||
if( stack.hasDisplayName() )
|
if( stack.hasCustomName() )
|
||||||
{
|
{
|
||||||
BlockEntity tileentity = world.getBlockEntity( pos );
|
BlockEntity tileentity = world.getBlockEntity( pos );
|
||||||
if( tileentity instanceof TileDiskDrive ) ((TileDiskDrive) tileentity).customName = stack.getDisplayName();
|
if( tileentity instanceof TileDiskDrive ) ((TileDiskDrive) tileentity).customName = stack.getName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -81,7 +81,7 @@ public class ContainerDiskDrive extends Container
|
|||||||
slot.markDirty();
|
slot.markDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
if( existing.getAmount() == result.getAmount() ) return ItemStack.EMPTY;
|
if( existing.getCount() == result.getCount() ) return ItemStack.EMPTY;
|
||||||
|
|
||||||
slot.onTakeItem( player, existing );
|
slot.onTakeItem( player, existing );
|
||||||
return result;
|
return result;
|
||||||
|
@@ -26,9 +26,9 @@ import net.minecraft.entity.ItemEntity;
|
|||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.chat.Component;
|
|
||||||
import net.minecraft.network.chat.TextComponent;
|
|
||||||
import net.minecraft.sound.SoundEvent;
|
import net.minecraft.sound.SoundEvent;
|
||||||
|
import net.minecraft.text.LiteralText;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.Nameable;
|
import net.minecraft.util.Nameable;
|
||||||
@@ -60,7 +60,7 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory
|
|||||||
String mountPath;
|
String mountPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
Component customName;
|
Text customName;
|
||||||
|
|
||||||
private final Map<IComputerAccess, MountInfo> m_computers = new HashMap<>();
|
private final Map<IComputerAccess, MountInfo> m_computers = new HashMap<>();
|
||||||
|
|
||||||
@@ -116,7 +116,7 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory
|
|||||||
public void fromTag( CompoundTag nbt )
|
public void fromTag( CompoundTag nbt )
|
||||||
{
|
{
|
||||||
super.fromTag( nbt );
|
super.fromTag( nbt );
|
||||||
customName = nbt.containsKey( NBT_NAME ) ? TextComponent.Serializer.fromJsonString( nbt.getString( NBT_NAME ) ) : null;
|
customName = nbt.containsKey( NBT_NAME ) ? LiteralText.Serializer.fromJson( nbt.getString( NBT_NAME ) ) : null;
|
||||||
if( nbt.containsKey( NBT_ITEM ) )
|
if( nbt.containsKey( NBT_ITEM ) )
|
||||||
{
|
{
|
||||||
CompoundTag item = nbt.getCompound( NBT_ITEM );
|
CompoundTag item = nbt.getCompound( NBT_ITEM );
|
||||||
@@ -129,7 +129,7 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory
|
|||||||
@Override
|
@Override
|
||||||
public CompoundTag toTag( CompoundTag nbt )
|
public CompoundTag toTag( CompoundTag nbt )
|
||||||
{
|
{
|
||||||
if( customName != null ) nbt.putString( NBT_NAME, TextComponent.Serializer.toJsonString( customName ) );
|
if( customName != null ) nbt.putString( NBT_NAME, LiteralText.Serializer.toJson( customName ) );
|
||||||
|
|
||||||
if( !m_diskStack.isEmpty() )
|
if( !m_diskStack.isEmpty() )
|
||||||
{
|
{
|
||||||
@@ -216,7 +216,7 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory
|
|||||||
{
|
{
|
||||||
if( m_diskStack.isEmpty() ) return ItemStack.EMPTY;
|
if( m_diskStack.isEmpty() ) return ItemStack.EMPTY;
|
||||||
|
|
||||||
if( m_diskStack.getAmount() <= count )
|
if( m_diskStack.getCount() <= count )
|
||||||
{
|
{
|
||||||
ItemStack disk = m_diskStack;
|
ItemStack disk = m_diskStack;
|
||||||
setInvStack( slot, ItemStack.EMPTY );
|
setInvStack( slot, ItemStack.EMPTY );
|
||||||
@@ -496,7 +496,7 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory
|
|||||||
protected void readDescription( @Nonnull CompoundTag nbt )
|
protected void readDescription( @Nonnull CompoundTag nbt )
|
||||||
{
|
{
|
||||||
super.readDescription( nbt );
|
super.readDescription( nbt );
|
||||||
customName = nbt.containsKey( NBT_NAME ) ? TextComponent.Serializer.fromJsonString( nbt.getString( NBT_NAME ) ) : null;
|
customName = nbt.containsKey( NBT_NAME ) ? LiteralText.Serializer.fromJson( nbt.getString( NBT_NAME ) ) : null;
|
||||||
m_diskStack = nbt.containsKey( NBT_ITEM ) ? ItemStack.fromTag( nbt.getCompound( NBT_ITEM ) ) : ItemStack.EMPTY;
|
m_diskStack = nbt.containsKey( NBT_ITEM ) ? ItemStack.fromTag( nbt.getCompound( NBT_ITEM ) ) : ItemStack.EMPTY;
|
||||||
updateBlock();
|
updateBlock();
|
||||||
}
|
}
|
||||||
@@ -505,7 +505,7 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory
|
|||||||
protected void writeDescription( @Nonnull CompoundTag nbt )
|
protected void writeDescription( @Nonnull CompoundTag nbt )
|
||||||
{
|
{
|
||||||
super.writeDescription( nbt );
|
super.writeDescription( nbt );
|
||||||
if( customName != null ) nbt.putString( NBT_NAME, TextComponent.Serializer.toJsonString( customName ) );
|
if( customName != null ) nbt.putString( NBT_NAME, LiteralText.Serializer.toJson( customName ) );
|
||||||
if( !m_diskStack.isEmpty() )
|
if( !m_diskStack.isEmpty() )
|
||||||
{
|
{
|
||||||
CompoundTag item = new CompoundTag();
|
CompoundTag item = new CompoundTag();
|
||||||
@@ -543,15 +543,15 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public Component getCustomName()
|
public Text getCustomName()
|
||||||
{
|
{
|
||||||
return customName;
|
return customName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public Component getName()
|
public Text getName()
|
||||||
{
|
{
|
||||||
return customName != null ? customName : getCachedState().getBlock().getTextComponent();
|
return customName != null ? customName : getCachedState().getBlock().getName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -41,15 +41,15 @@ import java.util.EnumMap;
|
|||||||
|
|
||||||
public class BlockCable extends BlockGeneric implements WaterloggableBlock
|
public class BlockCable extends BlockGeneric implements WaterloggableBlock
|
||||||
{
|
{
|
||||||
public static final EnumProperty<CableModemVariant> MODEM = EnumProperty.create( "modem", CableModemVariant.class );
|
public static final EnumProperty<CableModemVariant> MODEM = EnumProperty.of( "modem", CableModemVariant.class );
|
||||||
public static final BooleanProperty CABLE = BooleanProperty.create( "cable" );
|
public static final BooleanProperty CABLE = BooleanProperty.of( "cable" );
|
||||||
|
|
||||||
private static final BooleanProperty NORTH = BooleanProperty.create( "north" );
|
private static final BooleanProperty NORTH = BooleanProperty.of( "north" );
|
||||||
private static final BooleanProperty SOUTH = BooleanProperty.create( "south" );
|
private static final BooleanProperty SOUTH = BooleanProperty.of( "south" );
|
||||||
private static final BooleanProperty EAST = BooleanProperty.create( "east" );
|
private static final BooleanProperty EAST = BooleanProperty.of( "east" );
|
||||||
private static final BooleanProperty WEST = BooleanProperty.create( "west" );
|
private static final BooleanProperty WEST = BooleanProperty.of( "west" );
|
||||||
private static final BooleanProperty UP = BooleanProperty.create( "up" );
|
private static final BooleanProperty UP = BooleanProperty.of( "up" );
|
||||||
private static final BooleanProperty DOWN = BooleanProperty.create( "down" );
|
private static final BooleanProperty DOWN = BooleanProperty.of( "down" );
|
||||||
|
|
||||||
static final EnumMap<Direction, BooleanProperty> CONNECTIONS =
|
static final EnumMap<Direction, BooleanProperty> CONNECTIONS =
|
||||||
new EnumMap<>( new ImmutableMap.Builder<Direction, BooleanProperty>()
|
new EnumMap<>( new ImmutableMap.Builder<Direction, BooleanProperty>()
|
||||||
@@ -217,7 +217,7 @@ public class BlockCable extends BlockGeneric implements WaterloggableBlock
|
|||||||
BlockState state = getDefaultState()
|
BlockState state = getDefaultState()
|
||||||
.with( WATERLOGGED, getWaterloggedStateForPlacement( context ) );
|
.with( WATERLOGGED, getWaterloggedStateForPlacement( context ) );
|
||||||
|
|
||||||
if( context.getItemStack().getItem() instanceof ItemBlockCable.Cable )
|
if( context.getStack().getItem() instanceof ItemBlockCable.Cable )
|
||||||
{
|
{
|
||||||
World world = context.getWorld();
|
World world = context.getWorld();
|
||||||
BlockPos pos = context.getBlockPos();
|
BlockPos pos = context.getBlockPos();
|
||||||
@@ -225,7 +225,7 @@ public class BlockCable extends BlockGeneric implements WaterloggableBlock
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return state.with( MODEM, CableModemVariant.from( context.getFacing().getOpposite() ) );
|
return state.with( MODEM, CableModemVariant.from( context.getSide().getOpposite() ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -14,8 +14,8 @@ import net.minecraft.state.property.BooleanProperty;
|
|||||||
|
|
||||||
public class BlockWiredModemFull extends BlockGeneric
|
public class BlockWiredModemFull extends BlockGeneric
|
||||||
{
|
{
|
||||||
public static final BooleanProperty MODEM_ON = BooleanProperty.create( "modem" );
|
public static final BooleanProperty MODEM_ON = BooleanProperty.of( "modem" );
|
||||||
public static final BooleanProperty PERIPHERAL_ON = BooleanProperty.create( "peripheral" );
|
public static final BooleanProperty PERIPHERAL_ON = BooleanProperty.of( "peripheral" );
|
||||||
|
|
||||||
public BlockWiredModemFull( Settings settings )
|
public BlockWiredModemFull( Settings settings )
|
||||||
{
|
{
|
||||||
|
@@ -58,9 +58,9 @@ public abstract class ItemBlockCable extends BlockItem
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void appendItemsForGroup( ItemGroup group, DefaultedList<ItemStack> list )
|
public void appendStacks( ItemGroup group, DefaultedList<ItemStack> list )
|
||||||
{
|
{
|
||||||
if( isInItemGroup( group ) ) list.add( new ItemStack( this ) );
|
if( isIn( group ) ) list.add( new ItemStack( this ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -84,7 +84,7 @@ public abstract class ItemBlockCable extends BlockItem
|
|||||||
@Override
|
@Override
|
||||||
public ActionResult place( ItemPlacementContext context )
|
public ActionResult place( ItemPlacementContext context )
|
||||||
{
|
{
|
||||||
ItemStack stack = context.getItemStack();
|
ItemStack stack = context.getStack();
|
||||||
if( stack.isEmpty() ) return ActionResult.FAIL;
|
if( stack.isEmpty() ) return ActionResult.FAIL;
|
||||||
|
|
||||||
World world = context.getWorld();
|
World world = context.getWorld();
|
||||||
@@ -94,13 +94,13 @@ public abstract class ItemBlockCable extends BlockItem
|
|||||||
// Try to add a modem to a cable
|
// Try to add a modem to a cable
|
||||||
if( existingState.getBlock() == ComputerCraft.Blocks.cable && existingState.get( MODEM ) == CableModemVariant.None )
|
if( existingState.getBlock() == ComputerCraft.Blocks.cable && existingState.get( MODEM ) == CableModemVariant.None )
|
||||||
{
|
{
|
||||||
Direction side = context.getFacing().getOpposite();
|
Direction side = context.getSide().getOpposite();
|
||||||
BlockState newState = existingState
|
BlockState newState = existingState
|
||||||
.with( MODEM, CableModemVariant.from( side ) )
|
.with( MODEM, CableModemVariant.from( side ) )
|
||||||
.with( CONNECTIONS.get( side ), existingState.get( CABLE ) );
|
.with( CONNECTIONS.get( side ), existingState.get( CABLE ) );
|
||||||
if( placeAt( world, pos, newState ) )
|
if( placeAt( world, pos, newState ) )
|
||||||
{
|
{
|
||||||
stack.subtractAmount( 1 );
|
stack.decrement( 1 );
|
||||||
return ActionResult.SUCCESS;
|
return ActionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -120,19 +120,19 @@ public abstract class ItemBlockCable extends BlockItem
|
|||||||
@Override
|
@Override
|
||||||
public ActionResult place( ItemPlacementContext context )
|
public ActionResult place( ItemPlacementContext context )
|
||||||
{
|
{
|
||||||
ItemStack stack = context.getItemStack();
|
ItemStack stack = context.getStack();
|
||||||
if( stack.isEmpty() ) return ActionResult.FAIL;
|
if( stack.isEmpty() ) return ActionResult.FAIL;
|
||||||
|
|
||||||
World world = context.getWorld();
|
World world = context.getWorld();
|
||||||
BlockPos pos = context.getBlockPos();
|
BlockPos pos = context.getBlockPos();
|
||||||
|
|
||||||
// Try to add a cable to a modem inside the block we're clicking on.
|
// Try to add a cable to a modem inside the block we're clicking on.
|
||||||
BlockPos insidePos = pos.offset( context.getFacing().getOpposite() );
|
BlockPos insidePos = pos.offset( context.getSide().getOpposite() );
|
||||||
BlockState insideState = world.getBlockState( insidePos );
|
BlockState insideState = world.getBlockState( insidePos );
|
||||||
if( insideState.getBlock() == ComputerCraft.Blocks.cable && !insideState.get( BlockCable.CABLE )
|
if( insideState.getBlock() == ComputerCraft.Blocks.cable && !insideState.get( BlockCable.CABLE )
|
||||||
&& placeAtCorrected( world, insidePos, insideState.with( BlockCable.CABLE, true ) ) )
|
&& placeAtCorrected( world, insidePos, insideState.with( BlockCable.CABLE, true ) ) )
|
||||||
{
|
{
|
||||||
stack.subtractAmount( 1 );
|
stack.decrement( 1 );
|
||||||
return ActionResult.SUCCESS;
|
return ActionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,7 +141,7 @@ public abstract class ItemBlockCable extends BlockItem
|
|||||||
if( existingState.getBlock() == ComputerCraft.Blocks.cable && !existingState.get( BlockCable.CABLE )
|
if( existingState.getBlock() == ComputerCraft.Blocks.cable && !existingState.get( BlockCable.CABLE )
|
||||||
&& placeAtCorrected( world, pos, existingState.with( BlockCable.CABLE, true ) ) )
|
&& placeAtCorrected( world, pos, existingState.with( BlockCable.CABLE, true ) ) )
|
||||||
{
|
{
|
||||||
stack.subtractAmount( 1 );
|
stack.decrement( 1 );
|
||||||
return ActionResult.SUCCESS;
|
return ActionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -24,7 +24,7 @@ import net.minecraft.block.BlockState;
|
|||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.chat.TranslatableComponent;
|
import net.minecraft.text.TranslatableText;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.hit.BlockHitResult;
|
import net.minecraft.util.hit.BlockHitResult;
|
||||||
@@ -238,12 +238,12 @@ public class TileCable extends TileGeneric implements IPeripheralTile
|
|||||||
{
|
{
|
||||||
if( oldName != null )
|
if( oldName != null )
|
||||||
{
|
{
|
||||||
player.addChatMessage( new TranslatableComponent( "chat.computercraft.wired_modem.peripheral_disconnected",
|
player.addChatMessage( new TranslatableText( "chat.computercraft.wired_modem.peripheral_disconnected",
|
||||||
CommandCopy.createCopyText( oldName ) ), false );
|
CommandCopy.createCopyText( oldName ) ), false );
|
||||||
}
|
}
|
||||||
if( newName != null )
|
if( newName != null )
|
||||||
{
|
{
|
||||||
player.addChatMessage( new TranslatableComponent( "chat.computercraft.wired_modem.peripheral_connected",
|
player.addChatMessage( new TranslatableText( "chat.computercraft.wired_modem.peripheral_connected",
|
||||||
CommandCopy.createCopyText( newName ) ), false );
|
CommandCopy.createCopyText( newName ) ), false );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -22,8 +22,8 @@ import dan200.computercraft.shared.util.TickScheduler;
|
|||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.chat.TextComponent;
|
import net.minecraft.text.LiteralText;
|
||||||
import net.minecraft.network.chat.TranslatableComponent;
|
import net.minecraft.text.TranslatableText;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.hit.BlockHitResult;
|
import net.minecraft.util.hit.BlockHitResult;
|
||||||
@@ -194,14 +194,14 @@ public class TileWiredModemFull extends TileGeneric implements IPeripheralTile
|
|||||||
List<String> names = new ArrayList<>( peripherals );
|
List<String> names = new ArrayList<>( peripherals );
|
||||||
names.sort( Comparator.naturalOrder() );
|
names.sort( Comparator.naturalOrder() );
|
||||||
|
|
||||||
TextComponent base = new TextComponent( "" );
|
LiteralText base = new LiteralText( "" );
|
||||||
for( int i = 0; i < names.size(); i++ )
|
for( int i = 0; i < names.size(); i++ )
|
||||||
{
|
{
|
||||||
if( i > 0 ) base.append( ", " );
|
if( i > 0 ) base.append( ", " );
|
||||||
base.append( CommandCopy.createCopyText( names.get( i ) ) );
|
base.append( CommandCopy.createCopyText( names.get( i ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
player.addChatMessage( new TranslatableComponent( kind, base ), false );
|
player.addChatMessage( new TranslatableText( kind, base ), false );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -32,7 +32,7 @@ import javax.annotation.Nullable;
|
|||||||
public class BlockWirelessModem extends BlockGeneric implements WaterloggableBlock
|
public class BlockWirelessModem extends BlockGeneric implements WaterloggableBlock
|
||||||
{
|
{
|
||||||
public static final DirectionProperty FACING = Properties.FACING;
|
public static final DirectionProperty FACING = Properties.FACING;
|
||||||
public static final BooleanProperty ON = BooleanProperty.create( "on" );
|
public static final BooleanProperty ON = BooleanProperty.of( "on" );
|
||||||
|
|
||||||
public BlockWirelessModem( Settings settings, NamedBlockEntityType<? extends TileWirelessModem> type )
|
public BlockWirelessModem( Settings settings, NamedBlockEntityType<? extends TileWirelessModem> type )
|
||||||
{
|
{
|
||||||
@@ -91,7 +91,7 @@ public class BlockWirelessModem extends BlockGeneric implements WaterloggableBlo
|
|||||||
public BlockState getPlacementState( ItemPlacementContext placement )
|
public BlockState getPlacementState( ItemPlacementContext placement )
|
||||||
{
|
{
|
||||||
return getDefaultState()
|
return getDefaultState()
|
||||||
.with( FACING, placement.getFacing().getOpposite() )
|
.with( FACING, placement.getSide().getOpposite() )
|
||||||
.with( WATERLOGGED, getWaterloggedStateForPlacement( placement ) );
|
.with( WATERLOGGED, getWaterloggedStateForPlacement( placement ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -28,12 +28,12 @@ import javax.annotation.Nullable;
|
|||||||
|
|
||||||
public class BlockMonitor extends BlockGeneric
|
public class BlockMonitor extends BlockGeneric
|
||||||
{
|
{
|
||||||
public static final DirectionProperty ORIENTATION = DirectionProperty.create( "orientation",
|
public static final DirectionProperty ORIENTATION = DirectionProperty.of( "orientation",
|
||||||
Direction.UP, Direction.DOWN, Direction.NORTH );
|
Direction.UP, Direction.DOWN, Direction.NORTH );
|
||||||
|
|
||||||
public static final DirectionProperty FACING = Properties.FACING_HORIZONTAL;
|
public static final DirectionProperty FACING = Properties.HORIZONTAL_FACING;
|
||||||
|
|
||||||
static final EnumProperty<MonitorEdgeState> STATE = EnumProperty.create( "state", MonitorEdgeState.class );
|
static final EnumProperty<MonitorEdgeState> STATE = EnumProperty.of( "state", MonitorEdgeState.class );
|
||||||
|
|
||||||
public BlockMonitor( Settings settings, NamedBlockEntityType<? extends TileGeneric> type )
|
public BlockMonitor( Settings settings, NamedBlockEntityType<? extends TileGeneric> type )
|
||||||
{
|
{
|
||||||
@@ -78,7 +78,7 @@ public class BlockMonitor extends BlockGeneric
|
|||||||
}
|
}
|
||||||
|
|
||||||
return getDefaultState()
|
return getDefaultState()
|
||||||
.with( FACING, context.getPlayerHorizontalFacing().getOpposite() )
|
.with( FACING, context.getPlayerFacing().getOpposite() )
|
||||||
.with( ORIENTATION, orientation );
|
.with( ORIENTATION, orientation );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -25,9 +25,9 @@ import javax.annotation.Nullable;
|
|||||||
|
|
||||||
public class BlockPrinter extends BlockGeneric
|
public class BlockPrinter extends BlockGeneric
|
||||||
{
|
{
|
||||||
private static final DirectionProperty FACING = Properties.FACING_HORIZONTAL;
|
private static final DirectionProperty FACING = Properties.HORIZONTAL_FACING;
|
||||||
static final BooleanProperty TOP = BooleanProperty.create( "top" );
|
static final BooleanProperty TOP = BooleanProperty.of( "top" );
|
||||||
static final BooleanProperty BOTTOM = BooleanProperty.create( "bottom" );
|
static final BooleanProperty BOTTOM = BooleanProperty.of( "bottom" );
|
||||||
|
|
||||||
public BlockPrinter( Settings settings )
|
public BlockPrinter( Settings settings )
|
||||||
{
|
{
|
||||||
@@ -49,16 +49,16 @@ public class BlockPrinter extends BlockGeneric
|
|||||||
@Override
|
@Override
|
||||||
public BlockState getPlacementState( ItemPlacementContext placement )
|
public BlockState getPlacementState( ItemPlacementContext placement )
|
||||||
{
|
{
|
||||||
return getDefaultState().with( FACING, placement.getPlayerHorizontalFacing().getOpposite() );
|
return getDefaultState().with( FACING, placement.getPlayerFacing().getOpposite() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlaced( World world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack )
|
public void onPlaced( World world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack )
|
||||||
{
|
{
|
||||||
if( stack.hasDisplayName() )
|
if( stack.hasCustomName() )
|
||||||
{
|
{
|
||||||
BlockEntity tileentity = world.getBlockEntity( pos );
|
BlockEntity tileentity = world.getBlockEntity( pos );
|
||||||
if( tileentity instanceof TilePrinter ) ((TilePrinter) tileentity).customName = stack.getDisplayName();
|
if( tileentity instanceof TilePrinter ) ((TilePrinter) tileentity).customName = stack.getName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -112,7 +112,7 @@ public class ContainerPrinter extends Container
|
|||||||
slot.markDirty();
|
slot.markDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
if( stack.getAmount() == result.getAmount() ) return ItemStack.EMPTY;
|
if( stack.getCount() == result.getCount() ) return ItemStack.EMPTY;
|
||||||
|
|
||||||
slot.onTakeItem( player, stack );
|
slot.onTakeItem( player, stack );
|
||||||
return result;
|
return result;
|
||||||
|
@@ -22,8 +22,8 @@ import net.minecraft.item.Item;
|
|||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.Items;
|
import net.minecraft.item.Items;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.text.LiteralText;
|
||||||
import net.minecraft.network.chat.TextComponent;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.*;
|
import net.minecraft.util.*;
|
||||||
import net.minecraft.util.hit.BlockHitResult;
|
import net.minecraft.util.hit.BlockHitResult;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
@@ -52,9 +52,9 @@ public final class TilePrinter extends TileGeneric implements DefaultSidedInvent
|
|||||||
private static final int[] TOP_SLOTS = new int[] { 1, 2, 3, 4, 5, 6 };
|
private static final int[] TOP_SLOTS = new int[] { 1, 2, 3, 4, 5, 6 };
|
||||||
private static final int[] SIDE_SLOTS = new int[] { 0 };
|
private static final int[] SIDE_SLOTS = new int[] { 0 };
|
||||||
|
|
||||||
Component customName;
|
Text customName;
|
||||||
|
|
||||||
private final DefaultedList<ItemStack> m_inventory = DefaultedList.create( INVENTORY_SIZE, ItemStack.EMPTY );
|
private final DefaultedList<ItemStack> m_inventory = DefaultedList.ofSize( INVENTORY_SIZE, ItemStack.EMPTY );
|
||||||
private final ItemStorage m_itemHandlerAll = ItemStorage.wrap( this );
|
private final ItemStorage m_itemHandlerAll = ItemStorage.wrap( this );
|
||||||
|
|
||||||
private final Terminal m_page = new Terminal( ItemPrintout.LINE_MAX_LENGTH, ItemPrintout.LINES_PER_PAGE );
|
private final Terminal m_page = new Terminal( ItemPrintout.LINE_MAX_LENGTH, ItemPrintout.LINES_PER_PAGE );
|
||||||
@@ -86,7 +86,7 @@ public final class TilePrinter extends TileGeneric implements DefaultSidedInvent
|
|||||||
{
|
{
|
||||||
super.fromTag( nbt );
|
super.fromTag( nbt );
|
||||||
|
|
||||||
customName = nbt.containsKey( NBT_NAME ) ? TextComponent.Serializer.fromJsonString( nbt.getString( NBT_NAME ) ) : null;
|
customName = nbt.containsKey( NBT_NAME ) ? LiteralText.Serializer.fromJson( nbt.getString( NBT_NAME ) ) : null;
|
||||||
|
|
||||||
// Read page
|
// Read page
|
||||||
synchronized( m_page )
|
synchronized( m_page )
|
||||||
@@ -107,7 +107,7 @@ public final class TilePrinter extends TileGeneric implements DefaultSidedInvent
|
|||||||
@Override
|
@Override
|
||||||
public CompoundTag toTag( CompoundTag nbt )
|
public CompoundTag toTag( CompoundTag nbt )
|
||||||
{
|
{
|
||||||
if( customName != null ) nbt.putString( NBT_NAME, TextComponent.Serializer.toJsonString( customName ) );
|
if( customName != null ) nbt.putString( NBT_NAME, LiteralText.Serializer.toJson( customName ) );
|
||||||
|
|
||||||
// Write page
|
// Write page
|
||||||
synchronized( m_page )
|
synchronized( m_page )
|
||||||
@@ -130,14 +130,14 @@ public final class TilePrinter extends TileGeneric implements DefaultSidedInvent
|
|||||||
protected void writeDescription( @Nonnull CompoundTag nbt )
|
protected void writeDescription( @Nonnull CompoundTag nbt )
|
||||||
{
|
{
|
||||||
super.writeDescription( nbt );
|
super.writeDescription( nbt );
|
||||||
if( customName != null ) nbt.putString( NBT_NAME, TextComponent.Serializer.toJsonString( customName ) );
|
if( customName != null ) nbt.putString( NBT_NAME, LiteralText.Serializer.toJson( customName ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readDescription( @Nonnull CompoundTag nbt )
|
public void readDescription( @Nonnull CompoundTag nbt )
|
||||||
{
|
{
|
||||||
super.readDescription( nbt );
|
super.readDescription( nbt );
|
||||||
customName = nbt.containsKey( NBT_NAME ) ? TextComponent.Serializer.fromJsonString( nbt.getString( NBT_NAME ) ) : null;
|
customName = nbt.containsKey( NBT_NAME ) ? LiteralText.Serializer.fromJson( nbt.getString( NBT_NAME ) ) : null;
|
||||||
updateBlock();
|
updateBlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,7 +192,7 @@ public final class TilePrinter extends TileGeneric implements DefaultSidedInvent
|
|||||||
{
|
{
|
||||||
if( m_inventory.get( i ).isEmpty() ) return ItemStack.EMPTY;
|
if( m_inventory.get( i ).isEmpty() ) return ItemStack.EMPTY;
|
||||||
|
|
||||||
if( m_inventory.get( i ).getAmount() <= j )
|
if( m_inventory.get( i ).getCount() <= j )
|
||||||
{
|
{
|
||||||
ItemStack itemstack = m_inventory.get( i );
|
ItemStack itemstack = m_inventory.get( i );
|
||||||
m_inventory.set( i, ItemStack.EMPTY );
|
m_inventory.set( i, ItemStack.EMPTY );
|
||||||
@@ -313,7 +313,7 @@ public final class TilePrinter extends TileGeneric implements DefaultSidedInvent
|
|||||||
synchronized( m_inventory )
|
synchronized( m_inventory )
|
||||||
{
|
{
|
||||||
ItemStack inkStack = m_inventory.get( 0 );
|
ItemStack inkStack = m_inventory.get( 0 );
|
||||||
return isInk( inkStack ) ? inkStack.getAmount() : 0;
|
return isInk( inkStack ) ? inkStack.getCount() : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -327,7 +327,7 @@ public final class TilePrinter extends TileGeneric implements DefaultSidedInvent
|
|||||||
ItemStack paperStack = m_inventory.get( i );
|
ItemStack paperStack = m_inventory.get( i );
|
||||||
if( !paperStack.isEmpty() && isPaper( paperStack ) )
|
if( !paperStack.isEmpty() && isPaper( paperStack ) )
|
||||||
{
|
{
|
||||||
count += paperStack.getAmount();
|
count += paperStack.getCount();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -397,11 +397,11 @@ public final class TilePrinter extends TileGeneric implements DefaultSidedInvent
|
|||||||
m_page.setCursorPos( 0, 0 );
|
m_page.setCursorPos( 0, 0 );
|
||||||
|
|
||||||
// Decrement ink
|
// Decrement ink
|
||||||
inkStack.subtractAmount( 1 );
|
inkStack.decrement( 1 );
|
||||||
if( inkStack.isEmpty() ) m_inventory.set( 0, ItemStack.EMPTY );
|
if( inkStack.isEmpty() ) m_inventory.set( 0, ItemStack.EMPTY );
|
||||||
|
|
||||||
// Decrement paper
|
// Decrement paper
|
||||||
paperStack.subtractAmount( 1 );
|
paperStack.decrement( 1 );
|
||||||
if( paperStack.isEmpty() )
|
if( paperStack.isEmpty() )
|
||||||
{
|
{
|
||||||
m_inventory.set( i, ItemStack.EMPTY );
|
m_inventory.set( i, ItemStack.EMPTY );
|
||||||
@@ -529,15 +529,15 @@ public final class TilePrinter extends TileGeneric implements DefaultSidedInvent
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public Component getCustomName()
|
public Text getCustomName()
|
||||||
{
|
{
|
||||||
return customName;
|
return customName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public Component getName()
|
public Text getName()
|
||||||
{
|
{
|
||||||
return customName != null ? customName : getCachedState().getBlock().getTextComponent();
|
return customName != null ? customName : getCachedState().getBlock().getName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -19,7 +19,7 @@ import javax.annotation.Nullable;
|
|||||||
|
|
||||||
public class BlockSpeaker extends BlockGeneric
|
public class BlockSpeaker extends BlockGeneric
|
||||||
{
|
{
|
||||||
private static final DirectionProperty FACING = Properties.FACING_HORIZONTAL;
|
private static final DirectionProperty FACING = Properties.HORIZONTAL_FACING;
|
||||||
|
|
||||||
public BlockSpeaker( Settings settings )
|
public BlockSpeaker( Settings settings )
|
||||||
{
|
{
|
||||||
@@ -38,6 +38,6 @@ public class BlockSpeaker extends BlockGeneric
|
|||||||
@Override
|
@Override
|
||||||
public BlockState getPlacementState( ItemPlacementContext placement )
|
public BlockState getPlacementState( ItemPlacementContext placement )
|
||||||
{
|
{
|
||||||
return getDefaultState().with( FACING, placement.getPlayerHorizontalFacing().getOpposite() );
|
return getDefaultState().with( FACING, placement.getPlayerFacing().getOpposite() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -138,7 +138,7 @@ public class PocketAPI implements ILuaAPI
|
|||||||
{
|
{
|
||||||
// Consume an item from this stack and exit the loop
|
// Consume an item from this stack and exit the loop
|
||||||
invStack = invStack.copy();
|
invStack = invStack.copy();
|
||||||
invStack.subtractAmount( 1 );
|
invStack.decrement( 1 );
|
||||||
inv.set( (i + start) % inv.size(), invStack.isEmpty() ? ItemStack.EMPTY : invStack );
|
inv.set( (i + start) % inv.size(), invStack.isEmpty() ? ItemStack.EMPTY : invStack );
|
||||||
|
|
||||||
return newUpgrade;
|
return newUpgrade;
|
||||||
|
@@ -25,7 +25,6 @@ import dan200.computercraft.shared.pocket.apis.PocketAPI;
|
|||||||
import dan200.computercraft.shared.pocket.core.PocketServerComputer;
|
import dan200.computercraft.shared.pocket.core.PocketServerComputer;
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.minecraft.ChatFormat;
|
|
||||||
import net.minecraft.client.item.TooltipContext;
|
import net.minecraft.client.item.TooltipContext;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
@@ -35,9 +34,9 @@ import net.minecraft.item.ItemGroup;
|
|||||||
import net.minecraft.item.ItemPropertyGetter;
|
import net.minecraft.item.ItemPropertyGetter;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.text.LiteralText;
|
||||||
import net.minecraft.network.chat.TextComponent;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.network.chat.TranslatableComponent;
|
import net.minecraft.text.TranslatableText;
|
||||||
import net.minecraft.util.*;
|
import net.minecraft.util.*;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
@@ -60,24 +59,24 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I
|
|||||||
{
|
{
|
||||||
super( settings );
|
super( settings );
|
||||||
this.family = family;
|
this.family = family;
|
||||||
addProperty( new Identifier( ComputerCraft.MOD_ID, "state" ), COMPUTER_STATE );
|
addPropertyGetter( new Identifier( ComputerCraft.MOD_ID, "state" ), COMPUTER_STATE );
|
||||||
addProperty( new Identifier( ComputerCraft.MOD_ID, "coloured" ), COMPUTER_COLOURED );
|
addPropertyGetter( new Identifier( ComputerCraft.MOD_ID, "coloured" ), COMPUTER_COLOURED );
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack create( int id, String label, int colour, IPocketUpgrade upgrade )
|
public ItemStack create( int id, String label, int colour, IPocketUpgrade upgrade )
|
||||||
{
|
{
|
||||||
ItemStack result = new ItemStack( this );
|
ItemStack result = new ItemStack( this );
|
||||||
if( id >= 0 ) result.getOrCreateTag().putInt( NBT_ID, id );
|
if( id >= 0 ) result.getOrCreateTag().putInt( NBT_ID, id );
|
||||||
if( label != null ) result.setDisplayName( new TextComponent( label ) );
|
if( label != null ) result.setCustomName( new LiteralText( label ) );
|
||||||
if( upgrade != null ) result.getOrCreateTag().putString( NBT_UPGRADE, upgrade.getUpgradeID().toString() );
|
if( upgrade != null ) result.getOrCreateTag().putString( NBT_UPGRADE, upgrade.getUpgradeID().toString() );
|
||||||
if( colour != -1 ) result.getOrCreateTag().putInt( NBT_COLOUR, colour );
|
if( colour != -1 ) result.getOrCreateTag().putInt( NBT_COLOUR, colour );
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void appendItemsForGroup( ItemGroup group, DefaultedList<ItemStack> stacks )
|
public void appendStacks( ItemGroup group, DefaultedList<ItemStack> stacks )
|
||||||
{
|
{
|
||||||
if( !isInItemGroup( group ) ) return;
|
if( !isIn( group ) ) return;
|
||||||
stacks.add( create( -1, null, -1, null ) );
|
stacks.add( create( -1, null, -1, null ) );
|
||||||
for( IPocketUpgrade upgrade : PocketUpgrades.getVanillaUpgrades() )
|
for( IPocketUpgrade upgrade : PocketUpgrades.getVanillaUpgrades() )
|
||||||
{
|
{
|
||||||
@@ -86,7 +85,7 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEntityTick( ItemStack stack, World world, Entity entity, int slotNum, boolean selected )
|
public void inventoryTick( ItemStack stack, World world, Entity entity, int slotNum, boolean selected )
|
||||||
{
|
{
|
||||||
if( !world.isClient )
|
if( !world.isClient )
|
||||||
{
|
{
|
||||||
@@ -161,33 +160,33 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I
|
|||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public Component getTranslatedNameTrimmed( @Nonnull ItemStack stack )
|
public Text getName( @Nonnull ItemStack stack )
|
||||||
{
|
{
|
||||||
String baseString = getTranslationKey( stack );
|
String baseString = getTranslationKey( stack );
|
||||||
IPocketUpgrade upgrade = getUpgrade( stack );
|
IPocketUpgrade upgrade = getUpgrade( stack );
|
||||||
if( upgrade != null )
|
if( upgrade != null )
|
||||||
{
|
{
|
||||||
return new TranslatableComponent( baseString + ".upgraded",
|
return new TranslatableText( baseString + ".upgraded",
|
||||||
new TranslatableComponent( upgrade.getUnlocalisedAdjective() )
|
new TranslatableText( upgrade.getUnlocalisedAdjective() )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return super.getTranslatedNameTrimmed( stack );
|
return super.getName( stack );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void buildTooltip( ItemStack stack, @Nullable World world, List<Component> list, TooltipContext flag )
|
public void appendTooltip( ItemStack stack, @Nullable World world, List<Text> list, TooltipContext flag )
|
||||||
{
|
{
|
||||||
if( flag.isAdvanced() )
|
if( flag.isAdvanced() )
|
||||||
{
|
{
|
||||||
int id = getComputerID( stack );
|
int id = getComputerID( stack );
|
||||||
if( id >= 0 )
|
if( id >= 0 )
|
||||||
{
|
{
|
||||||
list.add( new TranslatableComponent( "gui.computercraft.tooltip.computer_id", id )
|
list.add( new TranslatableText( "gui.computercraft.tooltip.computer_id", id )
|
||||||
.applyFormat( ChatFormat.GRAY ) );
|
.formatted( Formatting.GRAY ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -297,11 +296,11 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I
|
|||||||
{
|
{
|
||||||
if( label != null )
|
if( label != null )
|
||||||
{
|
{
|
||||||
stack.setDisplayName( new TextComponent( label ) );
|
stack.setCustomName( new LiteralText( label ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
stack.removeDisplayName();
|
stack.removeCustomName();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -387,7 +386,7 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I
|
|||||||
|
|
||||||
public static CompoundTag getUpgradeInfo( @Nonnull ItemStack stack )
|
public static CompoundTag getUpgradeInfo( @Nonnull ItemStack stack )
|
||||||
{
|
{
|
||||||
return stack.getOrCreateSubCompoundTag( NBT_UPGRADE_INFO );
|
return stack.getOrCreateSubTag( NBT_UPGRADE_INFO );
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final ItemPropertyGetter COMPUTER_STATE = ( stack, world, player ) -> getState( stack ).ordinal();
|
private static final ItemPropertyGetter COMPUTER_STATE = ( stack, world, player ) -> getState( stack ).ordinal();
|
||||||
|
@@ -65,16 +65,6 @@ public class ComputerCraftProxyCommon
|
|||||||
registerProviders();
|
registerProviders();
|
||||||
registerHandlers();
|
registerHandlers();
|
||||||
|
|
||||||
RecipeSerializer.register( ComputerCraft.MOD_ID + ":colour", ColourableRecipe.SERIALIZER );
|
|
||||||
RecipeSerializer.register( ComputerCraft.MOD_ID + ":computer_upgrade", ComputerUpgradeRecipe.SERIALIZER );
|
|
||||||
RecipeSerializer.register( ComputerCraft.MOD_ID + ":pocket_computer_upgrade", PocketComputerUpgradeRecipe.SERIALIZER );
|
|
||||||
RecipeSerializer.register( ComputerCraft.MOD_ID + ":disk", DiskRecipe.SERIALIZER );
|
|
||||||
RecipeSerializer.register( ComputerCraft.MOD_ID + ":printout", PrintoutRecipe.SERIALIZER );
|
|
||||||
RecipeSerializer.register( ComputerCraft.MOD_ID + ":turtle", TurtleRecipe.SERIALIZER );
|
|
||||||
RecipeSerializer.register( ComputerCraft.MOD_ID + ":turtle_upgrade", TurtleUpgradeRecipe.SERIALIZER );
|
|
||||||
RecipeSerializer.register( ComputerCraft.MOD_ID + ":impostor_shapeless", ImpostorShapelessRecipe.SERIALIZER );
|
|
||||||
RecipeSerializer.register( ComputerCraft.MOD_ID + ":impostor_shaped", ImpostorRecipe.SERIALIZER );
|
|
||||||
|
|
||||||
ArgumentSerializers.register();
|
ArgumentSerializers.register();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -31,7 +31,7 @@ public final class FurnaceRefuelHandler implements TurtleRefuelEvent.Handler
|
|||||||
{
|
{
|
||||||
ItemStorage storage = ItemStorage.wrap( turtle.getInventory() );
|
ItemStorage storage = ItemStorage.wrap( turtle.getInventory() );
|
||||||
ItemStack stack = storage.take( slot, limit, ItemStack.EMPTY, false );
|
ItemStack stack = storage.take( slot, limit, ItemStack.EMPTY, false );
|
||||||
int fuelToGive = getFuelPerItem( stack ) * stack.getAmount();
|
int fuelToGive = getFuelPerItem( stack ) * stack.getCount();
|
||||||
|
|
||||||
// Store the replacement item in the inventory
|
// Store the replacement item in the inventory
|
||||||
Item replacementStack = stack.getItem().getRecipeRemainder();
|
Item replacementStack = stack.getItem().getRecipeRemainder();
|
||||||
|
@@ -222,14 +222,14 @@ public class TurtleAPI implements ILuaAPI
|
|||||||
// getItemCount
|
// getItemCount
|
||||||
int slot = parseOptionalSlotNumber( args, 0, m_turtle.getSelectedSlot() );
|
int slot = parseOptionalSlotNumber( args, 0, m_turtle.getSelectedSlot() );
|
||||||
ItemStack stack = m_turtle.getInventory().getInvStack( slot );
|
ItemStack stack = m_turtle.getInventory().getInvStack( slot );
|
||||||
return new Object[] { stack.getAmount() };
|
return new Object[] { stack.getCount() };
|
||||||
}
|
}
|
||||||
case 15:
|
case 15:
|
||||||
{
|
{
|
||||||
// getItemSpace
|
// getItemSpace
|
||||||
int slot = parseOptionalSlotNumber( args, 0, m_turtle.getSelectedSlot() );
|
int slot = parseOptionalSlotNumber( args, 0, m_turtle.getSelectedSlot() );
|
||||||
ItemStack stack = m_turtle.getInventory().getInvStack( slot );
|
ItemStack stack = m_turtle.getInventory().getInvStack( slot );
|
||||||
return new Object[] { stack.isEmpty() ? 64 : Math.min( stack.getMaxAmount(), 64 ) - stack.getAmount() };
|
return new Object[] { stack.isEmpty() ? 64 : Math.min( stack.getMaxCount(), 64 ) - stack.getCount() };
|
||||||
}
|
}
|
||||||
case 16: // detect
|
case 16: // detect
|
||||||
return tryCommand( context, new TurtleDetectCommand( InteractDirection.Forward ) );
|
return tryCommand( context, new TurtleDetectCommand( InteractDirection.Forward ) );
|
||||||
@@ -346,7 +346,7 @@ public class TurtleAPI implements ILuaAPI
|
|||||||
|
|
||||||
Item item = stack.getItem();
|
Item item = stack.getItem();
|
||||||
String name = Registry.ITEM.getId( item ).toString();
|
String name = Registry.ITEM.getId( item ).toString();
|
||||||
int count = stack.getAmount();
|
int count = stack.getCount();
|
||||||
|
|
||||||
Map<String, Object> table = new HashMap<>();
|
Map<String, Object> table = new HashMap<>();
|
||||||
table.put( "name", name );
|
table.put( "name", name );
|
||||||
|
@@ -43,7 +43,7 @@ import javax.annotation.Nullable;
|
|||||||
|
|
||||||
public class BlockTurtle extends BlockComputerBase<TileTurtle> implements WaterloggableBlock
|
public class BlockTurtle extends BlockComputerBase<TileTurtle> implements WaterloggableBlock
|
||||||
{
|
{
|
||||||
public static final DirectionProperty FACING = Properties.FACING_HORIZONTAL;
|
public static final DirectionProperty FACING = Properties.HORIZONTAL_FACING;
|
||||||
|
|
||||||
private static final VoxelShape DEFAULT_SHAPE = VoxelShapes.cuboid(
|
private static final VoxelShape DEFAULT_SHAPE = VoxelShapes.cuboid(
|
||||||
0.125, 0.125, 0.125,
|
0.125, 0.125, 0.125,
|
||||||
@@ -88,7 +88,7 @@ public class BlockTurtle extends BlockComputerBase<TileTurtle> implements Waterl
|
|||||||
public BlockState getPlacementState( ItemPlacementContext placement )
|
public BlockState getPlacementState( ItemPlacementContext placement )
|
||||||
{
|
{
|
||||||
return getDefaultState()
|
return getDefaultState()
|
||||||
.with( FACING, placement.getPlayerHorizontalFacing() )
|
.with( FACING, placement.getPlayerFacing() )
|
||||||
.with( WATERLOGGED, getWaterloggedStateForPlacement( placement ) );
|
.with( WATERLOGGED, getWaterloggedStateForPlacement( placement ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -76,8 +76,8 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
|
|||||||
public TileTurtle( BlockEntityType<? extends TileGeneric> type, ComputerFamily family )
|
public TileTurtle( BlockEntityType<? extends TileGeneric> type, ComputerFamily family )
|
||||||
{
|
{
|
||||||
super( type, family );
|
super( type, family );
|
||||||
m_inventory = DefaultedList.create( INVENTORY_SIZE, ItemStack.EMPTY );
|
m_inventory = DefaultedList.ofSize( INVENTORY_SIZE, ItemStack.EMPTY );
|
||||||
m_previousInventory = DefaultedList.create( INVENTORY_SIZE, ItemStack.EMPTY );
|
m_previousInventory = DefaultedList.ofSize( INVENTORY_SIZE, ItemStack.EMPTY );
|
||||||
m_inventoryChanged = false;
|
m_inventoryChanged = false;
|
||||||
m_brain = new TurtleBrain( this );
|
m_brain = new TurtleBrain( this );
|
||||||
m_moveState = MoveState.NOT_MOVED;
|
m_moveState = MoveState.NOT_MOVED;
|
||||||
@@ -166,7 +166,7 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
|
|||||||
m_brain.setDyeColour( dye );
|
m_brain.setDyeColour( dye );
|
||||||
if( !player.isCreative() )
|
if( !player.isCreative() )
|
||||||
{
|
{
|
||||||
currentItem.subtractAmount( 1 );
|
currentItem.decrement( 1 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -269,8 +269,8 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
|
|||||||
|
|
||||||
// Read inventory
|
// Read inventory
|
||||||
ListTag nbttaglist = nbt.getList( "Items", NBTUtil.TAG_COMPOUND );
|
ListTag nbttaglist = nbt.getList( "Items", NBTUtil.TAG_COMPOUND );
|
||||||
m_inventory = DefaultedList.create( INVENTORY_SIZE, ItemStack.EMPTY );
|
m_inventory = DefaultedList.ofSize( INVENTORY_SIZE, ItemStack.EMPTY );
|
||||||
m_previousInventory = DefaultedList.create( INVENTORY_SIZE, ItemStack.EMPTY );
|
m_previousInventory = DefaultedList.ofSize( INVENTORY_SIZE, ItemStack.EMPTY );
|
||||||
for( int i = 0; i < nbttaglist.size(); i++ )
|
for( int i = 0; i < nbttaglist.size(); i++ )
|
||||||
{
|
{
|
||||||
CompoundTag tag = nbttaglist.getCompoundTag( i );
|
CompoundTag tag = nbttaglist.getCompoundTag( i );
|
||||||
@@ -444,7 +444,7 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
|
|||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( stack.getAmount() <= count )
|
if( stack.getCount() <= count )
|
||||||
{
|
{
|
||||||
setInvStack( slot, ItemStack.EMPTY );
|
setInvStack( slot, ItemStack.EMPTY );
|
||||||
return stack;
|
return stack;
|
||||||
@@ -503,7 +503,7 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
|
|||||||
{
|
{
|
||||||
for( int n = 0; n < getInvSize(); n++ )
|
for( int n = 0; n < getInvSize(); n++ )
|
||||||
{
|
{
|
||||||
if( !ItemStack.areEqual( getInvStack( n ), m_previousInventory.get( n ) ) )
|
if( !ItemStack.areEqualIgnoreDamage( getInvStack( n ), m_previousInventory.get( n ) ) )
|
||||||
{
|
{
|
||||||
m_inventoryChanged = true;
|
m_inventoryChanged = true;
|
||||||
break;
|
break;
|
||||||
|
@@ -38,7 +38,7 @@ import net.minecraft.tag.FluidTags;
|
|||||||
import net.minecraft.util.DyeColor;
|
import net.minecraft.util.DyeColor;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.BoundingBox;
|
import net.minecraft.util.math.Box;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
@@ -891,7 +891,7 @@ public class TurtleBrain implements ITurtleAccess
|
|||||||
maxZ -= moveDir.getOffsetZ() * push;
|
maxZ -= moveDir.getOffsetZ() * push;
|
||||||
}
|
}
|
||||||
|
|
||||||
BoundingBox aabb = new BoundingBox( minX, minY, minZ, maxX, maxY, maxZ );
|
Box aabb = new Box( minX, minY, minZ, maxX, maxY, maxZ );
|
||||||
List<Entity> list = world.getEntities( (Entity) null, aabb, EntityPredicates.EXCEPT_SPECTATOR );
|
List<Entity> list = world.getEntities( (Entity) null, aabb, EntityPredicates.EXCEPT_SPECTATOR );
|
||||||
if( !list.isEmpty() )
|
if( !list.isEmpty() )
|
||||||
{
|
{
|
||||||
|
@@ -78,6 +78,6 @@ public class TurtleInspectCommand implements ITurtleCommand
|
|||||||
private static Object getPropertyValue( Property property, Comparable value )
|
private static Object getPropertyValue( Property property, Comparable value )
|
||||||
{
|
{
|
||||||
if( value instanceof String || value instanceof Number || value instanceof Boolean ) return value;
|
if( value instanceof String || value instanceof Number || value instanceof Boolean ) return value;
|
||||||
return property.getValueAsString( value );
|
return property.getName( value );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,7 +20,7 @@ import net.minecraft.block.BlockState;
|
|||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.predicate.entity.EntityPredicates;
|
import net.minecraft.predicate.entity.EntityPredicates;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.BoundingBox;
|
import net.minecraft.util.math.Box;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.util.shape.VoxelShape;
|
import net.minecraft.util.shape.VoxelShape;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
@@ -68,7 +68,7 @@ public class TurtleMoveCommand implements ITurtleCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check there isn't anything in the way
|
// Check there isn't anything in the way
|
||||||
BoundingBox aabb = getBox( state.getCollisionShape( oldWorld, oldPosition ) );
|
Box aabb = getBox( state.getCollisionShape( oldWorld, oldPosition ) );
|
||||||
aabb = aabb.offset(
|
aabb = aabb.offset(
|
||||||
newPosition.getX(),
|
newPosition.getX(),
|
||||||
newPosition.getY(),
|
newPosition.getY(),
|
||||||
@@ -85,10 +85,10 @@ public class TurtleMoveCommand implements ITurtleCommand
|
|||||||
List<Entity> list = oldWorld.getEntities( (Entity) null, aabb, EntityPredicates.VALID_ENTITY );
|
List<Entity> list = oldWorld.getEntities( (Entity) null, aabb, EntityPredicates.VALID_ENTITY );
|
||||||
for( Entity entity : list )
|
for( Entity entity : list )
|
||||||
{
|
{
|
||||||
BoundingBox entityBB = entity.getBoundingBox();
|
Box entityBB = entity.getBoundingBox();
|
||||||
if( entityBB == null ) continue;
|
if( entityBB == null ) continue;
|
||||||
|
|
||||||
BoundingBox pushedBB = entityBB.offset(
|
Box pushedBB = entityBB.offset(
|
||||||
direction.getOffsetX(),
|
direction.getOffsetX(),
|
||||||
direction.getOffsetY(),
|
direction.getOffsetY(),
|
||||||
direction.getOffsetZ()
|
direction.getOffsetZ()
|
||||||
@@ -164,10 +164,10 @@ public class TurtleMoveCommand implements ITurtleCommand
|
|||||||
return TurtleCommandResult.success();
|
return TurtleCommandResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static BoundingBox getBox( VoxelShape shape )
|
private static Box getBox( VoxelShape shape )
|
||||||
{
|
{
|
||||||
return shape.isEmpty() ? EMPTY_BOX : shape.getBoundingBox();
|
return shape.isEmpty() ? EMPTY_BOX : shape.getBoundingBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final BoundingBox EMPTY_BOX = new BoundingBox( 0, 0, 0, 0, 0, 0 );
|
private static final Box EMPTY_BOX = new Box( 0, 0, 0, 0, 0, 0 );
|
||||||
}
|
}
|
||||||
|
@@ -21,7 +21,7 @@ import net.minecraft.block.entity.SignBlockEntity;
|
|||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.item.*;
|
import net.minecraft.item.*;
|
||||||
import net.minecraft.network.chat.TextComponent;
|
import net.minecraft.text.LiteralText;
|
||||||
import net.minecraft.util.ActionResult;
|
import net.minecraft.util.ActionResult;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.TypedActionResult;
|
import net.minecraft.util.TypedActionResult;
|
||||||
@@ -253,7 +253,7 @@ public class TurtlePlaceCommand implements ITurtleCommand
|
|||||||
}
|
}
|
||||||
else if( hitEntity instanceof LivingEntity )
|
else if( hitEntity instanceof LivingEntity )
|
||||||
{
|
{
|
||||||
placed = stackCopy.interactWithEntity( turtlePlayer, (LivingEntity) hitEntity, Hand.MAIN_HAND );
|
placed = stackCopy.useOnEntity( turtlePlayer, (LivingEntity) hitEntity, Hand.MAIN_HAND );
|
||||||
if( placed ) turtlePlayer.loadInventory( stackCopy );
|
if( placed ) turtlePlayer.loadInventory( stackCopy );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -268,7 +268,7 @@ public class TurtlePlaceCommand implements ITurtleCommand
|
|||||||
|
|
||||||
// Put everything we collected into the turtles inventory, then return
|
// Put everything we collected into the turtles inventory, then return
|
||||||
ItemStack remainder = turtlePlayer.unloadInventory( turtle );
|
ItemStack remainder = turtlePlayer.unloadInventory( turtle );
|
||||||
if( !placed && ItemStack.areEqual( stack, remainder ) )
|
if( !placed && ItemStack.areEqualIgnoreDamage( stack, remainder ) )
|
||||||
{
|
{
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
@@ -286,7 +286,7 @@ public class TurtlePlaceCommand implements ITurtleCommand
|
|||||||
{
|
{
|
||||||
World world = turtle.getWorld();
|
World world = turtle.getWorld();
|
||||||
if( !World.isValid( position ) || world.isAir( position ) ||
|
if( !World.isValid( position ) || world.isAir( position ) ||
|
||||||
(context.getItemStack().getItem() instanceof BlockItem && WorldUtil.isLiquidBlock( world, position )) )
|
(context.getStack().getItem() instanceof BlockItem && WorldUtil.isLiquidBlock( world, position )) )
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -375,7 +375,7 @@ public class TurtlePlaceCommand implements ITurtleCommand
|
|||||||
else if( actionResult == null )
|
else if( actionResult == null )
|
||||||
{
|
{
|
||||||
TypedActionResult<ItemStack> result = stackCopy.use( turtle.getWorld(), turtlePlayer, Hand.MAIN_HAND );
|
TypedActionResult<ItemStack> result = stackCopy.use( turtle.getWorld(), turtlePlayer, Hand.MAIN_HAND );
|
||||||
if( result.getResult() == ActionResult.SUCCESS && !ItemStack.areEqual( stack, result.getValue() ) )
|
if( result.getResult() == ActionResult.SUCCESS && !ItemStack.areEqualIgnoreDamage( stack, result.getValue() ) )
|
||||||
{
|
{
|
||||||
placed = true;
|
placed = true;
|
||||||
turtlePlayer.loadInventory( result.getValue() );
|
turtlePlayer.loadInventory( result.getValue() );
|
||||||
@@ -406,27 +406,27 @@ public class TurtlePlaceCommand implements ITurtleCommand
|
|||||||
{
|
{
|
||||||
if( split[i - firstLine].length() > 15 )
|
if( split[i - firstLine].length() > 15 )
|
||||||
{
|
{
|
||||||
signTile.text[i] = new TextComponent( split[i - firstLine].substring( 0, 15 ) );
|
signTile.text[i] = new LiteralText( split[i - firstLine].substring( 0, 15 ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
signTile.text[i] = new TextComponent( split[i - firstLine] );
|
signTile.text[i] = new LiteralText( split[i - firstLine] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
signTile.text[i] = new TextComponent( "" );
|
signTile.text[i] = new LiteralText( "" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
signTile.markDirty();
|
signTile.markDirty();
|
||||||
world.scheduleBlockRender( signTile.getPos() ); // TODO: This doesn't do anything!
|
world.updateListeners( tile.getPos(), tile.getCachedState(), tile.getCachedState(), 3 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Put everything we collected into the turtles inventory, then return
|
// Put everything we collected into the turtles inventory, then return
|
||||||
ItemStack remainder = turtlePlayer.unloadInventory( turtle );
|
ItemStack remainder = turtlePlayer.unloadInventory( turtle );
|
||||||
if( !placed && ItemStack.areEqual( stack, remainder ) )
|
if( !placed && ItemStack.areEqualIgnoreDamage( stack, remainder ) )
|
||||||
{
|
{
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
|
@@ -20,7 +20,7 @@ import net.minecraft.inventory.Inventory;
|
|||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.predicate.entity.EntityPredicates;
|
import net.minecraft.predicate.entity.EntityPredicates;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.BoundingBox;
|
import net.minecraft.util.math.Box;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
@@ -97,7 +97,7 @@ public class TurtleSuckCommand implements ITurtleCommand
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Suck up loose items off the ground
|
// Suck up loose items off the ground
|
||||||
BoundingBox aabb = new BoundingBox(
|
Box aabb = new Box(
|
||||||
newPosition.getX(), newPosition.getY(), newPosition.getZ(),
|
newPosition.getX(), newPosition.getY(), newPosition.getZ(),
|
||||||
newPosition.getX() + 1.0, newPosition.getY() + 1.0, newPosition.getZ() + 1.0
|
newPosition.getX() + 1.0, newPosition.getY() + 1.0, newPosition.getZ() + 1.0
|
||||||
);
|
);
|
||||||
@@ -116,7 +116,7 @@ public class TurtleSuckCommand implements ITurtleCommand
|
|||||||
ItemStack stack = entityItem.getStack().copy();
|
ItemStack stack = entityItem.getStack().copy();
|
||||||
ItemStack storeStack;
|
ItemStack storeStack;
|
||||||
ItemStack leaveStack;
|
ItemStack leaveStack;
|
||||||
if( stack.getAmount() > m_quantity )
|
if( stack.getCount() > m_quantity )
|
||||||
{
|
{
|
||||||
storeStack = stack.split( m_quantity );
|
storeStack = stack.split( m_quantity );
|
||||||
leaveStack = stack;
|
leaveStack = stack;
|
||||||
@@ -144,7 +144,7 @@ public class TurtleSuckCommand implements ITurtleCommand
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
leaveStack.addAmount( remainder.getAmount() );
|
leaveStack.increment( remainder.getCount() );
|
||||||
entityItem.setStack( leaveStack );
|
entityItem.setStack( leaveStack );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@@ -129,7 +129,7 @@ public class ContainerTurtle extends Container implements IContainerComputer
|
|||||||
slot.markDirty();
|
slot.markDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
if( clickedStack.getAmount() != originalStack.getAmount() )
|
if( clickedStack.getCount() != originalStack.getCount() )
|
||||||
{
|
{
|
||||||
slot.onTakeItem( player, clickedStack );
|
slot.onTakeItem( player, clickedStack );
|
||||||
}
|
}
|
||||||
|
@@ -16,9 +16,9 @@ import dan200.computercraft.shared.turtle.blocks.BlockTurtle;
|
|||||||
import net.minecraft.item.ItemGroup;
|
import net.minecraft.item.ItemGroup;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.text.LiteralText;
|
||||||
import net.minecraft.network.chat.TextComponent;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.network.chat.TranslatableComponent;
|
import net.minecraft.text.TranslatableText;
|
||||||
import net.minecraft.util.DefaultedList;
|
import net.minecraft.util.DefaultedList;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ public class ItemTurtle extends ItemComputerBase implements ITurtleItem
|
|||||||
{
|
{
|
||||||
// Build the stack
|
// Build the stack
|
||||||
ItemStack stack = new ItemStack( this );
|
ItemStack stack = new ItemStack( this );
|
||||||
if( label != null ) stack.setDisplayName( new TextComponent( label ) );
|
if( label != null ) stack.setCustomName( new LiteralText( label ) );
|
||||||
if( id >= 0 ) stack.getOrCreateTag().putInt( NBT_ID, id );
|
if( id >= 0 ) stack.getOrCreateTag().putInt( NBT_ID, id );
|
||||||
IColouredItem.setColourBasic( stack, colour );
|
IColouredItem.setColourBasic( stack, colour );
|
||||||
if( fuelLevel > 0 ) stack.getOrCreateTag().putInt( NBT_FUEL, fuelLevel );
|
if( fuelLevel > 0 ) stack.getOrCreateTag().putInt( NBT_FUEL, fuelLevel );
|
||||||
@@ -57,9 +57,9 @@ public class ItemTurtle extends ItemComputerBase implements ITurtleItem
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void appendItemsForGroup( @Nonnull ItemGroup group, @Nonnull DefaultedList<ItemStack> list )
|
public void appendStacks( @Nonnull ItemGroup group, @Nonnull DefaultedList<ItemStack> list )
|
||||||
{
|
{
|
||||||
if( !isInItemGroup( group ) ) return;
|
if( !isIn( group ) ) return;
|
||||||
|
|
||||||
ComputerFamily family = getFamily();
|
ComputerFamily family = getFamily();
|
||||||
|
|
||||||
@@ -74,33 +74,33 @@ public class ItemTurtle extends ItemComputerBase implements ITurtleItem
|
|||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public Component getTranslatedNameTrimmed( @Nonnull ItemStack stack )
|
public Text getName( @Nonnull ItemStack stack )
|
||||||
{
|
{
|
||||||
String baseString = getTranslationKey( stack );
|
String baseString = getTranslationKey( stack );
|
||||||
ITurtleUpgrade left = getUpgrade( stack, TurtleSide.Left );
|
ITurtleUpgrade left = getUpgrade( stack, TurtleSide.Left );
|
||||||
ITurtleUpgrade right = getUpgrade( stack, TurtleSide.Right );
|
ITurtleUpgrade right = getUpgrade( stack, TurtleSide.Right );
|
||||||
if( left != null && right != null )
|
if( left != null && right != null )
|
||||||
{
|
{
|
||||||
return new TranslatableComponent( baseString + ".upgraded_twice",
|
return new TranslatableText( baseString + ".upgraded_twice",
|
||||||
new TranslatableComponent( right.getUnlocalisedAdjective() ),
|
new TranslatableText( right.getUnlocalisedAdjective() ),
|
||||||
new TranslatableComponent( left.getUnlocalisedAdjective() )
|
new TranslatableText( left.getUnlocalisedAdjective() )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if( left != null )
|
else if( left != null )
|
||||||
{
|
{
|
||||||
return new TranslatableComponent( baseString + ".upgraded",
|
return new TranslatableText( baseString + ".upgraded",
|
||||||
new TranslatableComponent( left.getUnlocalisedAdjective() )
|
new TranslatableText( left.getUnlocalisedAdjective() )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if( right != null )
|
else if( right != null )
|
||||||
{
|
{
|
||||||
return new TranslatableComponent( baseString + ".upgraded",
|
return new TranslatableText( baseString + ".upgraded",
|
||||||
new TranslatableComponent( right.getUnlocalisedAdjective() )
|
new TranslatableText( right.getUnlocalisedAdjective() )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return new TranslatableComponent( baseString );
|
return new TranslatableText( baseString );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -91,7 +91,7 @@ public class TurtleInventoryCrafting extends CraftingInventory
|
|||||||
if( result.isEmpty() ) break;
|
if( result.isEmpty() ) break;
|
||||||
results.add( result );
|
results.add( result );
|
||||||
|
|
||||||
result.onCrafted( world, player, result.getAmount() );
|
result.onCraft( world, player, result.getCount() );
|
||||||
DefaultedList<ItemStack> remainders = recipe.getRemainingStacks( this );
|
DefaultedList<ItemStack> remainders = recipe.getRemainingStacks( this );
|
||||||
|
|
||||||
for( int slot = 0; slot < remainders.size(); slot++ )
|
for( int slot = 0; slot < remainders.size(); slot++ )
|
||||||
@@ -115,7 +115,7 @@ public class TurtleInventoryCrafting extends CraftingInventory
|
|||||||
}
|
}
|
||||||
else if( existing.getItem() == remainder.getItem() && ItemStack.areTagsEqual( existing, remainder ) )
|
else if( existing.getItem() == remainder.getItem() && ItemStack.areTagsEqual( existing, remainder ) )
|
||||||
{
|
{
|
||||||
remainder.addAmount( existing.getAmount() );
|
remainder.increment( existing.getCount() );
|
||||||
setInvStack( slot, remainder );
|
setInvStack( slot, remainder );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@@ -131,7 +131,7 @@ public class TurtleTool extends AbstractTurtleUpgrade
|
|||||||
|
|
||||||
// Fire several events to ensure we have permissions.
|
// Fire several events to ensure we have permissions.
|
||||||
if( AttackEntityCallback.EVENT.invoker().interact( turtlePlayer, world, Hand.MAIN_HAND, hitEntity, null ) == ActionResult.FAIL
|
if( AttackEntityCallback.EVENT.invoker().interact( turtlePlayer, world, Hand.MAIN_HAND, hitEntity, null ) == ActionResult.FAIL
|
||||||
|| !hitEntity.canPlayerAttack() )
|
|| !hitEntity.isAttackable() )
|
||||||
{
|
{
|
||||||
return TurtleCommandResult.failure( "Nothing to attack here" );
|
return TurtleCommandResult.failure( "Nothing to attack here" );
|
||||||
}
|
}
|
||||||
@@ -147,7 +147,7 @@ public class TurtleTool extends AbstractTurtleUpgrade
|
|||||||
|
|
||||||
// Attack the entity
|
// Attack the entity
|
||||||
boolean attacked = false;
|
boolean attacked = false;
|
||||||
if( !hitEntity.handlePlayerAttack( turtlePlayer ) )
|
if( !hitEntity.handleAttack( turtlePlayer ) )
|
||||||
{
|
{
|
||||||
float damage = (float) turtlePlayer.getAttributeInstance( EntityAttributes.ATTACK_DAMAGE ).getValue();
|
float damage = (float) turtlePlayer.getAttributeInstance( EntityAttributes.ATTACK_DAMAGE ).getValue();
|
||||||
damage *= getDamageMultiplier();
|
damage *= getDamageMultiplier();
|
||||||
|
@@ -10,7 +10,7 @@ import net.minecraft.entity.Entity;
|
|||||||
import net.minecraft.entity.ItemEntity;
|
import net.minecraft.entity.ItemEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.BoundingBox;
|
import net.minecraft.util.math.Box;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
@@ -28,7 +28,7 @@ public final class DropConsumer
|
|||||||
private static List<ItemStack> remainingDrops;
|
private static List<ItemStack> remainingDrops;
|
||||||
private static WeakReference<World> dropWorld;
|
private static WeakReference<World> dropWorld;
|
||||||
private static BlockPos dropPos;
|
private static BlockPos dropPos;
|
||||||
private static BoundingBox dropBounds;
|
private static Box dropBounds;
|
||||||
private static WeakReference<Entity> dropEntity;
|
private static WeakReference<Entity> dropEntity;
|
||||||
|
|
||||||
public static void set( Entity entity, Function<ItemStack, ItemStack> consumer )
|
public static void set( Entity entity, Function<ItemStack, ItemStack> consumer )
|
||||||
@@ -38,7 +38,7 @@ public final class DropConsumer
|
|||||||
dropEntity = new WeakReference<>( entity );
|
dropEntity = new WeakReference<>( entity );
|
||||||
dropWorld = new WeakReference<>( entity.world );
|
dropWorld = new WeakReference<>( entity.world );
|
||||||
dropPos = null;
|
dropPos = null;
|
||||||
dropBounds = new BoundingBox( entity.getBlockPos() ).expand( 2, 2, 2 );
|
dropBounds = new Box( entity.getBlockPos() ).expand( 2, 2, 2 );
|
||||||
|
|
||||||
// entity.captureDrops( new ArrayList<>() );
|
// entity.captureDrops( new ArrayList<>() );
|
||||||
}
|
}
|
||||||
@@ -50,7 +50,7 @@ public final class DropConsumer
|
|||||||
dropEntity = null;
|
dropEntity = null;
|
||||||
dropWorld = new WeakReference<>( world );
|
dropWorld = new WeakReference<>( world );
|
||||||
dropPos = pos;
|
dropPos = pos;
|
||||||
dropBounds = new BoundingBox( pos ).expand( 2, 2, 2 );
|
dropBounds = new Box( pos ).expand( 2, 2, 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<ItemStack> clear()
|
public static List<ItemStack> clear()
|
||||||
|
@@ -76,7 +76,7 @@ public final class ImpostorRecipe extends ShapedRecipe
|
|||||||
int width = buf.readVarInt();
|
int width = buf.readVarInt();
|
||||||
int height = buf.readVarInt();
|
int height = buf.readVarInt();
|
||||||
String group = buf.readString( Short.MAX_VALUE );
|
String group = buf.readString( Short.MAX_VALUE );
|
||||||
DefaultedList<Ingredient> items = DefaultedList.create( width * height, Ingredient.EMPTY );
|
DefaultedList<Ingredient> items = DefaultedList.ofSize( width * height, Ingredient.EMPTY );
|
||||||
for( int k = 0; k < items.size(); ++k ) items.set( k, Ingredient.fromPacket( buf ) );
|
for( int k = 0; k < items.size(); ++k ) items.set( k, Ingredient.fromPacket( buf ) );
|
||||||
ItemStack result = buf.readItemStack();
|
ItemStack result = buf.readItemStack();
|
||||||
return new ImpostorRecipe( identifier, group, width, height, items, result );
|
return new ImpostorRecipe( identifier, group, width, height, items, result );
|
||||||
|
@@ -80,7 +80,7 @@ public final class ImpostorShapelessRecipe extends ShapelessRecipe
|
|||||||
|
|
||||||
private DefaultedList<Ingredient> readIngredients( JsonArray arrays )
|
private DefaultedList<Ingredient> readIngredients( JsonArray arrays )
|
||||||
{
|
{
|
||||||
DefaultedList<Ingredient> items = DefaultedList.create();
|
DefaultedList<Ingredient> items = DefaultedList.of();
|
||||||
for( int i = 0; i < arrays.size(); ++i )
|
for( int i = 0; i < arrays.size(); ++i )
|
||||||
{
|
{
|
||||||
Ingredient ingredient = Ingredient.fromJson( arrays.get( i ) );
|
Ingredient ingredient = Ingredient.fromJson( arrays.get( i ) );
|
||||||
@@ -95,7 +95,7 @@ public final class ImpostorShapelessRecipe extends ShapelessRecipe
|
|||||||
{
|
{
|
||||||
String s = buffer.readString( 32767 );
|
String s = buffer.readString( 32767 );
|
||||||
int i = buffer.readVarInt();
|
int i = buffer.readVarInt();
|
||||||
DefaultedList<Ingredient> items = DefaultedList.create( i, Ingredient.EMPTY );
|
DefaultedList<Ingredient> items = DefaultedList.ofSize( i, Ingredient.EMPTY );
|
||||||
|
|
||||||
for( int j = 0; j < items.size(); j++ ) items.set( j, Ingredient.fromPacket( buffer ) );
|
for( int j = 0; j < items.size(); j++ ) items.set( j, Ingredient.fromPacket( buffer ) );
|
||||||
ItemStack result = buffer.readItemStack();
|
ItemStack result = buffer.readItemStack();
|
||||||
|
@@ -26,7 +26,7 @@ public final class InventoryUtil
|
|||||||
|
|
||||||
public static boolean areItemsEqual( @Nonnull ItemStack a, @Nonnull ItemStack b )
|
public static boolean areItemsEqual( @Nonnull ItemStack a, @Nonnull ItemStack b )
|
||||||
{
|
{
|
||||||
return a == b || ItemStack.areEqual( a, b );
|
return a == b || ItemStack.areEqualIgnoreDamage( a, b );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean areItemsStackable( @Nonnull ItemStack a, @Nonnull ItemStack b )
|
public static boolean areItemsStackable( @Nonnull ItemStack a, @Nonnull ItemStack b )
|
||||||
@@ -171,16 +171,16 @@ public final class InventoryUtil
|
|||||||
ItemStack extracted = inventory.take( slot, count, partialStack, false );
|
ItemStack extracted = inventory.take( slot, count, partialStack, false );
|
||||||
if( extracted.isEmpty() ) continue;
|
if( extracted.isEmpty() ) continue;
|
||||||
|
|
||||||
count -= extracted.getAmount();
|
count -= extracted.getCount();
|
||||||
if( partialStack.isEmpty() )
|
if( partialStack.isEmpty() )
|
||||||
{
|
{
|
||||||
// If we've extracted for this first time, then limit the count to the maximum stack size.
|
// If we've extracted for this first time, then limit the count to the maximum stack size.
|
||||||
partialStack = extracted;
|
partialStack = extracted;
|
||||||
count = Math.min( count, extracted.getMaxAmount() );
|
count = Math.min( count, extracted.getMaxCount() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
partialStack.addAmount( extracted.getAmount() );
|
partialStack.increment( extracted.getCount() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -71,10 +71,10 @@ public interface ItemStorage
|
|||||||
if( simulate )
|
if( simulate )
|
||||||
{
|
{
|
||||||
existing = existing.copy();
|
existing = existing.copy();
|
||||||
if( existing.getAmount() > limit ) existing.setAmount( limit );
|
if( existing.getCount() > limit ) existing.setCount( limit );
|
||||||
return existing;
|
return existing;
|
||||||
}
|
}
|
||||||
else if( existing.getAmount() < limit )
|
else if( existing.getCount() < limit )
|
||||||
{
|
{
|
||||||
setAndDirty( slot, ItemStack.EMPTY );
|
setAndDirty( slot, ItemStack.EMPTY );
|
||||||
return existing;
|
return existing;
|
||||||
@@ -96,10 +96,10 @@ public interface ItemStorage
|
|||||||
ItemStack existing = inventory.getInvStack( slot );
|
ItemStack existing = inventory.getInvStack( slot );
|
||||||
if( existing.isEmpty() )
|
if( existing.isEmpty() )
|
||||||
{
|
{
|
||||||
int limit = Math.min( stack.getMaxAmount(), inventory.getInvMaxStackAmount() );
|
int limit = Math.min( stack.getMaxCount(), inventory.getInvMaxStackAmount() );
|
||||||
if( limit <= 0 ) return stack;
|
if( limit <= 0 ) return stack;
|
||||||
|
|
||||||
if( stack.getAmount() < limit )
|
if( stack.getCount() < limit )
|
||||||
{
|
{
|
||||||
if( !simulate ) setAndDirty( slot, stack );
|
if( !simulate ) setAndDirty( slot, stack );
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
@@ -114,14 +114,14 @@ public interface ItemStorage
|
|||||||
}
|
}
|
||||||
else if( areStackable( stack, existing ) )
|
else if( areStackable( stack, existing ) )
|
||||||
{
|
{
|
||||||
int limit = Math.min( existing.getMaxAmount(), inventory.getInvMaxStackAmount() ) - existing.getAmount();
|
int limit = Math.min( existing.getMaxCount(), inventory.getInvMaxStackAmount() ) - existing.getCount();
|
||||||
if( limit <= 0 ) return stack;
|
if( limit <= 0 ) return stack;
|
||||||
|
|
||||||
if( stack.getAmount() < limit )
|
if( stack.getCount() < limit )
|
||||||
{
|
{
|
||||||
if( !simulate )
|
if( !simulate )
|
||||||
{
|
{
|
||||||
existing.addAmount( stack.getAmount() );
|
existing.increment( stack.getCount() );
|
||||||
setAndDirty( slot, existing );
|
setAndDirty( slot, existing );
|
||||||
}
|
}
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
@@ -129,10 +129,10 @@ public interface ItemStorage
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
stack = stack.copy();
|
stack = stack.copy();
|
||||||
stack.subtractAmount( limit );
|
stack.decrement( limit );
|
||||||
if( !simulate )
|
if( !simulate )
|
||||||
{
|
{
|
||||||
existing.addAmount( limit );
|
existing.increment( limit );
|
||||||
setAndDirty( slot, existing );
|
setAndDirty( slot, existing );
|
||||||
}
|
}
|
||||||
return stack;
|
return stack;
|
||||||
|
@@ -74,7 +74,7 @@ public final class RecipeUtil
|
|||||||
|
|
||||||
int width = pattern[0].length();
|
int width = pattern[0].length();
|
||||||
int height = pattern.length;
|
int height = pattern.length;
|
||||||
DefaultedList<Ingredient> ingredients = DefaultedList.create( width * height, Ingredient.EMPTY );
|
DefaultedList<Ingredient> ingredients = DefaultedList.ofSize( width * height, Ingredient.EMPTY );
|
||||||
|
|
||||||
Set<Character> missingKeys = Sets.newHashSet( ingMap.keySet() );
|
Set<Character> missingKeys = Sets.newHashSet( ingMap.keySet() );
|
||||||
missingKeys.remove( ' ' );
|
missingKeys.remove( ' ' );
|
||||||
@@ -104,7 +104,7 @@ public final class RecipeUtil
|
|||||||
|
|
||||||
public static DefaultedList<Ingredient> getIngredients( JsonObject json )
|
public static DefaultedList<Ingredient> getIngredients( JsonObject json )
|
||||||
{
|
{
|
||||||
DefaultedList<Ingredient> ingredients = DefaultedList.create();
|
DefaultedList<Ingredient> ingredients = DefaultedList.of();
|
||||||
for( JsonElement ele : JsonHelper.getArray( json, "ingredients" ) )
|
for( JsonElement ele : JsonHelper.getArray( json, "ingredients" ) )
|
||||||
{
|
{
|
||||||
ingredients.add( Ingredient.fromJson( ele ) );
|
ingredients.add( Ingredient.fromJson( ele ) );
|
||||||
|
@@ -12,8 +12,8 @@ import dan200.computercraft.shared.network.client.PlayRecordClientMessage;
|
|||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.MusicDiscItem;
|
import net.minecraft.item.MusicDiscItem;
|
||||||
import net.minecraft.network.chat.TranslatableComponent;
|
|
||||||
import net.minecraft.sound.SoundEvent;
|
import net.minecraft.sound.SoundEvent;
|
||||||
|
import net.minecraft.text.TranslatableText;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
@@ -35,6 +35,6 @@ public final class RecordUtil
|
|||||||
Item item = recordStack.getItem();
|
Item item = recordStack.getItem();
|
||||||
if( !(item instanceof MusicDiscItem) ) return null;
|
if( !(item instanceof MusicDiscItem) ) return null;
|
||||||
|
|
||||||
return new TranslatableComponent( item.getTranslationKey() + ".desc" ).getString();
|
return new TranslatableText( item.getTranslationKey() + ".desc" ).getString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -13,7 +13,7 @@ import net.minecraft.entity.player.PlayerEntity;
|
|||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.hit.HitResult;
|
import net.minecraft.util.hit.HitResult;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.BoundingBox;
|
import net.minecraft.util.math.Box;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.util.shape.VoxelShape;
|
import net.minecraft.util.shape.VoxelShape;
|
||||||
@@ -32,16 +32,16 @@ public final class WorldUtil
|
|||||||
private static final Entity ENTITY = new ItemEntity( EntityType.ITEM, null )
|
private static final Entity ENTITY = new ItemEntity( EntityType.ITEM, null )
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public EntitySize getSize( EntityPose pos )
|
public EntityDimensions getDimensions( EntityPose pos )
|
||||||
{
|
{
|
||||||
return EntitySize.constant( 0, 0 );
|
return EntityDimensions.fixed( 0, 0 );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
ENTITY.noClip = true;
|
ENTITY.noClip = true;
|
||||||
ENTITY.refreshSize();
|
ENTITY.calculateDimensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isLiquidBlock( World world, BlockPos pos )
|
public static boolean isLiquidBlock( World world, BlockPos pos )
|
||||||
@@ -55,7 +55,7 @@ public final class WorldUtil
|
|||||||
{
|
{
|
||||||
if( shape.isEmpty() ) return false;
|
if( shape.isEmpty() ) return false;
|
||||||
// AxisAlignedBB.contains, but without strict inequalities.
|
// AxisAlignedBB.contains, but without strict inequalities.
|
||||||
BoundingBox bb = shape.getBoundingBox();
|
Box bb = shape.getBoundingBox();
|
||||||
return vec.x >= bb.minX && vec.x <= bb.maxX && vec.y >= bb.minY && vec.y <= bb.maxY && vec.z >= bb.minZ && vec.z <= bb.maxZ;
|
return vec.x >= bb.minX && vec.x <= bb.maxX && vec.y >= bb.minY && vec.y <= bb.maxY && vec.z >= bb.minZ && vec.z <= bb.maxZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@ public final class WorldUtil
|
|||||||
float xStretch = Math.abs( vecDir.x ) > 0.25f ? 0.0f : 1.0f;
|
float xStretch = Math.abs( vecDir.x ) > 0.25f ? 0.0f : 1.0f;
|
||||||
float yStretch = Math.abs( vecDir.y ) > 0.25f ? 0.0f : 1.0f;
|
float yStretch = Math.abs( vecDir.y ) > 0.25f ? 0.0f : 1.0f;
|
||||||
float zStretch = Math.abs( vecDir.z ) > 0.25f ? 0.0f : 1.0f;
|
float zStretch = Math.abs( vecDir.z ) > 0.25f ? 0.0f : 1.0f;
|
||||||
BoundingBox bigBox = new BoundingBox(
|
Box bigBox = new Box(
|
||||||
Math.min( vecStart.x, vecEnd.x ) - 0.375f * xStretch,
|
Math.min( vecStart.x, vecEnd.x ) - 0.375f * xStretch,
|
||||||
Math.min( vecStart.y, vecEnd.y ) - 0.375f * yStretch,
|
Math.min( vecStart.y, vecEnd.y ) - 0.375f * yStretch,
|
||||||
Math.min( vecStart.z, vecEnd.z ) - 0.375f * zStretch,
|
Math.min( vecStart.z, vecEnd.z ) - 0.375f * zStretch,
|
||||||
@@ -90,7 +90,7 @@ public final class WorldUtil
|
|||||||
List<Entity> list = world.getEntities( Entity.class, bigBox, CAN_COLLIDE );
|
List<Entity> list = world.getEntities( Entity.class, bigBox, CAN_COLLIDE );
|
||||||
for( Entity entity : list )
|
for( Entity entity : list )
|
||||||
{
|
{
|
||||||
BoundingBox littleBox = entity.getBoundingBox();
|
Box littleBox = entity.getBoundingBox();
|
||||||
|
|
||||||
if( littleBox.contains( vecStart ) )
|
if( littleBox.contains( vecStart ) )
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user