mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-01-23 23:46:55 +00:00
Bump to 1.14.1pr1
Which means bumping mappings version. Oh boy, this was not a bundle of laughs...
This commit is contained in:
parent
2a716244e9
commit
b11d4bb209
@ -53,7 +53,7 @@ configurations {
|
||||
dependencies {
|
||||
minecraft "com.mojang:minecraft:${mc_version}"
|
||||
mappings "net.fabricmc:yarn:${mc_version}+build.${mappings_version}"
|
||||
modCompile "net.fabricmc:fabric-loader:0.4.2+build.132"
|
||||
modCompile "net.fabricmc:fabric-loader:0.4.6+build.141"
|
||||
modCompile "net.fabricmc:fabric:0.2.7+build.126"
|
||||
|
||||
/*
|
||||
@ -151,7 +151,7 @@ task proguard(type: ProGuardTask, dependsOn: jar) {
|
||||
|
||||
// LWJGL and Apache bundle Java 9 versions, which is great, but rather breaks Proguard
|
||||
dontwarn 'module-info'
|
||||
dontwarn 'org.apache.**,org.lwjgl.**'
|
||||
dontwarn 'org.apache.**,org.lwjgl.**,javax.crypto.SecretKey'
|
||||
}
|
||||
|
||||
task proguardMove(dependsOn: proguard) {
|
||||
|
@ -2,5 +2,5 @@
|
||||
mod_version=1.82.4
|
||||
|
||||
# Minecraft properties
|
||||
mc_version=1.14
|
||||
mc_version=1.14.1 Pre-Release 1
|
||||
mappings_version=1
|
||||
|
@ -8,7 +8,7 @@ package dan200.computercraft.api;
|
||||
|
||||
import dan200.computercraft.api.turtle.ITurtleUpgrade;
|
||||
import dan200.computercraft.api.turtle.TurtleUpgradeType;
|
||||
import net.minecraft.item.ItemProvider;
|
||||
import net.minecraft.item.ItemConvertible;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.SystemUtil;
|
||||
@ -35,7 +35,7 @@ public abstract class AbstractTurtleUpgrade implements ITurtleUpgrade
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
protected AbstractTurtleUpgrade( Identifier id, TurtleUpgradeType type, String adjective, ItemProvider item )
|
||||
protected AbstractTurtleUpgrade( Identifier id, TurtleUpgradeType type, String adjective, ItemConvertible item )
|
||||
{
|
||||
this( id, type, adjective, new ItemStack( item ) );
|
||||
}
|
||||
@ -45,7 +45,7 @@ public abstract class AbstractTurtleUpgrade implements ITurtleUpgrade
|
||||
this( id, type, SystemUtil.createTranslationKey( "upgrade", id ) + ".adjective", stack );
|
||||
}
|
||||
|
||||
protected AbstractTurtleUpgrade( Identifier id, TurtleUpgradeType type, ItemProvider item )
|
||||
protected AbstractTurtleUpgrade( Identifier id, TurtleUpgradeType type, ItemConvertible item )
|
||||
{
|
||||
this( id, type, new ItemStack( item ) );
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
package dan200.computercraft.api.pocket;
|
||||
|
||||
import net.minecraft.item.ItemProvider;
|
||||
import net.minecraft.item.ItemConvertible;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.SystemUtil;
|
||||
@ -31,12 +31,12 @@ public abstract class AbstractPocketUpgrade implements IPocketUpgrade
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
protected AbstractPocketUpgrade( Identifier identifier, String adjective, ItemProvider item )
|
||||
protected AbstractPocketUpgrade( Identifier identifier, String adjective, ItemConvertible item )
|
||||
{
|
||||
this( identifier, adjective, new ItemStack( item ) );
|
||||
}
|
||||
|
||||
protected AbstractPocketUpgrade( Identifier id, ItemProvider item )
|
||||
protected AbstractPocketUpgrade( Identifier id, ItemConvertible item )
|
||||
{
|
||||
this( id, SystemUtil.createTranslationKey( "upgrade", id ) + ".adjective", new ItemStack( item ) );
|
||||
}
|
||||
|
@ -25,6 +25,8 @@ import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.network.NetworkSide;
|
||||
import net.minecraft.network.NetworkState;
|
||||
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.server.network.ServerPlayNetworkHandler;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
@ -34,14 +36,12 @@ import net.minecraft.server.network.packet.VehicleMoveC2SPacket;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.text.ChatMessageType;
|
||||
import net.minecraft.text.TextComponent;
|
||||
import net.minecraft.util.DefaultedList;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.village.TraderOfferList;
|
||||
import net.minecraft.world.GameMode;
|
||||
import net.minecraft.world.chunk.ChunkPos;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -135,7 +135,7 @@ public class FakePlayer extends ServerPlayerEntity
|
||||
public void method_14241() { }
|
||||
|
||||
@Override
|
||||
public void addChatMessage( TextComponent textComponent, boolean status ) { }
|
||||
public void addChatMessage( Component textComponent, boolean status ) { }
|
||||
|
||||
@Override
|
||||
protected void method_6040() { }
|
||||
@ -162,7 +162,7 @@ public class FakePlayer extends ServerPlayerEntity
|
||||
public void setGameMode( GameMode gameMode ) { }
|
||||
|
||||
@Override
|
||||
public void sendChatMessage( TextComponent textComponent, ChatMessageType chatMessageType ) { }
|
||||
public void sendChatMessage( Component textComponent, ChatMessageType chatMessageType ) { }
|
||||
|
||||
@Override
|
||||
public String getServerBrand()
|
||||
@ -214,7 +214,7 @@ public class FakePlayer extends ServerPlayerEntity
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect( TextComponent message ) { }
|
||||
public void disconnect( Component message ) { }
|
||||
|
||||
@Override
|
||||
public void onRequestCommandCompletions( RequestCommandCompletionsC2SPacket packet ) { }
|
||||
@ -230,7 +230,7 @@ public class FakePlayer extends ServerPlayerEntity
|
||||
{
|
||||
FakeConnection()
|
||||
{
|
||||
super( NetworkSide.SERVER );
|
||||
super( NetworkSide.CLIENTBOUND );
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -244,7 +244,7 @@ public class FakePlayer extends ServerPlayerEntity
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect( TextComponent message )
|
||||
public void disconnect( Component 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.TableFormatter;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
||||
import net.minecraft.ChatFormat;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.hud.ChatHud;
|
||||
import net.minecraft.client.util.TextComponentUtil;
|
||||
import net.minecraft.text.TextComponent;
|
||||
import net.minecraft.text.TextFormat;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@ -35,7 +35,7 @@ public class ClientTableFormatter implements TableFormatter
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public TextComponent getPadding( TextComponent component, int width )
|
||||
public Component getPadding( Component component, int width )
|
||||
{
|
||||
int extraWidth = width - getWidth( component );
|
||||
if( extraWidth <= 0 ) return null;
|
||||
@ -46,7 +46,7 @@ public class ClientTableFormatter implements TableFormatter
|
||||
int spaces = MathHelper.floor( extraWidth / spaceWidth );
|
||||
int extra = extraWidth - (int) (spaces * spaceWidth);
|
||||
|
||||
return ChatHelpers.coloured( StringUtils.repeat( ' ', spaces ) + StringUtils.repeat( (char) 712, extra ), TextFormat.GRAY );
|
||||
return ChatHelpers.coloured( StringUtils.repeat( ' ', spaces ) + StringUtils.repeat( (char) 712, extra ), ChatFormat.GRAY );
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -56,20 +56,20 @@ public class ClientTableFormatter implements TableFormatter
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth( TextComponent component )
|
||||
public int getWidth( Component component )
|
||||
{
|
||||
return renderer().getStringWidth( component.getFormattedText() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeLine( int id, TextComponent component )
|
||||
public void writeLine( int id, Component component )
|
||||
{
|
||||
MinecraftClient mc = MinecraftClient.getInstance();
|
||||
ChatHud chat = mc.inGameHud.getChatHud();
|
||||
|
||||
// Trim the text if it goes over the allowed length
|
||||
int maxWidth = MathHelper.floor( chat.getWidth() / chat.getScale() );
|
||||
List<TextComponent> list = TextComponentUtil.wrapLines( component, maxWidth, mc.textRenderer, false, false );
|
||||
List<Component> list = TextComponentUtil.wrapLines( component, maxWidth, mc.textRenderer, false, false );
|
||||
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.ContainerScreen;
|
||||
import net.minecraft.container.Container;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.text.StringTextComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
@ -38,7 +38,7 @@ public class GuiComputer<T extends Container> extends ContainerScreen<T>
|
||||
|
||||
public GuiComputer( T container, PlayerInventory player, ComputerFamily family, ClientComputer computer, int termWidth, int termHeight )
|
||||
{
|
||||
super( container, player, new StringTextComponent( "" ) );
|
||||
super( container, player, new TextComponent( "" ) );
|
||||
|
||||
m_family = family;
|
||||
m_computer = computer;
|
||||
|
@ -31,14 +31,14 @@ public abstract class ItemMapLikeRenderer
|
||||
PlayerEntity player = MinecraftClient.getInstance().player;
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
if( hand == Hand.MAIN && player.getOffHandStack().isEmpty() )
|
||||
if( hand == Hand.MAIN_HAND && player.getOffHandStack().isEmpty() )
|
||||
{
|
||||
renderItemFirstPersonCenter( pitch, equipProgress, swingProgress, stack );
|
||||
}
|
||||
else
|
||||
{
|
||||
renderItemFirstPersonSide(
|
||||
hand == Hand.MAIN ? player.getMainHand() : player.getMainHand().getOpposite(),
|
||||
hand == Hand.MAIN_HAND ? player.getMainHand() : player.getMainHand().getOpposite(),
|
||||
equipProgress, swingProgress, stack
|
||||
);
|
||||
}
|
||||
|
@ -11,7 +11,10 @@ import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import dan200.computercraft.api.filesystem.IMount;
|
||||
import dan200.computercraft.core.apis.handles.ArrayByteChannel;
|
||||
import net.minecraft.resource.*;
|
||||
import net.minecraft.resource.ReloadableResourceManager;
|
||||
import net.minecraft.resource.Resource;
|
||||
import net.minecraft.resource.ResourceManager;
|
||||
import net.minecraft.resource.ResourceReloadListener;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.profiler.Profiler;
|
||||
|
||||
@ -23,6 +26,8 @@ import java.io.InputStream;
|
||||
import java.nio.channels.Channels;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class ResourceMount implements IMount
|
||||
@ -241,7 +246,7 @@ public class ResourceMount implements IMount
|
||||
* While people should really be keeping a permanent reference to this, some people construct it every
|
||||
* method call, so let's make this as small as possible.
|
||||
*/
|
||||
static class Listener extends SupplyingResourceReloadListener<Void>
|
||||
static class Listener implements ResourceReloadListener
|
||||
{
|
||||
private static final Listener INSTANCE = new Listener();
|
||||
|
||||
@ -249,23 +254,19 @@ public class ResourceMount implements IMount
|
||||
private final Set<ReloadableResourceManager> managers = Collections.newSetFromMap( new WeakHashMap<>() );
|
||||
|
||||
@Override
|
||||
protected synchronized Void load( ResourceManager manager, Profiler profiler )
|
||||
{
|
||||
profiler.push( "Mount reloading" );
|
||||
try
|
||||
{
|
||||
for( ResourceMount mount : mounts ) mount.load();
|
||||
}
|
||||
finally
|
||||
{
|
||||
profiler.pop();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void apply( Void res, ResourceManager manager, Profiler profiler )
|
||||
public CompletableFuture<Void> reload( Synchronizer synchronizer, ResourceManager resourceManager, Profiler profiler, Profiler profiler1, Executor executor, Executor executor1 )
|
||||
{
|
||||
return CompletableFuture.runAsync( () -> {
|
||||
profiler.push( "Mount reloading" );
|
||||
try
|
||||
{
|
||||
for( ResourceMount mount : mounts ) mount.load();
|
||||
}
|
||||
finally
|
||||
{
|
||||
profiler.pop();
|
||||
}
|
||||
}, executor );
|
||||
}
|
||||
|
||||
synchronized void add( ReloadableResourceManager manager, ResourceMount mount )
|
||||
|
@ -48,11 +48,7 @@ import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.recipe.RecipeSerializer;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.MutableRegistry;
|
||||
|
@ -23,11 +23,11 @@ import dan200.computercraft.shared.computer.core.ServerComputer;
|
||||
import dan200.computercraft.shared.network.Containers;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.text.StringTextComponent;
|
||||
import net.minecraft.text.TextComponent;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@ -256,9 +256,9 @@ public final class CommandComputerCraft
|
||||
);
|
||||
}
|
||||
|
||||
private static TextComponent linkComputer( ServerCommandSource source, ServerComputer serverComputer, int computerId )
|
||||
private static Component linkComputer( ServerCommandSource source, ServerComputer serverComputer, int computerId )
|
||||
{
|
||||
TextComponent out = new StringTextComponent( "" );
|
||||
TextComponent out = new TextComponent( "" );
|
||||
|
||||
// Append the computer instance
|
||||
if( serverComputer == null )
|
||||
@ -298,7 +298,7 @@ public final class CommandComputerCraft
|
||||
return out;
|
||||
}
|
||||
|
||||
private static TextComponent linkPosition( ServerCommandSource context, ServerComputer computer )
|
||||
private static Component linkPosition( ServerCommandSource context, ServerComputer computer )
|
||||
{
|
||||
if( UserLevel.OP.test( context ) )
|
||||
{
|
||||
@ -344,7 +344,7 @@ public final class CommandComputerCraft
|
||||
|
||||
timings.sort( Comparator.<ComputerTracker, Long>comparing( x -> x.get( sortField ) ).reversed() );
|
||||
|
||||
TextComponent[] headers = new TextComponent[1 + fields.size()];
|
||||
Component[] headers = new Component[1 + fields.size()];
|
||||
headers[0] = translate( "commands.computercraft.track.dump.computer" );
|
||||
for( int i = 0; i < fields.size(); i++ ) headers[i + 1] = translate( fields.get( i ).translationKey() );
|
||||
TableBuilder table = new TableBuilder( TRACK_ID, headers );
|
||||
@ -354,9 +354,9 @@ public final class CommandComputerCraft
|
||||
Computer computer = entry.getComputer();
|
||||
ServerComputer serverComputer = computer == null ? null : lookup.get( computer );
|
||||
|
||||
TextComponent computerComponent = linkComputer( source, serverComputer, entry.getComputerId() );
|
||||
Component computerComponent = linkComputer( source, serverComputer, entry.getComputerId() );
|
||||
|
||||
TextComponent[] row = new TextComponent[1 + fields.size()];
|
||||
Component[] row = new Component[1 + fields.size()];
|
||||
row[0] = computerComponent;
|
||||
for( int i = 0; i < fields.size(); i++ ) row[i + 1] = text( entry.getFormatted( fields.get( i ) ) );
|
||||
table.row( row );
|
||||
|
@ -9,12 +9,11 @@ package dan200.computercraft.shared.command;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.network.chat.ClickEvent;
|
||||
import net.minecraft.network.chat.HoverEvent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.text.StringTextComponent;
|
||||
import net.minecraft.text.TextComponent;
|
||||
import net.minecraft.text.TranslatableTextComponent;
|
||||
import net.minecraft.text.event.ClickEvent;
|
||||
import net.minecraft.text.event.HoverEvent;
|
||||
|
||||
import static net.minecraft.server.command.CommandManager.argument;
|
||||
import static net.minecraft.server.command.CommandManager.literal;
|
||||
@ -53,10 +52,10 @@ public final class CommandCopy
|
||||
|
||||
public static TextComponent createCopyText( String text )
|
||||
{
|
||||
StringTextComponent name = new StringTextComponent( text );
|
||||
TextComponent name = new TextComponent( text );
|
||||
name.getStyle()
|
||||
.setClickEvent( new ClickEvent( ClickEvent.Action.RUN_COMMAND, PREFIX + text ) )
|
||||
.setHoverEvent( new HoverEvent( HoverEvent.Action.SHOW_TEXT, new TranslatableTextComponent( "gui.computercraft.tooltip.copy" ) ) );
|
||||
.setHoverEvent( new HoverEvent( HoverEvent.Action.SHOW_TEXT, new TranslatableComponent( "gui.computercraft.tooltip.copy" ) ) );
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ package dan200.computercraft.shared.command;
|
||||
import com.mojang.brigadier.exceptions.Dynamic2CommandExceptionType;
|
||||
import com.mojang.brigadier.exceptions.DynamicCommandExceptionType;
|
||||
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
|
||||
import net.minecraft.text.TranslatableTextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
|
||||
public final class Exceptions
|
||||
{
|
||||
@ -28,16 +28,16 @@ public final class Exceptions
|
||||
|
||||
private static SimpleCommandExceptionType translated( String key )
|
||||
{
|
||||
return new SimpleCommandExceptionType( new TranslatableTextComponent( key ) );
|
||||
return new SimpleCommandExceptionType( new TranslatableComponent( key ) );
|
||||
}
|
||||
|
||||
private static DynamicCommandExceptionType translated1( String key )
|
||||
{
|
||||
return new DynamicCommandExceptionType( x -> new TranslatableTextComponent( key, x ) );
|
||||
return new DynamicCommandExceptionType( x -> new TranslatableComponent( key, x ) );
|
||||
}
|
||||
|
||||
private static Dynamic2CommandExceptionType translated2( String key )
|
||||
{
|
||||
return new Dynamic2CommandExceptionType( ( x, y ) -> new TranslatableTextComponent( key, x, y ) );
|
||||
return new Dynamic2CommandExceptionType( ( x, y ) -> new TranslatableComponent( key, x, y ) );
|
||||
}
|
||||
}
|
||||
|
@ -17,8 +17,8 @@ import com.mojang.brigadier.suggestion.Suggestions;
|
||||
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
|
||||
import net.minecraft.command.arguments.ArgumentTypes;
|
||||
import net.minecraft.command.arguments.serialize.ArgumentSerializer;
|
||||
import net.minecraft.text.StringTextComponent;
|
||||
import net.minecraft.text.TextComponent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.util.PacketByteBuf;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@ -143,7 +143,7 @@ public final class RepeatArgumentType<T, U> implements ArgumentType<List<T>>
|
||||
{
|
||||
boolean isList = buf.readBoolean();
|
||||
ArgumentType<?> child = ArgumentTypes.fromPacket( buf );
|
||||
TextComponent message = buf.readTextComponent();
|
||||
Component message = buf.readTextComponent();
|
||||
BiConsumer<List<Object>, ?> appender = isList ? ( list, x ) -> list.addAll( (Collection) x ) : List::add;
|
||||
return new RepeatArgumentType( child, appender, isList, new SimpleCommandExceptionType( message ) );
|
||||
}
|
||||
@ -160,7 +160,7 @@ public final class RepeatArgumentType<T, U> implements ArgumentType<List<T>>
|
||||
{
|
||||
Message message = arg.some.create().getRawMessage();
|
||||
if( message instanceof TextComponent ) return (TextComponent) message;
|
||||
return new StringTextComponent( message.getString() );
|
||||
return new TextComponent( message.getString() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,11 +13,11 @@ import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.tree.CommandNode;
|
||||
import com.mojang.brigadier.tree.LiteralCommandNode;
|
||||
import net.minecraft.ChatFormat;
|
||||
import net.minecraft.network.chat.ClickEvent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.text.StringTextComponent;
|
||||
import net.minecraft.text.TextComponent;
|
||||
import net.minecraft.text.TextFormat;
|
||||
import net.minecraft.text.event.ClickEvent;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
@ -133,9 +133,9 @@ public final class HelpingArgumentBuilder extends LiteralArgumentBuilder<ServerC
|
||||
return node;
|
||||
}
|
||||
|
||||
private static final TextFormat HEADER = TextFormat.LIGHT_PURPLE;
|
||||
private static final TextFormat SYNOPSIS = TextFormat.AQUA;
|
||||
private static final TextFormat NAME = TextFormat.GREEN;
|
||||
private static final ChatFormat HEADER = ChatFormat.LIGHT_PURPLE;
|
||||
private static final ChatFormat SYNOPSIS = ChatFormat.AQUA;
|
||||
private static final ChatFormat NAME = ChatFormat.GREEN;
|
||||
|
||||
private static final class HelpCommand implements Command<ServerCommandSource>
|
||||
{
|
||||
@ -165,7 +165,7 @@ public final class HelpingArgumentBuilder extends LiteralArgumentBuilder<ServerC
|
||||
};
|
||||
}
|
||||
|
||||
private static TextComponent getHelp( CommandContext<ServerCommandSource> context, CommandNode<ServerCommandSource> node, String id, String command )
|
||||
private static Component 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
|
||||
// the shorthand usage, and emit that.
|
||||
@ -174,7 +174,7 @@ public final class HelpingArgumentBuilder extends LiteralArgumentBuilder<ServerC
|
||||
temp.addChild( node );
|
||||
String usage = dispatcher.getSmartUsage( temp, context.getSource() ).get( node ).substring( node.getName().length() );
|
||||
|
||||
TextComponent output = new StringTextComponent( "" )
|
||||
Component output = new TextComponent( "" )
|
||||
.append( coloured( "/" + command + usage, HEADER ) )
|
||||
.append( " " )
|
||||
.append( coloured( translate( "commands." + id + ".synopsis" ), SYNOPSIS ) )
|
||||
@ -190,7 +190,7 @@ public final class HelpingArgumentBuilder extends LiteralArgumentBuilder<ServerC
|
||||
|
||||
output.append( "\n" );
|
||||
|
||||
TextComponent component = coloured( child.getName(), NAME );
|
||||
Component component = coloured( child.getName(), NAME );
|
||||
component.getStyle().setClickEvent( new ClickEvent(
|
||||
ClickEvent.Action.SUGGEST_COMMAND,
|
||||
"/" + command + " " + child.getName()
|
||||
|
@ -6,9 +6,8 @@
|
||||
|
||||
package dan200.computercraft.shared.command.text;
|
||||
|
||||
import net.minecraft.text.*;
|
||||
import net.minecraft.text.event.ClickEvent;
|
||||
import net.minecraft.text.event.HoverEvent;
|
||||
import net.minecraft.ChatFormat;
|
||||
import net.minecraft.network.chat.*;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
/**
|
||||
@ -16,73 +15,73 @@ import net.minecraft.util.math.BlockPos;
|
||||
*/
|
||||
public final class ChatHelpers
|
||||
{
|
||||
private static final TextFormat HEADER = TextFormat.LIGHT_PURPLE;
|
||||
private static final ChatFormat HEADER = ChatFormat.LIGHT_PURPLE;
|
||||
|
||||
private ChatHelpers() {}
|
||||
|
||||
public static TextComponent coloured( String text, TextFormat colour )
|
||||
public static Component coloured( String text, ChatFormat colour )
|
||||
{
|
||||
TextComponent component = new StringTextComponent( text == null ? "" : text );
|
||||
TextComponent component = new TextComponent( text == null ? "" : text );
|
||||
component.getStyle().setColor( colour );
|
||||
return component;
|
||||
}
|
||||
|
||||
public static <T extends TextComponent> T coloured( T component, TextFormat colour )
|
||||
public static <T extends Component> T coloured( T component, ChatFormat colour )
|
||||
{
|
||||
component.getStyle().setColor( colour );
|
||||
return component;
|
||||
}
|
||||
|
||||
public static TextComponent text( String text )
|
||||
public static Component text( String text )
|
||||
{
|
||||
return new StringTextComponent( text == null ? "" : text );
|
||||
return new TextComponent( text == null ? "" : text );
|
||||
}
|
||||
|
||||
public static TextComponent translate( String text )
|
||||
public static Component translate( String text )
|
||||
{
|
||||
return new TranslatableTextComponent( text == null ? "" : text );
|
||||
return new TranslatableComponent( text == null ? "" : text );
|
||||
}
|
||||
|
||||
public static TextComponent translate( String text, Object... args )
|
||||
public static Component translate( String text, Object... args )
|
||||
{
|
||||
return new TranslatableTextComponent( text == null ? "" : text, args );
|
||||
return new TranslatableComponent( text == null ? "" : text, args );
|
||||
}
|
||||
|
||||
public static TextComponent list( TextComponent... children )
|
||||
public static Component list( Component... children )
|
||||
{
|
||||
TextComponent component = new StringTextComponent( "" );
|
||||
for( TextComponent child : children )
|
||||
Component component = new TextComponent( "" );
|
||||
for( Component child : children )
|
||||
{
|
||||
component.append( child );
|
||||
}
|
||||
return component;
|
||||
}
|
||||
|
||||
public static TextComponent position( BlockPos pos )
|
||||
public static Component position( BlockPos pos )
|
||||
{
|
||||
if( pos == null ) return translate( "commands.computercraft.generic.no_position" );
|
||||
return translate( "commands.computercraft.generic.position", pos.getX(), pos.getY(), pos.getZ() );
|
||||
}
|
||||
|
||||
public static TextComponent bool( boolean value )
|
||||
public static Component bool( boolean value )
|
||||
{
|
||||
return value
|
||||
? coloured( translate( "commands.computercraft.generic.yes" ), TextFormat.GREEN )
|
||||
: coloured( translate( "commands.computercraft.generic.no" ), TextFormat.RED );
|
||||
? coloured( translate( "commands.computercraft.generic.yes" ), ChatFormat.GREEN )
|
||||
: coloured( translate( "commands.computercraft.generic.no" ), ChatFormat.RED );
|
||||
}
|
||||
|
||||
public static TextComponent link( TextComponent component, String command, TextComponent toolTip )
|
||||
public static Component link( Component component, String command, Component toolTip )
|
||||
{
|
||||
Style style = component.getStyle();
|
||||
|
||||
if( style.getColor() == null ) style.setColor( TextFormat.YELLOW );
|
||||
if( style.getColor() == null ) style.setColor( ChatFormat.YELLOW );
|
||||
style.setClickEvent( new ClickEvent( ClickEvent.Action.RUN_COMMAND, command ) );
|
||||
style.setHoverEvent( new HoverEvent( HoverEvent.Action.SHOW_TEXT, toolTip ) );
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
public static TextComponent header( String text )
|
||||
public static Component header( String text )
|
||||
{
|
||||
return coloured( text, HEADER );
|
||||
}
|
||||
|
@ -6,9 +6,9 @@
|
||||
|
||||
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.text.StringTextComponent;
|
||||
import net.minecraft.text.TextComponent;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -23,12 +23,12 @@ public class ServerTableFormatter implements TableFormatter
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable
|
||||
TextComponent getPadding( TextComponent component, int width )
|
||||
@Nullable
|
||||
public Component getPadding( Component component, int width )
|
||||
{
|
||||
int extraWidth = width - getWidth( component );
|
||||
if( extraWidth <= 0 ) return null;
|
||||
return new StringTextComponent( StringUtils.repeat( ' ', extraWidth ) );
|
||||
return new TextComponent( StringUtils.repeat( ' ', extraWidth ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -38,13 +38,13 @@ public class ServerTableFormatter implements TableFormatter
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth( TextComponent component )
|
||||
public int getWidth( Component component )
|
||||
{
|
||||
return component.getText().length();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeLine( int id, TextComponent component )
|
||||
public void writeLine( int id, Component component )
|
||||
{
|
||||
source.sendFeedback( component, false );
|
||||
}
|
||||
|
@ -9,9 +9,9 @@ package dan200.computercraft.shared.command.text;
|
||||
import dan200.computercraft.shared.command.CommandUtils;
|
||||
import dan200.computercraft.shared.network.NetworkHandler;
|
||||
import dan200.computercraft.shared.network.client.ChatTableClientMessage;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.text.TextComponent;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
@ -22,11 +22,11 @@ public class TableBuilder
|
||||
{
|
||||
private final int id;
|
||||
private int columns = -1;
|
||||
private final TextComponent[] headers;
|
||||
private final ArrayList<TextComponent[]> rows = new ArrayList<>();
|
||||
private final Component[] headers;
|
||||
private final ArrayList<Component[]> rows = new ArrayList<>();
|
||||
private int additional;
|
||||
|
||||
public TableBuilder( int id, @Nonnull TextComponent... headers )
|
||||
public TableBuilder( int id, @Nonnull Component... headers )
|
||||
{
|
||||
if( id < 0 ) throw new IllegalArgumentException( "ID must be positive" );
|
||||
this.id = id;
|
||||
@ -45,13 +45,13 @@ public class TableBuilder
|
||||
{
|
||||
if( id < 0 ) throw new IllegalArgumentException( "ID must be positive" );
|
||||
this.id = id;
|
||||
this.headers = new TextComponent[headers.length];
|
||||
this.headers = new Component[headers.length];
|
||||
columns = headers.length;
|
||||
|
||||
for( int i = 0; i < headers.length; i++ ) this.headers[i] = ChatHelpers.header( headers[i] );
|
||||
}
|
||||
|
||||
public void row( @Nonnull TextComponent... row )
|
||||
public void row( @Nonnull Component... row )
|
||||
{
|
||||
if( columns == -1 ) columns = row.length;
|
||||
if( row.length != columns ) throw new IllegalArgumentException( "Row is the incorrect length" );
|
||||
@ -85,13 +85,13 @@ public class TableBuilder
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public TextComponent[] getHeaders()
|
||||
public Component[] getHeaders()
|
||||
{
|
||||
return headers;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public List<TextComponent[]> getRows()
|
||||
public List<Component[]> getRows()
|
||||
{
|
||||
return rows;
|
||||
}
|
||||
|
@ -6,9 +6,9 @@
|
||||
|
||||
package dan200.computercraft.shared.command.text;
|
||||
|
||||
import net.minecraft.text.StringTextComponent;
|
||||
import net.minecraft.text.TextComponent;
|
||||
import net.minecraft.text.TextFormat;
|
||||
import net.minecraft.ChatFormat;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -18,8 +18,8 @@ import static dan200.computercraft.shared.command.text.ChatHelpers.translate;
|
||||
|
||||
public interface TableFormatter
|
||||
{
|
||||
TextComponent SEPARATOR = coloured( "| ", TextFormat.GRAY );
|
||||
TextComponent HEADER = coloured( "=", TextFormat.GRAY );
|
||||
Component SEPARATOR = coloured( "| ", ChatFormat.GRAY );
|
||||
Component HEADER = coloured( "=", ChatFormat.GRAY );
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
@Nullable
|
||||
TextComponent getPadding( TextComponent component, int width );
|
||||
Component getPadding( Component component, int width );
|
||||
|
||||
/**
|
||||
* Get the minimum padding between each column
|
||||
@ -38,9 +38,9 @@ public interface TableFormatter
|
||||
*/
|
||||
int getColumnPadding();
|
||||
|
||||
int getWidth( TextComponent component );
|
||||
int getWidth( Component component );
|
||||
|
||||
void writeLine( int id, TextComponent component );
|
||||
void writeLine( int id, Component component );
|
||||
|
||||
default int display( TableBuilder table )
|
||||
{
|
||||
@ -50,13 +50,13 @@ public interface TableFormatter
|
||||
int columns = table.getColumns();
|
||||
int[] maxWidths = new int[columns];
|
||||
|
||||
TextComponent[] headers = table.getHeaders();
|
||||
Component[] headers = table.getHeaders();
|
||||
if( headers != null )
|
||||
{
|
||||
for( int i = 0; i < columns; i++ ) maxWidths[i] = getWidth( headers[i] );
|
||||
}
|
||||
|
||||
for( TextComponent[] row : table.getRows() )
|
||||
for( Component[] row : table.getRows() )
|
||||
{
|
||||
for( int i = 0; i < row.length; i++ )
|
||||
{
|
||||
@ -77,11 +77,11 @@ public interface TableFormatter
|
||||
|
||||
if( headers != null )
|
||||
{
|
||||
StringTextComponent line = new StringTextComponent( "" );
|
||||
TextComponent line = new TextComponent( "" );
|
||||
for( int i = 0; i < columns - 1; i++ )
|
||||
{
|
||||
line.append( headers[i] );
|
||||
TextComponent padding = getPadding( headers[i], maxWidths[i] );
|
||||
Component padding = getPadding( headers[i], maxWidths[i] );
|
||||
if( padding != null ) line.append( padding );
|
||||
line.append( SEPARATOR );
|
||||
}
|
||||
@ -93,16 +93,16 @@ public interface TableFormatter
|
||||
// it a tad prettier.
|
||||
int rowCharWidth = getWidth( HEADER );
|
||||
int rowWidth = totalWidth / rowCharWidth + (totalWidth % rowCharWidth == 0 ? 0 : 1);
|
||||
writeLine( rowId++, coloured( StringUtils.repeat( HEADER.getText(), rowWidth ), TextFormat.GRAY ) );
|
||||
writeLine( rowId++, coloured( StringUtils.repeat( HEADER.getText(), rowWidth ), ChatFormat.GRAY ) );
|
||||
}
|
||||
|
||||
for( TextComponent[] row : table.getRows() )
|
||||
for( Component[] row : table.getRows() )
|
||||
{
|
||||
StringTextComponent line = new StringTextComponent( "" );
|
||||
TextComponent line = new TextComponent( "" );
|
||||
for( int i = 0; i < columns - 1; i++ )
|
||||
{
|
||||
line.append( row[i] );
|
||||
TextComponent padding = getPadding( row[i], maxWidths[i] );
|
||||
Component padding = getPadding( row[i], maxWidths[i] );
|
||||
if( padding != null ) line.append( padding );
|
||||
line.append( SEPARATOR );
|
||||
}
|
||||
@ -112,7 +112,7 @@ public interface TableFormatter
|
||||
|
||||
if( table.getAdditional() > 0 )
|
||||
{
|
||||
writeLine( rowId++, coloured( translate( "commands.computercraft.generic.additional_rows", table.getAdditional() ), TextFormat.AQUA ) );
|
||||
writeLine( rowId++, coloured( translate( "commands.computercraft.generic.additional_rows", table.getAdditional() ), ChatFormat.AQUA ) );
|
||||
}
|
||||
|
||||
return rowId - table.getId();
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
package dan200.computercraft.shared.common;
|
||||
|
||||
import dan200.computercraft.shared.util.NamedBlockEntityType;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockEntityProvider;
|
||||
import net.minecraft.block.BlockState;
|
||||
@ -26,10 +27,11 @@ public abstract class BlockGeneric extends Block implements BlockEntityProvider
|
||||
{
|
||||
private final BlockEntityType<? extends TileGeneric> type;
|
||||
|
||||
public BlockGeneric( Settings settings, BlockEntityType<? extends TileGeneric> type )
|
||||
public BlockGeneric( Settings settings, NamedBlockEntityType<? extends TileGeneric> type )
|
||||
{
|
||||
super( settings );
|
||||
this.type = type;
|
||||
type.setBlock( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -9,9 +9,9 @@ package dan200.computercraft.shared.computer.blocks;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.computer.core.ComputerState;
|
||||
import dan200.computercraft.shared.computer.items.ComputerItemFactory;
|
||||
import dan200.computercraft.shared.util.NamedBlockEntityType;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.item.ItemPlacementContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.state.StateFactory;
|
||||
@ -28,7 +28,7 @@ public class BlockComputer extends BlockComputerBase<TileComputer>
|
||||
public static final EnumProperty<ComputerState> STATE = EnumProperty.create( "state", ComputerState.class );
|
||||
public static final DirectionProperty FACING = Properties.FACING_HORIZONTAL;
|
||||
|
||||
public BlockComputer( Settings settings, ComputerFamily family, BlockEntityType<? extends TileComputer> type )
|
||||
public BlockComputer( Settings settings, ComputerFamily family, NamedBlockEntityType<? extends TileComputer> type )
|
||||
{
|
||||
super( settings, family, type );
|
||||
setDefaultState( getDefaultState()
|
||||
@ -40,7 +40,7 @@ public class BlockComputer extends BlockComputerBase<TileComputer>
|
||||
@Override
|
||||
protected void appendProperties( StateFactory.Builder<Block, BlockState> builder )
|
||||
{
|
||||
builder.with( FACING, STATE );
|
||||
builder.add( FACING, STATE );
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -13,9 +13,9 @@ import dan200.computercraft.shared.common.IBundledRedstoneBlock;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.computer.core.ServerComputer;
|
||||
import dan200.computercraft.shared.computer.items.IComputerItem;
|
||||
import dan200.computercraft.shared.util.NamedBlockEntityType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Identifier;
|
||||
@ -35,7 +35,7 @@ public abstract class BlockComputerBase<T extends TileComputerBase> extends Bloc
|
||||
|
||||
private final ComputerFamily family;
|
||||
|
||||
protected BlockComputerBase( Settings settings, ComputerFamily family, BlockEntityType<? extends T> type )
|
||||
protected BlockComputerBase( Settings settings, ComputerFamily family, NamedBlockEntityType<? extends T> type )
|
||||
{
|
||||
super( settings, type );
|
||||
this.family = family;
|
||||
|
@ -13,13 +13,13 @@ import dan200.computercraft.shared.computer.core.ServerComputer;
|
||||
import dan200.computercraft.shared.util.NamedBlockEntityType;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
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.command.CommandOutput;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.text.StringTextComponent;
|
||||
import net.minecraft.text.TextComponent;
|
||||
import net.minecraft.text.TranslatableTextComponent;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.Vec2f;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
@ -54,7 +54,7 @@ public class TileCommandComputer extends TileComputer
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage( TextComponent textComponent )
|
||||
public void sendMessage( Component textComponent )
|
||||
{
|
||||
output.put( output.size() + 1, textComponent.getText() );
|
||||
}
|
||||
@ -104,7 +104,7 @@ public class TileCommandComputer extends TileComputer
|
||||
return new ServerCommandSource( receiver,
|
||||
new Vec3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 ), Vec2f.ZERO,
|
||||
(ServerWorld) getWorld(), 2,
|
||||
name, new StringTextComponent( name ),
|
||||
name, new TextComponent( name ),
|
||||
getWorld().getServer(), null
|
||||
);
|
||||
}
|
||||
@ -123,12 +123,12 @@ public class TileCommandComputer extends TileComputer
|
||||
MinecraftServer server = player.getServer();
|
||||
if( server == null || !server.areCommandBlocksEnabled() )
|
||||
{
|
||||
player.addChatMessage( new TranslatableTextComponent( "advMode.notEnabled" ), true );
|
||||
player.addChatMessage( new TranslatableComponent( "advMode.notEnabled" ), true );
|
||||
return false;
|
||||
}
|
||||
else if( !player.isCreativeLevelTwoOp() )
|
||||
{
|
||||
player.addChatMessage( new TranslatableTextComponent( "advMode.notAllowed" ), true );
|
||||
player.addChatMessage( new TranslatableComponent( "advMode.notAllowed" ), true );
|
||||
return false;
|
||||
}
|
||||
else
|
||||
|
@ -28,8 +28,8 @@ import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.text.StringTextComponent;
|
||||
import net.minecraft.text.TextComponent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.Nameable;
|
||||
import net.minecraft.util.Tickable;
|
||||
@ -439,9 +439,9 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public TextComponent getName()
|
||||
public Component getName()
|
||||
{
|
||||
return hasCustomName() ? new StringTextComponent( m_label ) : getCachedState().getBlock().getTextComponent();
|
||||
return hasCustomName() ? new TextComponent( m_label ) : getCachedState().getBlock().getTextComponent();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -452,8 +452,8 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public TextComponent getCustomName()
|
||||
public Component getCustomName()
|
||||
{
|
||||
return hasCustomName() ? new StringTextComponent( m_label ) : null;
|
||||
return hasCustomName() ? new TextComponent( m_label ) : null;
|
||||
}
|
||||
}
|
||||
|
@ -6,11 +6,11 @@
|
||||
|
||||
package dan200.computercraft.shared.computer.core;
|
||||
|
||||
import net.minecraft.util.StringRepresentable;
|
||||
import net.minecraft.util.SnakeCaseIdentifiable;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public enum ComputerState implements StringRepresentable
|
||||
public enum ComputerState implements SnakeCaseIdentifiable
|
||||
{
|
||||
OFF( "off" ),
|
||||
ON( "on" ),
|
||||
@ -25,7 +25,7 @@ public enum ComputerState implements StringRepresentable
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String asString()
|
||||
public String toSnakeCase()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
@ -10,8 +10,8 @@ import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.shared.computer.core.*;
|
||||
import net.minecraft.container.Container;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.text.TranslatableTextComponent;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
@ -53,12 +53,12 @@ public class ContainerViewComputer extends Container implements IContainerComput
|
||||
MinecraftServer server = player.getServer();
|
||||
if( server == null || !server.areCommandBlocksEnabled() )
|
||||
{
|
||||
player.addChatMessage( new TranslatableTextComponent( "advMode.notEnabled" ), false );
|
||||
player.addChatMessage( new TranslatableComponent( "advMode.notEnabled" ), false );
|
||||
return false;
|
||||
}
|
||||
else if( !player.isCreativeLevelTwoOp() )
|
||||
{
|
||||
player.addChatMessage( new TranslatableTextComponent( "advMode.notAllowed" ), false );
|
||||
player.addChatMessage( new TranslatableComponent( "advMode.notAllowed" ), false );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ package dan200.computercraft.shared.computer.items;
|
||||
import dan200.computercraft.shared.computer.blocks.BlockComputer;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.text.StringTextComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@ -24,7 +24,7 @@ public class ItemComputer extends ItemComputerBase
|
||||
{
|
||||
ItemStack result = new ItemStack( this );
|
||||
if( id >= 0 ) result.getOrCreateTag().putInt( NBT_ID, id );
|
||||
if( label != null ) result.setDisplayName( new StringTextComponent( label ) );
|
||||
if( label != null ) result.setDisplayName( new TextComponent( label ) );
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -12,13 +12,13 @@ import dan200.computercraft.api.filesystem.IMount;
|
||||
import dan200.computercraft.api.media.IMedia;
|
||||
import dan200.computercraft.shared.computer.blocks.BlockComputerBase;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import net.minecraft.ChatFormat;
|
||||
import net.minecraft.client.item.TooltipContext;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.text.StringTextComponent;
|
||||
import net.minecraft.text.TextComponent;
|
||||
import net.minecraft.text.TextFormat;
|
||||
import net.minecraft.text.TranslatableTextComponent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@ -36,15 +36,15 @@ public abstract class ItemComputerBase extends BlockItem implements IComputerIte
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildTooltip( @Nonnull ItemStack stack, @Nullable World world, @Nonnull List<TextComponent> list, @Nonnull TooltipContext options )
|
||||
public void buildTooltip( @Nonnull ItemStack stack, @Nullable World world, @Nonnull List<Component> list, @Nonnull TooltipContext options )
|
||||
{
|
||||
if( options.isAdvanced() )
|
||||
{
|
||||
int id = getComputerID( stack );
|
||||
if( id >= 0 )
|
||||
{
|
||||
list.add( new TranslatableTextComponent( "gui.computercraft.tooltip.computer_id", id )
|
||||
.applyFormat( TextFormat.GRAY ) );
|
||||
list.add( new TranslatableComponent( "gui.computercraft.tooltip.computer_id", id )
|
||||
.applyFormat( ChatFormat.GRAY ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -68,7 +68,7 @@ public abstract class ItemComputerBase extends BlockItem implements IComputerIte
|
||||
{
|
||||
if( label != null )
|
||||
{
|
||||
stack.setDisplayName( new StringTextComponent( label ) );
|
||||
stack.setDisplayName( new TextComponent( label ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -12,15 +12,15 @@ import dan200.computercraft.api.filesystem.IMount;
|
||||
import dan200.computercraft.api.media.IMedia;
|
||||
import dan200.computercraft.shared.common.IColouredItem;
|
||||
import dan200.computercraft.shared.util.Colour;
|
||||
import net.minecraft.ChatFormat;
|
||||
import net.minecraft.client.item.TooltipContext;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.text.StringTextComponent;
|
||||
import net.minecraft.text.TextComponent;
|
||||
import net.minecraft.text.TextFormat;
|
||||
import net.minecraft.text.TranslatableTextComponent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.util.DefaultedList;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@ -58,15 +58,15 @@ public class ItemDisk extends Item implements IMedia, IColouredItem
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildTooltip( ItemStack stack, @Nullable World world, List<TextComponent> list, TooltipContext options )
|
||||
public void buildTooltip( ItemStack stack, @Nullable World world, List<Component> list, TooltipContext options )
|
||||
{
|
||||
if( options.isAdvanced() )
|
||||
{
|
||||
int id = getDiskID( stack );
|
||||
if( id >= 0 )
|
||||
{
|
||||
list.add( new TranslatableTextComponent( "gui.computercraft.tooltip.disk_id", id )
|
||||
.applyFormat( TextFormat.GRAY ) );
|
||||
list.add( new TranslatableComponent( "gui.computercraft.tooltip.disk_id", id )
|
||||
.applyFormat( ChatFormat.GRAY ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -82,7 +82,7 @@ public class ItemDisk extends Item implements IMedia, IColouredItem
|
||||
{
|
||||
if( label != null )
|
||||
{
|
||||
stack.setDisplayName( new StringTextComponent( label ) );
|
||||
stack.setDisplayName( new TextComponent( label ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -13,8 +13,8 @@ import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.text.StringTextComponent;
|
||||
import net.minecraft.text.TextComponent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.TypedActionResult;
|
||||
@ -50,10 +50,10 @@ public class ItemPrintout extends Item
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildTooltip( @Nonnull ItemStack stack, World world, List<TextComponent> list, TooltipContext options )
|
||||
public void buildTooltip( @Nonnull ItemStack stack, World world, List<Component> list, TooltipContext options )
|
||||
{
|
||||
String title = getTitle( stack );
|
||||
if( title != null && !title.isEmpty() ) list.add( new StringTextComponent( title ) );
|
||||
if( title != null && !title.isEmpty() ) list.add( new TextComponent( title ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -17,8 +17,8 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.text.StringTextComponent;
|
||||
import net.minecraft.text.TextComponent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.util.DefaultedList;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@ -44,10 +44,10 @@ public class ItemTreasureDisk extends Item implements IMedia
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildTooltip( ItemStack stack, @Nullable World world, List<TextComponent> list, TooltipContext context )
|
||||
public void buildTooltip( ItemStack stack, @Nullable World world, List<Component> list, TooltipContext context )
|
||||
{
|
||||
String label = getTitle( stack );
|
||||
if( !label.isEmpty() ) list.add( new StringTextComponent( label ) );
|
||||
if( !label.isEmpty() ) list.add( new TextComponent( label ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -14,10 +14,10 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.fabric.api.network.ClientSidePacketRegistry;
|
||||
import net.fabricmc.fabric.api.network.PacketContext;
|
||||
import net.fabricmc.fabric.api.network.ServerSidePacketRegistry;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.packet.CustomPayloadS2CPacket;
|
||||
|
@ -12,7 +12,7 @@ import dan200.computercraft.shared.network.NetworkMessage;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.network.PacketContext;
|
||||
import net.minecraft.text.TextComponent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.util.PacketByteBuf;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@ -39,13 +39,13 @@ public class ChatTableClientMessage implements NetworkMessage
|
||||
buf.writeBoolean( table.getHeaders() != null );
|
||||
if( table.getHeaders() != null )
|
||||
{
|
||||
for( TextComponent header : table.getHeaders() ) buf.writeTextComponent( header );
|
||||
for( Component header : table.getHeaders() ) buf.writeTextComponent( header );
|
||||
}
|
||||
|
||||
buf.writeVarInt( table.getRows().size() );
|
||||
for( TextComponent[] row : table.getRows() )
|
||||
for( Component[] row : table.getRows() )
|
||||
{
|
||||
for( TextComponent column : row ) buf.writeTextComponent( column );
|
||||
for( Component column : row ) buf.writeTextComponent( column );
|
||||
}
|
||||
|
||||
buf.writeVarInt( table.getAdditional() );
|
||||
@ -59,7 +59,7 @@ public class ChatTableClientMessage implements NetworkMessage
|
||||
TableBuilder table;
|
||||
if( buf.readBoolean() )
|
||||
{
|
||||
TextComponent[] headers = new TextComponent[columns];
|
||||
Component[] headers = new Component[columns];
|
||||
for( int i = 0; i < columns; i++ ) headers[i] = buf.readTextComponent();
|
||||
table = new TableBuilder( id, headers );
|
||||
}
|
||||
@ -71,7 +71,7 @@ public class ChatTableClientMessage implements NetworkMessage
|
||||
int rows = buf.readVarInt();
|
||||
for( int i = 0; i < rows; i++ )
|
||||
{
|
||||
TextComponent[] row = new TextComponent[columns];
|
||||
Component[] row = new Component[columns];
|
||||
for( int j = 0; j < columns; j++ ) row[j] = buf.readTextComponent();
|
||||
table.row( row );
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public class BlockDiskDrive extends BlockGeneric
|
||||
@Override
|
||||
protected void appendProperties( StateFactory.Builder<Block, BlockState> properties )
|
||||
{
|
||||
properties.with( FACING, STATE );
|
||||
properties.add( FACING, STATE );
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -6,9 +6,9 @@
|
||||
|
||||
package dan200.computercraft.shared.peripheral.diskdrive;
|
||||
|
||||
import net.minecraft.util.StringRepresentable;
|
||||
import net.minecraft.util.SnakeCaseIdentifiable;
|
||||
|
||||
public enum DiskDriveState implements StringRepresentable
|
||||
public enum DiskDriveState implements SnakeCaseIdentifiable
|
||||
{
|
||||
EMPTY( "empty" ),
|
||||
FULL( "full" ),
|
||||
@ -23,7 +23,7 @@ public enum DiskDriveState implements StringRepresentable
|
||||
|
||||
|
||||
@Override
|
||||
public String asString()
|
||||
public String toSnakeCase()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
@ -26,8 +26,9 @@ import net.minecraft.entity.ItemEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
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.text.TextComponent;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.Nameable;
|
||||
@ -59,7 +60,7 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory
|
||||
String mountPath;
|
||||
}
|
||||
|
||||
TextComponent customName;
|
||||
Component customName;
|
||||
|
||||
private final Map<IComputerAccess, MountInfo> m_computers = new HashMap<>();
|
||||
|
||||
@ -542,14 +543,14 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public TextComponent getCustomName()
|
||||
public Component getCustomName()
|
||||
{
|
||||
return customName;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public TextComponent getName()
|
||||
public Component getName()
|
||||
{
|
||||
return customName != null ? customName : getCachedState().getBlock().getTextComponent();
|
||||
}
|
||||
|
@ -18,8 +18,8 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.entity.EntityContext;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.VerticalEntityPosition;
|
||||
import net.minecraft.fluid.FluidState;
|
||||
import net.minecraft.item.ItemPlacementContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@ -75,7 +75,7 @@ public class BlockCable extends BlockGeneric implements WaterloggableBlock
|
||||
@Override
|
||||
protected void appendProperties( StateFactory.Builder<Block, BlockState> builder )
|
||||
{
|
||||
builder.with( MODEM, CABLE, NORTH, SOUTH, EAST, WEST, UP, DOWN, WATERLOGGED );
|
||||
builder.add( MODEM, CABLE, NORTH, SOUTH, EAST, WEST, UP, DOWN, WATERLOGGED );
|
||||
}
|
||||
|
||||
public static boolean canConnectIn( BlockState state, Direction direction )
|
||||
@ -92,7 +92,7 @@ public class BlockCable extends BlockGeneric implements WaterloggableBlock
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public VoxelShape getOutlineShape( BlockState state, BlockView world, BlockPos pos, VerticalEntityPosition position )
|
||||
public VoxelShape getOutlineShape( BlockState state, BlockView world, BlockPos pos, EntityContext position )
|
||||
{
|
||||
return CableShapes.getShape( state );
|
||||
}
|
||||
|
@ -29,6 +29,6 @@ public class BlockWiredModemFull extends BlockGeneric
|
||||
@Override
|
||||
protected void appendProperties( StateFactory.Builder<Block, BlockState> builder )
|
||||
{
|
||||
builder.with( MODEM_ON, PERIPHERAL_ON );
|
||||
builder.add( MODEM_ON, PERIPHERAL_ON );
|
||||
}
|
||||
}
|
||||
|
@ -6,12 +6,12 @@
|
||||
|
||||
package dan200.computercraft.shared.peripheral.modem.wired;
|
||||
|
||||
import net.minecraft.util.StringRepresentable;
|
||||
import net.minecraft.util.SnakeCaseIdentifiable;
|
||||
import net.minecraft.util.math.Direction;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public enum CableModemVariant implements StringRepresentable
|
||||
public enum CableModemVariant implements SnakeCaseIdentifiable
|
||||
{
|
||||
None( "none", null ),
|
||||
DownOff( "down_off", Direction.DOWN ),
|
||||
@ -65,7 +65,7 @@ public enum CableModemVariant implements StringRepresentable
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String asString()
|
||||
public String toSnakeCase()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
@ -9,11 +9,7 @@ package dan200.computercraft.shared.peripheral.modem.wired;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemPlacementContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.util.ActionResult;
|
||||
|
@ -24,7 +24,7 @@ import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.text.TranslatableTextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
@ -238,12 +238,12 @@ public class TileCable extends TileGeneric implements IPeripheralTile
|
||||
{
|
||||
if( oldName != null )
|
||||
{
|
||||
player.addChatMessage( new TranslatableTextComponent( "chat.computercraft.wired_modem.peripheral_disconnected",
|
||||
player.addChatMessage( new TranslatableComponent( "chat.computercraft.wired_modem.peripheral_disconnected",
|
||||
CommandCopy.createCopyText( oldName ) ), false );
|
||||
}
|
||||
if( newName != null )
|
||||
{
|
||||
player.addChatMessage( new TranslatableTextComponent( "chat.computercraft.wired_modem.peripheral_connected",
|
||||
player.addChatMessage( new TranslatableComponent( "chat.computercraft.wired_modem.peripheral_connected",
|
||||
CommandCopy.createCopyText( newName ) ), false );
|
||||
}
|
||||
}
|
||||
|
@ -22,8 +22,8 @@ import dan200.computercraft.shared.util.TickScheduler;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.text.StringTextComponent;
|
||||
import net.minecraft.text.TranslatableTextComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
@ -194,14 +194,14 @@ public class TileWiredModemFull extends TileGeneric implements IPeripheralTile
|
||||
List<String> names = new ArrayList<>( peripherals );
|
||||
names.sort( Comparator.naturalOrder() );
|
||||
|
||||
StringTextComponent base = new StringTextComponent( "" );
|
||||
TextComponent base = new TextComponent( "" );
|
||||
for( int i = 0; i < names.size(); i++ )
|
||||
{
|
||||
if( i > 0 ) base.append( ", " );
|
||||
base.append( CommandCopy.createCopyText( names.get( i ) ) );
|
||||
}
|
||||
|
||||
player.addChatMessage( new TranslatableTextComponent( kind, base ), false );
|
||||
player.addChatMessage( new TranslatableComponent( kind, base ), false );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -8,11 +8,11 @@ package dan200.computercraft.shared.peripheral.modem.wireless;
|
||||
|
||||
import dan200.computercraft.shared.common.BlockGeneric;
|
||||
import dan200.computercraft.shared.peripheral.modem.ModemShapes;
|
||||
import dan200.computercraft.shared.util.NamedBlockEntityType;
|
||||
import dan200.computercraft.shared.util.WaterloggableBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.entity.VerticalEntityPosition;
|
||||
import net.minecraft.entity.EntityContext;
|
||||
import net.minecraft.fluid.FluidState;
|
||||
import net.minecraft.item.ItemPlacementContext;
|
||||
import net.minecraft.state.StateFactory;
|
||||
@ -34,7 +34,7 @@ public class BlockWirelessModem extends BlockGeneric implements WaterloggableBlo
|
||||
public static final DirectionProperty FACING = Properties.FACING;
|
||||
public static final BooleanProperty ON = BooleanProperty.create( "on" );
|
||||
|
||||
public BlockWirelessModem( Settings settings, BlockEntityType<? extends TileWirelessModem> type )
|
||||
public BlockWirelessModem( Settings settings, NamedBlockEntityType<? extends TileWirelessModem> type )
|
||||
{
|
||||
super( settings, type );
|
||||
setDefaultState( getStateFactory().getDefaultState()
|
||||
@ -46,13 +46,13 @@ public class BlockWirelessModem extends BlockGeneric implements WaterloggableBlo
|
||||
@Override
|
||||
protected void appendProperties( StateFactory.Builder<Block, BlockState> builder )
|
||||
{
|
||||
builder.with( FACING, ON, WATERLOGGED );
|
||||
builder.add( FACING, ON, WATERLOGGED );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
@Deprecated
|
||||
public VoxelShape getOutlineShape( BlockState blockState, BlockView world, BlockPos pos, VerticalEntityPosition position )
|
||||
public VoxelShape getOutlineShape( BlockState blockState, BlockView world, BlockPos pos, EntityContext position )
|
||||
{
|
||||
return ModemShapes.getBounds( blockState.get( FACING ) );
|
||||
}
|
||||
|
@ -8,11 +8,11 @@ package dan200.computercraft.shared.peripheral.monitor;
|
||||
|
||||
import dan200.computercraft.shared.common.BlockGeneric;
|
||||
import dan200.computercraft.shared.common.TileGeneric;
|
||||
import dan200.computercraft.shared.util.NamedBlockEntityType;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockRenderLayer;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.item.ItemPlacementContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@ -35,7 +35,7 @@ public class BlockMonitor extends BlockGeneric
|
||||
|
||||
static final EnumProperty<MonitorEdgeState> STATE = EnumProperty.create( "state", MonitorEdgeState.class );
|
||||
|
||||
public BlockMonitor( Settings settings, BlockEntityType<? extends TileGeneric> type )
|
||||
public BlockMonitor( Settings settings, NamedBlockEntityType<? extends TileGeneric> type )
|
||||
{
|
||||
super( settings, type );
|
||||
setDefaultState( getStateFactory().getDefaultState()
|
||||
@ -53,7 +53,7 @@ public class BlockMonitor extends BlockGeneric
|
||||
@Override
|
||||
protected void appendProperties( StateFactory.Builder<Block, BlockState> builder )
|
||||
{
|
||||
builder.with( ORIENTATION, FACING, STATE );
|
||||
builder.add( ORIENTATION, FACING, STATE );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -6,13 +6,13 @@
|
||||
|
||||
package dan200.computercraft.shared.peripheral.monitor;
|
||||
|
||||
import net.minecraft.util.StringRepresentable;
|
||||
import net.minecraft.util.SnakeCaseIdentifiable;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import static dan200.computercraft.shared.peripheral.monitor.MonitorEdgeState.Flags.*;
|
||||
|
||||
public enum MonitorEdgeState implements StringRepresentable
|
||||
public enum MonitorEdgeState implements SnakeCaseIdentifiable
|
||||
{
|
||||
NONE( "none", 0 ),
|
||||
|
||||
@ -60,7 +60,7 @@ public enum MonitorEdgeState implements StringRepresentable
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String asString()
|
||||
public String toSnakeCase()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public class BlockPrinter extends BlockGeneric
|
||||
protected void appendProperties( StateFactory.Builder<Block, BlockState> properties )
|
||||
{
|
||||
super.appendProperties( properties );
|
||||
properties.with( FACING, TOP, BOTTOM );
|
||||
properties.add( FACING, TOP, BOTTOM );
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -22,7 +22,8 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.text.TextComponent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@ -51,7 +52,7 @@ 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[] SIDE_SLOTS = new int[] { 0 };
|
||||
|
||||
TextComponent customName;
|
||||
Component customName;
|
||||
|
||||
private final DefaultedList<ItemStack> m_inventory = DefaultedList.create( INVENTORY_SIZE, ItemStack.EMPTY );
|
||||
private final ItemStorage m_itemHandlerAll = ItemStorage.wrap( this );
|
||||
@ -528,14 +529,14 @@ public final class TilePrinter extends TileGeneric implements DefaultSidedInvent
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public TextComponent getCustomName()
|
||||
public Component getCustomName()
|
||||
{
|
||||
return customName;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public TextComponent getName()
|
||||
public Component getName()
|
||||
{
|
||||
return customName != null ? customName : getCachedState().getBlock().getTextComponent();
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ public class BlockSpeaker extends BlockGeneric
|
||||
@Override
|
||||
protected void appendProperties( StateFactory.Builder<Block, BlockState> properties )
|
||||
{
|
||||
properties.with( FACING );
|
||||
properties.add( FACING );
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -106,7 +106,7 @@ public abstract class SpeakerPeripheral implements IPeripheral
|
||||
Instrument instrument = null;
|
||||
for( Instrument testInstrument : Instrument.values() )
|
||||
{
|
||||
if( testInstrument.asString().equalsIgnoreCase( name ) )
|
||||
if( testInstrument.toSnakeCase().equalsIgnoreCase( name ) )
|
||||
{
|
||||
instrument = testInstrument;
|
||||
break;
|
||||
|
@ -25,6 +25,7 @@ import dan200.computercraft.shared.pocket.apis.PocketAPI;
|
||||
import dan200.computercraft.shared.pocket.core.PocketServerComputer;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.ChatFormat;
|
||||
import net.minecraft.client.item.TooltipContext;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@ -34,10 +35,9 @@ import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemPropertyGetter;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.text.StringTextComponent;
|
||||
import net.minecraft.text.TextComponent;
|
||||
import net.minecraft.text.TextFormat;
|
||||
import net.minecraft.text.TranslatableTextComponent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@ -68,7 +68,7 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I
|
||||
{
|
||||
ItemStack result = new ItemStack( this );
|
||||
if( id >= 0 ) result.getOrCreateTag().putInt( NBT_ID, id );
|
||||
if( label != null ) result.setDisplayName( new StringTextComponent( label ) );
|
||||
if( label != null ) result.setDisplayName( new TextComponent( label ) );
|
||||
if( upgrade != null ) result.getOrCreateTag().putString( NBT_UPGRADE, upgrade.getUpgradeID().toString() );
|
||||
if( colour != -1 ) result.getOrCreateTag().putInt( NBT_COLOUR, colour );
|
||||
return result;
|
||||
@ -161,14 +161,14 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public TextComponent getTranslatedNameTrimmed( @Nonnull ItemStack stack )
|
||||
public Component getTranslatedNameTrimmed( @Nonnull ItemStack stack )
|
||||
{
|
||||
String baseString = getTranslationKey( stack );
|
||||
IPocketUpgrade upgrade = getUpgrade( stack );
|
||||
if( upgrade != null )
|
||||
{
|
||||
return new TranslatableTextComponent( baseString + ".upgraded",
|
||||
new TranslatableTextComponent( upgrade.getUnlocalisedAdjective() )
|
||||
return new TranslatableComponent( baseString + ".upgraded",
|
||||
new TranslatableComponent( upgrade.getUnlocalisedAdjective() )
|
||||
);
|
||||
}
|
||||
else
|
||||
@ -179,15 +179,15 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I
|
||||
|
||||
|
||||
@Override
|
||||
public void buildTooltip( ItemStack stack, @Nullable World world, List<TextComponent> list, TooltipContext flag )
|
||||
public void buildTooltip( ItemStack stack, @Nullable World world, List<Component> list, TooltipContext flag )
|
||||
{
|
||||
if( flag.isAdvanced() )
|
||||
{
|
||||
int id = getComputerID( stack );
|
||||
if( id >= 0 )
|
||||
{
|
||||
list.add( new TranslatableTextComponent( "gui.computercraft.tooltip.computer_id", id )
|
||||
.applyFormat( TextFormat.GRAY ) );
|
||||
list.add( new TranslatableComponent( "gui.computercraft.tooltip.computer_id", id )
|
||||
.applyFormat( ChatFormat.GRAY ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -297,7 +297,7 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I
|
||||
{
|
||||
if( label != null )
|
||||
{
|
||||
stack.setDisplayName( new StringTextComponent( label ) );
|
||||
stack.setDisplayName( new TextComponent( label ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -13,14 +13,14 @@ import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.turtle.core.TurtleBrain;
|
||||
import dan200.computercraft.shared.turtle.items.ITurtleItem;
|
||||
import dan200.computercraft.shared.turtle.items.TurtleItemFactory;
|
||||
import dan200.computercraft.shared.util.NamedBlockEntityType;
|
||||
import dan200.computercraft.shared.util.WaterloggableBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.entity.EntityContext;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.VerticalEntityPosition;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.fluid.FluidState;
|
||||
import net.minecraft.item.ItemPlacementContext;
|
||||
@ -50,7 +50,7 @@ public class BlockTurtle extends BlockComputerBase<TileTurtle> implements Waterl
|
||||
0.875, 0.875, 0.875
|
||||
);
|
||||
|
||||
public BlockTurtle( Settings settings, ComputerFamily family, BlockEntityType<TileTurtle> type )
|
||||
public BlockTurtle( Settings settings, ComputerFamily family, NamedBlockEntityType<TileTurtle> type )
|
||||
{
|
||||
super( settings, family, type );
|
||||
setDefaultState( getStateFactory().getDefaultState()
|
||||
@ -62,7 +62,7 @@ public class BlockTurtle extends BlockComputerBase<TileTurtle> implements Waterl
|
||||
@Override
|
||||
protected void appendProperties( StateFactory.Builder<Block, BlockState> builder )
|
||||
{
|
||||
builder.with( FACING, WATERLOGGED );
|
||||
builder.add( FACING, WATERLOGGED );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@ -76,7 +76,7 @@ public class BlockTurtle extends BlockComputerBase<TileTurtle> implements Waterl
|
||||
@Nonnull
|
||||
@Override
|
||||
@Deprecated
|
||||
public VoxelShape getOutlineShape( BlockState state, BlockView world, BlockPos pos, VerticalEntityPosition position )
|
||||
public VoxelShape getOutlineShape( BlockState state, BlockView world, BlockPos pos, EntityContext position )
|
||||
{
|
||||
BlockEntity tile = world.getBlockEntity( pos );
|
||||
Vec3d offset = tile instanceof TileTurtle ? ((TileTurtle) tile).getRenderOffset( 1.0f ) : Vec3d.ZERO;
|
||||
|
@ -60,7 +60,7 @@ public class TurtleCompareCommand implements ITurtleCommand
|
||||
{
|
||||
for( ItemStack drop : drops )
|
||||
{
|
||||
if( drop.getItem() == lookAtBlock.getItem() )
|
||||
if( drop.getItem() == lookAtBlock.asItem() )
|
||||
{
|
||||
lookAtStack = drop;
|
||||
break;
|
||||
|
@ -22,7 +22,7 @@ import net.minecraft.block.entity.SignBlockEntity;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.text.StringTextComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.TypedActionResult;
|
||||
@ -228,10 +228,10 @@ public class TurtlePlaceCommand implements ITurtleCommand
|
||||
|
||||
// Place on the entity
|
||||
boolean placed = false;
|
||||
ActionResult cancelResult = null; // ForgeHooks.onInteractEntityAt( turtlePlayer, hitEntity, hitPos, Hand.MAIN );
|
||||
ActionResult cancelResult = null; // ForgeHooks.onInteractEntityAt( turtlePlayer, hitEntity, hitPos, Hand.MAIN_HAND);
|
||||
if( cancelResult == null )
|
||||
{
|
||||
cancelResult = hitEntity.interactAt( turtlePlayer, hitPos, Hand.MAIN );
|
||||
cancelResult = hitEntity.interactAt( turtlePlayer, hitPos, Hand.MAIN_HAND );
|
||||
}
|
||||
|
||||
if( cancelResult == ActionResult.SUCCESS )
|
||||
@ -241,20 +241,20 @@ public class TurtlePlaceCommand implements ITurtleCommand
|
||||
else
|
||||
{
|
||||
// See PlayerEntity.interactOn
|
||||
// cancelResult = ForgeHooks.onInteractEntity( turtlePlayer, hitEntity, Hand.MAIN );
|
||||
// cancelResult = ForgeHooks.onInteractEntity( turtlePlayer, hitEntity, Hand.MAIN_HAND);
|
||||
if( cancelResult == ActionResult.SUCCESS )
|
||||
{
|
||||
placed = true;
|
||||
}
|
||||
else if( cancelResult == null )
|
||||
{
|
||||
if( hitEntity.interact( turtlePlayer, Hand.MAIN ) )
|
||||
if( hitEntity.interact( turtlePlayer, Hand.MAIN_HAND ) )
|
||||
{
|
||||
placed = true;
|
||||
}
|
||||
else if( hitEntity instanceof LivingEntity )
|
||||
{
|
||||
placed = stackCopy.interactWithEntity( turtlePlayer, (LivingEntity) hitEntity, Hand.MAIN );
|
||||
placed = stackCopy.interactWithEntity( turtlePlayer, (LivingEntity) hitEntity, Hand.MAIN_HAND );
|
||||
if( placed ) turtlePlayer.loadInventory( stackCopy );
|
||||
}
|
||||
}
|
||||
@ -336,7 +336,7 @@ public class TurtlePlaceCommand implements ITurtleCommand
|
||||
}
|
||||
|
||||
// Check if there's something suitable to place onto
|
||||
ItemUsageContext context = new ItemUsageContext( turtlePlayer, Hand.MAIN, new BlockHitResult( new Vec3d( hitX, hitY, hitZ ), side, position, false ) );
|
||||
ItemUsageContext context = new ItemUsageContext( turtlePlayer, Hand.MAIN_HAND, new BlockHitResult( new Vec3d( hitX, hitY, hitZ ), side, position, false ) );
|
||||
if( !canDeployOnBlock( new ItemPlacementContext( context ), turtle, turtlePlayer, position, side, allowReplace, outErrorMessage ) )
|
||||
{
|
||||
return stack;
|
||||
@ -354,7 +354,7 @@ public class TurtlePlaceCommand implements ITurtleCommand
|
||||
PlayerInteractEvent.RightClickBlock event = ForgeHooks.onRightClickBlock( turtlePlayer, Hand.MAIN, position, side, new Vec3d( hitX, hitY, hitZ ) );
|
||||
if( !event.isCanceled() ) */
|
||||
{
|
||||
/* if( item.onItemUseFirst( turtlePlayer, turtle.getWorld(), position, side, hitX, hitY, hitZ, Hand.MAIN ) == ActionResult.SUCCESS )
|
||||
/* if( item.onItemUseFirst( turtlePlayer, turtle.getWorld(), position, side, hitX, hitY, hitZ, Hand.MAIN_HAND) == ActionResult.SUCCESS )
|
||||
{
|
||||
placed = true;
|
||||
turtlePlayer.loadInventory( stackCopy );
|
||||
@ -370,14 +370,14 @@ public class TurtlePlaceCommand implements ITurtleCommand
|
||||
|
||||
if( !placed && (item instanceof BucketItem || item instanceof BoatItem || item instanceof LilyPadItem || item instanceof GlassBottleItem) )
|
||||
{
|
||||
ActionResult actionResult = null; // ForgeHooks.onItemRightClick( turtlePlayer, Hand.MAIN );
|
||||
ActionResult actionResult = null; // ForgeHooks.onItemRightClick( turtlePlayer, Hand.MAIN_HAND);
|
||||
if( actionResult == ActionResult.SUCCESS )
|
||||
{
|
||||
placed = true;
|
||||
}
|
||||
else if( actionResult == null )
|
||||
{
|
||||
TypedActionResult<ItemStack> result = stackCopy.use( turtle.getWorld(), turtlePlayer, Hand.MAIN );
|
||||
TypedActionResult<ItemStack> result = stackCopy.use( turtle.getWorld(), turtlePlayer, Hand.MAIN_HAND );
|
||||
if( result.getResult() == ActionResult.SUCCESS && !ItemStack.areEqual( stack, result.getValue() ) )
|
||||
{
|
||||
placed = true;
|
||||
@ -409,16 +409,16 @@ public class TurtlePlaceCommand implements ITurtleCommand
|
||||
{
|
||||
if( split[i - firstLine].length() > 15 )
|
||||
{
|
||||
signTile.text[i] = new StringTextComponent( split[i - firstLine].substring( 0, 15 ) );
|
||||
signTile.text[i] = new TextComponent( split[i - firstLine].substring( 0, 15 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
signTile.text[i] = new StringTextComponent( split[i - firstLine] );
|
||||
signTile.text[i] = new TextComponent( split[i - firstLine] );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
signTile.text[i] = new StringTextComponent( "" );
|
||||
signTile.text[i] = new TextComponent( "" );
|
||||
}
|
||||
}
|
||||
signTile.markDirty();
|
||||
|
@ -16,9 +16,9 @@ import dan200.computercraft.shared.turtle.blocks.BlockTurtle;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.text.StringTextComponent;
|
||||
import net.minecraft.text.TextComponent;
|
||||
import net.minecraft.text.TranslatableTextComponent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.util.DefaultedList;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
@ -37,7 +37,7 @@ public class ItemTurtle extends ItemComputerBase implements ITurtleItem
|
||||
{
|
||||
// Build the stack
|
||||
ItemStack stack = new ItemStack( this );
|
||||
if( label != null ) stack.setDisplayName( new StringTextComponent( label ) );
|
||||
if( label != null ) stack.setDisplayName( new TextComponent( label ) );
|
||||
if( id >= 0 ) stack.getOrCreateTag().putInt( NBT_ID, id );
|
||||
IColouredItem.setColourBasic( stack, colour );
|
||||
if( fuelLevel > 0 ) stack.getOrCreateTag().putInt( NBT_FUEL, fuelLevel );
|
||||
@ -74,33 +74,33 @@ public class ItemTurtle extends ItemComputerBase implements ITurtleItem
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public TextComponent getTranslatedNameTrimmed( @Nonnull ItemStack stack )
|
||||
public Component getTranslatedNameTrimmed( @Nonnull ItemStack stack )
|
||||
{
|
||||
String baseString = getTranslationKey( stack );
|
||||
ITurtleUpgrade left = getUpgrade( stack, TurtleSide.Left );
|
||||
ITurtleUpgrade right = getUpgrade( stack, TurtleSide.Right );
|
||||
if( left != null && right != null )
|
||||
{
|
||||
return new TranslatableTextComponent( baseString + ".upgraded_twice",
|
||||
new TranslatableTextComponent( right.getUnlocalisedAdjective() ),
|
||||
new TranslatableTextComponent( left.getUnlocalisedAdjective() )
|
||||
return new TranslatableComponent( baseString + ".upgraded_twice",
|
||||
new TranslatableComponent( right.getUnlocalisedAdjective() ),
|
||||
new TranslatableComponent( left.getUnlocalisedAdjective() )
|
||||
);
|
||||
}
|
||||
else if( left != null )
|
||||
{
|
||||
return new TranslatableTextComponent( baseString + ".upgraded",
|
||||
new TranslatableTextComponent( left.getUnlocalisedAdjective() )
|
||||
return new TranslatableComponent( baseString + ".upgraded",
|
||||
new TranslatableComponent( left.getUnlocalisedAdjective() )
|
||||
);
|
||||
}
|
||||
else if( right != null )
|
||||
{
|
||||
return new TranslatableTextComponent( baseString + ".upgraded",
|
||||
new TranslatableTextComponent( right.getUnlocalisedAdjective() )
|
||||
return new TranslatableComponent( baseString + ".upgraded",
|
||||
new TranslatableComponent( right.getUnlocalisedAdjective() )
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new TranslatableTextComponent( baseString );
|
||||
return new TranslatableComponent( baseString );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -130,7 +130,7 @@ public class TurtleTool extends AbstractTurtleUpgrade
|
||||
Entity hitEntity = hit.getKey();
|
||||
|
||||
// Fire several events to ensure we have permissions.
|
||||
if( AttackEntityCallback.EVENT.invoker().interact( turtlePlayer, world, Hand.MAIN, hitEntity, null ) == ActionResult.FAIL
|
||||
if( AttackEntityCallback.EVENT.invoker().interact( turtlePlayer, world, Hand.MAIN_HAND, hitEntity, null ) == ActionResult.FAIL
|
||||
|| !hitEntity.canPlayerAttack() )
|
||||
{
|
||||
return TurtleCommandResult.failure( "Nothing to attack here" );
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
package dan200.computercraft.shared.util;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.inventory.SidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -10,6 +10,7 @@ import com.mojang.datafixers.DataFixUtils;
|
||||
import com.mojang.datafixers.types.Type;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.datafixers.Schemas;
|
||||
@ -17,16 +18,20 @@ import net.minecraft.datafixers.TypeReferences;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.MutableRegistry;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collections;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class NamedBlockEntityType<T extends BlockEntity> extends BlockEntityType<T>
|
||||
public final class NamedBlockEntityType<T extends BlockEntity> extends BlockEntityType<T>
|
||||
{
|
||||
private final Identifier identifier;
|
||||
private Block block;
|
||||
|
||||
private NamedBlockEntityType( Identifier identifier, Supplier<? extends T> supplier )
|
||||
{
|
||||
super( supplier, getDatafixer( identifier ) );
|
||||
super( supplier, Collections.emptySet(), getDatafixer( identifier ) );
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
@ -45,6 +50,18 @@ public class NamedBlockEntityType<T extends BlockEntity> extends BlockEntityType
|
||||
return identifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean method_20526( Block block )
|
||||
{
|
||||
return block == this.block;
|
||||
}
|
||||
|
||||
public void setBlock( @Nonnull Block block )
|
||||
{
|
||||
if( this.block != null ) throw new IllegalStateException( "Cannot override block" );
|
||||
this.block = Objects.requireNonNull( block, "block cannot be null" );
|
||||
}
|
||||
|
||||
public void register( MutableRegistry<BlockEntityType<?>> registry )
|
||||
{
|
||||
registry.add( getId(), this );
|
||||
@ -66,14 +83,14 @@ public class NamedBlockEntityType<T extends BlockEntity> extends BlockEntityType
|
||||
}
|
||||
}
|
||||
|
||||
private static class FixedPointSupplier<T extends BlockEntity> implements Supplier<T>
|
||||
private static final class FixedPointSupplier<T extends BlockEntity> implements Supplier<T>
|
||||
{
|
||||
final NamedBlockEntityType<T> factory;
|
||||
private final Function<NamedBlockEntityType<T>, ? extends T> builder;
|
||||
|
||||
private FixedPointSupplier( Identifier identifier, Function<NamedBlockEntityType<T>, ? extends T> builder )
|
||||
{
|
||||
this.factory = create( identifier, this );
|
||||
factory = create( identifier, this );
|
||||
this.builder = builder;
|
||||
}
|
||||
|
||||
|
@ -12,8 +12,8 @@ import dan200.computercraft.shared.network.client.PlayRecordClientMessage;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.MusicDiscItem;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.text.TranslatableTextComponent;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
@ -35,6 +35,6 @@ public final class RecordUtil
|
||||
Item item = recordStack.getItem();
|
||||
if( !(item instanceof MusicDiscItem) ) return null;
|
||||
|
||||
return new TranslatableTextComponent( item.getTranslationKey() + ".desc" ).getString();
|
||||
return new TranslatableComponent( item.getTranslationKey() + ".desc" ).getString();
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ public class ResourceMountTest
|
||||
@BeforeEach
|
||||
public void before()
|
||||
{
|
||||
ReloadableResourceManagerImpl manager = new ReloadableResourceManagerImpl( ResourceType.DATA, null );
|
||||
ReloadableResourceManagerImpl manager = new ReloadableResourceManagerImpl( ResourceType.SERVER_DATA, null );
|
||||
manager.addPack( new DirectoryResourcePack( new File( "src/main/resources" ) ) );
|
||||
|
||||
mount = new ResourceMount( "computercraft", "lua/rom", manager );
|
||||
|
Loading…
Reference in New Issue
Block a user