mirror of
				https://github.com/SquidDev-CC/CC-Tweaked
				synced 2025-10-31 13:42:59 +00:00 
			
		
		
		
	Merge remote-tracking branch 'origin/fabric' into fabric
This commit is contained in:
		| @@ -20,6 +20,7 @@ repositories { | |||||||
| } | } | ||||||
|  |  | ||||||
| minecraft { | minecraft { | ||||||
|  |     accessWidener = file("src/main/resources/computercraft.accesswidener") | ||||||
| } | } | ||||||
|  |  | ||||||
| configurations { | configurations { | ||||||
|   | |||||||
| @@ -15,6 +15,8 @@ import dan200.computercraft.shared.media.items.ItemDisk; | |||||||
| import dan200.computercraft.shared.pocket.items.ItemPocketComputer; | import dan200.computercraft.shared.pocket.items.ItemPocketComputer; | ||||||
| import dan200.computercraft.shared.util.Colour; | import dan200.computercraft.shared.util.Colour; | ||||||
|  |  | ||||||
|  | import net.fabricmc.api.EnvType; | ||||||
|  | import net.fabricmc.api.Environment; | ||||||
| import net.minecraft.client.MinecraftClient; | import net.minecraft.client.MinecraftClient; | ||||||
| import net.minecraft.client.render.model.BakedModel; | import net.minecraft.client.render.model.BakedModel; | ||||||
| import net.minecraft.client.render.model.ModelLoader; | import net.minecraft.client.render.model.ModelLoader; | ||||||
| @@ -31,6 +33,7 @@ import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback; | |||||||
| /** | /** | ||||||
|  * Registers textures and models for items. |  * Registers textures and models for items. | ||||||
|  */ |  */ | ||||||
|  | @Environment(EnvType.CLIENT) | ||||||
| public final class ClientRegistry { | public final class ClientRegistry { | ||||||
|     private static final String[] EXTRA_MODELS = new String[] { |     private static final String[] EXTRA_MODELS = new String[] { | ||||||
|         "turtle_modem_normal_off_left", |         "turtle_modem_normal_off_left", | ||||||
| @@ -104,6 +107,7 @@ public final class ClientRegistry { | |||||||
|         model.getTextureDependencies(loader::getOrLoadModel, new HashSet<>()); |         model.getTextureDependencies(loader::getOrLoadModel, new HashSet<>()); | ||||||
|         SpriteAtlasTexture sprite = MinecraftClient.getInstance() |         SpriteAtlasTexture sprite = MinecraftClient.getInstance() | ||||||
|                                                    .getSpriteAtlas(); |                                                    .getSpriteAtlas(); | ||||||
|         return model.bake(loader, sprite::getSprite, ModelRotation.X0_Y0); |         return model.bake(loader, spriteIdentifier -> MinecraftClient.getInstance() | ||||||
|  |             .getSpriteAtlas(spriteIdentifier.getAtlasId()).apply(spriteIdentifier.getTextureId()), ModelRotation.X0_Y0); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -14,6 +14,9 @@ import dan200.computercraft.shared.command.text.ChatHelpers; | |||||||
| import dan200.computercraft.shared.command.text.TableBuilder; | import dan200.computercraft.shared.command.text.TableBuilder; | ||||||
| import dan200.computercraft.shared.command.text.TableFormatter; | import dan200.computercraft.shared.command.text.TableFormatter; | ||||||
| import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; | import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; | ||||||
|  | import net.fabricmc.api.EnvType; | ||||||
|  | import net.fabricmc.api.Environment; | ||||||
|  | import net.minecraft.text.OrderedText; | ||||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||||
|  |  | ||||||
| import net.minecraft.client.MinecraftClient; | import net.minecraft.client.MinecraftClient; | ||||||
| @@ -24,6 +27,7 @@ import net.minecraft.text.Text; | |||||||
| import net.minecraft.util.Formatting; | import net.minecraft.util.Formatting; | ||||||
| import net.minecraft.util.math.MathHelper; | import net.minecraft.util.math.MathHelper; | ||||||
|  |  | ||||||
|  | @Environment(EnvType.CLIENT) | ||||||
| public class ClientTableFormatter implements TableFormatter { | public class ClientTableFormatter implements TableFormatter { | ||||||
|     public static final ClientTableFormatter INSTANCE = new ClientTableFormatter(); |     public static final ClientTableFormatter INSTANCE = new ClientTableFormatter(); | ||||||
|  |  | ||||||
| @@ -39,7 +43,7 @@ public class ClientTableFormatter implements TableFormatter { | |||||||
|  |  | ||||||
|         TextRenderer renderer = renderer(); |         TextRenderer renderer = renderer(); | ||||||
|  |  | ||||||
|         float spaceWidth = renderer.getCharWidth(' '); |         float spaceWidth = renderer.getWidth(" "); | ||||||
|         int spaces = MathHelper.floor(extraWidth / spaceWidth); |         int spaces = MathHelper.floor(extraWidth / spaceWidth); | ||||||
|         int extra = extraWidth - (int) (spaces * spaceWidth); |         int extra = extraWidth - (int) (spaces * spaceWidth); | ||||||
|  |  | ||||||
| @@ -57,7 +61,7 @@ public class ClientTableFormatter implements TableFormatter { | |||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public int getWidth(Text component) { |     public int getWidth(Text component) { | ||||||
|         return renderer().getWidth(component.asFormattedString()); |         return renderer().getWidth(component.asString()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
| @@ -67,9 +71,9 @@ public class ClientTableFormatter implements TableFormatter { | |||||||
|  |  | ||||||
|         // Trim the text if it goes over the allowed length |         // Trim the text if it goes over the allowed length | ||||||
|         int maxWidth = MathHelper.floor(chat.getWidth() / chat.getChatScale()); |         int maxWidth = MathHelper.floor(chat.getWidth() / chat.getChatScale()); | ||||||
|         List<Text> list = ChatMessages.breakRenderedChatMessageLines(component, maxWidth, mc.textRenderer, false, false); |         List<OrderedText> list = ChatMessages.breakRenderedChatMessageLines(component, maxWidth, mc.textRenderer); | ||||||
|         if (!list.isEmpty()) { |         if (!list.isEmpty()) { | ||||||
|             chat.addMessage(list.get(0), id); |             chat.addMessage((Text) list.get(0), id); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -16,6 +16,7 @@ import com.mojang.blaze3d.platform.GlStateManager; | |||||||
| import dan200.computercraft.core.terminal.TextBuffer; | import dan200.computercraft.core.terminal.TextBuffer; | ||||||
| import dan200.computercraft.shared.common.ContainerHeldItem; | import dan200.computercraft.shared.common.ContainerHeldItem; | ||||||
| import dan200.computercraft.shared.media.items.ItemPrintout; | import dan200.computercraft.shared.media.items.ItemPrintout; | ||||||
|  | import net.minecraft.client.util.math.MatrixStack; | ||||||
| import org.lwjgl.glfw.GLFW; | import org.lwjgl.glfw.GLFW; | ||||||
|  |  | ||||||
| import net.minecraft.client.gui.screen.ingame.HandledScreen; | import net.minecraft.client.gui.screen.ingame.HandledScreen; | ||||||
| @@ -102,23 +103,23 @@ public class GuiPrintout extends HandledScreen<ContainerHeldItem> { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void drawBackground(float partialTicks, int mouseX, int mouseY) { |     public void drawBackground(MatrixStack stack, float partialTicks, int mouseX, int mouseY) { | ||||||
|         // Draw the printout |         // Draw the printout | ||||||
|         GlStateManager.color4f(1.0f, 1.0f, 1.0f, 1.0f); |         GlStateManager.color4f(1.0f, 1.0f, 1.0f, 1.0f); | ||||||
|         GlStateManager.enableDepthTest(); |         GlStateManager.enableDepthTest(); | ||||||
|  |  | ||||||
|         drawBorder(this.x, this.y, blitOffset, this.m_page, this.m_pages, this.m_book); |         drawBorder(this.x, this.y, getZOffset(), this.m_page, this.m_pages, this.m_book); | ||||||
|         drawText(this.x + X_TEXT_MARGIN, this.y + Y_TEXT_MARGIN, ItemPrintout.LINES_PER_PAGE * this.m_page, this.m_text, this.m_colours); |         drawText(this.x + X_TEXT_MARGIN, this.y + Y_TEXT_MARGIN, ItemPrintout.LINES_PER_PAGE * this.m_page, this.m_text, this.m_colours); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void render(int mouseX, int mouseY, float partialTicks) { |     public void render(MatrixStack stack, int mouseX, int mouseY, float partialTicks) { | ||||||
|         // We must take the background further back in order to not overlap with our printed pages. |         // We must take the background further back in order to not overlap with our printed pages. | ||||||
|         blitOffset--; |         setZOffset(getZOffset() - 1); | ||||||
|         renderBackground(); |         renderBackground(stack); | ||||||
|         blitOffset++; |         setZOffset(getZOffset() + 1); | ||||||
|  |  | ||||||
|         super.render(mouseX, mouseY, partialTicks); |         super.render(stack, mouseX, mouseY, partialTicks); | ||||||
|         this.drawMouseoverTooltip(mouseX, mouseY); |         this.drawMouseoverTooltip(stack, mouseX, mouseY); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -14,6 +14,7 @@ import dan200.computercraft.shared.computer.core.ClientComputer; | |||||||
| import dan200.computercraft.shared.computer.core.ComputerFamily; | import dan200.computercraft.shared.computer.core.ComputerFamily; | ||||||
| import dan200.computercraft.shared.turtle.blocks.TileTurtle; | import dan200.computercraft.shared.turtle.blocks.TileTurtle; | ||||||
| import dan200.computercraft.shared.turtle.inventory.ContainerTurtle; | import dan200.computercraft.shared.turtle.inventory.ContainerTurtle; | ||||||
|  | import net.minecraft.client.util.math.MatrixStack; | ||||||
| import org.lwjgl.glfw.GLFW; | import org.lwjgl.glfw.GLFW; | ||||||
|  |  | ||||||
| import net.minecraft.client.gui.screen.ingame.HandledScreen; | import net.minecraft.client.gui.screen.ingame.HandledScreen; | ||||||
| @@ -43,12 +44,12 @@ public class GuiTurtle extends HandledScreen<ContainerTurtle> { | |||||||
|     @Override |     @Override | ||||||
|     protected void init() { |     protected void init() { | ||||||
|         super.init(); |         super.init(); | ||||||
|         minecraft.keyboard.enableRepeatEvents(true); |         client.keyboard.setRepeatEvents(true); | ||||||
|  |  | ||||||
|         int termPxWidth = ComputerCraft.terminalWidth_turtle * FixedWidthFontRenderer.FONT_WIDTH; |         int termPxWidth = ComputerCraft.terminalWidth_turtle * FixedWidthFontRenderer.FONT_WIDTH; | ||||||
|         int termPxHeight = ComputerCraft.terminalHeight_turtle * FixedWidthFontRenderer.FONT_HEIGHT; |         int termPxHeight = ComputerCraft.terminalHeight_turtle * FixedWidthFontRenderer.FONT_HEIGHT; | ||||||
|  |  | ||||||
|         this.terminal = new WidgetTerminal(minecraft, () -> this.m_computer, ComputerCraft.terminalWidth_turtle, ComputerCraft.terminalHeight_turtle, 2, 2, 2, 2); |         this.terminal = new WidgetTerminal(client, () -> this.m_computer, ComputerCraft.terminalWidth_turtle, ComputerCraft.terminalHeight_turtle, 2, 2, 2, 2); | ||||||
|         this.terminalWrapper = new WidgetWrapper(this.terminal, 2 + 8 + this.x, 2 + 8 + this.y, termPxWidth, termPxHeight); |         this.terminalWrapper = new WidgetWrapper(this.terminal, 2 + 8 + this.x, 2 + 8 + this.y, termPxWidth, termPxHeight); | ||||||
|  |  | ||||||
|         this.children.add(this.terminalWrapper); |         this.children.add(this.terminalWrapper); | ||||||
| @@ -79,7 +80,7 @@ public class GuiTurtle extends HandledScreen<ContainerTurtle> { | |||||||
|         super.removed(); |         super.removed(); | ||||||
|         this.children.remove(this.terminal); |         this.children.remove(this.terminal); | ||||||
|         this.terminal = null; |         this.terminal = null; | ||||||
|         minecraft.keyboard.enableRepeatEvents(false); |         client.keyboard.setRepeatEvents(false); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
| @@ -89,37 +90,37 @@ public class GuiTurtle extends HandledScreen<ContainerTurtle> { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     protected void drawBackground(float partialTicks, int mouseX, int mouseY) { |     protected void drawBackground(MatrixStack stack, float partialTicks, int mouseX, int mouseY) { | ||||||
|         // Draw term |         // Draw term | ||||||
|         boolean advanced = this.m_family == ComputerFamily.Advanced; |         boolean advanced = this.m_family == ComputerFamily.Advanced; | ||||||
|         this.terminal.draw(this.terminalWrapper.getX(), this.terminalWrapper.getY()); |         this.terminal.draw(this.terminalWrapper.getX(), this.terminalWrapper.getY()); | ||||||
|  |  | ||||||
|         // Draw border/inventory |         // Draw border/inventory | ||||||
|         GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F); |         GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F); | ||||||
|         minecraft.getTextureManager() |         client.getTextureManager() | ||||||
|                  .bindTextureInner(advanced ? BACKGROUND_ADVANCED : BACKGROUND_NORMAL); |                  .bindTextureInner(advanced ? BACKGROUND_ADVANCED : BACKGROUND_NORMAL); | ||||||
|         blit(this.x, this.y, 0, 0, this.backgroundWidth, this.backgroundHeight); |         drawTexture(stack, this.x, this.y, 0, 0, this.backgroundWidth, this.backgroundHeight); | ||||||
|  |  | ||||||
|         this.drawSelectionSlot(advanced); |         this.drawSelectionSlot(stack, advanced); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private void drawSelectionSlot(boolean advanced) { |     private void drawSelectionSlot(MatrixStack stack, boolean advanced) { | ||||||
|         // Draw selection slot |         // Draw selection slot | ||||||
|         int slot = this.m_container.getSelectedSlot(); |         int slot = this.m_container.getSelectedSlot(); | ||||||
|         if (slot >= 0) { |         if (slot >= 0) { | ||||||
|             GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F); |             GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F); | ||||||
|             int slotX = slot % 4; |             int slotX = slot % 4; | ||||||
|             int slotY = slot / 4; |             int slotY = slot / 4; | ||||||
|             minecraft.getTextureManager() |             client.getTextureManager() | ||||||
|                      .bindTextureInner(advanced ? BACKGROUND_ADVANCED : BACKGROUND_NORMAL); |                      .bindTextureInner(advanced ? BACKGROUND_ADVANCED : BACKGROUND_NORMAL); | ||||||
|             blit(this.x + this.m_container.m_turtleInvStartX - 2 + slotX * 18, this.y + this.m_container.m_playerInvStartY - 2 + slotY * 18, 0, 217, 24, 24); |             drawTexture(stack, this.x + this.m_container.m_turtleInvStartX - 2 + slotX * 18, this.y + this.m_container.m_playerInvStartY - 2 + slotY * 18, 0, 217, 24, 24); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void render(int mouseX, int mouseY, float partialTicks) { |     public void render(MatrixStack stack, int mouseX, int mouseY, float partialTicks) { | ||||||
|         renderBackground(); |         renderBackground(stack); | ||||||
|         super.render(mouseX, mouseY, partialTicks); |         super.render(stack, mouseX, mouseY, partialTicks); | ||||||
|         this.drawMouseoverTooltip(mouseX, mouseY); |         this.drawMouseoverTooltip(stack, mouseX, mouseY); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -20,6 +20,8 @@ import dan200.computercraft.shared.computer.core.ClientComputer; | |||||||
| import dan200.computercraft.shared.computer.core.IComputer; | import dan200.computercraft.shared.computer.core.IComputer; | ||||||
| import dan200.computercraft.shared.util.Colour; | import dan200.computercraft.shared.util.Colour; | ||||||
| import dan200.computercraft.shared.util.Palette; | import dan200.computercraft.shared.util.Palette; | ||||||
|  | import net.fabricmc.api.EnvType; | ||||||
|  | import net.fabricmc.api.Environment; | ||||||
| import org.lwjgl.glfw.GLFW; | import org.lwjgl.glfw.GLFW; | ||||||
| import org.lwjgl.opengl.GL11; | import org.lwjgl.opengl.GL11; | ||||||
|  |  | ||||||
| @@ -30,6 +32,7 @@ import net.minecraft.client.render.BufferBuilder; | |||||||
| import net.minecraft.client.render.Tessellator; | import net.minecraft.client.render.Tessellator; | ||||||
| import net.minecraft.client.render.VertexFormats; | import net.minecraft.client.render.VertexFormats; | ||||||
|  |  | ||||||
|  | @Environment(EnvType.CLIENT) | ||||||
| public class WidgetTerminal implements Element { | public class WidgetTerminal implements Element { | ||||||
|     private static final float TERMINATE_TIME = 0.5f; |     private static final float TERMINATE_TIME = 0.5f; | ||||||
|  |  | ||||||
| @@ -410,16 +413,16 @@ public class WidgetTerminal implements Element { | |||||||
|                     BufferBuilder buffer = tesslector.getBuffer(); |                     BufferBuilder buffer = tesslector.getBuffer(); | ||||||
|                     buffer.begin(GL11.GL_QUADS, VertexFormats.POSITION_TEXTURE); |                     buffer.begin(GL11.GL_QUADS, VertexFormats.POSITION_TEXTURE); | ||||||
|                     buffer.vertex(x, y + height, 0) |                     buffer.vertex(x, y + height, 0) | ||||||
|                           .texture(0 / 256.0, height / 256.0) |                           .texture(0 / 256.0f, height / 256.0f) | ||||||
|                           .next(); |                           .next(); | ||||||
|                     buffer.vertex(x + width, y + height, 0) |                     buffer.vertex(x + width, y + height, 0) | ||||||
|                           .texture(width / 256.0, height / 256.0) |                           .texture(width / 256.0f, height / 256.f) | ||||||
|                           .next(); |                           .next(); | ||||||
|                     buffer.vertex(x + width, y, 0) |                     buffer.vertex(x + width, y, 0) | ||||||
|                           .texture(width / 256.0, 0 / 256.0) |                           .texture(width / 256.0f, 0 / 256.0f) | ||||||
|                           .next(); |                           .next(); | ||||||
|                     buffer.vertex(x, y, 0) |                     buffer.vertex(x, y, 0) | ||||||
|                           .texture(0 / 256.0, 0 / 256.0) |                           .texture(0 / 256.0f, 0 / 256.0f) | ||||||
|                           .next(); |                           .next(); | ||||||
|                     tesslector.draw(); |                     tesslector.draw(); | ||||||
|                 } finally { |                 } finally { | ||||||
|   | |||||||
| @@ -32,12 +32,12 @@ import dan200.computercraft.shared.peripheral.monitor.TileMonitor; | |||||||
| import dan200.computercraft.shared.turtle.blocks.TileTurtle; | import dan200.computercraft.shared.turtle.blocks.TileTurtle; | ||||||
| import dan200.computercraft.shared.turtle.inventory.ContainerTurtle; | import dan200.computercraft.shared.turtle.inventory.ContainerTurtle; | ||||||
|  |  | ||||||
|  | import net.fabricmc.fabric.api.client.rendereregistry.v1.BlockEntityRendererRegistry; | ||||||
| import net.minecraft.client.texture.SpriteAtlasTexture; | import net.minecraft.client.texture.SpriteAtlasTexture; | ||||||
| import net.minecraft.inventory.SimpleInventory; | import net.minecraft.inventory.SimpleInventory; | ||||||
| import net.minecraft.screen.ArrayPropertyDelegate; | import net.minecraft.screen.ArrayPropertyDelegate; | ||||||
|  |  | ||||||
| import net.fabricmc.fabric.api.client.model.ModelLoadingRegistry; | import net.fabricmc.fabric.api.client.model.ModelLoadingRegistry; | ||||||
| import net.fabricmc.fabric.api.client.render.BlockEntityRendererRegistry; |  | ||||||
| import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback; | import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback; | ||||||
| import net.fabricmc.fabric.api.event.client.ClientTickCallback; | import net.fabricmc.fabric.api.event.client.ClientTickCallback; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -9,9 +9,9 @@ package dan200.computercraft.shared.command.arguments; | |||||||
| import com.mojang.brigadier.arguments.ArgumentType; | import com.mojang.brigadier.arguments.ArgumentType; | ||||||
| import dan200.computercraft.ComputerCraft; | import dan200.computercraft.ComputerCraft; | ||||||
|  |  | ||||||
| import net.minecraft.command.arguments.ArgumentTypes; | import net.minecraft.command.argument.ArgumentTypes; | ||||||
| import net.minecraft.command.arguments.serialize.ArgumentSerializer; | import net.minecraft.command.argument.serialize.ArgumentSerializer; | ||||||
| import net.minecraft.command.arguments.serialize.ConstantArgumentSerializer; | import net.minecraft.command.argument.serialize.ConstantArgumentSerializer; | ||||||
| import net.minecraft.util.Identifier; | import net.minecraft.util.Identifier; | ||||||
|  |  | ||||||
| public final class ArgumentSerializers { | public final class ArgumentSerializers { | ||||||
|   | |||||||
| @@ -36,7 +36,7 @@ import dan200.computercraft.ComputerCraft; | |||||||
| import dan200.computercraft.shared.computer.core.ComputerFamily; | import dan200.computercraft.shared.computer.core.ComputerFamily; | ||||||
| import dan200.computercraft.shared.computer.core.ServerComputer; | import dan200.computercraft.shared.computer.core.ServerComputer; | ||||||
|  |  | ||||||
| import net.minecraft.command.arguments.serialize.ArgumentSerializer; | import net.minecraft.command.argument.serialize.ArgumentSerializer; | ||||||
| import net.minecraft.network.PacketByteBuf; | import net.minecraft.network.PacketByteBuf; | ||||||
| import net.minecraft.server.command.ServerCommandSource; | import net.minecraft.server.command.ServerCommandSource; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -25,8 +25,8 @@ import com.mojang.brigadier.exceptions.SimpleCommandExceptionType; | |||||||
| import com.mojang.brigadier.suggestion.Suggestions; | import com.mojang.brigadier.suggestion.Suggestions; | ||||||
| import com.mojang.brigadier.suggestion.SuggestionsBuilder; | import com.mojang.brigadier.suggestion.SuggestionsBuilder; | ||||||
|  |  | ||||||
| import net.minecraft.command.arguments.ArgumentTypes; | import net.minecraft.command.argument.ArgumentTypes; | ||||||
| import net.minecraft.command.arguments.serialize.ArgumentSerializer; | import net.minecraft.command.argument.serialize.ArgumentSerializer; | ||||||
| import net.minecraft.network.PacketByteBuf; | import net.minecraft.network.PacketByteBuf; | ||||||
| import net.minecraft.text.LiteralText; | import net.minecraft.text.LiteralText; | ||||||
| import net.minecraft.text.Text; | import net.minecraft.text.Text; | ||||||
|   | |||||||
| @@ -6,12 +6,7 @@ | |||||||
|  |  | ||||||
| package dan200.computercraft.shared.command.text; | package dan200.computercraft.shared.command.text; | ||||||
|  |  | ||||||
| import net.minecraft.text.ClickEvent; | import net.minecraft.text.*; | ||||||
| import net.minecraft.text.HoverEvent; |  | ||||||
| import net.minecraft.text.LiteralText; |  | ||||||
| import net.minecraft.text.Style; |  | ||||||
| import net.minecraft.text.Text; |  | ||||||
| import net.minecraft.text.TranslatableText; |  | ||||||
| import net.minecraft.util.Formatting; | import net.minecraft.util.Formatting; | ||||||
| import net.minecraft.util.math.BlockPos; | import net.minecraft.util.math.BlockPos; | ||||||
|  |  | ||||||
| @@ -28,7 +23,7 @@ public final class ChatHelpers { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static Text list(Text... children) { |     public static Text list(Text... children) { | ||||||
|         Text component = new LiteralText(""); |         MutableText component = new LiteralText(""); | ||||||
|         for (Text child : children) { |         for (Text child : children) { | ||||||
|             component.append(child); |             component.append(child); | ||||||
|         } |         } | ||||||
| @@ -68,7 +63,7 @@ public final class ChatHelpers { | |||||||
|             style.withColor(Formatting.YELLOW); |             style.withColor(Formatting.YELLOW); | ||||||
|         } |         } | ||||||
|         style.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, command)); |         style.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, command)); | ||||||
|         style.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, toolTip)); |         style.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, toolTip)); | ||||||
|  |  | ||||||
|         return component; |         return component; | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -183,7 +183,6 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT | |||||||
|      * @param pos The position of the neighbour |      * @param pos The position of the neighbour | ||||||
|      * @param side The side we are reading from |      * @param side The side we are reading from | ||||||
|      * @return The effective redstone power |      * @return The effective redstone power | ||||||
|      * @see net.minecraft.block.RedstoneBlock#method_9991(World, BlockPos, BlockState) |  | ||||||
|      */ |      */ | ||||||
|     protected static int getRedstoneInput(World world, BlockPos pos, Direction side) { |     protected static int getRedstoneInput(World world, BlockPos pos, Direction side) { | ||||||
|         int power = world.getEmittedRedstonePower(pos, side); |         int power = world.getEmittedRedstonePower(pos, side); | ||||||
| @@ -321,8 +320,8 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void fromTag(CompoundTag nbt) { |     public void fromTag(BlockState state, CompoundTag nbt) { | ||||||
|         super.fromTag(nbt); |         super.fromTag(state, nbt); | ||||||
|  |  | ||||||
|         // Load ID, label and power state |         // Load ID, label and power state | ||||||
|         this.m_computerID = nbt.contains(NBT_ID) ? nbt.getInt(NBT_ID) : -1; |         this.m_computerID = nbt.contains(NBT_ID) ? nbt.getInt(NBT_ID) : -1; | ||||||
|   | |||||||
| @@ -39,7 +39,7 @@ public class MixinWorld { | |||||||
|  |  | ||||||
|     private static void setWorld(BlockEntity entity, Object world) { |     private static void setWorld(BlockEntity entity, Object world) { | ||||||
|         if (entity.getWorld() != world && entity instanceof TileGeneric) { |         if (entity.getWorld() != world && entity instanceof TileGeneric) { | ||||||
|             entity.setLocation((World) world); |             entity.setLocation((World) world, entity.getPos()); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -209,7 +209,7 @@ public class TurtleBrain implements ITurtleAccess { | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         // Ensure the chunk is loaded |         // Ensure the chunk is loaded | ||||||
|         if (!world.isBlockLoaded(pos)) { |         if (!world.isChunkLoaded(pos)) { | ||||||
|             return false; |             return false; | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -239,7 +239,7 @@ public class TurtleBrain implements ITurtleAccess { | |||||||
|                     if (newTile instanceof TileTurtle) { |                     if (newTile instanceof TileTurtle) { | ||||||
|                         // Copy the old turtle state into the new turtle |                         // Copy the old turtle state into the new turtle | ||||||
|                         TileTurtle newTurtle = (TileTurtle) newTile; |                         TileTurtle newTurtle = (TileTurtle) newTile; | ||||||
|                         newTurtle.setLocation(world); |                         newTurtle.setLocation(world, pos); | ||||||
|                         newTurtle.setPos(pos); |                         newTurtle.setPos(pos); | ||||||
|                         newTurtle.transferStateFrom(oldOwner); |                         newTurtle.transferStateFrom(oldOwner); | ||||||
|                         newTurtle.createServerComputer() |                         newTurtle.createServerComputer() | ||||||
| @@ -631,7 +631,7 @@ public class TurtleBrain implements ITurtleAccess { | |||||||
|                     } |                     } | ||||||
|  |  | ||||||
|                     Box aabb = new Box(minX, minY, minZ, maxX, maxY, maxZ); |                     Box aabb = new Box(minX, minY, minZ, maxX, maxY, maxZ); | ||||||
|                     List<Entity> list = world.getEntities((Entity) null, aabb, EntityPredicates.EXCEPT_SPECTATOR); |                     List<Entity> list = world.getOtherEntities((Entity) null, aabb, EntityPredicates.EXCEPT_SPECTATOR); | ||||||
|                     if (!list.isEmpty()) { |                     if (!list.isEmpty()) { | ||||||
|                         double pushStep = 1.0f / ANIM_DURATION; |                         double pushStep = 1.0f / ANIM_DURATION; | ||||||
|                         double pushStepX = moveDir.getOffsetX() * pushStep; |                         double pushStepX = moveDir.getOffsetX() * pushStep; | ||||||
|   | |||||||
| @@ -43,9 +43,8 @@ public final class TurtlePlayer extends FakePlayer { | |||||||
|  |  | ||||||
|     private void setState(ITurtleAccess turtle) { |     private void setState(ITurtleAccess turtle) { | ||||||
|         BlockPos position = turtle.getPosition(); |         BlockPos position = turtle.getPosition(); | ||||||
|         x = position.getX() + 0.5; |  | ||||||
|         y = position.getY() + 0.5; |         this.pos.add(0.5, 0.5, 0.5); | ||||||
|         z = position.getZ() + 0.5; |  | ||||||
|  |  | ||||||
|         this.yaw = turtle.getDirection() |         this.yaw = turtle.getDirection() | ||||||
|                          .asRotation(); |                          .asRotation(); | ||||||
| @@ -102,9 +101,9 @@ public final class TurtlePlayer extends FakePlayer { | |||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public Vec3d getCameraPosVec(float float_1) { |     public Vec3d getCameraPosVec(float float_1) { | ||||||
|         y -= this.getStandingEyeHeight(); |         this.pos.subtract(0, this.getStandingEyeHeight(), 0); | ||||||
|         Vec3d r = super.getCameraPosVec(float_1); |         Vec3d r = super.getCameraPosVec(float_1); | ||||||
|         y += this.getStandingEyeHeight(); |         this.pos.add(0, this.getStandingEyeHeight(), 0); | ||||||
|         return r; |         return r; | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ import java.util.concurrent.TimeUnit; | |||||||
| import blue.endless.jankson.Comment; | import blue.endless.jankson.Comment; | ||||||
| import blue.endless.jankson.Jankson; | import blue.endless.jankson.Jankson; | ||||||
| import blue.endless.jankson.JsonObject; | import blue.endless.jankson.JsonObject; | ||||||
| import blue.endless.jankson.impl.SyntaxError; | import blue.endless.jankson.api.SyntaxError; | ||||||
| import com.google.common.base.CaseFormat; | import com.google.common.base.CaseFormat; | ||||||
| import com.google.common.base.Converter; | import com.google.common.base.Converter; | ||||||
| import dan200.computercraft.ComputerCraft; | import dan200.computercraft.ComputerCraft; | ||||||
|   | |||||||
| @@ -11,6 +11,7 @@ import java.util.List; | |||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
|  |  | ||||||
| import com.google.common.base.Predicate; | import com.google.common.base.Predicate; | ||||||
|  | import net.minecraft.world.RaycastContext; | ||||||
| import org.apache.commons.lang3.tuple.Pair; | import org.apache.commons.lang3.tuple.Pair; | ||||||
|  |  | ||||||
| import net.minecraft.block.BlockState; | import net.minecraft.block.BlockState; | ||||||
| @@ -28,7 +29,6 @@ import net.minecraft.util.math.Box; | |||||||
| import net.minecraft.util.math.Direction; | import net.minecraft.util.math.Direction; | ||||||
| import net.minecraft.util.math.Vec3d; | import net.minecraft.util.math.Vec3d; | ||||||
| import net.minecraft.util.shape.VoxelShape; | import net.minecraft.util.shape.VoxelShape; | ||||||
| import net.minecraft.world.RayTraceContext; |  | ||||||
| import net.minecraft.world.World; | import net.minecraft.world.World; | ||||||
|  |  | ||||||
| public final class WorldUtil { | public final class WorldUtil { | ||||||
| @@ -69,10 +69,10 @@ public final class WorldUtil { | |||||||
|  |  | ||||||
|         // Raycast for blocks |         // Raycast for blocks | ||||||
|         ENTITY.updatePosition(vecStart.x, vecStart.y, vecStart.z); |         ENTITY.updatePosition(vecStart.x, vecStart.y, vecStart.z); | ||||||
|         HitResult result = world.rayTrace(new RayTraceContext(vecStart, |         HitResult result = world.raycast(new RaycastContext(vecStart, | ||||||
|                                                               vecEnd, |                                                               vecEnd, | ||||||
|                                                               RayTraceContext.ShapeType.OUTLINE, |                                                               RaycastContext.ShapeType.OUTLINE, | ||||||
|                                                               RayTraceContext.FluidHandling.NONE, |                                                               RaycastContext.FluidHandling.NONE, | ||||||
|                                                               ENTITY)); |                                                               ENTITY)); | ||||||
|         if (result != null && result.getType() == HitResult.Type.BLOCK) { |         if (result != null && result.getType() == HitResult.Type.BLOCK) { | ||||||
|             distance = vecStart.distanceTo(result.getPos()); |             distance = vecStart.distanceTo(result.getPos()); | ||||||
| @@ -92,7 +92,7 @@ public final class WorldUtil { | |||||||
|  |  | ||||||
|         Entity closest = null; |         Entity closest = null; | ||||||
|         double closestDist = 99.0; |         double closestDist = 99.0; | ||||||
|         List<Entity> list = world.getEntities(Entity.class, bigBox, CAN_COLLIDE); |         List<Entity> list = world.getEntitiesByClass(Entity.class, bigBox, CAN_COLLIDE); | ||||||
|         for (Entity entity : list) { |         for (Entity entity : list) { | ||||||
|             Box littleBox = entity.getBoundingBox(); |             Box littleBox = entity.getBoundingBox(); | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										12
									
								
								src/main/resources/computercraft.accesswidener
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								src/main/resources/computercraft.accesswidener
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,12 @@ | |||||||
|  | accessWidener v1 named | ||||||
|  |  | ||||||
|  | accessible method net/minecraft/client/gui/hud/ChatHud addMessage (Lnet/minecraft/text/Text;I)V | ||||||
|  | accessible method net/minecraft/client/gui/hud/ChatHud removeMessage (I)V | ||||||
|  | accessible field net/minecraft/block/entity/BlockEntity invalid Z | ||||||
|  | accessible method net/minecraft/world/World isValid (Lnet/minecraft/util/math/BlockPos;)Z | ||||||
|  | accessible method net/minecraft/client/render/item/HeldItemRenderer renderArmHoldingItem (Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;IFFLnet/minecraft/util/Arm;)V | ||||||
|  | accessible method net/minecraft/client/render/item/HeldItemRenderer renderArm (Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/util/Arm;)V | ||||||
|  | accessible method net/minecraft/client/render/item/HeldItemRenderer getMapAngle (F)F | ||||||
|  | accessible method net/minecraft/client/texture/TextureManager bindTextureInner (Lnet/minecraft/util/Identifier;)V | ||||||
|  | accessible field net/minecraft/entity/Entity pos Lnet/minecraft/util/math/Vec3d; | ||||||
|  | extendable method net/minecraft/entity/Entity getCameraPosVec (F)Lnet/minecraft/util/math/Vec3d; | ||||||
		Reference in New Issue
	
	Block a user
	 Devan-Kerman
					Devan-Kerman