mirror of
				https://github.com/SquidDev-CC/CC-Tweaked
				synced 2025-10-30 21:23:00 +00:00 
			
		
		
		
	Update to MC 1.18
- Build fails right now due to module issues, so this won't be pushed to GitHub. - Monitors render transparently when loaded into the world. I don't think this is a 1.17 bug, so not sure what's going on here!
This commit is contained in:
		
							
								
								
									
										17
									
								
								build.gradle
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								build.gradle
									
									
									
									
									
								
							| @@ -5,7 +5,7 @@ buildscript { | |||||||
|         maven { url = 'https://maven.parchmentmc.org' } |         maven { url = 'https://maven.parchmentmc.org' } | ||||||
|     } |     } | ||||||
|     dependencies { |     dependencies { | ||||||
|         classpath 'net.minecraftforge.gradle:ForgeGradle:5.1.24' |         classpath 'net.minecraftforge.gradle:ForgeGradle:5.1.+' | ||||||
|         classpath 'org.parchmentmc:librarian:1.+' |         classpath 'org.parchmentmc:librarian:1.+' | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @@ -29,7 +29,7 @@ version = mod_version | |||||||
| group = "org.squiddev" | group = "org.squiddev" | ||||||
| archivesBaseName = "cc-tweaked-${mc_version}" | archivesBaseName = "cc-tweaked-${mc_version}" | ||||||
| 
 | 
 | ||||||
| def javaVersion = JavaLanguageVersion.of(16) | def javaVersion = JavaLanguageVersion.of(17) | ||||||
| java { | java { | ||||||
|     toolchain { |     toolchain { | ||||||
|         languageVersion = javaVersion |         languageVersion = javaVersion | ||||||
| @@ -47,6 +47,7 @@ tasks.withType(JavaExec).configureEach { | |||||||
| 
 | 
 | ||||||
| sourceSets { | sourceSets { | ||||||
|     main.java { |     main.java { | ||||||
|  |         exclude 'dan200/computercraft/shared/integration/jei/**' | ||||||
|         exclude 'dan200/computercraft/shared/integration/morered/**' |         exclude 'dan200/computercraft/shared/integration/morered/**' | ||||||
|     } |     } | ||||||
|     main.resources { |     main.resources { | ||||||
| @@ -122,7 +123,8 @@ minecraft { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     mappings channel: 'parchment', version: "${mapping_version}-${mc_version}" |     // mappings channel: 'parchment', version: "${mapping_version}-${mc_version}" | ||||||
|  |     mappings channel: 'official', version: mc_version | ||||||
| 
 | 
 | ||||||
|     accessTransformer file('src/main/resources/META-INF/accesstransformer.cfg') |     accessTransformer file('src/main/resources/META-INF/accesstransformer.cfg') | ||||||
|     accessTransformer file('src/testMod/resources/META-INF/accesstransformer.cfg') |     accessTransformer file('src/testMod/resources/META-INF/accesstransformer.cfg') | ||||||
| @@ -151,10 +153,8 @@ dependencies { | |||||||
| 
 | 
 | ||||||
|     minecraft "net.minecraftforge:forge:${mc_version}-${forge_version}" |     minecraft "net.minecraftforge:forge:${mc_version}-${forge_version}" | ||||||
| 
 | 
 | ||||||
|     compileOnly fg.deobf("mezz.jei:jei-1.17.1:8.0.0.14:api") |     // compileOnly fg.deobf("mezz.jei:jei-1.17.1:8.0.0.14:api") | ||||||
|     // compileOnly fg.deobf("commoble.morered:morered-1.16.5:2.1.1.0") |     // runtimeOnly fg.deobf("mezz.jei:jei-1.17.1:8.0.0.14") | ||||||
| 
 |  | ||||||
|     runtimeOnly fg.deobf("mezz.jei:jei-1.17.1:8.0.0.14") |  | ||||||
| 
 | 
 | ||||||
|     shade 'org.squiddev:Cobalt:0.5.2-SNAPSHOT' |     shade 'org.squiddev:Cobalt:0.5.2-SNAPSHOT' | ||||||
| 
 | 
 | ||||||
| @@ -430,7 +430,8 @@ task setupServer(type: Copy) { | |||||||
|     if (name != "Client" || project.findProperty('cc.tweaked.clientTests') == 'true') { |     if (name != "Client" || project.findProperty('cc.tweaked.clientTests') == 'true') { | ||||||
|         // Don't run client tests unless explicitly opted into them. They're a bit of a faff |         // Don't run client tests unless explicitly opted into them. They're a bit of a faff | ||||||
|         // to run and pretty flakey. |         // to run and pretty flakey. | ||||||
|         check.dependsOn("jacocoTest${name}Report") |         // check.dependsOn("jacocoTest${name}Report") | ||||||
|  |         // TODO: Fix this! Doesn't load due to jetbrains annotations appearing twice | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|   | |||||||
| @@ -4,7 +4,7 @@ org.gradle.jvmargs=-Xmx3G | |||||||
| mod_version=1.99.0 | mod_version=1.99.0 | ||||||
|  |  | ||||||
| # Minecraft properties (update mods.toml when changing) | # Minecraft properties (update mods.toml when changing) | ||||||
| mc_version=1.17.1 | mc_version=1.18 | ||||||
| mapping_version=2021.09.05 | mapping_version=2021.09.05 | ||||||
| forge_version=37.0.85 | forge_version=38.0.0 | ||||||
| # NO SERIOUSLY, UPDATE mods.toml WHEN CHANGING | # NO SERIOUSLY, UPDATE mods.toml WHEN CHANGING | ||||||
|   | |||||||
| @@ -38,7 +38,7 @@ import net.minecraft.world.level.block.entity.BlockEntity; | |||||||
| import net.minecraftforge.common.capabilities.Capability; | import net.minecraftforge.common.capabilities.Capability; | ||||||
| import net.minecraftforge.common.util.LazyOptional; | import net.minecraftforge.common.util.LazyOptional; | ||||||
| import net.minecraftforge.fml.ModList; | import net.minecraftforge.fml.ModList; | ||||||
| import net.minecraftforge.fmllegacy.server.ServerLifecycleHooks; | import net.minecraftforge.server.ServerLifecycleHooks; | ||||||
| 
 | 
 | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| import java.io.File; | import java.io.File; | ||||||
|   | |||||||
| @@ -32,7 +32,7 @@ import net.minecraftforge.api.distmarker.Dist; | |||||||
| import net.minecraftforge.client.event.ColorHandlerEvent; | import net.minecraftforge.client.event.ColorHandlerEvent; | ||||||
| import net.minecraftforge.client.event.EntityRenderersEvent; | import net.minecraftforge.client.event.EntityRenderersEvent; | ||||||
| import net.minecraftforge.client.event.ModelRegistryEvent; | import net.minecraftforge.client.event.ModelRegistryEvent; | ||||||
| import net.minecraftforge.client.model.ModelLoader; | import net.minecraftforge.client.model.ForgeModelBakery; | ||||||
| import net.minecraftforge.client.model.ModelLoaderRegistry; | import net.minecraftforge.client.model.ModelLoaderRegistry; | ||||||
| import net.minecraftforge.eventbus.api.SubscribeEvent; | import net.minecraftforge.eventbus.api.SubscribeEvent; | ||||||
| import net.minecraftforge.fml.common.Mod; | import net.minecraftforge.fml.common.Mod; | ||||||
| @@ -76,7 +76,7 @@ public final class ClientRegistry | |||||||
|         ModelLoaderRegistry.registerLoader( new ResourceLocation( ComputerCraft.MOD_ID, "turtle" ), TurtleModelLoader.INSTANCE ); |         ModelLoaderRegistry.registerLoader( new ResourceLocation( ComputerCraft.MOD_ID, "turtle" ), TurtleModelLoader.INSTANCE ); | ||||||
|         for( String model : EXTRA_MODELS ) |         for( String model : EXTRA_MODELS ) | ||||||
|         { |         { | ||||||
|             ModelLoader.addSpecialModel( new ModelResourceLocation( new ResourceLocation( ComputerCraft.MOD_ID, model ), "inventory" ) ); |             ForgeModelBakery.addSpecialModel( new ModelResourceLocation( new ResourceLocation( ComputerCraft.MOD_ID, model ), "inventory" ) ); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|   | |||||||
| @@ -71,12 +71,12 @@ public class DynamicImageButton extends Button | |||||||
|         RenderSystem.disableDepthTest(); |         RenderSystem.disableDepthTest(); | ||||||
| 
 | 
 | ||||||
|         int yTex = yTexStart; |         int yTex = yTexStart; | ||||||
|         if( isHovered() ) yTex += yDiffTex; |         if( isHoveredOrFocused() ) yTex += yDiffTex; | ||||||
| 
 | 
 | ||||||
|         blit( stack, x, y, xTexStart.getAsInt(), yTex, width, height, textureWidth, textureHeight ); |         blit( stack, x, y, xTexStart.getAsInt(), yTex, width, height, textureWidth, textureHeight ); | ||||||
|         RenderSystem.enableDepthTest(); |         RenderSystem.enableDepthTest(); | ||||||
| 
 | 
 | ||||||
|         if( isHovered() ) renderToolTip( stack, mouseX, mouseY ); |         if( isHovered ) renderToolTip( stack, mouseX, mouseY ); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Nonnull |     @Nonnull | ||||||
|   | |||||||
| @@ -45,8 +45,8 @@ public final class CableHighlightRenderer | |||||||
|     { |     { | ||||||
|         BlockHitResult hit = event.getTarget(); |         BlockHitResult hit = event.getTarget(); | ||||||
|         BlockPos pos = hit.getBlockPos(); |         BlockPos pos = hit.getBlockPos(); | ||||||
|         Level world = event.getInfo().getEntity().getCommandSenderWorld(); |         Level world = event.getCamera().getEntity().getCommandSenderWorld(); | ||||||
|         Camera info = event.getInfo(); |         Camera info = event.getCamera(); | ||||||
| 
 | 
 | ||||||
|         BlockState state = world.getBlockState( pos ); |         BlockState state = world.getBlockState( pos ); | ||||||
| 
 | 
 | ||||||
| @@ -67,9 +67,9 @@ public final class CableHighlightRenderer | |||||||
|         double yOffset = pos.getY() - cameraPos.y(); |         double yOffset = pos.getY() - cameraPos.y(); | ||||||
|         double zOffset = pos.getZ() - cameraPos.z(); |         double zOffset = pos.getZ() - cameraPos.z(); | ||||||
| 
 | 
 | ||||||
|         VertexConsumer buffer = event.getBuffers().getBuffer( RenderType.lines() ); |         VertexConsumer buffer = event.getMultiBufferSource().getBuffer( RenderType.lines() ); | ||||||
|         Matrix4f matrix4f = event.getMatrix().last().pose(); |         Matrix4f matrix4f = event.getPoseStack().last().pose(); | ||||||
|         Matrix3f normal = event.getMatrix().last().normal(); |         Matrix3f normal = event.getPoseStack().last().normal(); | ||||||
|         // TODO: Can we just accesstransformer out LevelRenderer.renderShape? |         // TODO: Can we just accesstransformer out LevelRenderer.renderShape? | ||||||
|         shape.forAllEdges( ( x1, y1, z1, x2, y2, z2 ) -> { |         shape.forAllEdges( ( x1, y1, z1, x2, y2, z2 ) -> { | ||||||
|             float xDelta = (float) (x2 - x1); |             float xDelta = (float) (x2 - x1); | ||||||
|   | |||||||
| @@ -48,7 +48,7 @@ public final class ItemPocketRenderer extends ItemMapLikeRenderer | |||||||
| 
 | 
 | ||||||
|         event.setCanceled( true ); |         event.setCanceled( true ); | ||||||
|         INSTANCE.renderItemFirstPerson( |         INSTANCE.renderItemFirstPerson( | ||||||
|             event.getMatrixStack(), event.getBuffers(), event.getLight(), |             event.getPoseStack(), event.getMultiBufferSource(), event.getPackedLight(), | ||||||
|             event.getHand(), event.getInterpolatedPitch(), event.getEquipProgress(), event.getSwingProgress(), event.getItemStack() |             event.getHand(), event.getInterpolatedPitch(), event.getEquipProgress(), event.getSwingProgress(), event.getItemStack() | ||||||
|         ); |         ); | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -45,7 +45,7 @@ public final class ItemPrintoutRenderer extends ItemMapLikeRenderer | |||||||
| 
 | 
 | ||||||
|         event.setCanceled( true ); |         event.setCanceled( true ); | ||||||
|         INSTANCE.renderItemFirstPerson( |         INSTANCE.renderItemFirstPerson( | ||||||
|             event.getMatrixStack(), event.getBuffers(), event.getLight(), |             event.getPoseStack(), event.getMultiBufferSource(), event.getPackedLight(), | ||||||
|             event.getHand(), event.getInterpolatedPitch(), event.getEquipProgress(), event.getSwingProgress(), event.getItemStack() |             event.getHand(), event.getInterpolatedPitch(), event.getEquipProgress(), event.getSwingProgress(), event.getItemStack() | ||||||
|         ); |         ); | ||||||
|     } |     } | ||||||
| @@ -63,11 +63,11 @@ public final class ItemPrintoutRenderer extends ItemMapLikeRenderer | |||||||
|     @SubscribeEvent |     @SubscribeEvent | ||||||
|     public static void onRenderInFrame( RenderItemInFrameEvent event ) |     public static void onRenderInFrame( RenderItemInFrameEvent event ) | ||||||
|     { |     { | ||||||
|         ItemStack stack = event.getItem(); |         ItemStack stack = event.getItemStack(); | ||||||
|         if( !(stack.getItem() instanceof ItemPrintout) ) return; |         if( !(stack.getItem() instanceof ItemPrintout) ) return; | ||||||
|         event.setCanceled( true ); |         event.setCanceled( true ); | ||||||
| 
 | 
 | ||||||
|         PoseStack transform = event.getMatrix(); |         PoseStack transform = event.getPoseStack(); | ||||||
| 
 | 
 | ||||||
|         // Move a little bit forward to ensure we're not clipping with the frame |         // Move a little bit forward to ensure we're not clipping with the frame | ||||||
|         transform.translate( 0.0f, 0.0f, -0.001f ); |         transform.translate( 0.0f, 0.0f, -0.001f ); | ||||||
| @@ -75,8 +75,8 @@ public final class ItemPrintoutRenderer extends ItemMapLikeRenderer | |||||||
|         transform.scale( 0.95f, 0.95f, -0.95f ); |         transform.scale( 0.95f, 0.95f, -0.95f ); | ||||||
|         transform.translate( -0.5f, -0.5f, 0.0f ); |         transform.translate( -0.5f, -0.5f, 0.0f ); | ||||||
| 
 | 
 | ||||||
|         int light = event.getEntityItemFrame().getType() == EntityType.GLOW_ITEM_FRAME ? 0xf000d2 : event.getLight(); // See getLightVal. |         int light = event.getItemFrameEntity().getType() == EntityType.GLOW_ITEM_FRAME ? 0xf000d2 : event.getPackedLight(); // See getLightVal. | ||||||
|         drawPrintout( transform, event.getBuffers(), stack, light ); |         drawPrintout( transform, event.getMultiBufferSource(), stack, light ); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     private static void drawPrintout( PoseStack transform, MultiBufferSource render, ItemStack stack, int light ) |     private static void drawPrintout( PoseStack transform, MultiBufferSource render, ItemStack stack, int light ) | ||||||
|   | |||||||
| @@ -41,9 +41,9 @@ public final class MonitorHighlightRenderer | |||||||
|     public static void drawHighlight( DrawSelectionEvent.HighlightBlock event ) |     public static void drawHighlight( DrawSelectionEvent.HighlightBlock event ) | ||||||
|     { |     { | ||||||
|         // Preserve normal behaviour when crouching. |         // Preserve normal behaviour when crouching. | ||||||
|         if( event.getInfo().getEntity().isCrouching() ) return; |         if( event.getCamera().getEntity().isCrouching() ) return; | ||||||
| 
 | 
 | ||||||
|         Level world = event.getInfo().getEntity().getCommandSenderWorld(); |         Level world = event.getCamera().getEntity().getCommandSenderWorld(); | ||||||
|         BlockPos pos = event.getTarget().getBlockPos(); |         BlockPos pos = event.getTarget().getBlockPos(); | ||||||
| 
 | 
 | ||||||
|         BlockEntity tile = world.getBlockEntity( pos ); |         BlockEntity tile = world.getBlockEntity( pos ); | ||||||
| @@ -60,13 +60,13 @@ public final class MonitorHighlightRenderer | |||||||
|         if( monitor.getYIndex() != 0 ) faces.remove( monitor.getDown().getOpposite() ); |         if( monitor.getYIndex() != 0 ) faces.remove( monitor.getDown().getOpposite() ); | ||||||
|         if( monitor.getYIndex() != monitor.getHeight() - 1 ) faces.remove( monitor.getDown() ); |         if( monitor.getYIndex() != monitor.getHeight() - 1 ) faces.remove( monitor.getDown() ); | ||||||
| 
 | 
 | ||||||
|         PoseStack transformStack = event.getMatrix(); |         PoseStack transformStack = event.getPoseStack(); | ||||||
|         Vec3 cameraPos = event.getInfo().getPosition(); |         Vec3 cameraPos = event.getCamera().getPosition(); | ||||||
|         transformStack.pushPose(); |         transformStack.pushPose(); | ||||||
|         transformStack.translate( pos.getX() - cameraPos.x(), pos.getY() - cameraPos.y(), pos.getZ() - cameraPos.z() ); |         transformStack.translate( pos.getX() - cameraPos.x(), pos.getY() - cameraPos.y(), pos.getZ() - cameraPos.z() ); | ||||||
| 
 | 
 | ||||||
|         // I wish I could think of a better way to do this |         // I wish I could think of a better way to do this | ||||||
|         VertexConsumer buffer = event.getBuffers().getBuffer( RenderType.lines() ); |         VertexConsumer buffer = event.getMultiBufferSource().getBuffer( RenderType.lines() ); | ||||||
|         Matrix4f transform = transformStack.last().pose(); |         Matrix4f transform = transformStack.last().pose(); | ||||||
|         Matrix3f normal = transformStack.last().normal(); |         Matrix3f normal = transformStack.last().normal(); | ||||||
|         if( faces.contains( NORTH ) || faces.contains( WEST ) ) line( buffer, transform, normal, 0, 0, 0, UP ); |         if( faces.contains( NORTH ) || faces.contains( WEST ) ) line( buffer, transform, normal, 0, 0, 0, UP ); | ||||||
|   | |||||||
| @@ -26,7 +26,7 @@ import net.minecraft.world.level.storage.loot.predicates.AlternativeLootItemCond | |||||||
| import net.minecraft.world.level.storage.loot.predicates.ExplosionCondition; | import net.minecraft.world.level.storage.loot.predicates.ExplosionCondition; | ||||||
| import net.minecraft.world.level.storage.loot.predicates.LootItemBlockStatePropertyCondition; | import net.minecraft.world.level.storage.loot.predicates.LootItemBlockStatePropertyCondition; | ||||||
| import net.minecraft.world.level.storage.loot.providers.number.ConstantValue; | import net.minecraft.world.level.storage.loot.providers.number.ConstantValue; | ||||||
| import net.minecraftforge.fmllegacy.RegistryObject; | import net.minecraftforge.registries.RegistryObject; | ||||||
| 
 | 
 | ||||||
| import java.util.function.BiConsumer; | import java.util.function.BiConsumer; | ||||||
| 
 | 
 | ||||||
|   | |||||||
| @@ -28,11 +28,11 @@ import net.minecraft.world.level.storage.loot.entries.LootTableReference; | |||||||
| import net.minecraft.world.level.storage.loot.providers.number.ConstantValue; | import net.minecraft.world.level.storage.loot.providers.number.ConstantValue; | ||||||
| import net.minecraftforge.event.*; | import net.minecraftforge.event.*; | ||||||
| import net.minecraftforge.event.entity.player.PlayerContainerEvent; | import net.minecraftforge.event.entity.player.PlayerContainerEvent; | ||||||
|  | import net.minecraftforge.event.server.ServerStartedEvent; | ||||||
|  | import net.minecraftforge.event.server.ServerStartingEvent; | ||||||
|  | import net.minecraftforge.event.server.ServerStoppedEvent; | ||||||
| import net.minecraftforge.eventbus.api.SubscribeEvent; | import net.minecraftforge.eventbus.api.SubscribeEvent; | ||||||
| import net.minecraftforge.fml.common.Mod; | import net.minecraftforge.fml.common.Mod; | ||||||
| import net.minecraftforge.fmlserverevents.FMLServerStartedEvent; |  | ||||||
| import net.minecraftforge.fmlserverevents.FMLServerStartingEvent; |  | ||||||
| import net.minecraftforge.fmlserverevents.FMLServerStoppedEvent; |  | ||||||
| 
 | 
 | ||||||
| import java.util.Arrays; | import java.util.Arrays; | ||||||
| import java.util.HashSet; | import java.util.HashSet; | ||||||
| @@ -84,7 +84,7 @@ public final class CommonHooks | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @SubscribeEvent |     @SubscribeEvent | ||||||
|     public static void onServerStarting( FMLServerStartingEvent event ) |     public static void onServerStarting( ServerStartingEvent event ) | ||||||
|     { |     { | ||||||
|         MinecraftServer server = event.getServer(); |         MinecraftServer server = event.getServer(); | ||||||
|         if( server instanceof DedicatedServer dediServer && dediServer.getProperties().enableJmxMonitoring ) |         if( server instanceof DedicatedServer dediServer && dediServer.getProperties().enableJmxMonitoring ) | ||||||
| @@ -94,7 +94,7 @@ public final class CommonHooks | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @SubscribeEvent |     @SubscribeEvent | ||||||
|     public static void onServerStarted( FMLServerStartedEvent event ) |     public static void onServerStarted( ServerStartedEvent event ) | ||||||
|     { |     { | ||||||
|         ComputerCraft.serverComputerRegistry.reset(); |         ComputerCraft.serverComputerRegistry.reset(); | ||||||
|         WirelessNetwork.resetNetworks(); |         WirelessNetwork.resetNetworks(); | ||||||
| @@ -104,7 +104,7 @@ public final class CommonHooks | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @SubscribeEvent |     @SubscribeEvent | ||||||
|     public static void onServerStopped( FMLServerStoppedEvent event ) |     public static void onServerStopped( ServerStoppedEvent event ) | ||||||
|     { |     { | ||||||
|         ComputerCraft.serverComputerRegistry.reset(); |         ComputerCraft.serverComputerRegistry.reset(); | ||||||
|         WirelessNetwork.resetNetworks(); |         WirelessNetwork.resetNetworks(); | ||||||
|   | |||||||
| @@ -96,11 +96,11 @@ import net.minecraftforge.fluids.capability.CapabilityFluidHandler; | |||||||
| import net.minecraftforge.fml.common.Mod; | import net.minecraftforge.fml.common.Mod; | ||||||
| import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; | import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; | ||||||
| import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; | import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; | ||||||
| import net.minecraftforge.fmllegacy.RegistryObject; |  | ||||||
| import net.minecraftforge.items.CapabilityItemHandler; | import net.minecraftforge.items.CapabilityItemHandler; | ||||||
| import net.minecraftforge.registries.DeferredRegister; | import net.minecraftforge.registries.DeferredRegister; | ||||||
| import net.minecraftforge.registries.ForgeRegistries; | import net.minecraftforge.registries.ForgeRegistries; | ||||||
| import net.minecraftforge.registries.RegistryBuilder; | import net.minecraftforge.registries.RegistryBuilder; | ||||||
|  | import net.minecraftforge.registries.RegistryObject; | ||||||
| 
 | 
 | ||||||
| import java.util.function.BiFunction; | import java.util.function.BiFunction; | ||||||
| 
 | 
 | ||||||
|   | |||||||
| @@ -13,7 +13,7 @@ import net.minecraftforge.api.distmarker.Dist; | |||||||
| import net.minecraftforge.client.event.ClientChatEvent; | import net.minecraftforge.client.event.ClientChatEvent; | ||||||
| import net.minecraftforge.eventbus.api.SubscribeEvent; | import net.minecraftforge.eventbus.api.SubscribeEvent; | ||||||
| import net.minecraftforge.fml.common.Mod; | import net.minecraftforge.fml.common.Mod; | ||||||
| import net.minecraftforge.fmllegacy.server.ServerLifecycleHooks; | import net.minecraftforge.server.ServerLifecycleHooks; | ||||||
| 
 | 
 | ||||||
| import java.io.File; | import java.io.File; | ||||||
| 
 | 
 | ||||||
|   | |||||||
| @@ -19,7 +19,7 @@ import net.minecraft.world.level.block.entity.BlockEntity; | |||||||
| import net.minecraft.world.level.block.entity.BlockEntityType; | import net.minecraft.world.level.block.entity.BlockEntityType; | ||||||
| import net.minecraft.world.level.block.state.BlockState; | import net.minecraft.world.level.block.state.BlockState; | ||||||
| import net.minecraft.world.phys.BlockHitResult; | import net.minecraft.world.phys.BlockHitResult; | ||||||
| import net.minecraftforge.fmllegacy.RegistryObject; | import net.minecraftforge.registries.RegistryObject; | ||||||
| 
 | 
 | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| import javax.annotation.Nullable; | import javax.annotation.Nullable; | ||||||
|   | |||||||
| @@ -12,11 +12,11 @@ import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket; | |||||||
| import net.minecraft.world.InteractionHand; | import net.minecraft.world.InteractionHand; | ||||||
| import net.minecraft.world.InteractionResult; | import net.minecraft.world.InteractionResult; | ||||||
| import net.minecraft.world.entity.player.Player; | import net.minecraft.world.entity.player.Player; | ||||||
|  | import net.minecraft.world.level.block.Block; | ||||||
| import net.minecraft.world.level.block.entity.BlockEntity; | import net.minecraft.world.level.block.entity.BlockEntity; | ||||||
| import net.minecraft.world.level.block.entity.BlockEntityType; | import net.minecraft.world.level.block.entity.BlockEntityType; | ||||||
| import net.minecraft.world.level.block.state.BlockState; | import net.minecraft.world.level.block.state.BlockState; | ||||||
| import net.minecraft.world.phys.BlockHitResult; | import net.minecraft.world.phys.BlockHitResult; | ||||||
| import net.minecraftforge.common.util.Constants; |  | ||||||
| 
 | 
 | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| 
 | 
 | ||||||
| @@ -36,7 +36,7 @@ public abstract class TileGeneric extends BlockEntity | |||||||
|         setChanged(); |         setChanged(); | ||||||
|         BlockPos pos = getBlockPos(); |         BlockPos pos = getBlockPos(); | ||||||
|         BlockState state = getBlockState(); |         BlockState state = getBlockState(); | ||||||
|         getLevel().sendBlockUpdated( pos, state, state, Constants.BlockFlags.DEFAULT ); |         getLevel().sendBlockUpdated( pos, state, state, Block.UPDATE_ALL ); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Nonnull |     @Nonnull | ||||||
| @@ -76,7 +76,8 @@ public abstract class TileGeneric extends BlockEntity | |||||||
|     @Override |     @Override | ||||||
|     public final void onDataPacket( Connection net, ClientboundBlockEntityDataPacket packet ) |     public final void onDataPacket( Connection net, ClientboundBlockEntityDataPacket packet ) | ||||||
|     { |     { | ||||||
|         if( packet.getType() == 0 ) handleUpdateTag( packet.getTag() ); |         var tag = packet.getTag(); | ||||||
|  |         if( tag != null ) handleUpdateTag( tag ); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Override |     @Override | ||||||
|   | |||||||
| @@ -18,7 +18,7 @@ import net.minecraft.world.level.block.state.StateDefinition; | |||||||
| import net.minecraft.world.level.block.state.properties.BlockStateProperties; | import net.minecraft.world.level.block.state.properties.BlockStateProperties; | ||||||
| import net.minecraft.world.level.block.state.properties.DirectionProperty; | import net.minecraft.world.level.block.state.properties.DirectionProperty; | ||||||
| import net.minecraft.world.level.block.state.properties.EnumProperty; | import net.minecraft.world.level.block.state.properties.EnumProperty; | ||||||
| import net.minecraftforge.fmllegacy.RegistryObject; | import net.minecraftforge.registries.RegistryObject; | ||||||
| 
 | 
 | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| import javax.annotation.Nullable; | import javax.annotation.Nullable; | ||||||
|   | |||||||
| @@ -32,7 +32,7 @@ import net.minecraft.world.level.storage.loot.LootContext; | |||||||
| import net.minecraft.world.level.storage.loot.parameters.LootContextParams; | import net.minecraft.world.level.storage.loot.parameters.LootContextParams; | ||||||
| import net.minecraft.world.phys.HitResult; | import net.minecraft.world.phys.HitResult; | ||||||
| import net.minecraft.world.phys.Vec3; | import net.minecraft.world.phys.Vec3; | ||||||
| import net.minecraftforge.fmllegacy.RegistryObject; | import net.minecraftforge.registries.RegistryObject; | ||||||
| 
 | 
 | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| import javax.annotation.Nullable; | import javax.annotation.Nullable; | ||||||
| @@ -119,7 +119,7 @@ public abstract class BlockComputerBase<T extends TileComputerBase> extends Bloc | |||||||
| 
 | 
 | ||||||
|     @Nonnull |     @Nonnull | ||||||
|     @Override |     @Override | ||||||
|     public ItemStack getPickBlock( BlockState state, HitResult target, BlockGetter world, BlockPos pos, Player player ) |     public ItemStack getCloneItemStack( BlockState state, HitResult target, BlockGetter world, BlockPos pos, Player player ) | ||||||
|     { |     { | ||||||
|         BlockEntity tile = world.getBlockEntity( pos ); |         BlockEntity tile = world.getBlockEntity( pos ); | ||||||
|         if( tile instanceof TileComputerBase ) |         if( tile instanceof TileComputerBase ) | ||||||
| @@ -128,7 +128,7 @@ public abstract class BlockComputerBase<T extends TileComputerBase> extends Bloc | |||||||
|             if( !result.isEmpty() ) return result; |             if( !result.isEmpty() ) return result; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         return super.getPickBlock( state, target, world, pos, player ); |         return super.getCloneItemStack( state, target, world, pos, player ); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Override |     @Override | ||||||
|   | |||||||
| @@ -388,7 +388,7 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT | |||||||
|     @Override |     @Override | ||||||
|     public final ClientboundBlockEntityDataPacket getUpdatePacket() |     public final ClientboundBlockEntityDataPacket getUpdatePacket() | ||||||
|     { |     { | ||||||
|         return new ClientboundBlockEntityDataPacket( worldPosition, 0, getUpdateTag() ); |         return ClientboundBlockEntityDataPacket.create( this ); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Nonnull |     @Nonnull | ||||||
|   | |||||||
| @@ -28,7 +28,7 @@ import net.minecraft.server.MinecraftServer; | |||||||
| import net.minecraft.world.entity.player.Player; | import net.minecraft.world.entity.player.Player; | ||||||
| import net.minecraft.world.inventory.AbstractContainerMenu; | import net.minecraft.world.inventory.AbstractContainerMenu; | ||||||
| import net.minecraft.world.level.Level; | import net.minecraft.world.level.Level; | ||||||
| import net.minecraftforge.fmllegacy.server.ServerLifecycleHooks; | import net.minecraftforge.server.ServerLifecycleHooks; | ||||||
| import net.minecraftforge.versions.mcp.MCPVersion; | import net.minecraftforge.versions.mcp.MCPVersion; | ||||||
| 
 | 
 | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
|   | |||||||
| @@ -16,11 +16,11 @@ import net.minecraft.world.entity.player.Player; | |||||||
| import net.minecraft.world.level.Level; | import net.minecraft.world.level.Level; | ||||||
| import net.minecraft.world.level.chunk.LevelChunk; | import net.minecraft.world.level.chunk.LevelChunk; | ||||||
| import net.minecraft.world.phys.Vec3; | import net.minecraft.world.phys.Vec3; | ||||||
| import net.minecraftforge.fmllegacy.network.NetworkDirection; | import net.minecraftforge.network.NetworkDirection; | ||||||
| import net.minecraftforge.fmllegacy.network.NetworkEvent; | import net.minecraftforge.network.NetworkEvent; | ||||||
| import net.minecraftforge.fmllegacy.network.NetworkRegistry; | import net.minecraftforge.network.NetworkRegistry; | ||||||
| import net.minecraftforge.fmllegacy.network.PacketDistributor; | import net.minecraftforge.network.PacketDistributor; | ||||||
| import net.minecraftforge.fmllegacy.network.simple.SimpleChannel; | import net.minecraftforge.network.simple.SimpleChannel; | ||||||
| 
 | 
 | ||||||
| import java.util.function.Function; | import java.util.function.Function; | ||||||
| import java.util.function.Supplier; | import java.util.function.Supplier; | ||||||
|   | |||||||
| @@ -6,7 +6,7 @@ | |||||||
| package dan200.computercraft.shared.network; | package dan200.computercraft.shared.network; | ||||||
| 
 | 
 | ||||||
| import net.minecraft.network.FriendlyByteBuf; | import net.minecraft.network.FriendlyByteBuf; | ||||||
| import net.minecraftforge.fmllegacy.network.NetworkEvent; | import net.minecraftforge.network.NetworkEvent; | ||||||
| 
 | 
 | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| 
 | 
 | ||||||
|   | |||||||
| @@ -10,7 +10,7 @@ import dan200.computercraft.shared.command.text.TableBuilder; | |||||||
| import dan200.computercraft.shared.network.NetworkMessage; | import dan200.computercraft.shared.network.NetworkMessage; | ||||||
| import net.minecraft.network.FriendlyByteBuf; | import net.minecraft.network.FriendlyByteBuf; | ||||||
| import net.minecraft.network.chat.Component; | import net.minecraft.network.chat.Component; | ||||||
| import net.minecraftforge.fmllegacy.network.NetworkEvent; | import net.minecraftforge.network.NetworkEvent; | ||||||
| 
 | 
 | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| 
 | 
 | ||||||
|   | |||||||
| @@ -9,7 +9,7 @@ import dan200.computercraft.shared.computer.core.ComputerState; | |||||||
| import dan200.computercraft.shared.computer.core.ServerComputer; | import dan200.computercraft.shared.computer.core.ServerComputer; | ||||||
| import net.minecraft.nbt.CompoundTag; | import net.minecraft.nbt.CompoundTag; | ||||||
| import net.minecraft.network.FriendlyByteBuf; | import net.minecraft.network.FriendlyByteBuf; | ||||||
| import net.minecraftforge.fmllegacy.network.NetworkEvent; | import net.minecraftforge.network.NetworkEvent; | ||||||
| 
 | 
 | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| 
 | 
 | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ package dan200.computercraft.shared.network.client; | |||||||
| 
 | 
 | ||||||
| import dan200.computercraft.ComputerCraft; | import dan200.computercraft.ComputerCraft; | ||||||
| import net.minecraft.network.FriendlyByteBuf; | import net.minecraft.network.FriendlyByteBuf; | ||||||
| import net.minecraftforge.fmllegacy.network.NetworkEvent; | import net.minecraftforge.network.NetworkEvent; | ||||||
| 
 | 
 | ||||||
| public class ComputerDeletedClientMessage extends ComputerClientMessage | public class ComputerDeletedClientMessage extends ComputerClientMessage | ||||||
| { | { | ||||||
|   | |||||||
| @@ -6,7 +6,7 @@ | |||||||
| package dan200.computercraft.shared.network.client; | package dan200.computercraft.shared.network.client; | ||||||
| 
 | 
 | ||||||
| import net.minecraft.network.FriendlyByteBuf; | import net.minecraft.network.FriendlyByteBuf; | ||||||
| import net.minecraftforge.fmllegacy.network.NetworkEvent; | import net.minecraftforge.network.NetworkEvent; | ||||||
| 
 | 
 | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| 
 | 
 | ||||||
|   | |||||||
| @@ -12,7 +12,7 @@ import net.minecraft.client.player.LocalPlayer; | |||||||
| import net.minecraft.core.BlockPos; | import net.minecraft.core.BlockPos; | ||||||
| import net.minecraft.network.FriendlyByteBuf; | import net.minecraft.network.FriendlyByteBuf; | ||||||
| import net.minecraft.world.level.block.entity.BlockEntity; | import net.minecraft.world.level.block.entity.BlockEntity; | ||||||
| import net.minecraftforge.fmllegacy.network.NetworkEvent; | import net.minecraftforge.network.NetworkEvent; | ||||||
| 
 | 
 | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| 
 | 
 | ||||||
|   | |||||||
| @@ -13,7 +13,7 @@ import net.minecraft.network.chat.TextComponent; | |||||||
| import net.minecraft.sounds.SoundEvent; | import net.minecraft.sounds.SoundEvent; | ||||||
| import net.minecraftforge.api.distmarker.Dist; | import net.minecraftforge.api.distmarker.Dist; | ||||||
| import net.minecraftforge.api.distmarker.OnlyIn; | import net.minecraftforge.api.distmarker.OnlyIn; | ||||||
| import net.minecraftforge.fmllegacy.network.NetworkEvent; | import net.minecraftforge.network.NetworkEvent; | ||||||
| 
 | 
 | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| 
 | 
 | ||||||
|   | |||||||
| @@ -11,7 +11,7 @@ import net.minecraft.network.FriendlyByteBuf; | |||||||
| import net.minecraft.world.phys.Vec3; | import net.minecraft.world.phys.Vec3; | ||||||
| import net.minecraftforge.api.distmarker.Dist; | import net.minecraftforge.api.distmarker.Dist; | ||||||
| import net.minecraftforge.api.distmarker.OnlyIn; | import net.minecraftforge.api.distmarker.OnlyIn; | ||||||
| import net.minecraftforge.fmllegacy.network.NetworkEvent; | import net.minecraftforge.network.NetworkEvent; | ||||||
| 
 | 
 | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| import java.util.UUID; | import java.util.UUID; | ||||||
|   | |||||||
| @@ -12,7 +12,7 @@ import net.minecraft.resources.ResourceLocation; | |||||||
| import net.minecraft.world.phys.Vec3; | import net.minecraft.world.phys.Vec3; | ||||||
| import net.minecraftforge.api.distmarker.Dist; | import net.minecraftforge.api.distmarker.Dist; | ||||||
| import net.minecraftforge.api.distmarker.OnlyIn; | import net.minecraftforge.api.distmarker.OnlyIn; | ||||||
| import net.minecraftforge.fmllegacy.network.NetworkEvent; | import net.minecraftforge.network.NetworkEvent; | ||||||
| 
 | 
 | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| import java.util.UUID; | import java.util.UUID; | ||||||
|   | |||||||
| @@ -10,7 +10,7 @@ import dan200.computercraft.shared.network.NetworkMessage; | |||||||
| import net.minecraft.network.FriendlyByteBuf; | import net.minecraft.network.FriendlyByteBuf; | ||||||
| import net.minecraftforge.api.distmarker.Dist; | import net.minecraftforge.api.distmarker.Dist; | ||||||
| import net.minecraftforge.api.distmarker.OnlyIn; | import net.minecraftforge.api.distmarker.OnlyIn; | ||||||
| import net.minecraftforge.fmllegacy.network.NetworkEvent; | import net.minecraftforge.network.NetworkEvent; | ||||||
| 
 | 
 | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| import java.util.UUID; | import java.util.UUID; | ||||||
|   | |||||||
| @@ -17,7 +17,7 @@ import dan200.computercraft.shared.UpgradeManager; | |||||||
| import dan200.computercraft.shared.network.NetworkMessage; | import dan200.computercraft.shared.network.NetworkMessage; | ||||||
| import net.minecraft.network.FriendlyByteBuf; | import net.minecraft.network.FriendlyByteBuf; | ||||||
| import net.minecraft.resources.ResourceLocation; | import net.minecraft.resources.ResourceLocation; | ||||||
| import net.minecraftforge.fmllegacy.network.NetworkEvent; | import net.minecraftforge.network.NetworkEvent; | ||||||
| import net.minecraftforge.registries.IForgeRegistry; | import net.minecraftforge.registries.IForgeRegistry; | ||||||
| import net.minecraftforge.registries.RegistryManager; | import net.minecraftforge.registries.RegistryManager; | ||||||
| 
 | 
 | ||||||
|   | |||||||
| @@ -13,7 +13,7 @@ import net.minecraft.client.Minecraft; | |||||||
| import net.minecraft.client.gui.screens.Screen; | import net.minecraft.client.gui.screens.Screen; | ||||||
| import net.minecraft.network.FriendlyByteBuf; | import net.minecraft.network.FriendlyByteBuf; | ||||||
| import net.minecraft.network.chat.Component; | import net.minecraft.network.chat.Component; | ||||||
| import net.minecraftforge.fmllegacy.network.NetworkEvent; | import net.minecraftforge.network.NetworkEvent; | ||||||
| 
 | 
 | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| 
 | 
 | ||||||
|   | |||||||
| @@ -12,16 +12,16 @@ import net.minecraft.world.entity.player.Inventory; | |||||||
| import net.minecraft.world.entity.player.Player; | import net.minecraft.world.entity.player.Player; | ||||||
| import net.minecraft.world.inventory.AbstractContainerMenu; | import net.minecraft.world.inventory.AbstractContainerMenu; | ||||||
| import net.minecraft.world.inventory.MenuType; | import net.minecraft.world.inventory.MenuType; | ||||||
| import net.minecraftforge.common.extensions.IForgeContainerType; | import net.minecraftforge.common.extensions.IForgeMenuType; | ||||||
| import net.minecraftforge.fmllegacy.network.IContainerFactory; | import net.minecraftforge.network.IContainerFactory; | ||||||
| import net.minecraftforge.fmllegacy.network.NetworkHooks; | import net.minecraftforge.network.NetworkHooks; | ||||||
| 
 | 
 | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| import java.util.function.Consumer; | import java.util.function.Consumer; | ||||||
| import java.util.function.Function; | import java.util.function.Function; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * An extension over the basic {@link IForgeContainerType}/{@link NetworkHooks#openGui(ServerPlayer, MenuProvider, Consumer)} |  * An extension over the basic {@link IForgeMenuType}/{@link NetworkHooks#openGui(ServerPlayer, MenuProvider, Consumer)} | ||||||
|  * hooks, with a more convenient way of reading and writing data. |  * hooks, with a more convenient way of reading and writing data. | ||||||
|  */ |  */ | ||||||
| public interface ContainerData | public interface ContainerData | ||||||
| @@ -35,7 +35,7 @@ public interface ContainerData | |||||||
| 
 | 
 | ||||||
|     static <C extends AbstractContainerMenu, T extends ContainerData> MenuType<C> toType( Function<FriendlyByteBuf, T> reader, Factory<C, T> factory ) |     static <C extends AbstractContainerMenu, T extends ContainerData> MenuType<C> toType( Function<FriendlyByteBuf, T> reader, Factory<C, T> factory ) | ||||||
|     { |     { | ||||||
|         return IForgeContainerType.create( ( id, player, data ) -> factory.create( id, player, reader.apply( data ) ) ); |         return IForgeMenuType.create( ( id, player, data ) -> factory.create( id, player, reader.apply( data ) ) ); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     static <C extends AbstractContainerMenu, T extends ContainerData> MenuType<C> toType( Function<FriendlyByteBuf, T> reader, FixedFactory<C, T> factory ) |     static <C extends AbstractContainerMenu, T extends ContainerData> MenuType<C> toType( Function<FriendlyByteBuf, T> reader, FixedFactory<C, T> factory ) | ||||||
| @@ -60,7 +60,7 @@ public interface ContainerData | |||||||
| 
 | 
 | ||||||
|         private FixedPointContainerFactory( Function<FriendlyByteBuf, T> reader, FixedFactory<C, T> factory ) |         private FixedPointContainerFactory( Function<FriendlyByteBuf, T> reader, FixedFactory<C, T> factory ) | ||||||
|         { |         { | ||||||
|             MenuType<C> type = this.type = IForgeContainerType.create( this ); |             MenuType<C> type = this.type = IForgeMenuType.create( this ); | ||||||
|             impl = ( id, player, data ) -> factory.create( type, id, player, reader.apply( data ) ); |             impl = ( id, player, data ) -> factory.create( type, id, player, reader.apply( data ) ); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ package dan200.computercraft.shared.network.server; | |||||||
| import dan200.computercraft.shared.computer.core.IContainerComputer; | import dan200.computercraft.shared.computer.core.IContainerComputer; | ||||||
| import dan200.computercraft.shared.computer.core.ServerComputer; | import dan200.computercraft.shared.computer.core.ServerComputer; | ||||||
| import net.minecraft.network.FriendlyByteBuf; | import net.minecraft.network.FriendlyByteBuf; | ||||||
| import net.minecraftforge.fmllegacy.network.NetworkEvent; | import net.minecraftforge.network.NetworkEvent; | ||||||
| 
 | 
 | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| 
 | 
 | ||||||
|   | |||||||
| @@ -10,7 +10,7 @@ import dan200.computercraft.shared.computer.core.IContainerComputer; | |||||||
| import dan200.computercraft.shared.computer.core.ServerComputer; | import dan200.computercraft.shared.computer.core.ServerComputer; | ||||||
| import dan200.computercraft.shared.network.NetworkMessage; | import dan200.computercraft.shared.network.NetworkMessage; | ||||||
| import net.minecraft.network.FriendlyByteBuf; | import net.minecraft.network.FriendlyByteBuf; | ||||||
| import net.minecraftforge.fmllegacy.network.NetworkEvent; | import net.minecraftforge.network.NetworkEvent; | ||||||
| 
 | 
 | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| 
 | 
 | ||||||
|   | |||||||
| @@ -9,7 +9,7 @@ import dan200.computercraft.shared.computer.core.IContainerComputer; | |||||||
| import dan200.computercraft.shared.computer.core.ServerComputer; | import dan200.computercraft.shared.computer.core.ServerComputer; | ||||||
| import net.minecraft.network.FriendlyByteBuf; | import net.minecraft.network.FriendlyByteBuf; | ||||||
| import net.minecraft.server.level.ServerPlayer; | import net.minecraft.server.level.ServerPlayer; | ||||||
| import net.minecraftforge.fmllegacy.network.NetworkEvent; | import net.minecraftforge.network.NetworkEvent; | ||||||
| 
 | 
 | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| 
 | 
 | ||||||
|   | |||||||
| @@ -9,7 +9,7 @@ import dan200.computercraft.shared.computer.core.IContainerComputer; | |||||||
| import dan200.computercraft.shared.computer.core.InputState; | import dan200.computercraft.shared.computer.core.InputState; | ||||||
| import dan200.computercraft.shared.computer.core.ServerComputer; | import dan200.computercraft.shared.computer.core.ServerComputer; | ||||||
| import net.minecraft.network.FriendlyByteBuf; | import net.minecraft.network.FriendlyByteBuf; | ||||||
| import net.minecraftforge.fmllegacy.network.NetworkEvent; | import net.minecraftforge.network.NetworkEvent; | ||||||
| 
 | 
 | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| 
 | 
 | ||||||
|   | |||||||
| @@ -9,7 +9,7 @@ import dan200.computercraft.shared.computer.core.IContainerComputer; | |||||||
| import dan200.computercraft.shared.computer.core.InputState; | import dan200.computercraft.shared.computer.core.InputState; | ||||||
| import dan200.computercraft.shared.computer.core.ServerComputer; | import dan200.computercraft.shared.computer.core.ServerComputer; | ||||||
| import net.minecraft.network.FriendlyByteBuf; | import net.minecraft.network.FriendlyByteBuf; | ||||||
| import net.minecraftforge.fmllegacy.network.NetworkEvent; | import net.minecraftforge.network.NetworkEvent; | ||||||
| 
 | 
 | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| 
 | 
 | ||||||
|   | |||||||
| @@ -10,7 +10,7 @@ import dan200.computercraft.shared.computer.core.ServerComputer; | |||||||
| import dan200.computercraft.shared.util.NBTUtil; | import dan200.computercraft.shared.util.NBTUtil; | ||||||
| import net.minecraft.nbt.CompoundTag; | import net.minecraft.nbt.CompoundTag; | ||||||
| import net.minecraft.network.FriendlyByteBuf; | import net.minecraft.network.FriendlyByteBuf; | ||||||
| import net.minecraftforge.fmllegacy.network.NetworkEvent; | import net.minecraftforge.network.NetworkEvent; | ||||||
| 
 | 
 | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| import javax.annotation.Nullable; | import javax.annotation.Nullable; | ||||||
|   | |||||||
| @@ -9,7 +9,7 @@ import dan200.computercraft.ComputerCraft; | |||||||
| import dan200.computercraft.shared.computer.core.ServerComputer; | import dan200.computercraft.shared.computer.core.ServerComputer; | ||||||
| import dan200.computercraft.shared.network.NetworkMessage; | import dan200.computercraft.shared.network.NetworkMessage; | ||||||
| import net.minecraft.network.FriendlyByteBuf; | import net.minecraft.network.FriendlyByteBuf; | ||||||
| import net.minecraftforge.fmllegacy.network.NetworkEvent; | import net.minecraftforge.network.NetworkEvent; | ||||||
| 
 | 
 | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| 
 | 
 | ||||||
|   | |||||||
| @@ -14,7 +14,7 @@ import dan200.computercraft.shared.network.NetworkHandler; | |||||||
| import io.netty.handler.codec.DecoderException; | import io.netty.handler.codec.DecoderException; | ||||||
| import net.minecraft.network.FriendlyByteBuf; | import net.minecraft.network.FriendlyByteBuf; | ||||||
| import net.minecraft.server.level.ServerPlayer; | import net.minecraft.server.level.ServerPlayer; | ||||||
| import net.minecraftforge.fmllegacy.network.NetworkEvent; | import net.minecraftforge.network.NetworkEvent; | ||||||
| 
 | 
 | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| import java.nio.ByteBuffer; | import java.nio.ByteBuffer; | ||||||
|   | |||||||
| @@ -37,9 +37,9 @@ import net.minecraft.world.level.block.state.BlockState; | |||||||
| import net.minecraft.world.phys.BlockHitResult; | import net.minecraft.world.phys.BlockHitResult; | ||||||
| import net.minecraftforge.common.capabilities.Capability; | import net.minecraftforge.common.capabilities.Capability; | ||||||
| import net.minecraftforge.common.util.LazyOptional; | import net.minecraftforge.common.util.LazyOptional; | ||||||
| import net.minecraftforge.fmllegacy.network.NetworkHooks; |  | ||||||
| import net.minecraftforge.items.IItemHandlerModifiable; | import net.minecraftforge.items.IItemHandlerModifiable; | ||||||
| import net.minecraftforge.items.wrapper.InvWrapper; | import net.minecraftforge.items.wrapper.InvWrapper; | ||||||
|  | import net.minecraftforge.network.NetworkHooks; | ||||||
| 
 | 
 | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| import javax.annotation.Nullable; | import javax.annotation.Nullable; | ||||||
|   | |||||||
| @@ -60,9 +60,9 @@ public class ItemData | |||||||
|             data.put( "maxDamage", stack.getMaxDamage() ); |             data.put( "maxDamage", stack.getMaxDamage() ); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if( stack.getItem().showDurabilityBar( stack ) ) |         if( stack.getItem().isBarVisible( stack ) ) | ||||||
|         { |         { | ||||||
|             data.put( "durability", stack.getItem().getDurabilityForDisplay( stack ) ); |             data.put( "durability", stack.getItem().getBarWidth( stack ) / 13.0 ); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         data.put( "tags", DataHelpers.getTags( stack.getItem().getTags() ) ); |         data.put( "tags", DataHelpers.getTags( stack.getItem().getTags() ) ); | ||||||
|   | |||||||
| @@ -98,7 +98,7 @@ public class BlockCable extends BlockGeneric implements SimpleWaterloggedBlock | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Override |     @Override | ||||||
|     public boolean removedByPlayer( BlockState state, Level world, BlockPos pos, Player player, boolean willHarvest, FluidState fluid ) |     public boolean onDestroyedByPlayer( BlockState state, Level world, BlockPos pos, Player player, boolean willHarvest, FluidState fluid ) | ||||||
|     { |     { | ||||||
|         if( state.getValue( CABLE ) && state.getValue( MODEM ).getFacing() != null ) |         if( state.getValue( CABLE ) && state.getValue( MODEM ).getFacing() != null ) | ||||||
|         { |         { | ||||||
| @@ -140,12 +140,12 @@ public class BlockCable extends BlockGeneric implements SimpleWaterloggedBlock | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         return super.removedByPlayer( state, world, pos, player, willHarvest, fluid ); |         return super.onDestroyedByPlayer( state, world, pos, player, willHarvest, fluid ); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Nonnull |     @Nonnull | ||||||
|     @Override |     @Override | ||||||
|     public ItemStack getPickBlock( BlockState state, HitResult hit, BlockGetter world, BlockPos pos, Player player ) |     public ItemStack getCloneItemStack( BlockState state, HitResult hit, BlockGetter world, BlockPos pos, Player player ) | ||||||
|     { |     { | ||||||
|         Direction modem = state.getValue( MODEM ).getFacing(); |         Direction modem = state.getValue( MODEM ).getFacing(); | ||||||
|         boolean cable = state.getValue( CABLE ); |         boolean cable = state.getValue( CABLE ); | ||||||
|   | |||||||
| @@ -346,7 +346,7 @@ public class TileCable extends TileGeneric | |||||||
|         for( Direction facing : DirectionUtil.FACINGS ) |         for( Direction facing : DirectionUtil.FACINGS ) | ||||||
|         { |         { | ||||||
|             BlockPos offset = current.relative( facing ); |             BlockPos offset = current.relative( facing ); | ||||||
|             if( !world.isAreaLoaded( offset, 0 ) ) continue; |             if( !world.isLoaded( offset ) ) continue; | ||||||
| 
 | 
 | ||||||
|             LazyOptional<IWiredElement> element = ComputerCraftAPI.getWiredElementAt( world, offset, facing.getOpposite() ); |             LazyOptional<IWiredElement> element = ComputerCraftAPI.getWiredElementAt( world, offset, facing.getOpposite() ); | ||||||
|             if( !element.isPresent() ) continue; |             if( !element.isPresent() ) continue; | ||||||
|   | |||||||
| @@ -306,7 +306,7 @@ public class TileWiredModemFull extends TileGeneric | |||||||
|         for( Direction facing : DirectionUtil.FACINGS ) |         for( Direction facing : DirectionUtil.FACINGS ) | ||||||
|         { |         { | ||||||
|             BlockPos offset = current.relative( facing ); |             BlockPos offset = current.relative( facing ); | ||||||
|             if( !world.isAreaLoaded( offset, 0 ) ) continue; |             if( !world.isLoaded( offset ) ) continue; | ||||||
| 
 | 
 | ||||||
|             LazyOptional<IWiredElement> element = ComputerCraftAPI.getWiredElementAt( world, offset, facing.getOpposite() ); |             LazyOptional<IWiredElement> element = ComputerCraftAPI.getWiredElementAt( world, offset, facing.getOpposite() ); | ||||||
|             if( !element.isPresent() ) continue; |             if( !element.isPresent() ) continue; | ||||||
|   | |||||||
| @@ -25,7 +25,7 @@ import net.minecraft.world.level.block.state.properties.DirectionProperty; | |||||||
| import net.minecraft.world.level.material.FluidState; | import net.minecraft.world.level.material.FluidState; | ||||||
| import net.minecraft.world.phys.shapes.CollisionContext; | import net.minecraft.world.phys.shapes.CollisionContext; | ||||||
| import net.minecraft.world.phys.shapes.VoxelShape; | import net.minecraft.world.phys.shapes.VoxelShape; | ||||||
| import net.minecraftforge.fmllegacy.RegistryObject; | import net.minecraftforge.registries.RegistryObject; | ||||||
| 
 | 
 | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| import javax.annotation.Nullable; | import javax.annotation.Nullable; | ||||||
|   | |||||||
| @@ -21,7 +21,7 @@ import net.minecraft.world.level.block.state.properties.BlockStateProperties; | |||||||
| import net.minecraft.world.level.block.state.properties.DirectionProperty; | import net.minecraft.world.level.block.state.properties.DirectionProperty; | ||||||
| import net.minecraft.world.level.block.state.properties.EnumProperty; | import net.minecraft.world.level.block.state.properties.EnumProperty; | ||||||
| import net.minecraftforge.common.util.FakePlayer; | import net.minecraftforge.common.util.FakePlayer; | ||||||
| import net.minecraftforge.fmllegacy.RegistryObject; | import net.minecraftforge.registries.RegistryObject; | ||||||
| 
 | 
 | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| import javax.annotation.Nullable; | import javax.annotation.Nullable; | ||||||
|   | |||||||
| @@ -101,7 +101,7 @@ public final class MonitorWatcher | |||||||
|             if( !(world instanceof ServerLevel) ) continue; |             if( !(world instanceof ServerLevel) ) continue; | ||||||
| 
 | 
 | ||||||
|             LevelChunk chunk = world.getChunkAt( pos ); |             LevelChunk chunk = world.getChunkAt( pos ); | ||||||
|             if( ((ServerLevel) world).getChunkSource().chunkMap.getPlayers( chunk.getPos(), false ).findAny().isEmpty() ) |             if( ((ServerLevel) world).getChunkSource().chunkMap.getPlayers( chunk.getPos(), false ).isEmpty() ) | ||||||
|             { |             { | ||||||
|                 continue; |                 continue; | ||||||
|             } |             } | ||||||
|   | |||||||
| @@ -261,7 +261,7 @@ public class TileMonitor extends TileGeneric | |||||||
|     @Override |     @Override | ||||||
|     public final ClientboundBlockEntityDataPacket getUpdatePacket() |     public final ClientboundBlockEntityDataPacket getUpdatePacket() | ||||||
|     { |     { | ||||||
|         return new ClientboundBlockEntityDataPacket( worldPosition, 0, getUpdateTag() ); |         return ClientboundBlockEntityDataPacket.create( this ); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Nonnull |     @Nonnull | ||||||
| @@ -398,7 +398,7 @@ public class TileMonitor extends TileGeneric | |||||||
|         BlockPos pos = toWorldPos( x, y ); |         BlockPos pos = toWorldPos( x, y ); | ||||||
| 
 | 
 | ||||||
|         Level world = getLevel(); |         Level world = getLevel(); | ||||||
|         if( world == null || !world.isAreaLoaded( pos, 0 ) ) return MonitorState.UNLOADED; |         if( world == null || !world.isLoaded( pos ) ) return MonitorState.UNLOADED; | ||||||
| 
 | 
 | ||||||
|         BlockEntity tile = world.getBlockEntity( pos ); |         BlockEntity tile = world.getBlockEntity( pos ); | ||||||
|         if( !(tile instanceof TileMonitor monitor) ) return MonitorState.MISSING; |         if( !(tile instanceof TileMonitor monitor) ) return MonitorState.MISSING; | ||||||
|   | |||||||
| @@ -31,10 +31,10 @@ import net.minecraft.world.phys.BlockHitResult; | |||||||
| import net.minecraft.world.phys.Vec3; | import net.minecraft.world.phys.Vec3; | ||||||
| import net.minecraftforge.common.capabilities.Capability; | import net.minecraftforge.common.capabilities.Capability; | ||||||
| import net.minecraftforge.common.util.LazyOptional; | import net.minecraftforge.common.util.LazyOptional; | ||||||
| import net.minecraftforge.fmllegacy.network.NetworkHooks; |  | ||||||
| import net.minecraftforge.items.IItemHandler; | import net.minecraftforge.items.IItemHandler; | ||||||
| import net.minecraftforge.items.wrapper.InvWrapper; | import net.minecraftforge.items.wrapper.InvWrapper; | ||||||
| import net.minecraftforge.items.wrapper.SidedInvWrapper; | import net.minecraftforge.items.wrapper.SidedInvWrapper; | ||||||
|  | import net.minecraftforge.network.NetworkHooks; | ||||||
| 
 | 
 | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| import javax.annotation.Nullable; | import javax.annotation.Nullable; | ||||||
|   | |||||||
| @@ -9,8 +9,7 @@ import dan200.computercraft.api.peripheral.IComputerAccess; | |||||||
| import dan200.computercraft.shared.network.NetworkHandler; | import dan200.computercraft.shared.network.NetworkHandler; | ||||||
| import dan200.computercraft.shared.network.client.SpeakerStopClientMessage; | import dan200.computercraft.shared.network.client.SpeakerStopClientMessage; | ||||||
| import net.minecraft.server.MinecraftServer; | import net.minecraft.server.MinecraftServer; | ||||||
| import net.minecraftforge.fml.LogicalSide; | import net.minecraftforge.server.ServerLifecycleHooks; | ||||||
| import net.minecraftforge.fmllegacy.LogicalSidedProvider; |  | ||||||
| 
 | 
 | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| import java.util.UUID; | import java.util.UUID; | ||||||
| @@ -34,7 +33,7 @@ public abstract class UpgradeSpeakerPeripheral extends SpeakerPeripheral | |||||||
|     public void detach( @Nonnull IComputerAccess computer ) |     public void detach( @Nonnull IComputerAccess computer ) | ||||||
|     { |     { | ||||||
|         // We could be in the process of shutting down the server, so we can't send packets in this case. |         // We could be in the process of shutting down the server, so we can't send packets in this case. | ||||||
|         MinecraftServer server = LogicalSidedProvider.INSTANCE.get( LogicalSide.SERVER ); |         MinecraftServer server = ServerLifecycleHooks.getCurrentServer(); | ||||||
|         if( server == null || server.isStopped() ) return; |         if( server == null || server.isStopped() ) return; | ||||||
| 
 | 
 | ||||||
|         NetworkHandler.sendToAllPlayers( new SpeakerStopClientMessage( source ) ); |         NetworkHandler.sendToAllPlayers( new SpeakerStopClientMessage( source ) ); | ||||||
|   | |||||||
| @@ -42,7 +42,7 @@ import net.minecraft.world.phys.Vec3; | |||||||
| import net.minecraft.world.phys.shapes.CollisionContext; | import net.minecraft.world.phys.shapes.CollisionContext; | ||||||
| import net.minecraft.world.phys.shapes.Shapes; | import net.minecraft.world.phys.shapes.Shapes; | ||||||
| import net.minecraft.world.phys.shapes.VoxelShape; | import net.minecraft.world.phys.shapes.VoxelShape; | ||||||
| import net.minecraftforge.fmllegacy.RegistryObject; | import net.minecraftforge.registries.RegistryObject; | ||||||
| 
 | 
 | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| import javax.annotation.Nullable; | import javax.annotation.Nullable; | ||||||
|   | |||||||
| @@ -304,7 +304,7 @@ public class TurtleBrain implements ITurtleAccess | |||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         // Ensure the chunk is loaded |         // Ensure the chunk is loaded | ||||||
|         if( !world.isAreaLoaded( pos, 0 ) ) return false; |         if( !world.isLoaded( pos ) ) return false; | ||||||
| 
 | 
 | ||||||
|         // Ensure we're inside the world border |         // Ensure we're inside the world border | ||||||
|         if( !world.getWorldBorder().isWithinBounds( pos ) ) return false; |         if( !world.getWorldBorder().isWithinBounds( pos ) ) return false; | ||||||
|   | |||||||
| @@ -137,7 +137,7 @@ public class TurtleMoveCommand implements ITurtleCommand | |||||||
|             return TurtleCommandResult.failure( "Cannot enter protected area" ); |             return TurtleCommandResult.failure( "Cannot enter protected area" ); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if( !world.isAreaLoaded( position, 0 ) ) return TurtleCommandResult.failure( "Cannot leave loaded world" ); |         if( !world.isLoaded( position ) ) return TurtleCommandResult.failure( "Cannot leave loaded world" ); | ||||||
|         if( !world.getWorldBorder().isWithinBounds( position ) ) |         if( !world.getWorldBorder().isWithinBounds( position ) ) | ||||||
|         { |         { | ||||||
|             return TurtleCommandResult.failure( "Cannot pass the world border" ); |             return TurtleCommandResult.failure( "Cannot pass the world border" ); | ||||||
|   | |||||||
| @@ -27,13 +27,13 @@ import net.minecraft.world.item.*; | |||||||
| import net.minecraft.world.item.context.BlockPlaceContext; | import net.minecraft.world.item.context.BlockPlaceContext; | ||||||
| import net.minecraft.world.item.context.UseOnContext; | import net.minecraft.world.item.context.UseOnContext; | ||||||
| import net.minecraft.world.level.Level; | import net.minecraft.world.level.Level; | ||||||
|  | import net.minecraft.world.level.block.Block; | ||||||
| import net.minecraft.world.level.block.entity.BlockEntity; | import net.minecraft.world.level.block.entity.BlockEntity; | ||||||
| import net.minecraft.world.level.block.entity.SignBlockEntity; | import net.minecraft.world.level.block.entity.SignBlockEntity; | ||||||
| import net.minecraft.world.level.block.state.BlockState; | import net.minecraft.world.level.block.state.BlockState; | ||||||
| import net.minecraft.world.phys.BlockHitResult; | import net.minecraft.world.phys.BlockHitResult; | ||||||
| import net.minecraft.world.phys.Vec3; | import net.minecraft.world.phys.Vec3; | ||||||
| import net.minecraftforge.common.ForgeHooks; | import net.minecraftforge.common.ForgeHooks; | ||||||
| import net.minecraftforge.common.util.Constants; |  | ||||||
| import net.minecraftforge.event.entity.player.PlayerInteractEvent; | import net.minecraftforge.event.entity.player.PlayerInteractEvent; | ||||||
| import net.minecraftforge.eventbus.api.Event.Result; | import net.minecraftforge.eventbus.api.Event.Result; | ||||||
| import net.minecraftforge.items.IItemHandler; | import net.minecraftforge.items.IItemHandler; | ||||||
| @@ -321,7 +321,7 @@ public class TurtlePlaceCommand implements ITurtleCommand | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         signTile.setChanged(); |         signTile.setChanged(); | ||||||
|         world.sendBlockUpdated( tile.getBlockPos(), tile.getBlockState(), tile.getBlockState(), Constants.BlockFlags.DEFAULT ); |         world.sendBlockUpdated( tile.getBlockPos(), tile.getBlockState(), tile.getBlockState(), Block.UPDATE_ALL ); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     private static class ErrorMessage |     private static class ErrorMessage | ||||||
|   | |||||||
| @@ -17,7 +17,7 @@ import net.minecraft.world.item.crafting.Recipe; | |||||||
| import net.minecraft.world.item.crafting.RecipeType; | import net.minecraft.world.item.crafting.RecipeType; | ||||||
| import net.minecraft.world.level.Level; | import net.minecraft.world.level.Level; | ||||||
| import net.minecraftforge.common.ForgeHooks; | import net.minecraftforge.common.ForgeHooks; | ||||||
| import net.minecraftforge.fmllegacy.hooks.BasicEventHooks; | import net.minecraftforge.event.ForgeEventFactory; | ||||||
| 
 | 
 | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| import javax.annotation.Nullable; | import javax.annotation.Nullable; | ||||||
| @@ -91,7 +91,7 @@ public class TurtleInventoryCrafting extends CraftingContainer | |||||||
|             results.add( result ); |             results.add( result ); | ||||||
| 
 | 
 | ||||||
|             result.onCraftedBy( world, player, result.getCount() ); |             result.onCraftedBy( world, player, result.getCount() ); | ||||||
|             BasicEventHooks.firePlayerCraftingEvent( player, result, this ); |             ForgeEventFactory.firePlayerCraftingEvent( player, result, this ); | ||||||
| 
 | 
 | ||||||
|             ForgeHooks.setCraftingPlayer( player ); |             ForgeHooks.setCraftingPlayer( player ); | ||||||
|             NonNullList<ItemStack> remainders = recipe.getRemainingItems( this ); |             NonNullList<ItemStack> remainders = recipe.getRemainingItems( this ); | ||||||
|   | |||||||
| @@ -255,7 +255,7 @@ public class TurtleTool extends AbstractTurtleUpgrade | |||||||
| 
 | 
 | ||||||
|         // Destroy the block |         // Destroy the block | ||||||
|         boolean canHarvest = state.canHarvestBlock( world, blockPosition, turtlePlayer ); |         boolean canHarvest = state.canHarvestBlock( world, blockPosition, turtlePlayer ); | ||||||
|         boolean canBreak = state.removedByPlayer( world, blockPosition, turtlePlayer, canHarvest, fluidState ); |         boolean canBreak = state.onDestroyedByPlayer( world, blockPosition, turtlePlayer, canHarvest, fluidState ); | ||||||
|         if( canBreak ) state.getBlock().destroy( world, blockPosition, state ); |         if( canBreak ) state.getBlock().destroy( world, blockPosition, state ); | ||||||
|         if( canHarvest && canBreak ) |         if( canHarvest && canBreak ) | ||||||
|         { |         { | ||||||
|   | |||||||
| @@ -11,7 +11,7 @@ import com.google.gson.reflect.TypeToken; | |||||||
| import dan200.computercraft.ComputerCraft; | import dan200.computercraft.ComputerCraft; | ||||||
| import net.minecraft.server.MinecraftServer; | import net.minecraft.server.MinecraftServer; | ||||||
| import net.minecraft.world.level.storage.LevelResource; | import net.minecraft.world.level.storage.LevelResource; | ||||||
| import net.minecraftforge.fmllegacy.server.ServerLifecycleHooks; | import net.minecraftforge.server.ServerLifecycleHooks; | ||||||
| 
 | 
 | ||||||
| import java.io.File; | import java.io.File; | ||||||
| import java.io.Reader; | import java.io.Reader; | ||||||
|   | |||||||
| @@ -10,7 +10,8 @@ import dan200.computercraft.ComputerCraft; | |||||||
| import dan200.computercraft.shared.common.TileGeneric; | import dan200.computercraft.shared.common.TileGeneric; | ||||||
| import net.minecraft.core.BlockPos; | import net.minecraft.core.BlockPos; | ||||||
| import net.minecraft.world.level.Level; | import net.minecraft.world.level.Level; | ||||||
| import net.minecraft.world.level.TickList; | import net.minecraft.world.level.LevelAccessor; | ||||||
|  | import net.minecraft.world.level.block.Block; | ||||||
| import net.minecraft.world.level.block.entity.BlockEntity; | import net.minecraft.world.level.block.entity.BlockEntity; | ||||||
| import net.minecraftforge.event.TickEvent; | import net.minecraftforge.event.TickEvent; | ||||||
| import net.minecraftforge.eventbus.api.SubscribeEvent; | import net.minecraftforge.eventbus.api.SubscribeEvent; | ||||||
| @@ -21,7 +22,7 @@ import java.util.Iterator; | |||||||
| import java.util.Set; | import java.util.Set; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * A thread-safe version of {@link TickList#scheduleTick(BlockPos, Object, int)}. |  * A thread-safe version of {@link LevelAccessor#scheduleTick(BlockPos, Block, int)}. | ||||||
|  * |  * | ||||||
|  * We use this when modems and other peripherals change a block in a different thread. |  * We use this when modems and other peripherals change a block in a different thread. | ||||||
|  */ |  */ | ||||||
| @@ -58,9 +59,9 @@ public final class TickScheduler | |||||||
|             Level world = tile.getLevel(); |             Level world = tile.getLevel(); | ||||||
|             BlockPos pos = tile.getBlockPos(); |             BlockPos pos = tile.getBlockPos(); | ||||||
| 
 | 
 | ||||||
|             if( world != null && pos != null && world.isAreaLoaded( pos, 0 ) && world.getBlockEntity( pos ) == tile ) |             if( world != null && pos != null && world.isLoaded( pos ) && world.getBlockEntity( pos ) == tile ) | ||||||
|             { |             { | ||||||
|                 world.getBlockTicks().scheduleTick( pos, tile.getBlockState().getBlock(), 0 ); |                 world.scheduleTick( pos, tile.getBlockState().getBlock(), 0 ); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -48,7 +48,7 @@ public final class WaterloggableHelpers | |||||||
|     { |     { | ||||||
|         if( state.getValue( WATERLOGGED ) ) |         if( state.getValue( WATERLOGGED ) ) | ||||||
|         { |         { | ||||||
|             world.getLiquidTicks().scheduleTick( pos, Fluids.WATER, Fluids.WATER.getTickDelay( world ) ); |             world.scheduleTick( pos, Fluids.WATER, Fluids.WATER.getTickDelay( world ) ); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| modLoader="javafml" | modLoader="javafml" | ||||||
| loaderVersion="[37,38)" | loaderVersion="[38,39)" | ||||||
|  |  | ||||||
| issueTrackerURL="https://github.com/cc-tweaked/CC-Tweaked/issues" | issueTrackerURL="https://github.com/cc-tweaked/CC-Tweaked/issues" | ||||||
| logoFile="pack.png" | logoFile="pack.png" | ||||||
| @@ -21,6 +21,6 @@ CC: Tweaked is a fork of ComputerCraft, adding programmable computers, turtles a | |||||||
| [[dependencies.computercraft]] | [[dependencies.computercraft]] | ||||||
|     modId="forge" |     modId="forge" | ||||||
|     mandatory=true |     mandatory=true | ||||||
|     versionRange="[37.0.85,38)" |     versionRange="[38.0.0,39)" | ||||||
|     ordering="NONE" |     ordering="NONE" | ||||||
|     side="BOTH" |     side="BOTH" | ||||||
|   | |||||||
| @@ -27,7 +27,7 @@ import net.minecraft.world.level.levelgen.WorldGenSettings; | |||||||
| import net.minecraft.world.level.levelgen.flat.FlatLayerInfo; | import net.minecraft.world.level.levelgen.flat.FlatLayerInfo; | ||||||
| import net.minecraft.world.level.levelgen.flat.FlatLevelGeneratorSettings; | import net.minecraft.world.level.levelgen.flat.FlatLevelGeneratorSettings; | ||||||
| import net.minecraftforge.api.distmarker.Dist; | import net.minecraftforge.api.distmarker.Dist; | ||||||
| import net.minecraftforge.client.event.GuiScreenEvent; | import net.minecraftforge.client.event.ScreenEvent; | ||||||
| import net.minecraftforge.eventbus.api.SubscribeEvent; | import net.minecraftforge.eventbus.api.SubscribeEvent; | ||||||
| import net.minecraftforge.fml.common.Mod; | import net.minecraftforge.fml.common.Mod; | ||||||
| import org.apache.logging.log4j.LogManager; | import org.apache.logging.log4j.LogManager; | ||||||
| @@ -50,9 +50,9 @@ public final class ClientHooks | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @SubscribeEvent |     @SubscribeEvent | ||||||
|     public static void onGuiInit( GuiScreenEvent.InitGuiEvent event ) |     public static void onGuiInit( ScreenEvent.InitScreenEvent event ) | ||||||
|     { |     { | ||||||
|         if( triggered || !(event.getGui() instanceof TitleScreen) ) return; |         if( triggered || !(event.getScreen() instanceof TitleScreen) ) return; | ||||||
|         triggered = true; |         triggered = true; | ||||||
| 
 | 
 | ||||||
|         ClientHooks.openWorld(); |         ClientHooks.openWorld(); | ||||||
| @@ -93,7 +93,7 @@ public final class ClientHooks | |||||||
| 
 | 
 | ||||||
|             WorldGenSettings generator = new WorldGenSettings( 0, false, false, withOverworld( |             WorldGenSettings generator = new WorldGenSettings( 0, false, false, withOverworld( | ||||||
|                 dimensions, |                 dimensions, | ||||||
|                 DimensionType.defaultDimensions( dimensions, biomes, registries.registryOrThrow( Registry.NOISE_GENERATOR_SETTINGS_REGISTRY ), 0 ), |                 DimensionType.defaultDimensions( registries, 0 ), | ||||||
|                 new FlatLevelSource( flatSettings ) |                 new FlatLevelSource( flatSettings ) | ||||||
|             ) ); |             ) ); | ||||||
| 
 | 
 | ||||||
|   | |||||||
| @@ -5,9 +5,9 @@ | |||||||
|  */ |  */ | ||||||
| package dan200.computercraft.ingame.mod; | package dan200.computercraft.ingame.mod; | ||||||
| 
 | 
 | ||||||
|  | import dan200.computercraft.ingame.api.Times; | ||||||
| import net.minecraft.ChatFormatting; | import net.minecraft.ChatFormatting; | ||||||
| import net.minecraft.SharedConstants; | import net.minecraft.SharedConstants; | ||||||
| import dan200.computercraft.ingame.api.Times; |  | ||||||
| import net.minecraft.client.Minecraft; | import net.minecraft.client.Minecraft; | ||||||
| import net.minecraft.commands.CommandSourceStack; | import net.minecraft.commands.CommandSourceStack; | ||||||
| import net.minecraft.core.BlockPos; | import net.minecraft.core.BlockPos; | ||||||
| @@ -21,11 +21,11 @@ import net.minecraft.world.level.block.Rotation; | |||||||
| import net.minecraft.world.level.levelgen.Heightmap; | import net.minecraft.world.level.levelgen.Heightmap; | ||||||
| import net.minecraftforge.event.RegisterCommandsEvent; | import net.minecraftforge.event.RegisterCommandsEvent; | ||||||
| import net.minecraftforge.event.TickEvent; | import net.minecraftforge.event.TickEvent; | ||||||
|  | import net.minecraftforge.event.server.ServerStartedEvent; | ||||||
| import net.minecraftforge.eventbus.api.SubscribeEvent; | import net.minecraftforge.eventbus.api.SubscribeEvent; | ||||||
| import net.minecraftforge.fml.common.Mod; | import net.minecraftforge.fml.common.Mod; | ||||||
| import net.minecraftforge.fml.loading.FMLLoader; | import net.minecraftforge.fml.loading.FMLLoader; | ||||||
| import net.minecraftforge.fmllegacy.server.ServerLifecycleHooks; | import net.minecraftforge.server.ServerLifecycleHooks; | ||||||
| import net.minecraftforge.fmlserverevents.FMLServerStartedEvent; |  | ||||||
| import org.apache.logging.log4j.LogManager; | import org.apache.logging.log4j.LogManager; | ||||||
| import org.apache.logging.log4j.Logger; | import org.apache.logging.log4j.Logger; | ||||||
| 
 | 
 | ||||||
| @@ -49,7 +49,7 @@ public class TestHooks | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @SubscribeEvent |     @SubscribeEvent | ||||||
|     public static void onServerStarted( FMLServerStartedEvent event ) |     public static void onServerStarted( ServerStartedEvent event ) | ||||||
|     { |     { | ||||||
|         MinecraftServer server = event.getServer(); |         MinecraftServer server = event.getServer(); | ||||||
|         GameRules rules = server.getGameRules(); |         GameRules rules = server.getGameRules(); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Jonathan Coates
					Jonathan Coates