mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-11-01 06:03:00 +00:00
Compare commits
10 Commits
v1.16.1-1.
...
v1.16.1-1.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
29646a7f61 | ||
|
|
50d2712581 | ||
|
|
3093f882d8 | ||
|
|
e5cf0d1c61 | ||
|
|
6b102a8142 | ||
|
|
ac7979fb46 | ||
|
|
c8a6888a2f | ||
|
|
9ce33f8a3f | ||
|
|
d51851e763 | ||
|
|
fb70a1a998 |
@@ -10,7 +10,7 @@ do use the issue templates - they provide a useful hint on what information to p
|
||||
|
||||
## Developing
|
||||
In order to develop CC: Tweaked, you'll need to download the source code and then run it. This is a pretty simple
|
||||
process.
|
||||
process. When building on Windows, Use `gradlew.bat` instead of `./gradlew`.
|
||||
|
||||
- **Clone the repository:** `git clone https://github.com/SquidDev-CC/CC-Tweaked.git && cd CC-Tweaked`
|
||||
- **Setup Forge:** `./gradlew build`
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Mod properties
|
||||
mod_version=1.90.1
|
||||
mod_version=1.90.3
|
||||
|
||||
# Minecraft properties (update mods.toml when changing)
|
||||
mc_version=1.16.1
|
||||
forge_version=32.0.69
|
||||
mappings_version=20200707-1.16.1
|
||||
forge_version=32.0.75
|
||||
mappings_version=20200723-1.16.1
|
||||
|
||||
@@ -8,6 +8,7 @@ package dan200.computercraft;
|
||||
import dan200.computercraft.api.turtle.event.TurtleAction;
|
||||
import dan200.computercraft.core.apis.http.options.Action;
|
||||
import dan200.computercraft.core.apis.http.options.AddressRule;
|
||||
import dan200.computercraft.core.asm.GenericSource;
|
||||
import dan200.computercraft.shared.Config;
|
||||
import dan200.computercraft.shared.Registry;
|
||||
import dan200.computercraft.shared.computer.core.ClientComputerRegistry;
|
||||
@@ -16,6 +17,7 @@ import dan200.computercraft.shared.peripheral.monitor.MonitorRenderer;
|
||||
import dan200.computercraft.shared.pocket.peripherals.PocketModem;
|
||||
import dan200.computercraft.shared.pocket.peripherals.PocketSpeaker;
|
||||
import dan200.computercraft.shared.turtle.upgrades.*;
|
||||
import dan200.computercraft.shared.util.ServiceUtil;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -133,5 +135,6 @@ public final class ComputerCraft
|
||||
{
|
||||
Config.setup();
|
||||
Registry.setup();
|
||||
GenericSource.setup( () -> ServiceUtil.loadServicesForge( GenericSource.class ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public final class ComputerCraftAPIImpl implements IComputerCraftAPI
|
||||
|
||||
public static InputStream getResourceFile( String domain, String subPath )
|
||||
{
|
||||
IReloadableResourceManager manager = (IReloadableResourceManager) ServerLifecycleHooks.getCurrentServer().getDataPackRegistries().func_240970_h_();
|
||||
IReloadableResourceManager manager = (IReloadableResourceManager) ServerLifecycleHooks.getCurrentServer().getDataPackRegistries().getResourceManager();
|
||||
try
|
||||
{
|
||||
return manager.getResource( new ResourceLocation( domain, subPath ) ).getInputStream();
|
||||
@@ -97,7 +97,7 @@ public final class ComputerCraftAPIImpl implements IComputerCraftAPI
|
||||
@Override
|
||||
public IMount createResourceMount( @Nonnull String domain, @Nonnull String subPath )
|
||||
{
|
||||
IReloadableResourceManager manager = (IReloadableResourceManager) ServerLifecycleHooks.getCurrentServer().getDataPackRegistries().func_240970_h_();
|
||||
IReloadableResourceManager manager = (IReloadableResourceManager) ServerLifecycleHooks.getCurrentServer().getDataPackRegistries().getResourceManager();
|
||||
ResourceMount mount = ResourceMount.get( domain, subPath, manager );
|
||||
return mount.exists( "" ) ? mount : null;
|
||||
}
|
||||
|
||||
@@ -91,13 +91,13 @@ public final class GuiComputer<T extends ContainerComputerBase> extends Containe
|
||||
terminalWrapper = new WidgetWrapper( terminal, MARGIN + BORDER + guiLeft, MARGIN + BORDER + guiTop, termPxWidth, termPxHeight );
|
||||
|
||||
children.add( terminalWrapper );
|
||||
setFocused( terminalWrapper );
|
||||
setListener( terminalWrapper );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removed()
|
||||
public void onClose()
|
||||
{
|
||||
super.removed();
|
||||
super.onClose();
|
||||
children.remove( terminal );
|
||||
terminal = null;
|
||||
minecraft.keyboardListener.enableRepeatEvents( false );
|
||||
@@ -114,16 +114,16 @@ public final class GuiComputer<T extends ContainerComputerBase> extends Containe
|
||||
public boolean keyPressed( int key, int scancode, int modifiers )
|
||||
{
|
||||
// Forward the tab key to the terminal, rather than moving between controls.
|
||||
if( key == GLFW.GLFW_KEY_TAB && getFocused() != null && getFocused() == terminalWrapper )
|
||||
if( key == GLFW.GLFW_KEY_TAB && getListener() != null && getListener() == terminalWrapper )
|
||||
{
|
||||
return getFocused().keyPressed( key, scancode, modifiers );
|
||||
return getListener().keyPressed( key, scancode, modifiers );
|
||||
}
|
||||
|
||||
return super.keyPressed( key, scancode, modifiers );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void func_230450_a_( @Nonnull MatrixStack stack, float partialTicks, int mouseX, int mouseY )
|
||||
public void drawGuiContainerBackgroundLayer( @Nonnull MatrixStack stack, float partialTicks, int mouseX, int mouseY )
|
||||
{
|
||||
// Draw terminal
|
||||
terminal.draw( terminalWrapper.getX(), terminalWrapper.getY() );
|
||||
@@ -147,12 +147,12 @@ public final class GuiComputer<T extends ContainerComputerBase> extends Containe
|
||||
@Override
|
||||
public boolean mouseDragged( double x, double y, int button, double deltaX, double deltaY )
|
||||
{
|
||||
return (getFocused() != null && getFocused().mouseDragged( x, y, button, deltaX, deltaY ))
|
||||
return (getListener() != null && getListener().mouseDragged( x, y, button, deltaX, deltaY ))
|
||||
|| super.mouseDragged( x, y, button, deltaX, deltaY );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void func_230451_b_( @Nonnull MatrixStack transform, int mouseX, int mouseY )
|
||||
protected void drawGuiContainerForegroundLayer( @Nonnull MatrixStack transform, int mouseX, int mouseY )
|
||||
{
|
||||
// Skip rendering labels.
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public class GuiDiskDrive extends ContainerScreen<ContainerDiskDrive>
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void func_230450_a_( @Nonnull MatrixStack transform, float partialTicks, int mouseX, int mouseY )
|
||||
protected void drawGuiContainerBackgroundLayer( @Nonnull MatrixStack transform, float partialTicks, int mouseX, int mouseY )
|
||||
{
|
||||
RenderSystem.color4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
minecraft.getTextureManager().bindTexture( BACKGROUND );
|
||||
|
||||
@@ -33,7 +33,7 @@ public class GuiPrinter extends ContainerScreen<ContainerPrinter>
|
||||
}*/
|
||||
|
||||
@Override
|
||||
protected void func_230450_a_( @Nonnull MatrixStack transform, float partialTicks, int mouseX, int mouseY )
|
||||
protected void drawGuiContainerBackgroundLayer( @Nonnull MatrixStack transform, float partialTicks, int mouseX, int mouseY )
|
||||
{
|
||||
RenderSystem.color4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
minecraft.getTextureManager().bindTexture( BACKGROUND );
|
||||
|
||||
@@ -15,7 +15,6 @@ import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.math.vector.Matrix4f;
|
||||
import net.minecraft.util.math.vector.TransformationMatrix;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
@@ -25,8 +24,6 @@ import static dan200.computercraft.client.render.PrintoutRenderer.*;
|
||||
|
||||
public class GuiPrintout extends ContainerScreen<ContainerHeldItem>
|
||||
{
|
||||
private static final Matrix4f IDENTITY = TransformationMatrix.identity().getMatrix();
|
||||
|
||||
private final boolean m_book;
|
||||
private final int m_pages;
|
||||
private final TextBuffer[] m_text;
|
||||
@@ -94,7 +91,7 @@ public class GuiPrintout extends ContainerScreen<ContainerHeldItem>
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void func_230450_a_( @Nonnull MatrixStack transform, float partialTicks, int mouseX, int mouseY )
|
||||
protected void drawGuiContainerBackgroundLayer( @Nonnull MatrixStack transform, float partialTicks, int mouseX, int mouseY )
|
||||
{
|
||||
// Draw the printout
|
||||
RenderSystem.color4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
@@ -116,11 +113,10 @@ public class GuiPrintout extends ContainerScreen<ContainerHeldItem>
|
||||
setBlitOffset( getBlitOffset() + 1 );
|
||||
|
||||
super.render( stack, mouseX, mouseY, partialTicks );
|
||||
func_230459_a_( stack, mouseX, mouseY );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void func_230451_b_( @Nonnull MatrixStack transform, int mouseX, int mouseY )
|
||||
protected void drawGuiContainerForegroundLayer( @Nonnull MatrixStack transform, int mouseX, int mouseY )
|
||||
{
|
||||
// Skip rendering labels.
|
||||
}
|
||||
|
||||
@@ -64,13 +64,13 @@ public class GuiTurtle extends ContainerScreen<ContainerTurtle>
|
||||
terminalWrapper = new WidgetWrapper( terminal, 2 + 8 + guiLeft, 2 + 8 + guiTop, termPxWidth, termPxHeight );
|
||||
|
||||
children.add( terminalWrapper );
|
||||
setFocused( terminalWrapper );
|
||||
setListener( terminalWrapper );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removed()
|
||||
public void onClose()
|
||||
{
|
||||
super.removed();
|
||||
super.onClose();
|
||||
children.remove( terminal );
|
||||
terminal = null;
|
||||
minecraft.keyboardListener.enableRepeatEvents( false );
|
||||
@@ -87,41 +87,38 @@ public class GuiTurtle extends ContainerScreen<ContainerTurtle>
|
||||
public boolean keyPressed( int key, int scancode, int modifiers )
|
||||
{
|
||||
// Forward the tab key to the terminal, rather than moving between controls.
|
||||
if( key == GLFW.GLFW_KEY_TAB && getFocused() != null && getFocused() == terminalWrapper )
|
||||
if( key == GLFW.GLFW_KEY_TAB && getListener() != null && getListener() == terminalWrapper )
|
||||
{
|
||||
return getFocused().keyPressed( key, scancode, modifiers );
|
||||
return getListener().keyPressed( key, scancode, modifiers );
|
||||
}
|
||||
|
||||
return super.keyPressed( key, scancode, modifiers );
|
||||
}
|
||||
|
||||
private void drawSelectionSlot( boolean advanced )
|
||||
{
|
||||
// Draw selection slot
|
||||
int slot = m_container.getSelectedSlot();
|
||||
if( slot >= 0 )
|
||||
{
|
||||
RenderSystem.color4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
int slotX = slot % 4;
|
||||
int slotY = slot / 4;
|
||||
minecraft.getTextureManager().bindTexture( advanced ? BACKGROUND_ADVANCED : BACKGROUND_NORMAL );
|
||||
// TODO: blit( guiLeft + ContainerTurtle.TURTLE_START_X - 2 + slotX * 18, guiTop + ContainerTurtle.PLAYER_START_Y - 2 + slotY * 18, 0, 217, 24, 24 );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void func_230450_a_( @Nonnull MatrixStack transform, float partialTicks, int mouseX, int mouseY )
|
||||
protected void drawGuiContainerBackgroundLayer( @Nonnull MatrixStack transform, float partialTicks, int mouseX, int mouseY )
|
||||
{
|
||||
// Draw term
|
||||
boolean advanced = m_family == ComputerFamily.ADVANCED;
|
||||
ResourceLocation texture = m_family == ComputerFamily.ADVANCED ? BACKGROUND_ADVANCED : BACKGROUND_NORMAL;
|
||||
terminal.draw( terminalWrapper.getX(), terminalWrapper.getY() );
|
||||
|
||||
// Draw border/inventory
|
||||
RenderSystem.color4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
minecraft.getTextureManager().bindTexture( advanced ? BACKGROUND_ADVANCED : BACKGROUND_NORMAL );
|
||||
minecraft.getTextureManager().bindTexture( texture );
|
||||
blit( transform, guiLeft, guiTop, 0, 0, xSize, ySize );
|
||||
|
||||
drawSelectionSlot( advanced );
|
||||
// Draw selection slot
|
||||
int slot = m_container.getSelectedSlot();
|
||||
if( slot >= 0 )
|
||||
{
|
||||
int slotX = slot % 4;
|
||||
int slotY = slot / 4;
|
||||
blit( transform,
|
||||
guiLeft + ContainerTurtle.TURTLE_START_X - 2 + slotX * 18,
|
||||
guiTop + ContainerTurtle.PLAYER_START_Y - 2 + slotY * 18,
|
||||
0, 217, 24, 24
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -135,12 +132,12 @@ public class GuiTurtle extends ContainerScreen<ContainerTurtle>
|
||||
@Override
|
||||
public boolean mouseDragged( double x, double y, int button, double deltaX, double deltaY )
|
||||
{
|
||||
return (getFocused() != null && getFocused().mouseDragged( x, y, button, deltaX, deltaY ))
|
||||
return (getListener() != null && getListener().mouseDragged( x, y, button, deltaX, deltaY ))
|
||||
|| super.mouseDragged( x, y, button, deltaX, deltaY );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void func_230451_b_( @Nonnull MatrixStack transform, int mouseX, int mouseY )
|
||||
protected void drawGuiContainerForegroundLayer( @Nonnull MatrixStack transform, int mouseX, int mouseY )
|
||||
{
|
||||
// Skip rendering labels.
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ package dan200.computercraft.core.asm;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.lua.LuaFunction;
|
||||
import dan200.computercraft.shared.peripheral.generic.GenericPeripheralProvider;
|
||||
import dan200.computercraft.shared.util.ServiceUtil;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -16,11 +17,12 @@ import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.StreamSupport;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* A generic source of {@link LuaMethod} functions. This allows for injecting methods onto objects you do not own.
|
||||
@@ -42,6 +44,18 @@ public interface GenericSource
|
||||
@Nonnull
|
||||
ResourceLocation id();
|
||||
|
||||
/**
|
||||
* Register a stream of generic sources.
|
||||
*
|
||||
* @param sources The source of generic methods.
|
||||
* @see ServiceUtil For ways to load this. Sadly {@link java.util.ServiceLoader} is broken under Forge, but we don't
|
||||
* want to add a hard-dep on Forge within core either.
|
||||
*/
|
||||
static void setup( Supplier<Stream<GenericSource>> sources )
|
||||
{
|
||||
GenericMethod.sources = sources;
|
||||
}
|
||||
|
||||
/**
|
||||
* A generic method is a method belonging to a {@link GenericSource} with a known target.
|
||||
*/
|
||||
@@ -51,6 +65,7 @@ public interface GenericSource
|
||||
final LuaFunction annotation;
|
||||
final Class<?> target;
|
||||
|
||||
static Supplier<Stream<GenericSource>> sources;
|
||||
private static List<GenericMethod> cache;
|
||||
|
||||
GenericMethod( Method method, LuaFunction annotation, Class<?> target )
|
||||
@@ -68,10 +83,16 @@ public interface GenericSource
|
||||
static List<GenericMethod> all()
|
||||
{
|
||||
if( cache != null ) return cache;
|
||||
return cache = StreamSupport
|
||||
.stream( ServiceLoader.load( GenericSource.class, GenericSource.class.getClassLoader() ).spliterator(), false )
|
||||
if( sources == null )
|
||||
{
|
||||
ComputerCraft.log.warn( "Getting GenericMethods without a provider" );
|
||||
return cache = Collections.emptyList();
|
||||
}
|
||||
|
||||
return cache = sources.get()
|
||||
.flatMap( x -> Arrays.stream( x.getClass().getDeclaredMethods() ) )
|
||||
.map( method -> {
|
||||
.map( method ->
|
||||
{
|
||||
LuaFunction annotation = method.getAnnotation( LuaFunction.class );
|
||||
if( annotation == null ) return null;
|
||||
|
||||
|
||||
@@ -38,16 +38,16 @@ public class Tags extends ItemTagsProvider
|
||||
@Override
|
||||
protected void registerTags()
|
||||
{
|
||||
func_240522_a_( COMPUTER ).func_240534_a_(
|
||||
getOrCreateBuilder( COMPUTER ).add(
|
||||
Registry.ModItems.COMPUTER_NORMAL.get(),
|
||||
Registry.ModItems.COMPUTER_ADVANCED.get(),
|
||||
Registry.ModItems.COMPUTER_COMMAND.get()
|
||||
);
|
||||
func_240522_a_( TURTLE ).func_240534_a_( Registry.ModItems.TURTLE_NORMAL.get(), Registry.ModItems.TURTLE_ADVANCED.get() );
|
||||
func_240522_a_( WIRED_MODEM ).func_240534_a_( Registry.ModItems.WIRED_MODEM.get(), Registry.ModItems.WIRED_MODEM_FULL.get() );
|
||||
func_240522_a_( MONITOR ).func_240534_a_( Registry.ModItems.MONITOR_NORMAL.get(), Registry.ModItems.MONITOR_ADVANCED.get() );
|
||||
getOrCreateBuilder( TURTLE ).add( Registry.ModItems.TURTLE_NORMAL.get(), Registry.ModItems.TURTLE_ADVANCED.get() );
|
||||
getOrCreateBuilder( WIRED_MODEM ).add( Registry.ModItems.WIRED_MODEM.get(), Registry.ModItems.WIRED_MODEM_FULL.get() );
|
||||
getOrCreateBuilder( MONITOR ).add( Registry.ModItems.MONITOR_NORMAL.get(), Registry.ModItems.MONITOR_ADVANCED.get() );
|
||||
|
||||
func_240522_a_( PIGLIN_LOVED ).func_240534_a_(
|
||||
getOrCreateBuilder( PIGLIN_LOVED ).add(
|
||||
Registry.ModItems.COMPUTER_ADVANCED.get(), Registry.ModItems.TURTLE_ADVANCED.get(),
|
||||
Registry.ModItems.WIRELESS_MODEM_ADVANCED.get(), Registry.ModItems.POCKET_COMPUTER_ADVANCED.get(),
|
||||
Registry.ModItems.MONITOR_ADVANCED.get()
|
||||
|
||||
@@ -289,11 +289,11 @@ public final class CommandComputerCraft
|
||||
// Append the computer instance
|
||||
if( serverComputer == null )
|
||||
{
|
||||
out.func_230529_a_( text( "?" ) );
|
||||
out.append( text( "?" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
out.func_230529_a_( link(
|
||||
out.append( link(
|
||||
text( Integer.toString( serverComputer.getInstanceID() ) ),
|
||||
"/computercraft dump " + serverComputer.getInstanceID(),
|
||||
translate( "commands.computercraft.dump.action" )
|
||||
@@ -301,20 +301,20 @@ public final class CommandComputerCraft
|
||||
}
|
||||
|
||||
// And ID
|
||||
out.func_240702_b_( " (id " + computerId + ")" );
|
||||
out.appendString( " (id " + computerId + ")" );
|
||||
|
||||
// And, if we're a player, some useful links
|
||||
if( serverComputer != null && UserLevel.OP.test( source ) && isPlayer( source ) )
|
||||
{
|
||||
out
|
||||
.func_240702_b_( " " )
|
||||
.func_230529_a_( link(
|
||||
.appendString( " " )
|
||||
.append( link(
|
||||
text( "\u261b" ),
|
||||
"/computercraft tp " + serverComputer.getInstanceID(),
|
||||
translate( "commands.computercraft.tp.action" )
|
||||
) )
|
||||
.func_240702_b_( " " )
|
||||
.func_230529_a_( link(
|
||||
.appendString( " " )
|
||||
.append( link(
|
||||
text( "\u20e2" ),
|
||||
"/computercraft view " + serverComputer.getInstanceID(),
|
||||
translate( "commands.computercraft.view.action" )
|
||||
|
||||
@@ -12,6 +12,7 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.Style;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.util.text.event.ClickEvent;
|
||||
import net.minecraft.util.text.event.HoverEvent;
|
||||
@@ -57,10 +58,8 @@ public final class CommandCopy
|
||||
|
||||
public static ITextComponent createCopyText( String text )
|
||||
{
|
||||
StringTextComponent name = new StringTextComponent( text );
|
||||
name.getStyle()
|
||||
return new StringTextComponent( text ).mergeStyle( Style.EMPTY
|
||||
.setClickEvent( new ClickEvent( ClickEvent.Action.RUN_COMMAND, PREFIX + text ) )
|
||||
.setHoverEvent( new HoverEvent( HoverEvent.Action.SHOW_TEXT, new TranslationTextComponent( "gui.computercraft.tooltip.copy" ) ) );
|
||||
return name;
|
||||
.setHoverEvent( new HoverEvent( HoverEvent.Action.SHOW_TEXT, new TranslationTextComponent( "gui.computercraft.tooltip.copy" ) ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,11 +175,11 @@ public final class HelpingArgumentBuilder extends LiteralArgumentBuilder<Command
|
||||
String usage = dispatcher.getSmartUsage( temp, context.getSource() ).get( node ).substring( node.getName().length() );
|
||||
|
||||
IFormattableTextComponent output = new StringTextComponent( "" )
|
||||
.func_230529_a_( coloured( "/" + command + usage, HEADER ) )
|
||||
.func_240702_b_( " " )
|
||||
.func_230529_a_( coloured( translate( "commands." + id + ".synopsis" ), SYNOPSIS ) )
|
||||
.func_240702_b_( "\n" )
|
||||
.func_230529_a_( translate( "commands." + id + ".desc" ) );
|
||||
.append( coloured( "/" + command + usage, HEADER ) )
|
||||
.appendString( " " )
|
||||
.append( coloured( translate( "commands." + id + ".synopsis" ), SYNOPSIS ) )
|
||||
.appendString( "\n" )
|
||||
.append( translate( "commands." + id + ".desc" ) );
|
||||
|
||||
for( CommandNode<CommandSource> child : node.getChildren() )
|
||||
{
|
||||
@@ -188,16 +188,16 @@ public final class HelpingArgumentBuilder extends LiteralArgumentBuilder<Command
|
||||
continue;
|
||||
}
|
||||
|
||||
output.func_240702_b_( "\n" );
|
||||
output.appendString( "\n" );
|
||||
|
||||
IFormattableTextComponent component = coloured( child.getName(), NAME );
|
||||
component.getStyle().setClickEvent( new ClickEvent(
|
||||
ClickEvent.Action.SUGGEST_COMMAND,
|
||||
"/" + command + " " + child.getName()
|
||||
) );
|
||||
output.func_230529_a_( component );
|
||||
output.append( component );
|
||||
|
||||
output.func_240702_b_( " - " ).func_230529_a_( translate( "commands." + id + "." + child.getName() + ".synopsis" ) );
|
||||
output.appendString( " - " ).append( translate( "commands." + id + "." + child.getName() + ".synopsis" ) );
|
||||
}
|
||||
|
||||
return output;
|
||||
|
||||
@@ -21,14 +21,12 @@ public final class ChatHelpers
|
||||
|
||||
public static IFormattableTextComponent coloured( String text, TextFormatting colour )
|
||||
{
|
||||
IFormattableTextComponent component = new StringTextComponent( text == null ? "" : text );
|
||||
component.getStyle().setFormatting( colour );
|
||||
return component;
|
||||
return new StringTextComponent( text == null ? "" : text ).mergeStyle( colour );
|
||||
}
|
||||
|
||||
public static <T extends IFormattableTextComponent> T coloured( T component, TextFormatting colour )
|
||||
{
|
||||
component.getStyle().setFormatting( colour );
|
||||
component.mergeStyle( colour );
|
||||
return component;
|
||||
}
|
||||
|
||||
@@ -52,7 +50,7 @@ public final class ChatHelpers
|
||||
IFormattableTextComponent component = new StringTextComponent( "" );
|
||||
for( ITextComponent child : children )
|
||||
{
|
||||
component.func_230529_a_( child );
|
||||
component.append( child );
|
||||
}
|
||||
return component;
|
||||
}
|
||||
@@ -74,11 +72,11 @@ public final class ChatHelpers
|
||||
{
|
||||
Style style = component.getStyle();
|
||||
|
||||
if( style.getColor() == null ) style.setFormatting( TextFormatting.YELLOW );
|
||||
style.setClickEvent( new ClickEvent( ClickEvent.Action.RUN_COMMAND, command ) );
|
||||
style.setHoverEvent( new HoverEvent( HoverEvent.Action.SHOW_TEXT, toolTip ) );
|
||||
if( style.getColor() == null ) style = style.setFormatting( TextFormatting.YELLOW );
|
||||
style = style.setClickEvent( new ClickEvent( ClickEvent.Action.RUN_COMMAND, command ) );
|
||||
style = style.setHoverEvent( new HoverEvent( HoverEvent.Action.SHOW_TEXT, toolTip ) );
|
||||
|
||||
return component;
|
||||
return component.setStyle( style );
|
||||
}
|
||||
|
||||
public static IFormattableTextComponent header( String text )
|
||||
|
||||
@@ -79,12 +79,12 @@ public interface TableFormatter
|
||||
StringTextComponent line = new StringTextComponent( "" );
|
||||
for( int i = 0; i < columns - 1; i++ )
|
||||
{
|
||||
line.func_230529_a_( headers[i] );
|
||||
line.append( headers[i] );
|
||||
ITextComponent padding = getPadding( headers[i], maxWidths[i] );
|
||||
if( padding != null ) line.func_230529_a_( padding );
|
||||
line.func_230529_a_( SEPARATOR );
|
||||
if( padding != null ) line.append( padding );
|
||||
line.append( SEPARATOR );
|
||||
}
|
||||
line.func_230529_a_( headers[columns - 1] );
|
||||
line.append( headers[columns - 1] );
|
||||
|
||||
writeLine( rowId++, line );
|
||||
|
||||
@@ -100,12 +100,12 @@ public interface TableFormatter
|
||||
StringTextComponent line = new StringTextComponent( "" );
|
||||
for( int i = 0; i < columns - 1; i++ )
|
||||
{
|
||||
line.func_230529_a_( row[i] );
|
||||
line.append( row[i] );
|
||||
ITextComponent padding = getPadding( row[i], maxWidths[i] );
|
||||
if( padding != null ) line.func_230529_a_( padding );
|
||||
line.func_230529_a_( SEPARATOR );
|
||||
if( padding != null ) line.append( padding );
|
||||
line.append( SEPARATOR );
|
||||
}
|
||||
line.func_230529_a_( row[columns - 1] );
|
||||
line.append( row[columns - 1] );
|
||||
writeLine( rowId++, line );
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ public abstract class ItemComputerBase extends BlockItem implements IComputerIte
|
||||
if( id >= 0 )
|
||||
{
|
||||
list.add( new TranslationTextComponent( "gui.computercraft.tooltip.computer_id", id )
|
||||
.func_240699_a_( TextFormatting.GRAY ) );
|
||||
.mergeStyle( TextFormatting.GRAY ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public class ItemDisk extends Item implements IMedia, IColouredItem
|
||||
if( id >= 0 )
|
||||
{
|
||||
list.add( new TranslationTextComponent( "gui.computercraft.tooltip.disk_id", id )
|
||||
.func_240699_a_( TextFormatting.GRAY ) );
|
||||
.mergeStyle( TextFormatting.GRAY ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ public class ItemData
|
||||
|
||||
enchants.ensureCapacity( enchants.size() + rawEnchants.size() );
|
||||
|
||||
for( Map.Entry<Enchantment, Integer> entry : EnchantmentHelper.func_226652_a_( rawEnchants ).entrySet() )
|
||||
for( Map.Entry<Enchantment, Integer> entry : EnchantmentHelper.deserializeEnchantments( rawEnchants ).entrySet() )
|
||||
{
|
||||
Enchantment enchantment = entry.getKey();
|
||||
Integer level = entry.getValue();
|
||||
|
||||
@@ -217,8 +217,8 @@ public class TileWiredModemFull extends TileGeneric
|
||||
StringTextComponent base = new StringTextComponent( "" );
|
||||
for( int i = 0; i < names.size(); i++ )
|
||||
{
|
||||
if( i > 0 ) base.func_240702_b_( ", " );
|
||||
base.func_230529_a_( CommandCopy.createCopyText( names.get( i ) ) );
|
||||
if( i > 0 ) base.appendString( ", " );
|
||||
base.append( CommandCopy.createCopyText( names.get( i ) ) );
|
||||
}
|
||||
|
||||
player.sendStatusMessage( new TranslationTextComponent( kind, base ), false );
|
||||
|
||||
@@ -403,7 +403,7 @@ public final class TilePrinter extends TileGeneric implements DefaultSidedInvent
|
||||
setInventorySlotContents( i, ItemStack.EMPTY );
|
||||
|
||||
// Spawn the item in the world
|
||||
WorldUtil.dropItemStack( stack, getWorld(), Vector3d.func_237491_b_( getPos() ).add( 0.5, 0.75, 0.5 ) );
|
||||
WorldUtil.dropItemStack( stack, getWorld(), Vector3d.copy( getPos() ).add( 0.5, 0.75, 0.5 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ public class PocketServerComputer extends ServerComputer implements IPocketAcces
|
||||
if( entity != null )
|
||||
{
|
||||
setWorld( entity.getEntityWorld() );
|
||||
setPosition( entity.func_233580_cy_() );
|
||||
setPosition( entity.getPosition() );
|
||||
}
|
||||
|
||||
// If a new entity has picked it up then rebroadcast the terminal to them
|
||||
|
||||
@@ -190,7 +190,7 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I
|
||||
if( id >= 0 )
|
||||
{
|
||||
list.add( new TranslationTextComponent( "gui.computercraft.tooltip.computer_id", id )
|
||||
.func_240699_a_( TextFormatting.GRAY ) );
|
||||
.mergeStyle( TextFormatting.GRAY ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ public final class ComputerCraftProxyCommon
|
||||
|
||||
private static void registerCondition( String name, LootConditionType serializer )
|
||||
{
|
||||
Registry.register( Registry.field_239704_ba_, new ResourceLocation( ComputerCraft.MOD_ID, name ), serializer );
|
||||
Registry.register( Registry.LOOT_CONDITION_TYPE, new ResourceLocation( ComputerCraft.MOD_ID, name ), serializer );
|
||||
}
|
||||
|
||||
private static void registerProviders()
|
||||
|
||||
@@ -25,6 +25,7 @@ import net.minecraft.tileentity.SignTileEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
|
||||
@@ -129,6 +130,12 @@ public final class TurtlePlayer extends FakePlayer
|
||||
return Registry.ModEntities.TURTLE_PLAYER.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector3d getPositionVec()
|
||||
{
|
||||
return new Vector3d( getPosX(), getPosY(), getPosZ() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getEyeHeight( @Nonnull Pose pose )
|
||||
{
|
||||
|
||||
@@ -149,7 +149,7 @@ public class TurtleTool extends AbstractTurtleUpgrade
|
||||
boolean attacked = false;
|
||||
if( !hitEntity.hitByEntity( turtlePlayer ) )
|
||||
{
|
||||
float damage = (float) turtlePlayer.func_233637_b_( Attributes.ATTACK_DAMAGE );
|
||||
float damage = (float) turtlePlayer.getAttributeValue( Attributes.ATTACK_DAMAGE );
|
||||
damage *= getDamageMultiplier();
|
||||
if( damage > 0.0f )
|
||||
{
|
||||
|
||||
@@ -41,7 +41,7 @@ public final class DropConsumer
|
||||
remainingDrops = new ArrayList<>();
|
||||
dropEntity = entity;
|
||||
dropWorld = entity.world;
|
||||
dropBounds = new AxisAlignedBB( entity.func_233580_cy_() ).grow( 2, 2, 2 );
|
||||
dropBounds = new AxisAlignedBB( entity.getPosition() ).grow( 2, 2, 2 );
|
||||
|
||||
entity.captureDrops( new ArrayList<>() );
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.storage.FolderName;
|
||||
import net.minecraftforge.fml.server.ServerLifecycleHooks;
|
||||
|
||||
import java.io.File;
|
||||
@@ -25,6 +26,7 @@ import java.util.Map;
|
||||
|
||||
public final class IDAssigner
|
||||
{
|
||||
private static final FolderName FOLDER = new FolderName( ComputerCraft.MOD_ID );
|
||||
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
|
||||
private static final Type ID_TOKEN = new TypeToken<Map<String, Integer>>()
|
||||
{
|
||||
@@ -40,9 +42,7 @@ public final class IDAssigner
|
||||
|
||||
public static File getDir()
|
||||
{
|
||||
File root = ServerLifecycleHooks.getCurrentServer().getDataDirectory();
|
||||
// TODO: File worldDirectory = server.getWorld( World.field_234918_g_ ).getSaveHandler().getWorldDirectory();
|
||||
return new File( root, ComputerCraft.MOD_ID );
|
||||
return ServerLifecycleHooks.getCurrentServer().func_240776_a_( FOLDER ).toFile();
|
||||
}
|
||||
|
||||
private static MinecraftServer getCachedServer()
|
||||
|
||||
@@ -20,6 +20,6 @@ public final class RecordUtil
|
||||
public static void playRecord( SoundEvent record, String recordInfo, World world, BlockPos pos )
|
||||
{
|
||||
NetworkMessage packet = record != null ? new PlayRecordClientMessage( pos, record, recordInfo ) : new PlayRecordClientMessage( pos );
|
||||
NetworkHandler.sendToAllAround( packet, world, Vector3d.func_237489_a_( pos ), 64 );
|
||||
NetworkHandler.sendToAllAround( packet, world, Vector3d.copyCentered( pos ), 64 );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
|
||||
package dan200.computercraft.shared.util;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import org.objectweb.asm.Type;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
public final class ServiceUtil
|
||||
{
|
||||
private static final Type AUTO_SERVICE = Type.getType( "Lcom/google/auto/service/AutoService;" );
|
||||
|
||||
private ServiceUtil()
|
||||
{
|
||||
}
|
||||
|
||||
public static <T> Stream<T> loadServices( Class<T> target )
|
||||
{
|
||||
return StreamSupport.stream( ServiceLoader.load( target, ServiceUtil.class.getClassLoader() ).spliterator(), false );
|
||||
}
|
||||
|
||||
public static <T> Stream<T> loadServicesForge( Class<T> target )
|
||||
{
|
||||
Type type = Type.getType( target );
|
||||
ClassLoader loader = ComputerCraftAPI.class.getClassLoader();
|
||||
return ModList.get().getAllScanData().stream()
|
||||
.flatMap( x -> x.getAnnotations().stream() )
|
||||
.filter( x -> x.getAnnotationType().equals( AUTO_SERVICE ) )
|
||||
.filter( x -> {
|
||||
Object value = x.getAnnotationData().get( "value" );
|
||||
return value instanceof List<?> && ((List<?>) value).contains( type );
|
||||
} )
|
||||
.flatMap( x -> {
|
||||
try
|
||||
{
|
||||
Class<?> klass = loader.loadClass( x.getClassType().getClassName() );
|
||||
if( !target.isAssignableFrom( klass ) )
|
||||
{
|
||||
ComputerCraft.log.error( "{} is not a subtype of {}", x.getClassType().getClassName(), target.getName() );
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
Class<? extends T> casted = klass.asSubclass( target );
|
||||
return Stream.of( casted.newInstance() );
|
||||
}
|
||||
catch( ReflectiveOperationException e )
|
||||
{
|
||||
ComputerCraft.log.error( "Cannot load {}", x.getClassType(), e );
|
||||
return Stream.empty();
|
||||
}
|
||||
} );
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,14 @@
|
||||
# New features in CC: Tweaked 1.90.3
|
||||
|
||||
* Fix the selected slot indicator missing from the turtle GUI.
|
||||
* Ensure we load/save computer data from the world directory, rather than a global one.
|
||||
|
||||
# New features in CC: Tweaked 1.90.2
|
||||
|
||||
* Fix generic peripherals not being registered outside a dev environment.
|
||||
* Fix `turtle.attack()` failing.
|
||||
* Correctly set styles for the output of `/computercraft` commands.
|
||||
|
||||
# New features in CC: Tweaked 1.90.1
|
||||
|
||||
* Update to Forge 32.0.69
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
New features in CC: Tweaked 1.90.1
|
||||
New features in CC: Tweaked 1.90.3
|
||||
|
||||
* Update to Forge 32.0.69
|
||||
* Fix the selected slot indicator missing from the turtle GUI.
|
||||
* Ensure we load/save computer data from the world directory, rather than a global one.
|
||||
|
||||
Type "help changelog" to see the full version history.
|
||||
|
||||
Reference in New Issue
Block a user