diff --git a/build.gradle b/build.gradle index eab59f562..fbfe1da1b 100644 --- a/build.gradle +++ b/build.gradle @@ -109,7 +109,7 @@ dependencies { compileOnly fg.deobf("mezz.jei:jei-1.15.2:6.0.0.3:api") compileOnly fg.deobf("com.blamejared.crafttweaker:CraftTweaker-1.15.2:6.0.0.9") - runtimeOnly fg.deobf("mezz.jei:jei-1.15.2:6.0.0.3") + // runtimeOnly fg.deobf("mezz.jei:jei-1.15.2:6.0.0.3") compileOnly 'com.google.auto.service:auto-service:1.0-rc7' annotationProcessor 'com.google.auto.service:auto-service:1.0-rc7' diff --git a/gradle.properties b/gradle.properties index 08369c0f6..77974d726 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,6 +2,6 @@ mod_version=1.90.0 # Minecraft properties (update mods.toml when changing) -mc_version=1.15.2 -forge_version=31.1.41 -mappings_version=20200429-1.15.1 +mc_version=1.16.1 +forge_version=32.0.63 +mappings_version=20200707-1.16.1 diff --git a/src/main/java/dan200/computercraft/ComputerCraft.java b/src/main/java/dan200/computercraft/ComputerCraft.java index d712dc914..aeb00ad15 100644 --- a/src/main/java/dan200/computercraft/ComputerCraft.java +++ b/src/main/java/dan200/computercraft/ComputerCraft.java @@ -16,7 +16,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 net.minecraft.resources.IReloadableResourceManager; +import net.minecraft.resources.IResourceManager; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.server.ServerLifecycleHooks; @@ -141,7 +141,7 @@ public final class ComputerCraft public static InputStream getResourceFile( String domain, String subPath ) { - IReloadableResourceManager manager = ServerLifecycleHooks.getCurrentServer().getResourceManager(); + IResourceManager manager = ServerLifecycleHooks.getCurrentServer().getDataPackRegistries().func_240970_h_(); try { return manager.getResource( new ResourceLocation( domain, subPath ) ).getInputStream(); diff --git a/src/main/java/dan200/computercraft/ComputerCraftAPIImpl.java b/src/main/java/dan200/computercraft/ComputerCraftAPIImpl.java index 28f6d4e71..fbe140d69 100644 --- a/src/main/java/dan200/computercraft/ComputerCraftAPIImpl.java +++ b/src/main/java/dan200/computercraft/ComputerCraftAPIImpl.java @@ -81,7 +81,7 @@ public final class ComputerCraftAPIImpl implements IComputerCraftAPI @Override public IMount createResourceMount( @Nonnull String domain, @Nonnull String subPath ) { - IReloadableResourceManager manager = ServerLifecycleHooks.getCurrentServer().getResourceManager(); + IReloadableResourceManager manager = (IReloadableResourceManager) ServerLifecycleHooks.getCurrentServer().getDataPackRegistries().func_240970_h_(); ResourceMount mount = ResourceMount.get( domain, subPath, manager ); return mount.exists( "" ) ? mount : null; } diff --git a/src/main/java/dan200/computercraft/api/client/TransformedModel.java b/src/main/java/dan200/computercraft/api/client/TransformedModel.java index c4c88eec3..ee40a44aa 100644 --- a/src/main/java/dan200/computercraft/api/client/TransformedModel.java +++ b/src/main/java/dan200/computercraft/api/client/TransformedModel.java @@ -6,11 +6,11 @@ package dan200.computercraft.api.client; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.TransformationMatrix; import net.minecraft.client.renderer.model.IBakedModel; import net.minecraft.client.renderer.model.ModelManager; import net.minecraft.client.renderer.model.ModelResourceLocation; import net.minecraft.item.ItemStack; +import net.minecraft.util.math.vector.TransformationMatrix; import javax.annotation.Nonnull; import java.util.Objects; diff --git a/src/main/java/dan200/computercraft/api/network/IPacketReceiver.java b/src/main/java/dan200/computercraft/api/network/IPacketReceiver.java index 49b37d889..509dc1d68 100644 --- a/src/main/java/dan200/computercraft/api/network/IPacketReceiver.java +++ b/src/main/java/dan200/computercraft/api/network/IPacketReceiver.java @@ -5,7 +5,7 @@ */ package dan200.computercraft.api.network; -import net.minecraft.util.math.Vec3d; +import net.minecraft.util.math.vector.Vector3d; import net.minecraft.world.World; import javax.annotation.Nonnull; @@ -29,7 +29,7 @@ public interface IPacketReceiver * @return The receiver's position. */ @Nonnull - Vec3d getPosition(); + Vector3d getPosition(); /** * Get the maximum distance this receiver can send and receive messages. diff --git a/src/main/java/dan200/computercraft/api/network/IPacketSender.java b/src/main/java/dan200/computercraft/api/network/IPacketSender.java index bb9dc63d1..7276fbf51 100644 --- a/src/main/java/dan200/computercraft/api/network/IPacketSender.java +++ b/src/main/java/dan200/computercraft/api/network/IPacketSender.java @@ -5,7 +5,7 @@ */ package dan200.computercraft.api.network; -import net.minecraft.util.math.Vec3d; +import net.minecraft.util.math.vector.Vector3d; import net.minecraft.world.World; import javax.annotation.Nonnull; @@ -29,7 +29,7 @@ public interface IPacketSender * @return The sender's position. */ @Nonnull - Vec3d getPosition(); + Vector3d getPosition(); /** * Get some sort of identification string for this sender. This does not strictly need to be unique, but you diff --git a/src/main/java/dan200/computercraft/api/turtle/ITurtleAccess.java b/src/main/java/dan200/computercraft/api/turtle/ITurtleAccess.java index 53b176dbf..b11aaf0c7 100644 --- a/src/main/java/dan200/computercraft/api/turtle/ITurtleAccess.java +++ b/src/main/java/dan200/computercraft/api/turtle/ITurtleAccess.java @@ -13,7 +13,7 @@ import net.minecraft.inventory.IInventory; import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; +import net.minecraft.util.math.vector.Vector3d; import net.minecraft.world.World; import net.minecraftforge.items.IItemHandlerModifiable; @@ -67,7 +67,7 @@ public interface ITurtleAccess * @see #getVisualYaw(float) */ @Nonnull - Vec3d getVisualPosition( float f ); + Vector3d getVisualPosition( float f ); /** * Returns the yaw the turtle is facing when it is rendered. diff --git a/src/main/java/dan200/computercraft/client/ClientTableFormatter.java b/src/main/java/dan200/computercraft/client/ClientTableFormatter.java index 991fbbb1d..14c471faa 100644 --- a/src/main/java/dan200/computercraft/client/ClientTableFormatter.java +++ b/src/main/java/dan200/computercraft/client/ClientTableFormatter.java @@ -12,14 +12,12 @@ import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.NewChatGui; -import net.minecraft.client.gui.RenderComponentsUtil; import net.minecraft.util.math.MathHelper; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextFormatting; import org.apache.commons.lang3.StringUtils; import javax.annotation.Nullable; -import java.util.List; public class ClientTableFormatter implements TableFormatter { @@ -57,7 +55,7 @@ public class ClientTableFormatter implements TableFormatter @Override public int getWidth( ITextComponent component ) { - return renderer().getStringWidth( component.getFormattedText() ); + return renderer().func_238414_a_( component ); } @Override @@ -66,10 +64,11 @@ public class ClientTableFormatter implements TableFormatter Minecraft mc = Minecraft.getInstance(); NewChatGui chat = mc.ingameGUI.getChatGUI(); - // Trim the text if it goes over the allowed length - int maxWidth = MathHelper.floor( chat.getChatWidth() / chat.getScale() ); - List list = RenderComponentsUtil.splitText( component, maxWidth, mc.fontRenderer, false, false ); - if( !list.isEmpty() ) chat.printChatMessageWithOptionalDeletion( list.get( 0 ), id ); + // TODO: Trim the text if it goes over the allowed length + // int maxWidth = MathHelper.floor( chat.getChatWidth() / chat.getScale() ); + // List list = RenderComponentsUtil.func_238505_a_( component, maxWidth, mc.fontRenderer ); + // if( !list.isEmpty() ) chat.printChatMessageWithOptionalDeletion( list.get( 0 ), id ); + chat.printChatMessageWithOptionalDeletion( component, id ); } @Override diff --git a/src/main/java/dan200/computercraft/client/gui/FixedWidthFontRenderer.java b/src/main/java/dan200/computercraft/client/gui/FixedWidthFontRenderer.java index e10c0351a..67b304185 100644 --- a/src/main/java/dan200/computercraft/client/gui/FixedWidthFontRenderer.java +++ b/src/main/java/dan200/computercraft/client/gui/FixedWidthFontRenderer.java @@ -13,10 +13,14 @@ import dan200.computercraft.core.terminal.TextBuffer; import dan200.computercraft.shared.util.Colour; import dan200.computercraft.shared.util.Palette; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.*; +import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.renderer.RenderState; +import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.client.renderer.vertex.VertexFormat; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.vector.Matrix4f; +import net.minecraft.util.math.vector.TransformationMatrix; import org.lwjgl.opengl.GL11; import javax.annotation.Nonnull; diff --git a/src/main/java/dan200/computercraft/client/gui/GuiComputer.java b/src/main/java/dan200/computercraft/client/gui/GuiComputer.java index 3008c9386..bd354e30c 100644 --- a/src/main/java/dan200/computercraft/client/gui/GuiComputer.java +++ b/src/main/java/dan200/computercraft/client/gui/GuiComputer.java @@ -5,6 +5,7 @@ */ package dan200.computercraft.client.gui; +import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.systems.RenderSystem; import dan200.computercraft.ComputerCraft; import dan200.computercraft.client.gui.widgets.WidgetTerminal; @@ -21,6 +22,8 @@ import net.minecraft.entity.player.PlayerInventory; import net.minecraft.util.text.ITextComponent; import org.lwjgl.glfw.GLFW; +import javax.annotation.Nonnull; + import static dan200.computercraft.client.render.ComputerBorderRenderer.BORDER; import static dan200.computercraft.client.render.ComputerBorderRenderer.MARGIN; @@ -120,7 +123,7 @@ public final class GuiComputer extends Containe } @Override - public void drawGuiContainerBackgroundLayer( float partialTicks, int mouseX, int mouseY ) + public void func_230450_a_( @Nonnull MatrixStack stack, float partialTicks, int mouseX, int mouseY ) { // Draw terminal terminal.draw( terminalWrapper.getX(), terminalWrapper.getY() ); @@ -135,11 +138,10 @@ public final class GuiComputer extends Containe } @Override - public void render( int mouseX, int mouseY, float partialTicks ) + public void render( @Nonnull MatrixStack stack, int mouseX, int mouseY, float partialTicks ) { - renderBackground(); - super.render( mouseX, mouseY, partialTicks ); - renderHoveredToolTip( mouseX, mouseY ); + super.render( stack, mouseX, mouseY, partialTicks ); + func_230459_a_( stack, mouseX, mouseY ); } @Override diff --git a/src/main/java/dan200/computercraft/client/gui/GuiDiskDrive.java b/src/main/java/dan200/computercraft/client/gui/GuiDiskDrive.java index 59b6e38d2..e4d2ab06c 100644 --- a/src/main/java/dan200/computercraft/client/gui/GuiDiskDrive.java +++ b/src/main/java/dan200/computercraft/client/gui/GuiDiskDrive.java @@ -5,6 +5,7 @@ */ package dan200.computercraft.client.gui; +import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.systems.RenderSystem; import dan200.computercraft.shared.peripheral.diskdrive.ContainerDiskDrive; import net.minecraft.client.gui.screen.inventory.ContainerScreen; @@ -12,6 +13,8 @@ import net.minecraft.entity.player.PlayerInventory; import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.ITextComponent; +import javax.annotation.Nonnull; + public class GuiDiskDrive extends ContainerScreen { private static final ResourceLocation BACKGROUND = new ResourceLocation( "computercraft", "textures/gui/disk_drive.png" ); @@ -22,26 +25,18 @@ public class GuiDiskDrive extends ContainerScreen } @Override - protected void drawGuiContainerForegroundLayer( int mouseX, int mouseY ) - { - String title = this.title.getFormattedText(); - font.drawString( title, (xSize - font.getStringWidth( title )) / 2.0f, 6, 0x404040 ); - font.drawString( title, 8, ySize - 96 + 2, 0x404040 ); - } - - @Override - protected void drawGuiContainerBackgroundLayer( float partialTicks, int mouseX, int mouseY ) + protected void func_230450_a_( @Nonnull MatrixStack transform, float partialTicks, int mouseX, int mouseY ) { RenderSystem.color4f( 1.0F, 1.0F, 1.0F, 1.0F ); minecraft.getTextureManager().bindTexture( BACKGROUND ); - blit( guiLeft, guiTop, 0, 0, xSize, ySize ); + blit( transform, guiLeft, guiTop, 0, 0, xSize, ySize ); } @Override - public void render( int mouseX, int mouseY, float partialTicks ) + public void render( @Nonnull MatrixStack transform, int mouseX, int mouseY, float partialTicks ) { - renderBackground(); - super.render( mouseX, mouseY, partialTicks ); - renderHoveredToolTip( mouseX, mouseY ); + renderBackground( transform ); + super.render( transform, mouseX, mouseY, partialTicks ); + func_230459_a_( transform, mouseX, mouseY ); } } diff --git a/src/main/java/dan200/computercraft/client/gui/GuiPrinter.java b/src/main/java/dan200/computercraft/client/gui/GuiPrinter.java index 6073a459f..a6c14aea3 100644 --- a/src/main/java/dan200/computercraft/client/gui/GuiPrinter.java +++ b/src/main/java/dan200/computercraft/client/gui/GuiPrinter.java @@ -5,14 +5,16 @@ */ package dan200.computercraft.client.gui; +import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.systems.RenderSystem; import dan200.computercraft.shared.peripheral.printer.ContainerPrinter; import net.minecraft.client.gui.screen.inventory.ContainerScreen; -import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.ITextComponent; +import javax.annotation.Nonnull; + public class GuiPrinter extends ContainerScreen { private static final ResourceLocation BACKGROUND = new ResourceLocation( "computercraft", "textures/gui/printer.png" ); @@ -22,29 +24,29 @@ public class GuiPrinter extends ContainerScreen super( container, player, title ); } - @Override + /*@Override protected void drawGuiContainerForegroundLayer( int mouseX, int mouseY ) { String title = getTitle().getFormattedText(); font.drawString( title, (xSize - font.getStringWidth( title )) / 2.0f, 6, 0x404040 ); font.drawString( I18n.format( "container.inventory" ), 8, ySize - 96 + 2, 0x404040 ); - } + }*/ @Override - protected void drawGuiContainerBackgroundLayer( float partialTicks, int mouseX, int mouseY ) + protected void func_230450_a_( @Nonnull MatrixStack transform, float partialTicks, int mouseX, int mouseY ) { RenderSystem.color4f( 1.0F, 1.0F, 1.0F, 1.0F ); minecraft.getTextureManager().bindTexture( BACKGROUND ); - blit( guiLeft, guiTop, 0, 0, xSize, ySize ); + blit( transform, guiLeft, guiTop, 0, 0, xSize, ySize ); - if( getContainer().isPrinting() ) blit( guiLeft + 34, guiTop + 21, 176, 0, 25, 45 ); + if( getContainer().isPrinting() ) blit( transform, guiLeft + 34, guiTop + 21, 176, 0, 25, 45 ); } @Override - public void render( int mouseX, int mouseY, float partialTicks ) + public void render( @Nonnull MatrixStack stack, int mouseX, int mouseY, float partialTicks ) { - renderBackground(); - super.render( mouseX, mouseY, partialTicks ); - renderHoveredToolTip( mouseX, mouseY ); + renderBackground( stack ); + super.render( stack, mouseX, mouseY, partialTicks ); + func_230459_a_( stack, mouseX, mouseY ); } } diff --git a/src/main/java/dan200/computercraft/client/gui/GuiPrintout.java b/src/main/java/dan200/computercraft/client/gui/GuiPrintout.java index 37927e62a..e60d997aa 100644 --- a/src/main/java/dan200/computercraft/client/gui/GuiPrintout.java +++ b/src/main/java/dan200/computercraft/client/gui/GuiPrintout.java @@ -5,6 +5,7 @@ */ package dan200.computercraft.client.gui; +import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.systems.RenderSystem; import dan200.computercraft.core.terminal.TextBuffer; import dan200.computercraft.shared.common.ContainerHeldItem; @@ -12,12 +13,14 @@ import dan200.computercraft.shared.media.items.ItemPrintout; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screen.inventory.ContainerScreen; import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.Matrix4f; -import net.minecraft.client.renderer.TransformationMatrix; 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; +import javax.annotation.Nonnull; + import static dan200.computercraft.client.render.PrintoutRenderer.*; public class GuiPrintout extends ContainerScreen @@ -91,27 +94,28 @@ public class GuiPrintout extends ContainerScreen } @Override - public void drawGuiContainerBackgroundLayer( float partialTicks, int mouseX, int mouseY ) + protected void func_230450_a_( @Nonnull MatrixStack transform, float partialTicks, int mouseX, int mouseY ) { // Draw the printout RenderSystem.color4f( 1.0f, 1.0f, 1.0f, 1.0f ); RenderSystem.enableDepthTest(); IRenderTypeBuffer.Impl renderer = Minecraft.getInstance().getRenderTypeBuffers().getBufferSource(); - drawBorder( IDENTITY, renderer, guiLeft, guiTop, getBlitOffset(), m_page, m_pages, m_book ); - drawText( IDENTITY, renderer, guiLeft + X_TEXT_MARGIN, guiTop + Y_TEXT_MARGIN, ItemPrintout.LINES_PER_PAGE * m_page, m_text, m_colours ); + Matrix4f matrix = transform.getLast().getMatrix(); + drawBorder( matrix, renderer, guiLeft, guiTop, getBlitOffset(), m_page, m_pages, m_book ); + drawText( matrix, renderer, guiLeft + X_TEXT_MARGIN, guiTop + Y_TEXT_MARGIN, ItemPrintout.LINES_PER_PAGE * m_page, m_text, m_colours ); renderer.finish(); } @Override - public void render( int mouseX, int mouseY, float partialTicks ) + public void render( @Nonnull MatrixStack stack, int mouseX, int mouseY, float partialTicks ) { // We must take the background further back in order to not overlap with our printed pages. setBlitOffset( getBlitOffset() - 1 ); - renderBackground(); + renderBackground( stack ); setBlitOffset( getBlitOffset() + 1 ); - super.render( mouseX, mouseY, partialTicks ); - renderHoveredToolTip( mouseX, mouseY ); + super.render( stack, mouseX, mouseY, partialTicks ); + func_230459_a_( stack, mouseX, mouseY ); } } diff --git a/src/main/java/dan200/computercraft/client/gui/GuiTurtle.java b/src/main/java/dan200/computercraft/client/gui/GuiTurtle.java index 517cf140f..f84902e6b 100644 --- a/src/main/java/dan200/computercraft/client/gui/GuiTurtle.java +++ b/src/main/java/dan200/computercraft/client/gui/GuiTurtle.java @@ -5,6 +5,7 @@ */ package dan200.computercraft.client.gui; +import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.systems.RenderSystem; import dan200.computercraft.ComputerCraft; import dan200.computercraft.client.gui.widgets.WidgetTerminal; @@ -18,6 +19,8 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.ITextComponent; import org.lwjgl.glfw.GLFW; +import javax.annotation.Nonnull; + public class GuiTurtle extends ContainerScreen { private static final ResourceLocation BACKGROUND_NORMAL = new ResourceLocation( "computercraft", "textures/gui/turtle_normal.png" ); @@ -102,12 +105,12 @@ public class GuiTurtle extends ContainerScreen int slotX = slot % 4; int slotY = slot / 4; minecraft.getTextureManager().bindTexture( advanced ? BACKGROUND_ADVANCED : BACKGROUND_NORMAL ); - blit( guiLeft + ContainerTurtle.TURTLE_START_X - 2 + slotX * 18, guiTop + ContainerTurtle.PLAYER_START_Y - 2 + slotY * 18, 0, 217, 24, 24 ); + // 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 drawGuiContainerBackgroundLayer( float partialTicks, int mouseX, int mouseY ) + protected void func_230450_a_( @Nonnull MatrixStack transform, float partialTicks, int mouseX, int mouseY ) { // Draw term boolean advanced = m_family == ComputerFamily.ADVANCED; @@ -116,17 +119,17 @@ public class GuiTurtle extends ContainerScreen // Draw border/inventory RenderSystem.color4f( 1.0F, 1.0F, 1.0F, 1.0F ); minecraft.getTextureManager().bindTexture( advanced ? BACKGROUND_ADVANCED : BACKGROUND_NORMAL ); - blit( guiLeft, guiTop, 0, 0, xSize, ySize ); + blit( transform, guiLeft, guiTop, 0, 0, xSize, ySize ); drawSelectionSlot( advanced ); } @Override - public void render( int mouseX, int mouseY, float partialTicks ) + public void render( @Nonnull MatrixStack stack, int mouseX, int mouseY, float partialTicks ) { - renderBackground(); - super.render( mouseX, mouseY, partialTicks ); - renderHoveredToolTip( mouseX, mouseY ); + renderBackground( stack ); + super.render( stack, mouseX, mouseY, partialTicks ); + func_230459_a_( stack, mouseX, mouseY ); } @Override diff --git a/src/main/java/dan200/computercraft/client/proxy/ComputerCraftProxyClient.java b/src/main/java/dan200/computercraft/client/proxy/ComputerCraftProxyClient.java index 70147c4c6..79facbaaf 100644 --- a/src/main/java/dan200/computercraft/client/proxy/ComputerCraftProxyClient.java +++ b/src/main/java/dan200/computercraft/client/proxy/ComputerCraftProxyClient.java @@ -11,13 +11,19 @@ import dan200.computercraft.client.render.TileEntityMonitorRenderer; import dan200.computercraft.client.render.TileEntityTurtleRenderer; import dan200.computercraft.client.render.TurtlePlayerRenderer; import dan200.computercraft.shared.Registry; +import dan200.computercraft.shared.common.IColouredItem; import dan200.computercraft.shared.computer.inventory.ContainerComputer; import dan200.computercraft.shared.computer.inventory.ContainerViewComputer; import dan200.computercraft.shared.peripheral.monitor.ClientMonitor; import dan200.computercraft.shared.pocket.inventory.ContainerPocketComputer; +import dan200.computercraft.shared.pocket.items.ItemPocketComputer; import net.minecraft.client.gui.ScreenManager; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderTypeLookup; +import net.minecraft.item.IItemPropertyGetter; +import net.minecraft.item.Item; +import net.minecraft.item.ItemModelsProperties; +import net.minecraft.util.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -26,6 +32,8 @@ import net.minecraftforge.fml.client.registry.RenderingRegistry; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; +import java.util.function.Supplier; + @Mod.EventBusSubscriber( modid = ComputerCraft.MOD_ID, value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD ) public final class ComputerCraftProxyClient { @@ -50,6 +58,25 @@ public final class ComputerCraftProxyClient // TODO: ClientRegistry.bindTileEntityRenderer( TileCable.FACTORY, x -> new TileEntityCableRenderer() ); RenderingRegistry.registerEntityRenderingHandler( Registry.ModEntities.TURTLE_PLAYER.get(), TurtlePlayerRenderer::new ); + + registerItemProperty( "state", + ( stack, world, player ) -> ItemPocketComputer.getState( stack ).ordinal(), + Registry.ModItems.POCKET_COMPUTER_NORMAL, Registry.ModItems.POCKET_COMPUTER_ADVANCED + ); + registerItemProperty( "state", + ( stack, world, player ) -> IColouredItem.getColourBasic( stack ) != -1 ? 1 : 0, + Registry.ModItems.POCKET_COMPUTER_NORMAL, Registry.ModItems.POCKET_COMPUTER_ADVANCED + ); + } + + @SafeVarargs + private static void registerItemProperty( String name, IItemPropertyGetter getter, Supplier... items ) + { + ResourceLocation id = new ResourceLocation( ComputerCraft.MOD_ID, name ); + for( Supplier item : items ) + { + ItemModelsProperties.func_239418_a_( item.get(), id, getter ); + } } private static void registerContainers() diff --git a/src/main/java/dan200/computercraft/client/render/CableHighlightRenderer.java b/src/main/java/dan200/computercraft/client/render/CableHighlightRenderer.java index f88700b98..b8571e938 100644 --- a/src/main/java/dan200/computercraft/client/render/CableHighlightRenderer.java +++ b/src/main/java/dan200/computercraft/client/render/CableHighlightRenderer.java @@ -14,14 +14,14 @@ import dan200.computercraft.shared.peripheral.modem.wired.CableShapes; import dan200.computercraft.shared.util.WorldUtil; import net.minecraft.block.BlockState; import net.minecraft.client.renderer.ActiveRenderInfo; -import net.minecraft.client.renderer.Matrix4f; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.entity.Entity; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.shapes.VoxelShape; +import net.minecraft.util.math.vector.Matrix4f; +import net.minecraft.util.math.vector.Vector3d; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.event.DrawHighlightEvent; @@ -63,7 +63,7 @@ public final class CableHighlightRenderer ? CableShapes.getModemShape( state ) : CableShapes.getCableShape( state ); - Vec3d cameraPos = info.getProjectedView(); + Vector3d cameraPos = info.getProjectedView(); double xOffset = pos.getX() - cameraPos.getX(); double yOffset = pos.getY() - cameraPos.getY(); double zOffset = pos.getZ() - cameraPos.getZ(); diff --git a/src/main/java/dan200/computercraft/client/render/ComputerBorderRenderer.java b/src/main/java/dan200/computercraft/client/render/ComputerBorderRenderer.java index 9c784d7fc..fb051995a 100644 --- a/src/main/java/dan200/computercraft/client/render/ComputerBorderRenderer.java +++ b/src/main/java/dan200/computercraft/client/render/ComputerBorderRenderer.java @@ -11,10 +11,10 @@ import com.mojang.blaze3d.vertex.IVertexBuilder; import dan200.computercraft.ComputerCraft; import dan200.computercraft.shared.computer.core.ComputerFamily; import net.minecraft.client.renderer.BufferBuilder; -import net.minecraft.client.renderer.Matrix4f; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.vector.Matrix4f; import org.lwjgl.opengl.GL11; import javax.annotation.Nonnull; diff --git a/src/main/java/dan200/computercraft/client/render/ItemMapLikeRenderer.java b/src/main/java/dan200/computercraft/client/render/ItemMapLikeRenderer.java index f25deea79..7ef903136 100644 --- a/src/main/java/dan200/computercraft/client/render/ItemMapLikeRenderer.java +++ b/src/main/java/dan200/computercraft/client/render/ItemMapLikeRenderer.java @@ -10,12 +10,12 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.entity.player.AbstractClientPlayerEntity; import net.minecraft.client.renderer.FirstPersonRenderer; import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.Vector3f; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.Hand; import net.minecraft.util.HandSide; import net.minecraft.util.math.MathHelper; +import net.minecraft.util.math.vector.Vector3f; public abstract class ItemMapLikeRenderer { diff --git a/src/main/java/dan200/computercraft/client/render/ItemPocketRenderer.java b/src/main/java/dan200/computercraft/client/render/ItemPocketRenderer.java index 157250d56..e260c048d 100644 --- a/src/main/java/dan200/computercraft/client/render/ItemPocketRenderer.java +++ b/src/main/java/dan200/computercraft/client/render/ItemPocketRenderer.java @@ -15,9 +15,13 @@ import dan200.computercraft.shared.computer.core.ComputerFamily; import dan200.computercraft.shared.pocket.items.ItemPocketComputer; import dan200.computercraft.shared.util.Colour; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.*; +import net.minecraft.client.renderer.BufferBuilder; +import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.item.ItemStack; +import net.minecraft.util.math.vector.Matrix4f; +import net.minecraft.util.math.vector.Vector3f; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.event.RenderHandEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; diff --git a/src/main/java/dan200/computercraft/client/render/ItemPrintoutRenderer.java b/src/main/java/dan200/computercraft/client/render/ItemPrintoutRenderer.java index 5fa6ada5d..9de945077 100644 --- a/src/main/java/dan200/computercraft/client/render/ItemPrintoutRenderer.java +++ b/src/main/java/dan200/computercraft/client/render/ItemPrintoutRenderer.java @@ -9,9 +9,9 @@ import com.mojang.blaze3d.matrix.MatrixStack; import dan200.computercraft.ComputerCraft; import dan200.computercraft.shared.media.items.ItemPrintout; import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.Matrix4f; -import net.minecraft.client.renderer.Vector3f; import net.minecraft.item.ItemStack; +import net.minecraft.util.math.vector.Matrix4f; +import net.minecraft.util.math.vector.Vector3f; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.event.RenderHandEvent; import net.minecraftforge.client.event.RenderItemInFrameEvent; diff --git a/src/main/java/dan200/computercraft/client/render/MonitorHighlightRenderer.java b/src/main/java/dan200/computercraft/client/render/MonitorHighlightRenderer.java index 54e8c80b9..847a45160 100644 --- a/src/main/java/dan200/computercraft/client/render/MonitorHighlightRenderer.java +++ b/src/main/java/dan200/computercraft/client/render/MonitorHighlightRenderer.java @@ -9,12 +9,12 @@ import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import dan200.computercraft.ComputerCraft; import dan200.computercraft.shared.peripheral.monitor.TileMonitor; -import net.minecraft.client.renderer.Matrix4f; import net.minecraft.client.renderer.RenderType; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; +import net.minecraft.util.math.vector.Matrix4f; +import net.minecraft.util.math.vector.Vector3d; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.event.DrawHighlightEvent; @@ -61,7 +61,7 @@ public final class MonitorHighlightRenderer if( monitor.getYIndex() != monitor.getHeight() - 1 ) faces.remove( monitor.getDown() ); MatrixStack transformStack = event.getMatrix(); - Vec3d cameraPos = event.getInfo().getProjectedView(); + Vector3d cameraPos = event.getInfo().getProjectedView(); transformStack.push(); transformStack.translate( pos.getX() - cameraPos.getX(), pos.getY() - cameraPos.getY(), pos.getZ() - cameraPos.getZ() ); diff --git a/src/main/java/dan200/computercraft/client/render/MonitorTextureBufferShader.java b/src/main/java/dan200/computercraft/client/render/MonitorTextureBufferShader.java index 483957a31..a1e361b3b 100644 --- a/src/main/java/dan200/computercraft/client/render/MonitorTextureBufferShader.java +++ b/src/main/java/dan200/computercraft/client/render/MonitorTextureBufferShader.java @@ -12,8 +12,8 @@ import com.mojang.blaze3d.systems.RenderSystem; import dan200.computercraft.ComputerCraft; import dan200.computercraft.client.gui.FixedWidthFontRenderer; import dan200.computercraft.shared.util.Palette; -import net.minecraft.client.renderer.Matrix4f; import net.minecraft.client.renderer.texture.TextureUtil; +import net.minecraft.util.math.vector.Matrix4f; import org.lwjgl.BufferUtils; import org.lwjgl.opengl.GL13; import org.lwjgl.opengl.GL20; diff --git a/src/main/java/dan200/computercraft/client/render/PrintoutRenderer.java b/src/main/java/dan200/computercraft/client/render/PrintoutRenderer.java index 53f1c358e..3d48b2d80 100644 --- a/src/main/java/dan200/computercraft/client/render/PrintoutRenderer.java +++ b/src/main/java/dan200/computercraft/client/render/PrintoutRenderer.java @@ -10,11 +10,11 @@ import dan200.computercraft.client.gui.FixedWidthFontRenderer; import dan200.computercraft.core.terminal.TextBuffer; import dan200.computercraft.shared.util.Palette; import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.Matrix4f; import net.minecraft.client.renderer.RenderState; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.vector.Matrix4f; import org.lwjgl.opengl.GL11; import static dan200.computercraft.client.gui.FixedWidthFontRenderer.FONT_HEIGHT; diff --git a/src/main/java/dan200/computercraft/client/render/TileEntityMonitorRenderer.java b/src/main/java/dan200/computercraft/client/render/TileEntityMonitorRenderer.java index 8f8530360..23edc49c7 100644 --- a/src/main/java/dan200/computercraft/client/render/TileEntityMonitorRenderer.java +++ b/src/main/java/dan200/computercraft/client/render/TileEntityMonitorRenderer.java @@ -17,13 +17,19 @@ import dan200.computercraft.shared.peripheral.monitor.MonitorRenderer; import dan200.computercraft.shared.peripheral.monitor.TileMonitor; import dan200.computercraft.shared.util.Colour; import dan200.computercraft.shared.util.DirectionUtil; -import net.minecraft.client.renderer.*; +import net.minecraft.client.renderer.BufferBuilder; +import net.minecraft.client.renderer.GLAllocation; +import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.client.renderer.vertex.VertexBuffer; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.vector.Matrix4f; +import net.minecraft.util.math.vector.TransformationMatrix; +import net.minecraft.util.math.vector.Vector3f; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL13; import org.lwjgl.opengl.GL20; diff --git a/src/main/java/dan200/computercraft/client/render/TileEntityTurtleRenderer.java b/src/main/java/dan200/computercraft/client/render/TileEntityTurtleRenderer.java index 91162280b..5c182b501 100644 --- a/src/main/java/dan200/computercraft/client/render/TileEntityTurtleRenderer.java +++ b/src/main/java/dan200/computercraft/client/render/TileEntityTurtleRenderer.java @@ -19,8 +19,6 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.renderer.Atlases; import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.Matrix4f; -import net.minecraft.client.renderer.Vector3f; import net.minecraft.client.renderer.model.BakedQuad; import net.minecraft.client.renderer.model.IBakedModel; import net.minecraft.client.renderer.model.ModelManager; @@ -31,7 +29,9 @@ import net.minecraft.util.Direction; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.RayTraceResult; -import net.minecraft.util.math.Vec3d; +import net.minecraft.util.math.vector.Matrix4f; +import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.util.math.vector.Vector3f; import net.minecraftforge.client.model.data.EmptyModelData; import javax.annotation.Nonnull; @@ -99,7 +99,7 @@ public class TileEntityTurtleRenderer extends TileEntityRenderer transform.push(); // Setup the transform. - Vec3d offset = turtle.getRenderOffset( partialTicks ); + Vector3d offset = turtle.getRenderOffset( partialTicks ); float yaw = turtle.getRenderYaw( partialTicks ); transform.translate( offset.x, offset.y, offset.z ); diff --git a/src/main/java/dan200/computercraft/client/render/TurtleModelLoader.java b/src/main/java/dan200/computercraft/client/render/TurtleModelLoader.java index 41249f178..fd8a1a67a 100644 --- a/src/main/java/dan200/computercraft/client/render/TurtleModelLoader.java +++ b/src/main/java/dan200/computercraft/client/render/TurtleModelLoader.java @@ -57,16 +57,16 @@ public final class TurtleModelLoader implements IModelLoader getTextures( IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors ) + public Collection getTextures( IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors ) { - Set materials = new HashSet<>(); + Set materials = new HashSet<>(); materials.addAll( modelGetter.apply( family ).getTextures( modelGetter, missingTextureErrors ) ); materials.addAll( modelGetter.apply( COLOUR_TURTLE_MODEL ).getTextures( modelGetter, missingTextureErrors ) ); return materials; } @Override - public IBakedModel bake( IModelConfiguration owner, ModelBakery bakery, Function spriteGetter, IModelTransform transform, ItemOverrideList overrides, ResourceLocation modelLocation ) + public IBakedModel bake( IModelConfiguration owner, ModelBakery bakery, Function spriteGetter, IModelTransform transform, ItemOverrideList overrides, ResourceLocation modelLocation ) { return new TurtleSmartItemModel( bakery.getBakedModel( family, transform, spriteGetter ), diff --git a/src/main/java/dan200/computercraft/client/render/TurtleMultiModel.java b/src/main/java/dan200/computercraft/client/render/TurtleMultiModel.java index 8f9a65cfd..256c53544 100644 --- a/src/main/java/dan200/computercraft/client/render/TurtleMultiModel.java +++ b/src/main/java/dan200/computercraft/client/render/TurtleMultiModel.java @@ -7,12 +7,12 @@ package dan200.computercraft.client.render; import dan200.computercraft.api.client.TransformedModel; import net.minecraft.block.BlockState; -import net.minecraft.client.renderer.TransformationMatrix; import net.minecraft.client.renderer.model.BakedQuad; import net.minecraft.client.renderer.model.IBakedModel; import net.minecraft.client.renderer.model.ItemOverrideList; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.util.Direction; +import net.minecraft.util.math.vector.TransformationMatrix; import net.minecraftforge.client.model.data.EmptyModelData; import net.minecraftforge.client.model.data.IModelData; import net.minecraftforge.client.model.pipeline.BakedQuadBuilder; diff --git a/src/main/java/dan200/computercraft/client/render/TurtleSmartItemModel.java b/src/main/java/dan200/computercraft/client/render/TurtleSmartItemModel.java index f99b61264..3272b6f50 100644 --- a/src/main/java/dan200/computercraft/client/render/TurtleSmartItemModel.java +++ b/src/main/java/dan200/computercraft/client/render/TurtleSmartItemModel.java @@ -15,14 +15,14 @@ import dan200.computercraft.shared.util.Holiday; import dan200.computercraft.shared.util.HolidayUtil; import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.TransformationMatrix; import net.minecraft.client.renderer.model.*; import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.world.ClientWorld; import net.minecraft.entity.LivingEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.Direction; import net.minecraft.util.ResourceLocation; -import net.minecraft.world.World; +import net.minecraft.util.math.vector.TransformationMatrix; import net.minecraftforge.client.model.data.IModelData; import javax.annotation.Nonnull; @@ -109,7 +109,7 @@ public class TurtleSmartItemModel implements IBakedModel { @Nonnull @Override - public IBakedModel getModelWithOverrides( @Nonnull IBakedModel originalModel, @Nonnull ItemStack stack, @Nullable World world, @Nullable LivingEntity entity ) + public IBakedModel func_239290_a_( @Nonnull IBakedModel originalModel, @Nonnull ItemStack stack, @Nullable ClientWorld world, @Nullable LivingEntity entity ) { ItemTurtle turtle = (ItemTurtle) stack.getItem(); int colour = turtle.getColour( stack ); diff --git a/src/main/java/dan200/computercraft/core/apis/FSAPI.java b/src/main/java/dan200/computercraft/core/apis/FSAPI.java index fc909c683..6d923ef77 100644 --- a/src/main/java/dan200/computercraft/core/apis/FSAPI.java +++ b/src/main/java/dan200/computercraft/core/apis/FSAPI.java @@ -385,8 +385,8 @@ public class FSAPI implements ILuaAPI * * @param path The path to check the free space for. * @return The amount of free space available, in bytes. - * @cc.treturn number|"unlimited" The amount of free space available, in bytes, or "unlimited". * @throws LuaException If the path doesn't exist. + * @cc.treturn number|"unlimited" The amount of free space available, in bytes, or "unlimited". */ @LuaFunction public final Object getFreeSpace( String path ) throws LuaException diff --git a/src/main/java/dan200/computercraft/core/apis/OSAPI.java b/src/main/java/dan200/computercraft/core/apis/OSAPI.java index 43a5c473f..d2e3cbb71 100644 --- a/src/main/java/dan200/computercraft/core/apis/OSAPI.java +++ b/src/main/java/dan200/computercraft/core/apis/OSAPI.java @@ -303,10 +303,10 @@ public class OSAPI implements ILuaAPI * always be in the range [0.0, 24.0). * * * If called with {@code ingame}, the current world time will be returned. - * This is the default if nothing is passed. + * This is the default if nothing is passed. * * If called with {@code utc}, returns the hour of the day in UTC time. * * If called with {@code local}, returns the hour of the day in the - * timezone the server is located in. + * timezone the server is located in. * * This function can also be called with a table returned from {@link #date}, * which will convert the date fields into a UNIX timestamp (number of @@ -314,9 +314,9 @@ public class OSAPI implements ILuaAPI * * @param args The locale of the time, or a table filled by {@code os.date("*t")} to decode. Defaults to {@code ingame} locale if not specified. * @return The hour of the selected locale, or a UNIX timestamp from the table, depending on the argument passed in. + * @throws LuaException If an invalid locale is passed. * @cc.tparam [opt] string|table locale The locale of the time, or a table filled by {@code os.date("*t")} to decode. Defaults to {@code ingame} locale if not specified. * @see #date To get a date table that can be converted with this function. - * @throws LuaException If an invalid locale is passed. */ @LuaFunction public final Object time( IArguments args ) throws LuaException @@ -342,11 +342,11 @@ public class OSAPI implements ILuaAPI * Returns the day depending on the locale specified. * * * If called with {@code ingame}, returns the number of days since the - * world was created. This is the default. + * world was created. This is the default. * * If called with {@code utc}, returns the number of days since 1 January - * 1970 in the UTC timezone. + * 1970 in the UTC timezone. * * If called with {@code local}, returns the number of days since 1 - * January 1970 in the server's local timezone. + * January 1970 in the server's local timezone. * * @param args The locale to get the day for. Defaults to {@code ingame} if not set. * @return The day depending on the selected locale. @@ -372,11 +372,11 @@ public class OSAPI implements ILuaAPI * Returns the number of seconds since an epoch depending on the locale. * * * If called with {@code ingame}, returns the number of seconds since the - * world was created. This is the default. + * world was created. This is the default. * * If called with {@code utc}, returns the number of seconds since 1 - * January 1970 in the UTC timezone. + * January 1970 in the UTC timezone. * * If called with {@code local}, returns the number of seconds since 1 - * January 1970 in the server's local timezone. + * January 1970 in the server's local timezone. * * @param args The locale to get the seconds for. Defaults to {@code ingame} if not set. * @return The seconds since the epoch depending on the selected locale. @@ -426,7 +426,7 @@ public class OSAPI implements ILuaAPI * timestamp (days since 1 January 1970) with {@link #date}. * * @param formatA The format of the string to return. This defaults to {@code %c}, which expands to a string similar to "Sat Dec 24 16:58:00 2011". - * @param timeA The time to convert to a string. This defaults to the current time. + * @param timeA The time to convert to a string. This defaults to the current time. * @return The resulting format string. * @throws LuaException If an invalid format is passed. */ diff --git a/src/main/java/dan200/computercraft/data/Generators.java b/src/main/java/dan200/computercraft/data/Generators.java index 69ef83b78..6fb250c19 100644 --- a/src/main/java/dan200/computercraft/data/Generators.java +++ b/src/main/java/dan200/computercraft/data/Generators.java @@ -7,6 +7,7 @@ package dan200.computercraft.data; import dan200.computercraft.shared.proxy.ComputerCraftProxyCommon; +import net.minecraft.data.BlockTagsProvider; import net.minecraft.data.DataGenerator; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; @@ -23,6 +24,6 @@ public class Generators DataGenerator generator = event.getGenerator(); generator.addProvider( new Recipes( generator ) ); generator.addProvider( new LootTables( generator ) ); - generator.addProvider( new Tags( generator ) ); + generator.addProvider( new Tags( generator, new BlockTagsProvider( generator ) ) ); } } diff --git a/src/main/java/dan200/computercraft/data/LootTableProvider.java b/src/main/java/dan200/computercraft/data/LootTableProvider.java index e24d07206..16be3be38 100644 --- a/src/main/java/dan200/computercraft/data/LootTableProvider.java +++ b/src/main/java/dan200/computercraft/data/LootTableProvider.java @@ -13,11 +13,11 @@ import dan200.computercraft.ComputerCraft; import net.minecraft.data.DataGenerator; import net.minecraft.data.DirectoryCache; import net.minecraft.data.IDataProvider; +import net.minecraft.loot.LootParameterSets; +import net.minecraft.loot.LootTable; +import net.minecraft.loot.LootTableManager; +import net.minecraft.loot.ValidationTracker; import net.minecraft.util.ResourceLocation; -import net.minecraft.world.storage.loot.LootParameterSets; -import net.minecraft.world.storage.loot.LootTable; -import net.minecraft.world.storage.loot.LootTableManager; -import net.minecraft.world.storage.loot.ValidationTracker; import javax.annotation.Nonnull; import java.io.IOException; diff --git a/src/main/java/dan200/computercraft/data/LootTables.java b/src/main/java/dan200/computercraft/data/LootTables.java index b85f0dea1..fbeee9e31 100644 --- a/src/main/java/dan200/computercraft/data/LootTables.java +++ b/src/main/java/dan200/computercraft/data/LootTables.java @@ -14,10 +14,10 @@ import dan200.computercraft.shared.data.PlayerCreativeLootCondition; import dan200.computercraft.shared.proxy.ComputerCraftProxyCommon; import net.minecraft.block.Block; import net.minecraft.data.DataGenerator; +import net.minecraft.loot.*; +import net.minecraft.loot.conditions.Alternative; +import net.minecraft.loot.conditions.SurvivesExplosion; import net.minecraft.util.ResourceLocation; -import net.minecraft.world.storage.loot.*; -import net.minecraft.world.storage.loot.conditions.Alternative; -import net.minecraft.world.storage.loot.conditions.SurvivesExplosion; import net.minecraftforge.fml.RegistryObject; import java.util.function.BiConsumer; @@ -77,9 +77,9 @@ public class LootTables extends LootTableProvider .rolls( ConstantRange.of( 1 ) ) .addEntry( DynamicLootEntry.func_216162_a( new ResourceLocation( ComputerCraft.MOD_ID, "computer" ) ) ) .acceptCondition( Alternative.builder( - BlockNamedEntityLootCondition.builder(), - HasComputerIdLootCondition.builder(), - PlayerCreativeLootCondition.builder().inverted() + BlockNamedEntityLootCondition.BUILDER, + HasComputerIdLootCondition.BUILDER, + PlayerCreativeLootCondition.BUILDER.inverted() ) ) ).build() ); } diff --git a/src/main/java/dan200/computercraft/data/Recipes.java b/src/main/java/dan200/computercraft/data/Recipes.java index a86ac212e..071de897b 100644 --- a/src/main/java/dan200/computercraft/data/Recipes.java +++ b/src/main/java/dan200/computercraft/data/Recipes.java @@ -21,7 +21,7 @@ import net.minecraft.advancements.criterion.ItemPredicate; import net.minecraft.block.Blocks; import net.minecraft.data.*; import net.minecraft.item.*; -import net.minecraft.tags.Tag; +import net.minecraft.tags.ITag; import net.minecraft.util.IItemProvider; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.Tags; @@ -309,7 +309,7 @@ public class Recipes extends RecipeProvider return DyeColor.byId( 15 - colour.ordinal() ); } - private static InventoryChangeTrigger.Instance inventoryChange( Tag stack ) + private static InventoryChangeTrigger.Instance inventoryChange( ITag stack ) { return InventoryChangeTrigger.Instance.forItems( ItemPredicate.Builder.create().tag( stack ).build() ); } diff --git a/src/main/java/dan200/computercraft/data/Tags.java b/src/main/java/dan200/computercraft/data/Tags.java index d822d6150..a8f981b2e 100644 --- a/src/main/java/dan200/computercraft/data/Tags.java +++ b/src/main/java/dan200/computercraft/data/Tags.java @@ -8,11 +8,12 @@ package dan200.computercraft.data; import dan200.computercraft.ComputerCraft; import dan200.computercraft.shared.Registry; +import net.minecraft.data.BlockTagsProvider; import net.minecraft.data.DataGenerator; import net.minecraft.data.ItemTagsProvider; import net.minecraft.item.Item; +import net.minecraft.tags.ITag; import net.minecraft.tags.ItemTags; -import net.minecraft.tags.Tag; import net.minecraft.util.ResourceLocation; import static dan200.computercraft.data.Tags.CCTags.*; @@ -21,33 +22,32 @@ public class Tags extends ItemTagsProvider { public static class CCTags { - public static final Tag COMPUTER = item( "computer" ); - public static final Tag TURTLE = item( "turtle" ); - public static final Tag WIRED_MODEM = item( "wired_modem" ); - public static final Tag MONITOR = item( "monitor" ); + public static final ITag.INamedTag COMPUTER = item( "computer" ); + public static final ITag.INamedTag TURTLE = item( "turtle" ); + public static final ITag.INamedTag WIRED_MODEM = item( "wired_modem" ); + public static final ITag.INamedTag MONITOR = item( "monitor" ); } - public Tags( DataGenerator generator ) + public Tags( DataGenerator generator, BlockTagsProvider tags ) { - super( generator ); + super( generator, tags ); } @Override protected void registerTags() { - getBuilder( COMPUTER ) - .add( Registry.ModItems.COMPUTER_NORMAL.get() ) - .add( Registry.ModItems.COMPUTER_ADVANCED.get() ) - .add( Registry.ModItems.COMPUTER_COMMAND.get() ); - getBuilder( TURTLE ).add( Registry.ModItems.TURTLE_NORMAL.get(), Registry.ModItems.TURTLE_ADVANCED.get() ); - getBuilder( WIRED_MODEM ).add( Registry.ModItems.WIRED_MODEM.get(), Registry.ModItems.WIRED_MODEM_FULL.get() ); - getBuilder( MONITOR ) - .add( Registry.ModItems.MONITOR_NORMAL.get() ) - .add( Registry.ModItems.MONITOR_ADVANCED.get() ); + func_240522_a_( COMPUTER ).func_240534_a_( + 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() ); } - private static Tag item( String name ) + private static ITag.INamedTag item( String name ) { - return new ItemTags.Wrapper( new ResourceLocation( ComputerCraft.MOD_ID, name ) ); + return ItemTags.makeWrapperTag( new ResourceLocation( ComputerCraft.MOD_ID, name ).toString() ); } } diff --git a/src/main/java/dan200/computercraft/shared/Registry.java b/src/main/java/dan200/computercraft/shared/Registry.java index fe8a2d448..903aa4c97 100644 --- a/src/main/java/dan200/computercraft/shared/Registry.java +++ b/src/main/java/dan200/computercraft/shared/Registry.java @@ -92,7 +92,7 @@ public final class Registry public static final class ModBlocks { - static final DeferredRegister BLOCKS = new DeferredRegister<>( ForgeRegistries.BLOCKS, ComputerCraft.MOD_ID ); + static final DeferredRegister BLOCKS = DeferredRegister.create( ForgeRegistries.BLOCKS, ComputerCraft.MOD_ID ); private static Block.Properties properties() { @@ -145,7 +145,7 @@ public final class Registry public static class ModTiles { - static final DeferredRegister> TILES = new DeferredRegister<>( ForgeRegistries.TILE_ENTITIES, ComputerCraft.MOD_ID ); + static final DeferredRegister> TILES = DeferredRegister.create( ForgeRegistries.TILE_ENTITIES, ComputerCraft.MOD_ID ); private static RegistryObject> ofBlock( RegistryObject block, Function, T> factory ) { @@ -183,7 +183,7 @@ public final class Registry public static final class ModItems { - static final DeferredRegister ITEMS = new DeferredRegister<>( ForgeRegistries.ITEMS, ComputerCraft.MOD_ID ); + static final DeferredRegister ITEMS = DeferredRegister.create( ForgeRegistries.ITEMS, ComputerCraft.MOD_ID ); private static Item.Properties properties() { @@ -281,7 +281,7 @@ public final class Registry public static class ModEntities { - static final DeferredRegister> ENTITIES = new DeferredRegister<>( ForgeRegistries.ENTITIES, ComputerCraft.MOD_ID ); + static final DeferredRegister> ENTITIES = DeferredRegister.create( ForgeRegistries.ENTITIES, ComputerCraft.MOD_ID ); public static final RegistryObject> TURTLE_PLAYER = ENTITIES.register( "turtle_player", () -> EntityType.Builder.create( EntityClassification.MISC ) @@ -293,7 +293,7 @@ public final class Registry public static class ModContainers { - static final DeferredRegister> CONTAINERS = new DeferredRegister<>( ForgeRegistries.CONTAINERS, ComputerCraft.MOD_ID ); + static final DeferredRegister> CONTAINERS = DeferredRegister.create( ForgeRegistries.CONTAINERS, ComputerCraft.MOD_ID ); public static final RegistryObject> COMPUTER = CONTAINERS.register( "computer", () -> ContainerData.toType( ComputerContainerData::new, ContainerComputer::new ) ); diff --git a/src/main/java/dan200/computercraft/shared/TurtlePermissions.java b/src/main/java/dan200/computercraft/shared/TurtlePermissions.java index 98c7eca75..57511d018 100644 --- a/src/main/java/dan200/computercraft/shared/TurtlePermissions.java +++ b/src/main/java/dan200/computercraft/shared/TurtlePermissions.java @@ -11,6 +11,7 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.server.MinecraftServer; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import net.minecraft.world.server.ServerWorld; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; @@ -20,13 +21,12 @@ public final class TurtlePermissions public static boolean isBlockEnterable( World world, BlockPos pos, PlayerEntity player ) { MinecraftServer server = world.getServer(); - return server == null || world.isRemote || !server.isBlockProtected( world, pos, player ); + return server == null || world.isRemote || (world instanceof ServerWorld && !server.isBlockProtected( (ServerWorld) world, pos, player )); } public static boolean isBlockEditable( World world, BlockPos pos, PlayerEntity player ) { - MinecraftServer server = world.getServer(); - return server == null || world.isRemote || !server.isBlockProtected( world, pos, player ); + return isBlockEnterable( world, pos, player ); } @SubscribeEvent diff --git a/src/main/java/dan200/computercraft/shared/command/CommandComputerCraft.java b/src/main/java/dan200/computercraft/shared/command/CommandComputerCraft.java index 876dcad5a..c8afb9c44 100644 --- a/src/main/java/dan200/computercraft/shared/command/CommandComputerCraft.java +++ b/src/main/java/dan200/computercraft/shared/command/CommandComputerCraft.java @@ -30,6 +30,7 @@ import net.minecraft.inventory.container.Container; import net.minecraft.inventory.container.INamedContainerProvider; import net.minecraft.network.play.server.SPlayerPositionLookPacket; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.IFormattableTextComponent; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.StringTextComponent; import net.minecraft.util.text.TranslationTextComponent; @@ -283,16 +284,16 @@ public final class CommandComputerCraft private static ITextComponent linkComputer( CommandSource source, ServerComputer serverComputer, int computerId ) { - ITextComponent out = new StringTextComponent( "" ); + IFormattableTextComponent out = new StringTextComponent( "" ); // Append the computer instance if( serverComputer == null ) { - out.appendSibling( text( "?" ) ); + out.func_230529_a_( text( "?" ) ); } else { - out.appendSibling( link( + out.func_230529_a_( link( text( Integer.toString( serverComputer.getInstanceID() ) ), "/computercraft dump " + serverComputer.getInstanceID(), translate( "commands.computercraft.dump.action" ) @@ -300,20 +301,20 @@ public final class CommandComputerCraft } // And ID - out.appendText( " (id " + computerId + ")" ); + out.func_240702_b_( " (id " + computerId + ")" ); // And, if we're a player, some useful links if( serverComputer != null && UserLevel.OP.test( source ) && isPlayer( source ) ) { out - .appendText( " " ) - .appendSibling( link( + .func_240702_b_( " " ) + .func_230529_a_( link( text( "\u261b" ), "/computercraft tp " + serverComputer.getInstanceID(), translate( "commands.computercraft.tp.action" ) ) ) - .appendText( " " ) - .appendSibling( link( + .func_240702_b_( " " ) + .func_230529_a_( link( text( "\u20e2" ), "/computercraft view " + serverComputer.getInstanceID(), translate( "commands.computercraft.view.action" ) diff --git a/src/main/java/dan200/computercraft/shared/command/builder/HelpingArgumentBuilder.java b/src/main/java/dan200/computercraft/shared/command/builder/HelpingArgumentBuilder.java index a90713133..48ba35e6c 100644 --- a/src/main/java/dan200/computercraft/shared/command/builder/HelpingArgumentBuilder.java +++ b/src/main/java/dan200/computercraft/shared/command/builder/HelpingArgumentBuilder.java @@ -13,6 +13,7 @@ import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.tree.CommandNode; import com.mojang.brigadier.tree.LiteralCommandNode; import net.minecraft.command.CommandSource; +import net.minecraft.util.text.IFormattableTextComponent; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.StringTextComponent; import net.minecraft.util.text.TextFormatting; @@ -173,12 +174,12 @@ public final class HelpingArgumentBuilder extends LiteralArgumentBuilder child : node.getChildren() ) { @@ -187,16 +188,16 @@ public final class HelpingArgumentBuilder extends LiteralArgumentBuilder T coloured( T component, TextFormatting colour ) + public static T coloured( T component, TextFormatting colour ) { - component.getStyle().setColor( colour ); + component.getStyle().setFormatting( colour ); return component; } - public static ITextComponent text( String text ) + public static IFormattableTextComponent text( String text ) { return new StringTextComponent( text == null ? "" : text ); } - public static ITextComponent translate( String text ) + public static IFormattableTextComponent translate( String text ) { return new TranslationTextComponent( text == null ? "" : text ); } - public static ITextComponent translate( String text, Object... args ) + public static IFormattableTextComponent translate( String text, Object... args ) { return new TranslationTextComponent( text == null ? "" : text, args ); } - public static ITextComponent list( ITextComponent... children ) + public static IFormattableTextComponent list( ITextComponent... children ) { - ITextComponent component = new StringTextComponent( "" ); + IFormattableTextComponent component = new StringTextComponent( "" ); for( ITextComponent child : children ) { - component.appendSibling( child ); + component.func_230529_a_( child ); } return component; } - public static ITextComponent position( BlockPos pos ) + public static IFormattableTextComponent 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 ITextComponent bool( boolean value ) + public static IFormattableTextComponent bool( boolean value ) { return value ? coloured( translate( "commands.computercraft.generic.yes" ), TextFormatting.GREEN ) : coloured( translate( "commands.computercraft.generic.no" ), TextFormatting.RED ); } - public static ITextComponent link( ITextComponent component, String command, ITextComponent toolTip ) + public static IFormattableTextComponent link( IFormattableTextComponent component, String command, ITextComponent toolTip ) { Style style = component.getStyle(); - if( style.getColor() == null ) style.setColor( TextFormatting.YELLOW ); + 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 ) ); return component; } - public static ITextComponent header( String text ) + public static IFormattableTextComponent header( String text ) { return coloured( text, HEADER ); } diff --git a/src/main/java/dan200/computercraft/shared/command/text/TableFormatter.java b/src/main/java/dan200/computercraft/shared/command/text/TableFormatter.java index 683989cd6..7d001f20c 100644 --- a/src/main/java/dan200/computercraft/shared/command/text/TableFormatter.java +++ b/src/main/java/dan200/computercraft/shared/command/text/TableFormatter.java @@ -79,12 +79,12 @@ public interface TableFormatter StringTextComponent line = new StringTextComponent( "" ); for( int i = 0; i < columns - 1; i++ ) { - line.appendSibling( headers[i] ); + line.func_230529_a_( headers[i] ); ITextComponent padding = getPadding( headers[i], maxWidths[i] ); - if( padding != null ) line.appendSibling( padding ); - line.appendSibling( SEPARATOR ); + if( padding != null ) line.func_230529_a_( padding ); + line.func_230529_a_( SEPARATOR ); } - line.appendSibling( headers[columns - 1] ); + line.func_230529_a_( 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.appendSibling( row[i] ); + line.func_230529_a_( row[i] ); ITextComponent padding = getPadding( row[i], maxWidths[i] ); - if( padding != null ) line.appendSibling( padding ); - line.appendSibling( SEPARATOR ); + if( padding != null ) line.func_230529_a_( padding ); + line.func_230529_a_( SEPARATOR ); } - line.appendSibling( row[columns - 1] ); + line.func_230529_a_( row[columns - 1] ); writeLine( rowId++, line ); } diff --git a/src/main/java/dan200/computercraft/shared/common/TileGeneric.java b/src/main/java/dan200/computercraft/shared/common/TileGeneric.java index 5d391cf8a..3814a7f74 100644 --- a/src/main/java/dan200/computercraft/shared/common/TileGeneric.java +++ b/src/main/java/dan200/computercraft/shared/common/TileGeneric.java @@ -105,9 +105,9 @@ public abstract class TileGeneric extends TileEntity } @Override - public void handleUpdateTag( @Nonnull CompoundNBT tag ) + public void handleUpdateTag( @Nonnull BlockState state, @Nonnull CompoundNBT tag ) { - super.handleUpdateTag( tag ); + super.handleUpdateTag( state, tag ); readDescription( tag ); } } diff --git a/src/main/java/dan200/computercraft/shared/computer/blocks/BlockComputerBase.java b/src/main/java/dan200/computercraft/shared/computer/blocks/BlockComputerBase.java index 0bf82c8e2..f990647c2 100644 --- a/src/main/java/dan200/computercraft/shared/computer/blocks/BlockComputerBase.java +++ b/src/main/java/dan200/computercraft/shared/computer/blocks/BlockComputerBase.java @@ -16,6 +16,8 @@ import net.minecraft.block.BlockState; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; +import net.minecraft.loot.LootContext; +import net.minecraft.loot.LootParameters; import net.minecraft.stats.Stats; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityType; @@ -26,8 +28,6 @@ import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; -import net.minecraft.world.storage.loot.LootContext; -import net.minecraft.world.storage.loot.LootParameters; import net.minecraftforge.fml.RegistryObject; import javax.annotation.Nonnull; diff --git a/src/main/java/dan200/computercraft/shared/computer/blocks/TileCommandComputer.java b/src/main/java/dan200/computercraft/shared/computer/blocks/TileCommandComputer.java index 20d542463..ed55abf4b 100644 --- a/src/main/java/dan200/computercraft/shared/computer/blocks/TileCommandComputer.java +++ b/src/main/java/dan200/computercraft/shared/computer/blocks/TileCommandComputer.java @@ -14,8 +14,8 @@ import net.minecraft.command.ICommandSource; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.server.MinecraftServer; import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.math.Vec2f; -import net.minecraft.util.math.Vec3d; +import net.minecraft.util.math.vector.Vector2f; +import net.minecraft.util.math.vector.Vector3d; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.StringTextComponent; import net.minecraft.util.text.TranslationTextComponent; @@ -25,6 +25,7 @@ import net.minecraft.world.server.ServerWorld; import javax.annotation.Nonnull; import java.util.HashMap; import java.util.Map; +import java.util.UUID; public class TileCommandComputer extends TileComputer { @@ -48,7 +49,7 @@ public class TileCommandComputer extends TileComputer } @Override - public void sendMessage( @Nonnull ITextComponent textComponent ) + public void sendMessage( @Nonnull ITextComponent textComponent, @Nonnull UUID id ) { output.put( output.size() + 1, textComponent.getString() ); } @@ -96,7 +97,7 @@ public class TileCommandComputer extends TileComputer } return new CommandSource( receiver, - new Vec3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 ), Vec2f.ZERO, + new Vector3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 ), Vector2f.ZERO, (ServerWorld) getWorld(), 2, name, new StringTextComponent( name ), getWorld().getServer(), null diff --git a/src/main/java/dan200/computercraft/shared/computer/blocks/TileComputerBase.java b/src/main/java/dan200/computercraft/shared/computer/blocks/TileComputerBase.java index b384810b9..c77012bbc 100644 --- a/src/main/java/dan200/computercraft/shared/computer/blocks/TileComputerBase.java +++ b/src/main/java/dan200/computercraft/shared/computer/blocks/TileComputerBase.java @@ -189,9 +189,9 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT } @Override - public void read( @Nonnull CompoundNBT nbt ) + public void read( @Nonnull BlockState state, @Nonnull CompoundNBT nbt ) { - super.read( nbt ); + super.read( state, nbt ); // Load ID, label and power state m_computerID = nbt.contains( NBT_ID ) ? nbt.getInt( NBT_ID ) : -1; diff --git a/src/main/java/dan200/computercraft/shared/computer/core/ComputerState.java b/src/main/java/dan200/computercraft/shared/computer/core/ComputerState.java index 82f603306..1d4699a7c 100644 --- a/src/main/java/dan200/computercraft/shared/computer/core/ComputerState.java +++ b/src/main/java/dan200/computercraft/shared/computer/core/ComputerState.java @@ -24,7 +24,7 @@ public enum ComputerState implements IStringSerializable @Nonnull @Override - public String getName() + public String getString() { return name; } diff --git a/src/main/java/dan200/computercraft/shared/computer/items/ItemComputerBase.java b/src/main/java/dan200/computercraft/shared/computer/items/ItemComputerBase.java index 3ac904dc8..04d61c252 100644 --- a/src/main/java/dan200/computercraft/shared/computer/items/ItemComputerBase.java +++ b/src/main/java/dan200/computercraft/shared/computer/items/ItemComputerBase.java @@ -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 ) - .applyTextStyle( TextFormatting.GRAY ) ); + .func_240699_a_( TextFormatting.GRAY ) ); } } } diff --git a/src/main/java/dan200/computercraft/shared/data/BlockNamedEntityLootCondition.java b/src/main/java/dan200/computercraft/shared/data/BlockNamedEntityLootCondition.java index 898c321ce..e08f5825d 100644 --- a/src/main/java/dan200/computercraft/shared/data/BlockNamedEntityLootCondition.java +++ b/src/main/java/dan200/computercraft/shared/data/BlockNamedEntityLootCondition.java @@ -5,12 +5,13 @@ */ package dan200.computercraft.shared.data; +import net.minecraft.loot.LootConditionType; +import net.minecraft.loot.LootContext; +import net.minecraft.loot.LootParameter; +import net.minecraft.loot.LootParameters; +import net.minecraft.loot.conditions.ILootCondition; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.INameable; -import net.minecraft.world.storage.loot.LootContext; -import net.minecraft.world.storage.loot.LootParameter; -import net.minecraft.world.storage.loot.LootParameters; -import net.minecraft.world.storage.loot.conditions.ILootCondition; import javax.annotation.Nonnull; import java.util.Collections; @@ -22,6 +23,8 @@ import java.util.Set; public final class BlockNamedEntityLootCondition implements ILootCondition { public static final BlockNamedEntityLootCondition INSTANCE = new BlockNamedEntityLootCondition(); + public static final LootConditionType TYPE = ConstantLootConditionSerializer.type( INSTANCE ); + public static final IBuilder BUILDER = () -> INSTANCE; private BlockNamedEntityLootCondition() { @@ -41,8 +44,10 @@ public final class BlockNamedEntityLootCondition implements ILootCondition return Collections.singleton( LootParameters.BLOCK_ENTITY ); } - public static IBuilder builder() + @Override + @Nonnull + public LootConditionType func_230419_b_() { - return () -> INSTANCE; + return TYPE; } } diff --git a/src/main/java/dan200/computercraft/shared/data/ConstantLootConditionSerializer.java b/src/main/java/dan200/computercraft/shared/data/ConstantLootConditionSerializer.java index 07ac6a830..87182f010 100644 --- a/src/main/java/dan200/computercraft/shared/data/ConstantLootConditionSerializer.java +++ b/src/main/java/dan200/computercraft/shared/data/ConstantLootConditionSerializer.java @@ -8,34 +8,34 @@ package dan200.computercraft.shared.data; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonObject; import com.google.gson.JsonSerializationContext; -import net.minecraft.util.ResourceLocation; -import net.minecraft.world.storage.loot.conditions.ILootCondition; +import net.minecraft.loot.ILootSerializer; +import net.minecraft.loot.LootConditionType; +import net.minecraft.loot.conditions.ILootCondition; import javax.annotation.Nonnull; -public final class ConstantLootConditionSerializer extends ILootCondition.AbstractSerializer +public final class ConstantLootConditionSerializer implements ILootSerializer { private final T instance; - private ConstantLootConditionSerializer( ResourceLocation id, Class klass, T instance ) + public ConstantLootConditionSerializer( T instance ) { - super( id, klass ); this.instance = instance; } - public static ILootCondition.AbstractSerializer of( ResourceLocation id, Class klass, T instance ) + public static LootConditionType type( T condition ) { - return new ConstantLootConditionSerializer<>( id, klass, instance ); + return new LootConditionType( new ConstantLootConditionSerializer<>( condition ) ); } @Override - public void serialize( @Nonnull JsonObject json, @Nonnull T object, @Nonnull JsonSerializationContext context ) + public void func_230424_a_( @Nonnull JsonObject json, @Nonnull T object, @Nonnull JsonSerializationContext context ) { } @Nonnull @Override - public T deserialize( @Nonnull JsonObject json, @Nonnull JsonDeserializationContext context ) + public T func_230423_a_( @Nonnull JsonObject json, @Nonnull JsonDeserializationContext context ) { return instance; } diff --git a/src/main/java/dan200/computercraft/shared/data/HasComputerIdLootCondition.java b/src/main/java/dan200/computercraft/shared/data/HasComputerIdLootCondition.java index 4da10a15c..57837e2b0 100644 --- a/src/main/java/dan200/computercraft/shared/data/HasComputerIdLootCondition.java +++ b/src/main/java/dan200/computercraft/shared/data/HasComputerIdLootCondition.java @@ -6,11 +6,12 @@ package dan200.computercraft.shared.data; import dan200.computercraft.shared.computer.blocks.IComputerTile; +import net.minecraft.loot.LootConditionType; +import net.minecraft.loot.LootContext; +import net.minecraft.loot.LootParameter; +import net.minecraft.loot.LootParameters; +import net.minecraft.loot.conditions.ILootCondition; import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.storage.loot.LootContext; -import net.minecraft.world.storage.loot.LootParameter; -import net.minecraft.world.storage.loot.LootParameters; -import net.minecraft.world.storage.loot.conditions.ILootCondition; import javax.annotation.Nonnull; import java.util.Collections; @@ -22,6 +23,8 @@ import java.util.Set; public final class HasComputerIdLootCondition implements ILootCondition { public static final HasComputerIdLootCondition INSTANCE = new HasComputerIdLootCondition(); + public static final LootConditionType TYPE = ConstantLootConditionSerializer.type( INSTANCE ); + public static final IBuilder BUILDER = () -> INSTANCE; private HasComputerIdLootCondition() { @@ -41,8 +44,10 @@ public final class HasComputerIdLootCondition implements ILootCondition return Collections.singleton( LootParameters.BLOCK_ENTITY ); } - public static IBuilder builder() + @Override + @Nonnull + public LootConditionType func_230419_b_() { - return () -> INSTANCE; + return TYPE; } } diff --git a/src/main/java/dan200/computercraft/shared/data/PlayerCreativeLootCondition.java b/src/main/java/dan200/computercraft/shared/data/PlayerCreativeLootCondition.java index 6a91f90fe..10f4ca56a 100644 --- a/src/main/java/dan200/computercraft/shared/data/PlayerCreativeLootCondition.java +++ b/src/main/java/dan200/computercraft/shared/data/PlayerCreativeLootCondition.java @@ -7,10 +7,11 @@ package dan200.computercraft.shared.data; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.world.storage.loot.LootContext; -import net.minecraft.world.storage.loot.LootParameter; -import net.minecraft.world.storage.loot.LootParameters; -import net.minecraft.world.storage.loot.conditions.ILootCondition; +import net.minecraft.loot.LootConditionType; +import net.minecraft.loot.LootContext; +import net.minecraft.loot.LootParameter; +import net.minecraft.loot.LootParameters; +import net.minecraft.loot.conditions.ILootCondition; import javax.annotation.Nonnull; import java.util.Collections; @@ -22,6 +23,8 @@ import java.util.Set; public final class PlayerCreativeLootCondition implements ILootCondition { public static final PlayerCreativeLootCondition INSTANCE = new PlayerCreativeLootCondition(); + public static final LootConditionType TYPE = ConstantLootConditionSerializer.type( INSTANCE ); + public static final IBuilder BUILDER = () -> INSTANCE; private PlayerCreativeLootCondition() { @@ -41,8 +44,10 @@ public final class PlayerCreativeLootCondition implements ILootCondition return Collections.singleton( LootParameters.THIS_ENTITY ); } - public static IBuilder builder() + @Override + @Nonnull + public LootConditionType func_230419_b_() { - return () -> INSTANCE; + return TYPE; } } diff --git a/src/main/java/dan200/computercraft/shared/media/items/ItemDisk.java b/src/main/java/dan200/computercraft/shared/media/items/ItemDisk.java index 6ef877402..017781cba 100644 --- a/src/main/java/dan200/computercraft/shared/media/items/ItemDisk.java +++ b/src/main/java/dan200/computercraft/shared/media/items/ItemDisk.java @@ -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 ) - .applyTextStyle( TextFormatting.GRAY ) ); + .func_240699_a_( TextFormatting.GRAY ) ); } } } diff --git a/src/main/java/dan200/computercraft/shared/media/recipes/DiskRecipe.java b/src/main/java/dan200/computercraft/shared/media/recipes/DiskRecipe.java index 0e5f81ab5..4ad832519 100644 --- a/src/main/java/dan200/computercraft/shared/media/recipes/DiskRecipe.java +++ b/src/main/java/dan200/computercraft/shared/media/recipes/DiskRecipe.java @@ -19,14 +19,14 @@ import net.minecraft.item.crafting.SpecialRecipe; import net.minecraft.item.crafting.SpecialRecipeSerializer; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; -import net.minecraftforge.common.Tags; import javax.annotation.Nonnull; public class DiskRecipe extends SpecialRecipe { private final Ingredient paper = Ingredient.fromItems( Items.PAPER ); - private final Ingredient redstone = Ingredient.fromTag( Tags.Items.DUSTS_REDSTONE ); + private final Ingredient redstone = Ingredient.fromItems( Items.REDSTONE ); + // TODO: Ingredient.fromTag( Tags.Items.DUSTS_REDSTONE ); public DiskRecipe( ResourceLocation id ) { diff --git a/src/main/java/dan200/computercraft/shared/network/NetworkHandler.java b/src/main/java/dan200/computercraft/shared/network/NetworkHandler.java index 5b905a76b..ca391be00 100644 --- a/src/main/java/dan200/computercraft/shared/network/NetworkHandler.java +++ b/src/main/java/dan200/computercraft/shared/network/NetworkHandler.java @@ -13,7 +13,7 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.network.PacketBuffer; import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.Vec3d; +import net.minecraft.util.math.vector.Vector3d; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; import net.minecraftforge.fml.network.NetworkDirection; @@ -76,9 +76,9 @@ public final class NetworkHandler network.sendToServer( packet ); } - public static void sendToAllAround( NetworkMessage packet, World world, Vec3d pos, double range ) + public static void sendToAllAround( NetworkMessage packet, World world, Vector3d pos, double range ) { - PacketDistributor.TargetPoint target = new PacketDistributor.TargetPoint( pos.x, pos.y, pos.z, range, world.getDimension().getType() ); + PacketDistributor.TargetPoint target = new PacketDistributor.TargetPoint( pos.x, pos.y, pos.z, range, world.func_234923_W_() ); network.send( PacketDistributor.NEAR.with( () -> target ), packet ); } diff --git a/src/main/java/dan200/computercraft/shared/network/client/PlayRecordClientMessage.java b/src/main/java/dan200/computercraft/shared/network/client/PlayRecordClientMessage.java index 9ba8d2021..fef9f5c11 100644 --- a/src/main/java/dan200/computercraft/shared/network/client/PlayRecordClientMessage.java +++ b/src/main/java/dan200/computercraft/shared/network/client/PlayRecordClientMessage.java @@ -10,6 +10,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.network.PacketBuffer; import net.minecraft.util.SoundEvent; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.StringTextComponent; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.network.NetworkEvent; @@ -81,7 +82,7 @@ public class PlayRecordClientMessage implements NetworkMessage public void handle( NetworkEvent.Context context ) { Minecraft mc = Minecraft.getInstance(); - mc.worldRenderer.playRecord( soundEvent, pos ); - if( name != null ) mc.ingameGUI.setRecordPlayingMessage( name ); + mc.worldRenderer.playRecord( soundEvent, pos, null ); + if( name != null ) mc.ingameGUI.func_238451_a_( new StringTextComponent( name ) ); } } diff --git a/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/DiskDriveState.java b/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/DiskDriveState.java index 17faae369..2d0a2d810 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/DiskDriveState.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/DiskDriveState.java @@ -24,7 +24,7 @@ public enum DiskDriveState implements IStringSerializable @Override @Nonnull - public String getName() + public String getString() { return name; } diff --git a/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/TileDiskDrive.java b/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/TileDiskDrive.java index 8e53b02b4..0ade6c201 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/TileDiskDrive.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/TileDiskDrive.java @@ -122,10 +122,10 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory } @Override - public void read( @Nonnull CompoundNBT nbt ) + public void read( @Nonnull BlockState state, @Nonnull CompoundNBT nbt ) { - super.read( nbt ); - customName = nbt.contains( NBT_NAME ) ? ITextComponent.Serializer.fromJson( nbt.getString( NBT_NAME ) ) : null; + super.read( state, nbt ); + customName = nbt.contains( NBT_NAME ) ? ITextComponent.Serializer.func_240643_a_( nbt.getString( NBT_NAME ) ) : null; if( nbt.contains( NBT_ITEM ) ) { CompoundNBT item = nbt.getCompound( NBT_ITEM ); diff --git a/src/main/java/dan200/computercraft/shared/peripheral/generic/data/BlockData.java b/src/main/java/dan200/computercraft/shared/peripheral/generic/data/BlockData.java index 13d516c8f..9a6fbdab3 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/generic/data/BlockData.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/generic/data/BlockData.java @@ -8,7 +8,7 @@ package dan200.computercraft.shared.peripheral.generic.data; import com.google.common.collect.ImmutableMap; import net.minecraft.block.BlockState; -import net.minecraft.state.IProperty; +import net.minecraft.state.Property; import javax.annotation.Nonnull; import java.util.HashMap; @@ -22,9 +22,9 @@ public class BlockData data.put( "name", DataHelpers.getId( state.getBlock() ) ); Map stateTable = new HashMap<>(); - for( ImmutableMap.Entry, ? extends Comparable> entry : state.getValues().entrySet() ) + for( ImmutableMap.Entry, ? extends Comparable> entry : state.getValues().entrySet() ) { - IProperty property = entry.getKey(); + Property property = entry.getKey(); stateTable.put( property.getName(), getPropertyValue( property, entry.getValue() ) ); } data.put( "state", stateTable ); @@ -34,7 +34,7 @@ public class BlockData } @SuppressWarnings( { "unchecked", "rawtypes" } ) - private static Object getPropertyValue( IProperty property, Comparable value ) + private static Object getPropertyValue( Property property, Comparable value ) { if( value instanceof String || value instanceof Number || value instanceof Boolean ) return value; return property.getName( value ); diff --git a/src/main/java/dan200/computercraft/shared/peripheral/generic/data/ItemData.java b/src/main/java/dan200/computercraft/shared/peripheral/generic/data/ItemData.java index 1a422487e..c20a91c85 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/generic/data/ItemData.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/generic/data/ItemData.java @@ -93,7 +93,7 @@ public class ItemData { try { - return ITextComponent.Serializer.fromJson( x.getString() ); + return ITextComponent.Serializer.func_240643_a_( x.getString() ); } catch( JsonParseException e ) { diff --git a/src/main/java/dan200/computercraft/shared/peripheral/modem/ModemPeripheral.java b/src/main/java/dan200/computercraft/shared/peripheral/modem/ModemPeripheral.java index 0805406a9..15527e062 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/modem/ModemPeripheral.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/modem/ModemPeripheral.java @@ -13,7 +13,7 @@ import dan200.computercraft.api.network.IPacketSender; import dan200.computercraft.api.network.Packet; import dan200.computercraft.api.peripheral.IComputerAccess; import dan200.computercraft.api.peripheral.IPeripheral; -import net.minecraft.util.math.Vec3d; +import net.minecraft.util.math.vector.Vector3d; import net.minecraft.world.World; import javax.annotation.Nonnull; @@ -171,7 +171,7 @@ public abstract class ModemPeripheral implements IPeripheral, IPacketSender, IPa parseChannel( replyChannel ); World world = getWorld(); - Vec3d position = getPosition(); + Vector3d position = getPosition(); IPacketNetwork network = m_network; if( world == null || position == null || network == null ) return; diff --git a/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/BlockCable.java b/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/BlockCable.java index 3bdbfee7a..a9c5ea36e 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/BlockCable.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/BlockCable.java @@ -15,7 +15,7 @@ import net.minecraft.block.BlockState; import net.minecraft.block.IWaterLoggable; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.fluid.IFluidState; +import net.minecraft.fluid.FluidState; import net.minecraft.item.BlockItemUseContext; import net.minecraft.item.ItemStack; import net.minecraft.state.BooleanProperty; @@ -100,7 +100,7 @@ public class BlockCable extends BlockGeneric implements IWaterLoggable } @Override - public boolean removedByPlayer( BlockState state, World world, BlockPos pos, PlayerEntity player, boolean willHarvest, IFluidState fluid ) + public boolean removedByPlayer( BlockState state, World world, BlockPos pos, PlayerEntity player, boolean willHarvest, FluidState fluid ) { if( state.get( CABLE ) && state.get( MODEM ).getFacing() != null ) { @@ -180,7 +180,7 @@ public class BlockCable extends BlockGeneric implements IWaterLoggable @Nonnull @Override @Deprecated - public IFluidState getFluidState( @Nonnull BlockState state ) + public FluidState getFluidState( @Nonnull BlockState state ) { return getWaterloggedFluidState( state ); } diff --git a/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/CableModemVariant.java b/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/CableModemVariant.java index 22d4b5ead..ed422b477 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/CableModemVariant.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/CableModemVariant.java @@ -65,7 +65,7 @@ public enum CableModemVariant implements IStringSerializable @Nonnull @Override - public String getName() + public String getString() { return name; } diff --git a/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/TileCable.java b/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/TileCable.java index 7d548ec5a..a5a506402 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/TileCable.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/TileCable.java @@ -28,7 +28,7 @@ import net.minecraft.util.Direction; import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.Vec3d; +import net.minecraft.util.math.vector.Vector3d; import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.World; import net.minecraftforge.common.capabilities.Capability; @@ -58,10 +58,10 @@ public class TileCable extends TileGeneric @Nonnull @Override - public Vec3d getPosition() + public Vector3d getPosition() { BlockPos pos = getPos(); - return new Vec3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 ); + return new Vector3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 ); } @Override @@ -103,10 +103,10 @@ public class TileCable extends TileGeneric @Nonnull @Override - public Vec3d getPosition() + public Vector3d getPosition() { BlockPos pos = getPos().offset( modemDirection ); - return new Vec3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 ); + return new Vector3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 ); } @Nonnull @@ -281,9 +281,9 @@ public class TileCable extends TileGeneric } @Override - public void read( @Nonnull CompoundNBT nbt ) + public void read( @Nonnull BlockState state, @Nonnull CompoundNBT nbt ) { - super.read( nbt ); + super.read( state, nbt ); m_peripheralAccessAllowed = nbt.getBoolean( NBT_PERIPHERAL_ENABLED ); m_peripheral.read( nbt, "" ); } @@ -422,12 +422,6 @@ public class TileCable extends TileGeneric m_node.updatePeripherals( peripherals ); } - @Override - public boolean canRenderBreaking() - { - return true; - } - @Nonnull @Override public LazyOptional getCapability( @Nonnull Capability capability, @Nullable Direction side ) diff --git a/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/TileWiredModemFull.java b/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/TileWiredModemFull.java index 349cb6d28..459aa7277 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/TileWiredModemFull.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/TileWiredModemFull.java @@ -26,7 +26,7 @@ import net.minecraft.util.Direction; import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.Vec3d; +import net.minecraft.util.math.vector.Vector3d; import net.minecraft.util.text.StringTextComponent; import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.World; @@ -85,10 +85,10 @@ public class TileWiredModemFull extends TileGeneric @Nonnull @Override - public Vec3d getPosition() + public Vector3d getPosition() { BlockPos pos = m_entity.getPos(); - return new Vec3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 ); + return new Vector3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 ); } } @@ -217,17 +217,17 @@ public class TileWiredModemFull extends TileGeneric StringTextComponent base = new StringTextComponent( "" ); for( int i = 0; i < names.size(); i++ ) { - if( i > 0 ) base.appendText( ", " ); - base.appendSibling( CommandCopy.createCopyText( names.get( i ) ) ); + if( i > 0 ) base.func_240702_b_( ", " ); + base.func_230529_a_( CommandCopy.createCopyText( names.get( i ) ) ); } player.sendStatusMessage( new TranslationTextComponent( kind, base ), false ); } @Override - public void read( @Nonnull CompoundNBT nbt ) + public void read( @Nonnull BlockState state, @Nonnull CompoundNBT nbt ) { - super.read( nbt ); + super.read( state, nbt ); m_peripheralAccessAllowed = nbt.getBoolean( NBT_PERIPHERAL_ENABLED ); for( int i = 0; i < m_peripherals.length; i++ ) m_peripherals[i].read( nbt, Integer.toString( i ) ); } @@ -399,10 +399,10 @@ public class TileWiredModemFull extends TileGeneric @Nonnull @Override - public Vec3d getPosition() + public Vector3d getPosition() { BlockPos pos = getPos().offset( side ); - return new Vec3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 ); + return new Vector3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 ); } @Nonnull diff --git a/src/main/java/dan200/computercraft/shared/peripheral/modem/wireless/BlockWirelessModem.java b/src/main/java/dan200/computercraft/shared/peripheral/modem/wireless/BlockWirelessModem.java index f95066025..9c26780d3 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/modem/wireless/BlockWirelessModem.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/modem/wireless/BlockWirelessModem.java @@ -10,7 +10,7 @@ import dan200.computercraft.shared.peripheral.modem.ModemShapes; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.IWaterLoggable; -import net.minecraft.fluid.IFluidState; +import net.minecraft.fluid.FluidState; import net.minecraft.item.BlockItemUseContext; import net.minecraft.state.BooleanProperty; import net.minecraft.state.DirectionProperty; @@ -62,7 +62,7 @@ public class BlockWirelessModem extends BlockGeneric implements IWaterLoggable @Nonnull @Override @Deprecated - public IFluidState getFluidState( @Nonnull BlockState state ) + public FluidState getFluidState( @Nonnull BlockState state ) { return getWaterloggedFluidState( state ); } diff --git a/src/main/java/dan200/computercraft/shared/peripheral/modem/wireless/TileWirelessModem.java b/src/main/java/dan200/computercraft/shared/peripheral/modem/wireless/TileWirelessModem.java index d13915afc..0ed6921c7 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/modem/wireless/TileWirelessModem.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/modem/wireless/TileWirelessModem.java @@ -15,7 +15,7 @@ import net.minecraft.block.BlockState; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; +import net.minecraft.util.math.vector.Vector3d; import net.minecraft.world.World; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.LazyOptional; @@ -46,10 +46,10 @@ public class TileWirelessModem extends TileGeneric @Nonnull @Override - public Vec3d getPosition() + public Vector3d getPosition() { BlockPos pos = entity.getPos().offset( entity.modemDirection ); - return new Vec3d( pos.getX(), pos.getY(), pos.getZ() ); + return new Vector3d( pos.getX(), pos.getY(), pos.getZ() ); } @Override diff --git a/src/main/java/dan200/computercraft/shared/peripheral/modem/wireless/WirelessModemPeripheral.java b/src/main/java/dan200/computercraft/shared/peripheral/modem/wireless/WirelessModemPeripheral.java index 68d77d366..6f8295f7d 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/modem/wireless/WirelessModemPeripheral.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/modem/wireless/WirelessModemPeripheral.java @@ -9,7 +9,7 @@ import dan200.computercraft.ComputerCraft; import dan200.computercraft.api.network.IPacketNetwork; import dan200.computercraft.shared.peripheral.modem.ModemPeripheral; import dan200.computercraft.shared.peripheral.modem.ModemState; -import net.minecraft.util.math.Vec3d; +import net.minecraft.util.math.vector.Vector3d; import net.minecraft.world.World; public abstract class WirelessModemPeripheral extends ModemPeripheral @@ -40,7 +40,7 @@ public abstract class WirelessModemPeripheral extends ModemPeripheral World world = getWorld(); if( world != null ) { - Vec3d position = getPosition(); + Vector3d position = getPosition(); double minRange = ComputerCraft.modemRange; double maxRange = ComputerCraft.modemHighAltitudeRange; if( world.isRaining() && world.isThundering() ) diff --git a/src/main/java/dan200/computercraft/shared/peripheral/monitor/MonitorEdgeState.java b/src/main/java/dan200/computercraft/shared/peripheral/monitor/MonitorEdgeState.java index 0ada54c82..cfc3a46e9 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/monitor/MonitorEdgeState.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/monitor/MonitorEdgeState.java @@ -59,7 +59,7 @@ public enum MonitorEdgeState implements IStringSerializable @Nonnull @Override - public String getName() + public String getString() { return name; } diff --git a/src/main/java/dan200/computercraft/shared/peripheral/monitor/TileMonitor.java b/src/main/java/dan200/computercraft/shared/peripheral/monitor/TileMonitor.java index 129f5f783..c9521f754 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/monitor/TileMonitor.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/monitor/TileMonitor.java @@ -14,6 +14,7 @@ import dan200.computercraft.shared.common.TileGeneric; import dan200.computercraft.shared.network.client.TerminalState; import dan200.computercraft.shared.util.CapabilityUtil; import dan200.computercraft.shared.util.TickScheduler; +import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.TileEntity; @@ -134,13 +135,14 @@ public class TileMonitor extends TileGeneric } @Override - public void read( @Nonnull CompoundNBT tag ) + public void read( @Nonnull BlockState state, @Nonnull CompoundNBT nbt ) { - super.read( tag ); - m_xIndex = tag.getInt( NBT_X ); - m_yIndex = tag.getInt( NBT_Y ); - m_width = tag.getInt( NBT_WIDTH ); - m_height = tag.getInt( NBT_HEIGHT ); + super.read( state, nbt ); + + m_xIndex = nbt.getInt( NBT_X ); + m_yIndex = nbt.getInt( NBT_Y ); + m_width = nbt.getInt( NBT_WIDTH ); + m_height = nbt.getInt( NBT_HEIGHT ); } @Override diff --git a/src/main/java/dan200/computercraft/shared/peripheral/printer/PrinterPeripheral.java b/src/main/java/dan200/computercraft/shared/peripheral/printer/PrinterPeripheral.java index 6e7da2aad..7c6543b14 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/printer/PrinterPeripheral.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/printer/PrinterPeripheral.java @@ -46,8 +46,8 @@ public class PrinterPeripheral implements IPeripheral * Writes text to the current page. * * @param arguments The values to write to the page. - * @cc.tparam string|number ... The values to write to the page. * @throws LuaException If any values couldn't be converted to a string, or if no page is started. + * @cc.tparam string|number ... The values to write to the page. */ @LuaFunction public final void write( IArguments arguments ) throws LuaException @@ -62,9 +62,9 @@ public class PrinterPeripheral implements IPeripheral * Returns the current position of the cursor on the page. * * @return The position of the cursor. + * @throws LuaException If a page isn't being printed. * @cc.treturn number The X position of the cursor. * @cc.treturn number The Y position of the cursor. - * @throws LuaException If a page isn't being printed. */ @LuaFunction public final Object[] getCursorPos() throws LuaException @@ -93,9 +93,9 @@ public class PrinterPeripheral implements IPeripheral * Returns the size of the current page. * * @return The size of the page. + * @throws LuaException If a page isn't being printed. * @cc.treturn number The width of the page. * @cc.treturn number The height of the page. - * @throws LuaException If a page isn't being printed. */ @LuaFunction public final Object[] getPageSize() throws LuaException diff --git a/src/main/java/dan200/computercraft/shared/peripheral/printer/TilePrinter.java b/src/main/java/dan200/computercraft/shared/peripheral/printer/TilePrinter.java index ac560c8b4..fc44c7dac 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/printer/TilePrinter.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/printer/TilePrinter.java @@ -22,7 +22,7 @@ import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.*; import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.Vec3d; +import net.minecraft.util.math.vector.Vector3d; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TranslationTextComponent; import net.minecraftforge.common.capabilities.Capability; @@ -91,11 +91,11 @@ public final class TilePrinter extends TileGeneric implements DefaultSidedInvent } @Override - public void read( @Nonnull CompoundNBT nbt ) + public void read( @Nonnull BlockState state, @Nonnull CompoundNBT nbt ) { - super.read( nbt ); + super.read( state, nbt ); - customName = nbt.contains( NBT_NAME ) ? ITextComponent.Serializer.fromJson( nbt.getString( NBT_NAME ) ) : null; + customName = nbt.contains( NBT_NAME ) ? ITextComponent.Serializer.func_240643_a_( nbt.getString( NBT_NAME ) ) : null; // Read page synchronized( m_page ) @@ -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(), new Vec3d( getPos() ).add( 0.5, 0.75, 0.5 ) ); + WorldUtil.dropItemStack( stack, getWorld(), Vector3d.func_237491_b_( getPos() ).add( 0.5, 0.75, 0.5 ) ); } } } diff --git a/src/main/java/dan200/computercraft/shared/peripheral/speaker/SpeakerPeripheral.java b/src/main/java/dan200/computercraft/shared/peripheral/speaker/SpeakerPeripheral.java index 217b5b59f..2e6202ac6 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/speaker/SpeakerPeripheral.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/speaker/SpeakerPeripheral.java @@ -16,7 +16,7 @@ import net.minecraft.state.properties.NoteBlockInstrument; import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocationException; import net.minecraft.util.SoundCategory; -import net.minecraft.util.math.Vec3d; +import net.minecraft.util.math.vector.Vector3d; import net.minecraft.world.World; import javax.annotation.Nonnull; @@ -44,7 +44,7 @@ public abstract class SpeakerPeripheral implements IPeripheral public abstract World getWorld(); - public abstract Vec3d getPosition(); + public abstract Vector3d getPosition(); public boolean madeSound( long ticks ) { @@ -66,9 +66,9 @@ public abstract class SpeakerPeripheral implements IPeripheral * with an optional volume and speed multiplier, and plays it through the speaker. * * @param context The Lua context - * @param name The name of the sound to play. + * @param name The name of the sound to play. * @param volumeA The volume to play the sound at, from 0.0 to 3.0. Defaults to 1.0. - * @param pitchA The speed to play the sound at, from 0.5 to 2.0. Defaults to 1.0. + * @param pitchA The speed to play the sound at, from 0.5 to 2.0. Defaults to 1.0. * @return Whether the sound could be played. * @throws LuaException If the sound name couldn't be decoded. */ @@ -102,9 +102,9 @@ public abstract class SpeakerPeripheral implements IPeripheral * and 6 and 18 map to C. * * @param context The Lua context - * @param name The name of the note to play. + * @param name The name of the note to play. * @param volumeA The volume to play the note at, from 0.0 to 3.0. Defaults to 1.0. - * @param pitchA The pitch to play the note at in semitones, from 0 to 24. Defaults to 12. + * @param pitchA The pitch to play the note at in semitones, from 0 to 24. Defaults to 12. * @return Whether the note could be played. * @throws LuaException If the instrument doesn't exist. */ @@ -117,7 +117,7 @@ public abstract class SpeakerPeripheral implements IPeripheral NoteBlockInstrument instrument = null; for( NoteBlockInstrument testInstrument : NoteBlockInstrument.values() ) { - if( testInstrument.getName().equalsIgnoreCase( name ) ) + if( testInstrument.getString().equalsIgnoreCase( name ) ) { instrument = testInstrument; break; @@ -144,7 +144,7 @@ public abstract class SpeakerPeripheral implements IPeripheral } World world = getWorld(); - Vec3d pos = getPosition(); + Vector3d pos = getPosition(); context.issueMainThreadTask( () -> { MinecraftServer server = world.getServer(); @@ -152,7 +152,7 @@ public abstract class SpeakerPeripheral implements IPeripheral float adjVolume = Math.min( volume, 3.0f ); server.getPlayerList().sendToAllNearExcept( - null, pos.x, pos.y, pos.z, adjVolume > 1.0f ? 16 * adjVolume : 16.0, world.dimension.getType(), + null, pos.x, pos.y, pos.z, adjVolume > 1.0f ? 16 * adjVolume : 16.0, world.func_234923_W_(), new SPlaySoundPacket( name, SoundCategory.RECORDS, pos, adjVolume, pitch ) ); return null; diff --git a/src/main/java/dan200/computercraft/shared/peripheral/speaker/TileSpeaker.java b/src/main/java/dan200/computercraft/shared/peripheral/speaker/TileSpeaker.java index 793ef4aad..79f2d7162 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/speaker/TileSpeaker.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/speaker/TileSpeaker.java @@ -12,7 +12,7 @@ import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; +import net.minecraft.util.math.vector.Vector3d; import net.minecraft.world.World; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.LazyOptional; @@ -77,10 +77,10 @@ public class TileSpeaker extends TileGeneric implements ITickableTileEntity } @Override - public Vec3d getPosition() + public Vector3d getPosition() { BlockPos pos = speaker.getPos(); - return new Vec3d( pos.getX(), pos.getY(), pos.getZ() ); + return new Vector3d( pos.getX(), pos.getY(), pos.getZ() ); } @Override diff --git a/src/main/java/dan200/computercraft/shared/pocket/core/PocketServerComputer.java b/src/main/java/dan200/computercraft/shared/pocket/core/PocketServerComputer.java index e165daf95..fdc21e23f 100644 --- a/src/main/java/dan200/computercraft/shared/pocket/core/PocketServerComputer.java +++ b/src/main/java/dan200/computercraft/shared/pocket/core/PocketServerComputer.java @@ -163,7 +163,7 @@ public class PocketServerComputer extends ServerComputer implements IPocketAcces if( entity != null ) { setWorld( entity.getEntityWorld() ); - setPosition( entity.getPosition() ); + setPosition( entity.func_233580_cy_() ); } // If a new entity has picked it up then rebroadcast the terminal to them diff --git a/src/main/java/dan200/computercraft/shared/pocket/items/ItemPocketComputer.java b/src/main/java/dan200/computercraft/shared/pocket/items/ItemPocketComputer.java index a6258216a..2c4979270 100644 --- a/src/main/java/dan200/computercraft/shared/pocket/items/ItemPocketComputer.java +++ b/src/main/java/dan200/computercraft/shared/pocket/items/ItemPocketComputer.java @@ -27,12 +27,14 @@ import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.inventory.IInventory; -import net.minecraft.item.IItemPropertyGetter; import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.*; +import net.minecraft.util.ActionResult; +import net.minecraft.util.ActionResultType; +import net.minecraft.util.Hand; +import net.minecraft.util.NonNullList; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.StringTextComponent; import net.minecraft.util.text.TextFormatting; @@ -60,8 +62,6 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I { super( settings ); this.family = family; - addPropertyOverride( new ResourceLocation( ComputerCraft.MOD_ID, "state" ), COMPUTER_STATE ); - addPropertyOverride( new ResourceLocation( ComputerCraft.MOD_ID, "coloured" ), COMPUTER_COLOURED ); } public ItemStack create( int id, String label, int colour, IPocketUpgrade upgrade ) @@ -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 ) - .applyTextStyle( TextFormatting.GRAY ) ); + .func_240699_a_( TextFormatting.GRAY ) ); } } } @@ -408,7 +408,4 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I { return stack.getOrCreateChildTag( NBT_UPGRADE_INFO ); } - - private static final IItemPropertyGetter COMPUTER_STATE = ( stack, world, player ) -> getState( stack ).ordinal(); - private static final IItemPropertyGetter COMPUTER_COLOURED = ( stack, world, player ) -> IColouredItem.getColourBasic( stack ) != -1 ? 1 : 0; } diff --git a/src/main/java/dan200/computercraft/shared/pocket/peripherals/PocketModemPeripheral.java b/src/main/java/dan200/computercraft/shared/pocket/peripherals/PocketModemPeripheral.java index 12e98c000..ceecca676 100644 --- a/src/main/java/dan200/computercraft/shared/pocket/peripherals/PocketModemPeripheral.java +++ b/src/main/java/dan200/computercraft/shared/pocket/peripherals/PocketModemPeripheral.java @@ -8,7 +8,7 @@ package dan200.computercraft.shared.pocket.peripherals; import dan200.computercraft.api.peripheral.IPeripheral; import dan200.computercraft.shared.peripheral.modem.ModemState; import dan200.computercraft.shared.peripheral.modem.wireless.WirelessModemPeripheral; -import net.minecraft.util.math.Vec3d; +import net.minecraft.util.math.vector.Vector3d; import net.minecraft.world.World; import javax.annotation.Nonnull; @@ -16,14 +16,14 @@ import javax.annotation.Nonnull; public class PocketModemPeripheral extends WirelessModemPeripheral { private World world = null; - private Vec3d position = Vec3d.ZERO; + private Vector3d position = Vector3d.ZERO; public PocketModemPeripheral( boolean advanced ) { super( new ModemState(), advanced ); } - void setLocation( World world, Vec3d position ) + void setLocation( World world, Vector3d position ) { this.position = position; this.world = world; @@ -38,7 +38,7 @@ public class PocketModemPeripheral extends WirelessModemPeripheral @Nonnull @Override - public Vec3d getPosition() + public Vector3d getPosition() { return position; } diff --git a/src/main/java/dan200/computercraft/shared/pocket/peripherals/PocketSpeakerPeripheral.java b/src/main/java/dan200/computercraft/shared/pocket/peripherals/PocketSpeakerPeripheral.java index 66182ff4d..cbd88aa3a 100644 --- a/src/main/java/dan200/computercraft/shared/pocket/peripherals/PocketSpeakerPeripheral.java +++ b/src/main/java/dan200/computercraft/shared/pocket/peripherals/PocketSpeakerPeripheral.java @@ -7,15 +7,15 @@ package dan200.computercraft.shared.pocket.peripherals; import dan200.computercraft.api.peripheral.IPeripheral; import dan200.computercraft.shared.peripheral.speaker.SpeakerPeripheral; -import net.minecraft.util.math.Vec3d; +import net.minecraft.util.math.vector.Vector3d; import net.minecraft.world.World; public class PocketSpeakerPeripheral extends SpeakerPeripheral { private World world = null; - private Vec3d position = Vec3d.ZERO; + private Vector3d position = Vector3d.ZERO; - void setLocation( World world, Vec3d position ) + void setLocation( World world, Vector3d position ) { this.position = position; this.world = world; @@ -28,7 +28,7 @@ public class PocketSpeakerPeripheral extends SpeakerPeripheral } @Override - public Vec3d getPosition() + public Vector3d getPosition() { return world != null ? position : null; } diff --git a/src/main/java/dan200/computercraft/shared/proxy/ComputerCraftProxyCommon.java b/src/main/java/dan200/computercraft/shared/proxy/ComputerCraftProxyCommon.java index d4b962cb3..5cf2699c3 100644 --- a/src/main/java/dan200/computercraft/shared/proxy/ComputerCraftProxyCommon.java +++ b/src/main/java/dan200/computercraft/shared/proxy/ComputerCraftProxyCommon.java @@ -19,7 +19,6 @@ import dan200.computercraft.shared.computer.core.IComputer; import dan200.computercraft.shared.computer.core.IContainerComputer; import dan200.computercraft.shared.computer.core.ServerComputer; import dan200.computercraft.shared.data.BlockNamedEntityLootCondition; -import dan200.computercraft.shared.data.ConstantLootConditionSerializer; import dan200.computercraft.shared.data.HasComputerIdLootCondition; import dan200.computercraft.shared.data.PlayerCreativeLootCondition; import dan200.computercraft.shared.media.items.RecordMedia; @@ -29,12 +28,9 @@ import dan200.computercraft.shared.util.NullStorage; import net.minecraft.inventory.container.Container; import net.minecraft.item.Item; import net.minecraft.item.MusicDiscItem; +import net.minecraft.loot.*; import net.minecraft.util.ResourceLocation; -import net.minecraft.world.storage.loot.ConstantRange; -import net.minecraft.world.storage.loot.LootPool; -import net.minecraft.world.storage.loot.LootTables; -import net.minecraft.world.storage.loot.TableLootEntry; -import net.minecraft.world.storage.loot.conditions.LootConditionManager; +import net.minecraft.util.registry.Registry; import net.minecraftforge.common.capabilities.CapabilityManager; import net.minecraftforge.event.LootTableLoadEvent; import net.minecraftforge.event.TickEvent; @@ -68,23 +64,14 @@ public final class ComputerCraftProxyCommon public static void registerLoot() { - LootConditionManager.registerCondition( ConstantLootConditionSerializer.of( - new ResourceLocation( ComputerCraft.MOD_ID, "block_named" ), - BlockNamedEntityLootCondition.class, - BlockNamedEntityLootCondition.INSTANCE - ) ); + registerCondition( "block_named", BlockNamedEntityLootCondition.TYPE ); + registerCondition( "player_creative", PlayerCreativeLootCondition.TYPE ); + registerCondition( "has_id", HasComputerIdLootCondition.TYPE ); + } - LootConditionManager.registerCondition( ConstantLootConditionSerializer.of( - new ResourceLocation( ComputerCraft.MOD_ID, "player_creative" ), - PlayerCreativeLootCondition.class, - PlayerCreativeLootCondition.INSTANCE - ) ); - - LootConditionManager.registerCondition( ConstantLootConditionSerializer.of( - new ResourceLocation( ComputerCraft.MOD_ID, "has_id" ), - HasComputerIdLootCondition.class, - HasComputerIdLootCondition.INSTANCE - ) ); + private static void registerCondition( String name, LootConditionType serializer ) + { + Registry.register( Registry.field_239704_ba_, new ResourceLocation( ComputerCraft.MOD_ID, name ), serializer ); } private static void registerProviders() diff --git a/src/main/java/dan200/computercraft/shared/turtle/blocks/BlockTurtle.java b/src/main/java/dan200/computercraft/shared/turtle/blocks/BlockTurtle.java index 6c1eb4871..9ccce8beb 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/blocks/BlockTurtle.java +++ b/src/main/java/dan200/computercraft/shared/turtle/blocks/BlockTurtle.java @@ -20,7 +20,7 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.projectile.DamagingProjectileEntity; -import net.minecraft.fluid.IFluidState; +import net.minecraft.fluid.FluidState; import net.minecraft.item.BlockItemUseContext; import net.minecraft.item.ItemStack; import net.minecraft.state.DirectionProperty; @@ -31,11 +31,14 @@ import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.Direction; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.util.math.shapes.VoxelShapes; -import net.minecraft.world.*; +import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.Explosion; +import net.minecraft.world.IBlockReader; +import net.minecraft.world.IWorld; +import net.minecraft.world.World; import net.minecraftforge.fml.RegistryObject; import javax.annotation.Nonnull; @@ -82,8 +85,8 @@ public class BlockTurtle extends BlockComputerBase implements IWater public VoxelShape getShape( @Nonnull BlockState state, IBlockReader world, @Nonnull BlockPos pos, @Nonnull ISelectionContext context ) { TileEntity tile = world.getTileEntity( pos ); - Vec3d offset = tile instanceof TileTurtle ? ((TileTurtle) tile).getRenderOffset( 1.0f ) : Vec3d.ZERO; - return offset.equals( Vec3d.ZERO ) ? DEFAULT_SHAPE : DEFAULT_SHAPE.withOffset( offset.x, offset.y, offset.z ); + Vector3d offset = tile instanceof TileTurtle ? ((TileTurtle) tile).getRenderOffset( 1.0f ) : Vector3d.ZERO; + return offset.equals( Vector3d.ZERO ) ? DEFAULT_SHAPE : DEFAULT_SHAPE.withOffset( offset.x, offset.y, offset.z ); } @Nullable @@ -98,7 +101,7 @@ public class BlockTurtle extends BlockComputerBase implements IWater @Nonnull @Override @Deprecated - public IFluidState getFluidState( @Nonnull BlockState state ) + public FluidState getFluidState( @Nonnull BlockState state ) { return getWaterloggedFluidState( state ); } @@ -151,14 +154,15 @@ public class BlockTurtle extends BlockComputerBase implements IWater } @Override - public float getExplosionResistance( BlockState state, IWorldReader world, BlockPos pos, @Nullable Entity exploder, Explosion explosion ) + public float getExplosionResistance( BlockState state, IBlockReader world, BlockPos pos, Explosion explosion ) { + Entity exploder = explosion.getExploder(); if( getFamily() == ComputerFamily.ADVANCED || exploder instanceof LivingEntity || exploder instanceof DamagingProjectileEntity ) { return 2000; } - return super.getExplosionResistance( state, world, pos, exploder, explosion ); + return super.getExplosionResistance( state, world, pos, explosion ); } @Nonnull diff --git a/src/main/java/dan200/computercraft/shared/turtle/blocks/ITurtleTile.java b/src/main/java/dan200/computercraft/shared/turtle/blocks/ITurtleTile.java index 541186682..505a25e78 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/blocks/ITurtleTile.java +++ b/src/main/java/dan200/computercraft/shared/turtle/blocks/ITurtleTile.java @@ -10,7 +10,7 @@ import dan200.computercraft.api.turtle.ITurtleUpgrade; import dan200.computercraft.api.turtle.TurtleSide; import dan200.computercraft.shared.computer.blocks.IComputerTile; import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.Vec3d; +import net.minecraft.util.math.vector.Vector3d; public interface ITurtleTile extends IComputerTile { @@ -22,7 +22,7 @@ public interface ITurtleTile extends IComputerTile ITurtleAccess getAccess(); - Vec3d getRenderOffset( float f ); + Vector3d getRenderOffset( float f ); float getRenderYaw( float f ); diff --git a/src/main/java/dan200/computercraft/shared/turtle/blocks/TileTurtle.java b/src/main/java/dan200/computercraft/shared/turtle/blocks/TileTurtle.java index 2d52d0ef9..939c4007e 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/blocks/TileTurtle.java +++ b/src/main/java/dan200/computercraft/shared/turtle/blocks/TileTurtle.java @@ -23,6 +23,7 @@ import dan200.computercraft.shared.turtle.apis.TurtleAPI; import dan200.computercraft.shared.turtle.core.TurtleBrain; import dan200.computercraft.shared.turtle.inventory.ContainerTurtle; import dan200.computercraft.shared.util.*; +import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.container.Container; @@ -36,7 +37,7 @@ import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.*; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.Vec3d; +import net.minecraft.util.math.vector.Vector3d; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.Constants; import net.minecraftforge.common.util.LazyOptional; @@ -256,9 +257,9 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default } @Override - public void read( @Nonnull CompoundNBT nbt ) + public void read( @Nonnull BlockState state, @Nonnull CompoundNBT nbt ) { - super.read( nbt ); + super.read( state, nbt ); // Read inventory ListNBT nbttaglist = nbt.getList( "Items", Constants.NBT.TAG_COMPOUND ); @@ -353,7 +354,7 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default } @Override - public Vec3d getRenderOffset( float f ) + public Vector3d getRenderOffset( float f ) { return m_brain.getRenderOffset( f ); } diff --git a/src/main/java/dan200/computercraft/shared/turtle/core/TurtleBrain.java b/src/main/java/dan200/computercraft/shared/turtle/core/TurtleBrain.java index 31b363aa3..52f9f666a 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/core/TurtleBrain.java +++ b/src/main/java/dan200/computercraft/shared/turtle/core/TurtleBrain.java @@ -26,7 +26,7 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.MoverType; -import net.minecraft.fluid.IFluidState; +import net.minecraft.fluid.FluidState; import net.minecraft.inventory.IInventory; import net.minecraft.item.DyeColor; import net.minecraft.nbt.CompoundNBT; @@ -38,7 +38,7 @@ import net.minecraft.util.EntityPredicates; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; +import net.minecraft.util.math.vector.Vector3d; import net.minecraft.world.World; import net.minecraftforge.common.util.Constants; import net.minecraftforge.items.IItemHandlerModifiable; @@ -304,7 +304,7 @@ public class TurtleBrain implements ITurtleAccess // Ensure we're inside the world border if( !world.getWorldBorder().contains( pos ) ) return false; - IFluidState existingFluid = world.getBlockState( pos ).getFluidState(); + FluidState existingFluid = world.getBlockState( pos ).getFluidState(); BlockState newState = oldBlock // We only mark this as waterlogged when travelling into a source block. This prevents us from spreading // fluid by creating a new source when moving into a block, causing the next block to be almost full and @@ -357,11 +357,11 @@ public class TurtleBrain implements ITurtleAccess @Nonnull @Override - public Vec3d getVisualPosition( float f ) + public Vector3d getVisualPosition( float f ) { - Vec3d offset = getRenderOffset( f ); + Vector3d offset = getRenderOffset( f ); BlockPos pos = m_owner.getPos(); - return new Vec3d( + return new Vector3d( pos.getX() + 0.5 + offset.x, pos.getY() + 0.5 + offset.y, pos.getZ() + 0.5 + offset.z @@ -659,7 +659,7 @@ public class TurtleBrain implements ITurtleAccess m_owner.updateBlock(); } - public Vec3d getRenderOffset( float f ) + public Vector3d getRenderOffset( float f ) { switch( m_animation ) { @@ -688,7 +688,7 @@ public class TurtleBrain implements ITurtleAccess } double distance = -1.0 + getAnimationFraction( f ); - return new Vec3d( + return new Vector3d( distance * dir.getXOffset(), distance * dir.getYOffset(), distance * dir.getZOffset() @@ -696,7 +696,7 @@ public class TurtleBrain implements ITurtleAccess } default: { - return Vec3d.ZERO; + return Vector3d.ZERO; } } } @@ -880,7 +880,7 @@ public class TurtleBrain implements ITurtleAccess double pushStepZ = moveDir.getZOffset() * pushStep; for( Entity entity : list ) { - entity.move( MoverType.PISTON, new Vec3d( pushStepX, pushStepY, pushStepZ ) ); + entity.move( MoverType.PISTON, new Vector3d( pushStepX, pushStepY, pushStepZ ) ); } } } @@ -893,7 +893,7 @@ public class TurtleBrain implements ITurtleAccess Holiday currentHoliday = HolidayUtil.getCurrentHoliday(); if( currentHoliday == Holiday.VALENTINES ) { - Vec3d position = getVisualPosition( 1.0f ); + Vector3d position = getVisualPosition( 1.0f ); if( position != null ) { double x = position.x + world.rand.nextGaussian() * 0.1; diff --git a/src/main/java/dan200/computercraft/shared/turtle/core/TurtlePlaceCommand.java b/src/main/java/dan200/computercraft/shared/turtle/core/TurtlePlaceCommand.java index 84dc412fb..69b903cba 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/core/TurtlePlaceCommand.java +++ b/src/main/java/dan200/computercraft/shared/turtle/core/TurtlePlaceCommand.java @@ -28,7 +28,7 @@ import net.minecraft.util.Direction; import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.Vec3d; +import net.minecraft.util.math.vector.Vector3d; import net.minecraft.util.text.StringTextComponent; import net.minecraft.world.World; import net.minecraftforge.common.ForgeHooks; @@ -210,9 +210,9 @@ public class TurtlePlaceCommand implements ITurtleCommand // See if there is an entity present final World world = turtle.getWorld(); final BlockPos position = turtle.getPosition(); - Vec3d turtlePos = turtlePlayer.getPositionVec(); - Vec3d rayDir = turtlePlayer.getLook( 1.0f ); - Pair hit = WorldUtil.rayTraceEntities( world, turtlePos, rayDir, 1.5 ); + Vector3d turtlePos = turtlePlayer.getPositionVec(); + Vector3d rayDir = turtlePlayer.getLook( 1.0f ); + Pair hit = WorldUtil.rayTraceEntities( world, turtlePos, rayDir, 1.5 ); if( hit == null ) { return stack; @@ -224,7 +224,7 @@ public class TurtlePlaceCommand implements ITurtleCommand // Start claiming entity drops Entity hitEntity = hit.getKey(); - Vec3d hitPos = hit.getValue(); + Vector3d hitPos = hit.getValue(); DropConsumer.set( hitEntity, drop -> InventoryUtil.storeItems( drop, turtle.getItemHandler(), turtle.getSelectedSlot() ) @@ -252,13 +252,13 @@ public class TurtlePlaceCommand implements ITurtleCommand } else if( cancelResult == null ) { - if( hitEntity.processInitialInteract( turtlePlayer, Hand.MAIN_HAND ) ) + if( hitEntity.processInitialInteract( turtlePlayer, Hand.MAIN_HAND ) == ActionResultType.CONSUME ) { placed = true; } else if( hitEntity instanceof LivingEntity ) { - placed = stackCopy.interactWithEntity( turtlePlayer, (LivingEntity) hitEntity, Hand.MAIN_HAND ); + placed = stackCopy.interactWithEntity( turtlePlayer, (LivingEntity) hitEntity, Hand.MAIN_HAND ).isSuccessOrConsume(); if( placed ) turtlePlayer.loadInventory( stackCopy ); } } @@ -338,7 +338,7 @@ public class TurtlePlaceCommand implements ITurtleCommand } // Check if there's something suitable to place onto - BlockRayTraceResult hit = new BlockRayTraceResult( new Vec3d( hitX, hitY, hitZ ), side, position, false ); + BlockRayTraceResult hit = new BlockRayTraceResult( new Vector3d( hitX, hitY, hitZ ), side, position, false ); ItemUseContext context = new ItemUseContext( turtlePlayer, Hand.MAIN_HAND, hit ); if( !canDeployOnBlock( new BlockItemUseContext( context ), turtle, turtlePlayer, position, side, allowReplace, outErrorMessage ) ) { @@ -405,22 +405,22 @@ public class TurtlePlaceCommand implements ITurtleCommand String s = (String) extraArguments[0]; String[] split = s.split( "\n" ); int firstLine = split.length <= 2 ? 1 : 0; - for( int i = 0; i < signTile.signText.length; i++ ) + for( int i = 0; i < 4; i++ ) { if( i >= firstLine && i < firstLine + split.length ) { if( split[i - firstLine].length() > 15 ) { - signTile.signText[i] = new StringTextComponent( split[i - firstLine].substring( 0, 15 ) ); + signTile.setText( i, new StringTextComponent( split[i - firstLine].substring( 0, 15 ) ) ); } else { - signTile.signText[i] = new StringTextComponent( split[i - firstLine] ); + signTile.setText( i, new StringTextComponent( split[i - firstLine] ) ); } } else { - signTile.signText[i] = new StringTextComponent( "" ); + signTile.setText( i, new StringTextComponent( "" ) ); } } signTile.markDirty(); diff --git a/src/main/java/dan200/computercraft/shared/turtle/core/TurtlePlayer.java b/src/main/java/dan200/computercraft/shared/turtle/core/TurtlePlayer.java index a9480bc40..691079d1e 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/core/TurtlePlayer.java +++ b/src/main/java/dan200/computercraft/shared/turtle/core/TurtlePlayer.java @@ -25,7 +25,6 @@ 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.Vec3d; import net.minecraft.world.server.ServerWorld; import net.minecraftforge.common.util.FakePlayer; @@ -130,12 +129,6 @@ public final class TurtlePlayer extends FakePlayer return Registry.ModEntities.TURTLE_PLAYER.get(); } - @Override - public Vec3d getPositionVector() - { - return getPositionVec(); - } - @Override public float getEyeHeight( @Nonnull Pose pose ) { diff --git a/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleModem.java b/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleModem.java index 4632d5db9..65f901f73 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleModem.java +++ b/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleModem.java @@ -16,7 +16,7 @@ import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.Direction; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; +import net.minecraft.util.math.vector.Vector3d; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -44,10 +44,10 @@ public class TurtleModem extends AbstractTurtleUpgrade @Nonnull @Override - public Vec3d getPosition() + public Vector3d getPosition() { BlockPos turtlePos = turtle.getPosition(); - return new Vec3d( + return new Vector3d( turtlePos.getX(), turtlePos.getY(), turtlePos.getZ() diff --git a/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleSpeaker.java b/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleSpeaker.java index 0a605660e..bcdb4b198 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleSpeaker.java +++ b/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleSpeaker.java @@ -17,7 +17,7 @@ import dan200.computercraft.shared.peripheral.speaker.SpeakerPeripheral; import net.minecraft.client.renderer.model.ModelResourceLocation; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; +import net.minecraft.util.math.vector.Vector3d; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -42,10 +42,10 @@ public class TurtleSpeaker extends AbstractTurtleUpgrade } @Override - public Vec3d getPosition() + public Vector3d getPosition() { BlockPos pos = turtle.getPosition(); - return new Vec3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 ); + return new Vector3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 ); } @Override diff --git a/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleTool.java b/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleTool.java index e3ddec335..721fa4f64 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleTool.java +++ b/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleTool.java @@ -19,12 +19,10 @@ import dan200.computercraft.shared.util.WorldUtil; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; -import net.minecraft.client.renderer.Matrix4f; -import net.minecraft.client.renderer.TransformationMatrix; import net.minecraft.entity.Entity; -import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.attributes.Attributes; import net.minecraft.entity.item.ArmorStandEntity; -import net.minecraft.fluid.IFluidState; +import net.minecraft.fluid.FluidState; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; @@ -32,7 +30,9 @@ import net.minecraft.util.DamageSource; import net.minecraft.util.Direction; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; +import net.minecraft.util.math.vector.Matrix4f; +import net.minecraft.util.math.vector.TransformationMatrix; +import net.minecraft.util.math.vector.Vector3d; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -119,9 +119,9 @@ public class TurtleTool extends AbstractTurtleUpgrade final TurtlePlayer turtlePlayer = TurtlePlaceCommand.createPlayer( turtle, position, direction ); // See if there is an entity present - Vec3d turtlePos = turtlePlayer.getPositionVec(); - Vec3d rayDir = turtlePlayer.getLook( 1.0f ); - Pair hit = WorldUtil.rayTraceEntities( world, turtlePos, rayDir, 1.5 ); + Vector3d turtlePos = turtlePlayer.getPositionVec(); + Vector3d rayDir = turtlePlayer.getLook( 1.0f ); + Pair hit = WorldUtil.rayTraceEntities( world, turtlePos, rayDir, 1.5 ); if( hit != null ) { // Load up the turtle's inventory @@ -149,7 +149,7 @@ public class TurtleTool extends AbstractTurtleUpgrade boolean attacked = false; if( !hitEntity.hitByEntity( turtlePlayer ) ) { - float damage = (float) turtlePlayer.getAttribute( SharedMonsterAttributes.ATTACK_DAMAGE ).getValue(); + float damage = (float) turtlePlayer.func_233637_b_( Attributes.ATTACK_DAMAGE ); damage *= getDamageMultiplier(); if( damage > 0.0f ) { @@ -201,7 +201,7 @@ public class TurtleTool extends AbstractTurtleUpgrade } BlockState state = world.getBlockState( blockPosition ); - IFluidState fluidState = world.getFluidState( blockPosition ); + FluidState fluidState = world.getFluidState( blockPosition ); TurtlePlayer turtlePlayer = TurtlePlaceCommand.createPlayer( turtle, turtlePosition, direction ); turtlePlayer.loadInventory( item.copy() ); diff --git a/src/main/java/dan200/computercraft/shared/util/ColourUtils.java b/src/main/java/dan200/computercraft/shared/util/ColourUtils.java index 3c776d1bd..f9f649f63 100644 --- a/src/main/java/dan200/computercraft/shared/util/ColourUtils.java +++ b/src/main/java/dan200/computercraft/shared/util/ColourUtils.java @@ -8,7 +8,7 @@ package dan200.computercraft.shared.util; import net.minecraft.item.DyeColor; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.tags.Tag; +import net.minecraft.tags.ITag; import net.minecraftforge.common.Tags; import javax.annotation.Nullable; @@ -16,7 +16,7 @@ import javax.annotation.Nullable; public final class ColourUtils { @SuppressWarnings( { "unchecked", "rawtypes" } ) - private static final Tag[] DYES = new Tag[] { + private static final ITag[] DYES = new ITag[] { Tags.Items.DYES_WHITE, Tags.Items.DYES_ORANGE, Tags.Items.DYES_MAGENTA, @@ -42,7 +42,7 @@ public final class ColourUtils { for( int i = 0; i < DYES.length; i++ ) { - Tag dye = DYES[i]; + ITag dye = DYES[i]; if( dye.contains( stack.getItem() ) ) return DyeColor.byId( i ); } diff --git a/src/main/java/dan200/computercraft/shared/util/DropConsumer.java b/src/main/java/dan200/computercraft/shared/util/DropConsumer.java index 14200f0eb..0378a620d 100644 --- a/src/main/java/dan200/computercraft/shared/util/DropConsumer.java +++ b/src/main/java/dan200/computercraft/shared/util/DropConsumer.java @@ -41,7 +41,7 @@ public final class DropConsumer remainingDrops = new ArrayList<>(); dropEntity = entity; dropWorld = entity.world; - dropBounds = new AxisAlignedBB( entity.getPosition() ).grow( 2, 2, 2 ); + dropBounds = new AxisAlignedBB( entity.func_233580_cy_() ).grow( 2, 2, 2 ); entity.captureDrops( new ArrayList<>() ); } @@ -79,7 +79,7 @@ public final class DropConsumer { // Capture any nearby item spawns if( dropWorld == event.getWorld() && event.getEntity() instanceof ItemEntity - && dropBounds.contains( event.getEntity().getPositionVector() ) ) + && dropBounds.contains( event.getEntity().getPositionVec() ) ) { handleDrops( ((ItemEntity) event.getEntity()).getItem() ); event.setCanceled( true ); diff --git a/src/main/java/dan200/computercraft/shared/util/IDAssigner.java b/src/main/java/dan200/computercraft/shared/util/IDAssigner.java index 229488422..4456fe493 100644 --- a/src/main/java/dan200/computercraft/shared/util/IDAssigner.java +++ b/src/main/java/dan200/computercraft/shared/util/IDAssigner.java @@ -10,7 +10,6 @@ import com.google.gson.GsonBuilder; import com.google.gson.reflect.TypeToken; import dan200.computercraft.ComputerCraft; import net.minecraft.server.MinecraftServer; -import net.minecraft.world.dimension.DimensionType; import net.minecraftforge.fml.server.ServerLifecycleHooks; import java.io.File; @@ -41,9 +40,9 @@ public final class IDAssigner public static File getDir() { - MinecraftServer server = ServerLifecycleHooks.getCurrentServer(); - File worldDirectory = server.getWorld( DimensionType.OVERWORLD ).getSaveHandler().getWorldDirectory(); - return new File( worldDirectory, ComputerCraft.MOD_ID ); + File root = ServerLifecycleHooks.getCurrentServer().getDataDirectory(); + // TODO: File worldDirectory = server.getWorld( World.field_234918_g_ ).getSaveHandler().getWorldDirectory(); + return new File( root, ComputerCraft.MOD_ID ); } private static MinecraftServer getCachedServer() diff --git a/src/main/java/dan200/computercraft/shared/util/InventoryUtil.java b/src/main/java/dan200/computercraft/shared/util/InventoryUtil.java index 11b8438ec..681627314 100644 --- a/src/main/java/dan200/computercraft/shared/util/InventoryUtil.java +++ b/src/main/java/dan200/computercraft/shared/util/InventoryUtil.java @@ -13,7 +13,7 @@ import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; +import net.minecraft.util.math.vector.Vector3d; import net.minecraft.world.World; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.items.CapabilityItemHandler; @@ -93,16 +93,16 @@ public final class InventoryUtil } // Look for entity with inventory - Vec3d vecStart = new Vec3d( + Vector3d vecStart = new Vector3d( pos.getX() + 0.5 + 0.6 * side.getXOffset(), pos.getY() + 0.5 + 0.6 * side.getYOffset(), pos.getZ() + 0.5 + 0.6 * side.getZOffset() ); Direction dir = side.getOpposite(); - Vec3d vecDir = new Vec3d( + Vector3d vecDir = new Vector3d( dir.getXOffset(), dir.getYOffset(), dir.getZOffset() ); - Pair hit = WorldUtil.rayTraceEntities( world, vecStart, vecDir, 1.1 ); + Pair hit = WorldUtil.rayTraceEntities( world, vecStart, vecDir, 1.1 ); if( hit != null ) { Entity entity = hit.getKey(); diff --git a/src/main/java/dan200/computercraft/shared/util/RecordUtil.java b/src/main/java/dan200/computercraft/shared/util/RecordUtil.java index 2fdb56422..66d3fef58 100644 --- a/src/main/java/dan200/computercraft/shared/util/RecordUtil.java +++ b/src/main/java/dan200/computercraft/shared/util/RecordUtil.java @@ -10,7 +10,7 @@ import dan200.computercraft.shared.network.NetworkMessage; import dan200.computercraft.shared.network.client.PlayRecordClientMessage; import net.minecraft.util.SoundEvent; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; +import net.minecraft.util.math.vector.Vector3d; import net.minecraft.world.World; public final class RecordUtil @@ -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, new Vec3d( pos ), 64 ); + NetworkHandler.sendToAllAround( packet, world, Vector3d.func_237489_a_( pos ), 64 ); } } diff --git a/src/main/java/dan200/computercraft/shared/util/WaterloggableHelpers.java b/src/main/java/dan200/computercraft/shared/util/WaterloggableHelpers.java index 978b78eff..13491150b 100644 --- a/src/main/java/dan200/computercraft/shared/util/WaterloggableHelpers.java +++ b/src/main/java/dan200/computercraft/shared/util/WaterloggableHelpers.java @@ -6,8 +6,8 @@ package dan200.computercraft.shared.util; import net.minecraft.block.BlockState; +import net.minecraft.fluid.FluidState; import net.minecraft.fluid.Fluids; -import net.minecraft.fluid.IFluidState; import net.minecraft.item.BlockItemUseContext; import net.minecraft.state.BooleanProperty; import net.minecraft.state.properties.BlockStateProperties; @@ -34,7 +34,7 @@ public final class WaterloggableHelpers * @param state The current state * @return This waterlogged block's current fluid */ - public static IFluidState getWaterloggedFluidState( BlockState state ) + public static FluidState getWaterloggedFluidState( BlockState state ) { return state.get( WATERLOGGED ) ? Fluids.WATER.getStillFluidState( false ) : Fluids.EMPTY.getDefaultState(); } diff --git a/src/main/java/dan200/computercraft/shared/util/WorldUtil.java b/src/main/java/dan200/computercraft/shared/util/WorldUtil.java index d483c7d74..f835911e3 100644 --- a/src/main/java/dan200/computercraft/shared/util/WorldUtil.java +++ b/src/main/java/dan200/computercraft/shared/util/WorldUtil.java @@ -12,9 +12,14 @@ import net.minecraft.entity.item.ItemEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.Direction; -import net.minecraft.util.math.*; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.RayTraceContext; +import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.shapes.VoxelShape; +import net.minecraft.util.math.vector.Vector3d; import net.minecraft.world.World; +import net.minecraftforge.common.ForgeMod; import org.apache.commons.lang3.tuple.Pair; import javax.annotation.Nonnull; @@ -56,7 +61,7 @@ public final class WorldUtil return world.getBlockState( pos ).getMaterial().isLiquid(); } - public static boolean isVecInside( VoxelShape shape, Vec3d vec ) + public static boolean isVecInside( VoxelShape shape, Vector3d vec ) { if( shape.isEmpty() ) return false; // AxisAlignedBB.contains, but without strict inequalities. @@ -64,9 +69,9 @@ public final class WorldUtil return vec.x >= bb.minX && vec.x <= bb.maxX && vec.y >= bb.minY && vec.y <= bb.maxY && vec.z >= bb.minZ && vec.z <= bb.maxZ; } - public static Pair rayTraceEntities( World world, Vec3d vecStart, Vec3d vecDir, double distance ) + public static Pair rayTraceEntities( World world, Vector3d vecStart, Vector3d vecDir, double distance ) { - Vec3d vecEnd = vecStart.add( vecDir.x * distance, vecDir.y * distance, vecDir.z * distance ); + Vector3d vecEnd = vecStart.add( vecDir.x * distance, vecDir.y * distance, vecDir.z * distance ); // Raycast for blocks Entity collisionEntity = getEntity( world ); @@ -105,7 +110,7 @@ public final class WorldUtil continue; } - Vec3d littleBoxResult = littleBox.rayTrace( vecStart, vecEnd ).orElse( null ); + Vector3d littleBoxResult = littleBox.rayTrace( vecStart, vecEnd ).orElse( null ); if( littleBoxResult != null ) { double dist = vecStart.distanceTo( littleBoxResult ); @@ -126,21 +131,21 @@ public final class WorldUtil } if( closest != null && closestDist <= distance ) { - Vec3d closestPos = vecStart.add( vecDir.x * closestDist, vecDir.y * closestDist, vecDir.z * closestDist ); + Vector3d closestPos = vecStart.add( vecDir.x * closestDist, vecDir.y * closestDist, vecDir.z * closestDist ); return Pair.of( closest, closestPos ); } return null; } - public static Vec3d getRayStart( LivingEntity entity ) + public static Vector3d getRayStart( LivingEntity entity ) { return entity.getEyePosition( 1 ); } - public static Vec3d getRayEnd( PlayerEntity player ) + public static Vector3d getRayEnd( PlayerEntity player ) { - double reach = player.getAttribute( PlayerEntity.REACH_DISTANCE ).getValue(); - Vec3d look = player.getLookVec(); + double reach = player.getAttribute( ForgeMod.REACH_DISTANCE.get() ).getValue(); + Vector3d look = player.getLookVec(); return getRayStart( player ).add( look.x * reach, look.y * reach, look.z * reach ); } @@ -170,15 +175,15 @@ public final class WorldUtil double xPos = pos.getX() + 0.5 + xDir * 0.4; double yPos = pos.getY() + 0.5 + yDir * 0.4; double zPos = pos.getZ() + 0.5 + zDir * 0.4; - dropItemStack( stack, world, new Vec3d( xPos, yPos, zPos ), xDir, yDir, zDir ); + dropItemStack( stack, world, new Vector3d( xPos, yPos, zPos ), xDir, yDir, zDir ); } - public static void dropItemStack( @Nonnull ItemStack stack, World world, Vec3d pos ) + public static void dropItemStack( @Nonnull ItemStack stack, World world, Vector3d pos ) { dropItemStack( stack, world, pos, 0.0, 0.0, 0.0 ); } - public static void dropItemStack( @Nonnull ItemStack stack, World world, Vec3d pos, double xDir, double yDir, double zDir ) + public static void dropItemStack( @Nonnull ItemStack stack, World world, Vector3d pos, double xDir, double yDir, double zDir ) { ItemEntity item = new ItemEntity( world, pos.x, pos.y, pos.z, stack.copy() ); item.setMotion( diff --git a/src/main/java/dan200/computercraft/shared/wired/WiredNetwork.java b/src/main/java/dan200/computercraft/shared/wired/WiredNetwork.java index c66c7e19b..a80758c65 100644 --- a/src/main/java/dan200/computercraft/shared/wired/WiredNetwork.java +++ b/src/main/java/dan200/computercraft/shared/wired/WiredNetwork.java @@ -10,7 +10,7 @@ import dan200.computercraft.api.network.Packet; import dan200.computercraft.api.network.wired.IWiredNetwork; import dan200.computercraft.api.network.wired.IWiredNode; import dan200.computercraft.api.peripheral.IPeripheral; -import net.minecraft.util.math.Vec3d; +import net.minecraft.util.math.vector.Vector3d; import net.minecraft.world.World; import javax.annotation.Nonnull; @@ -337,7 +337,7 @@ public final class WiredNetwork implements IWiredNetwork while( (point = transmitTo.pollFirst()) != null ) { World world = point.node.element.getWorld(); - Vec3d position = point.node.element.getPosition(); + Vector3d position = point.node.element.getPosition(); for( WiredNode neighbour : point.node.neighbours ) { TransmitPoint neighbourPoint = points.get( neighbour ); diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 94b6f2073..7c0c1635c 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -1,5 +1,5 @@ modLoader="javafml" -loaderVersion="[31,32)" +loaderVersion="[32,33)" issueTrackerURL="https://github.com/SquidDev-CC/CC-Tweaked/issues" displayURL="https://github.com/SquidDev-CC/CC-Tweaked" @@ -19,6 +19,6 @@ CC: Tweaked is a fork of ComputerCraft, adding programmable computers, turtles a [[dependencies.computercraft]] modId="forge" mandatory=true - versionRange="[31.0.13,32)" + versionRange="[32.0.23,33)" ordering="NONE" side="BOTH" diff --git a/src/test/java/dan200/computercraft/core/ComputerTestDelegate.java b/src/test/java/dan200/computercraft/core/ComputerTestDelegate.java index 2807f189b..8d8dfded7 100644 --- a/src/test/java/dan200/computercraft/core/ComputerTestDelegate.java +++ b/src/test/java/dan200/computercraft/core/ComputerTestDelegate.java @@ -20,7 +20,7 @@ import dan200.computercraft.core.filesystem.FileSystemException; import dan200.computercraft.core.terminal.Terminal; import dan200.computercraft.shared.peripheral.modem.ModemState; import dan200.computercraft.shared.peripheral.modem.wireless.WirelessModemPeripheral; -import net.minecraft.util.math.Vec3d; +import net.minecraft.util.math.vector.Vector3d; import net.minecraft.world.World; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -281,9 +281,9 @@ public class ComputerTestDelegate @Nonnull @Override - public Vec3d getPosition() + public Vector3d getPosition() { - return Vec3d.ZERO; + return Vector3d.ZERO; } @Override diff --git a/src/test/java/dan200/computercraft/core/filesystem/ResourceMountTest.java b/src/test/java/dan200/computercraft/core/filesystem/ResourceMountTest.java index 5c61f24fb..257f14326 100644 --- a/src/test/java/dan200/computercraft/core/filesystem/ResourceMountTest.java +++ b/src/test/java/dan200/computercraft/core/filesystem/ResourceMountTest.java @@ -28,7 +28,7 @@ public class ResourceMountTest @BeforeEach public void before() { - SimpleReloadableResourceManager manager = new SimpleReloadableResourceManager( ResourcePackType.SERVER_DATA, null ); + SimpleReloadableResourceManager manager = new SimpleReloadableResourceManager( ResourcePackType.SERVER_DATA ); manager.addResourcePack( new FolderPack( new File( "src/main/resources" ) ) ); mount = ResourceMount.get( "computercraft", "lua/rom", manager ); diff --git a/src/test/java/dan200/computercraft/shared/wired/NetworkTest.java b/src/test/java/dan200/computercraft/shared/wired/NetworkTest.java index 174558001..5bd4adbdb 100644 --- a/src/test/java/dan200/computercraft/shared/wired/NetworkTest.java +++ b/src/test/java/dan200/computercraft/shared/wired/NetworkTest.java @@ -16,7 +16,7 @@ import dan200.computercraft.api.peripheral.IPeripheral; import dan200.computercraft.shared.util.DirectionUtil; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; +import net.minecraft.util.math.vector.Vector3d; import net.minecraft.world.World; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @@ -315,13 +315,13 @@ public class NetworkTest private static final class NetworkElement implements IWiredElement { private final World world; - private final Vec3d position; + private final Vector3d position; private final String id; private final IWiredNode node; private final Map localPeripherals = Maps.newHashMap(); private final Map remotePeripherals = Maps.newHashMap(); - private NetworkElement( World world, Vec3d position, String id ) + private NetworkElement( World world, Vector3d position, String id ) { this.world = world; this.position = position; @@ -339,7 +339,7 @@ public class NetworkTest @Nonnull @Override - public Vec3d getPosition() + public Vector3d getPosition() { return position; }