1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-01-14 19:25:43 +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:
Jonathan Coates 2021-11-30 22:48:37 +00:00
parent 92fd93c0e0
commit 179da1d8cf
No known key found for this signature in database
GPG Key ID: B9E431FF07C98D06
64 changed files with 124 additions and 122 deletions

View File

@ -5,7 +5,7 @@ buildscript {
maven { url = 'https://maven.parchmentmc.org' }
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:5.1.24'
classpath 'net.minecraftforge.gradle:ForgeGradle:5.1.+'
classpath 'org.parchmentmc:librarian:1.+'
}
}
@ -29,7 +29,7 @@ version = mod_version
group = "org.squiddev"
archivesBaseName = "cc-tweaked-${mc_version}"
def javaVersion = JavaLanguageVersion.of(16)
def javaVersion = JavaLanguageVersion.of(17)
java {
toolchain {
languageVersion = javaVersion
@ -47,6 +47,7 @@ tasks.withType(JavaExec).configureEach {
sourceSets {
main.java {
exclude 'dan200/computercraft/shared/integration/jei/**'
exclude 'dan200/computercraft/shared/integration/morered/**'
}
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/testMod/resources/META-INF/accesstransformer.cfg')
@ -151,10 +153,8 @@ dependencies {
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("commoble.morered:morered-1.16.5:2.1.1.0")
runtimeOnly fg.deobf("mezz.jei:jei-1.17.1:8.0.0.14")
// compileOnly fg.deobf("mezz.jei:jei-1.17.1:8.0.0.14:api")
// runtimeOnly fg.deobf("mezz.jei:jei-1.17.1:8.0.0.14")
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') {
// Don't run client tests unless explicitly opted into them. They're a bit of a faff
// 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
}
}

View File

@ -4,7 +4,7 @@ org.gradle.jvmargs=-Xmx3G
mod_version=1.99.0
# Minecraft properties (update mods.toml when changing)
mc_version=1.17.1
mc_version=1.18
mapping_version=2021.09.05
forge_version=37.0.85
forge_version=38.0.0
# NO SERIOUSLY, UPDATE mods.toml WHEN CHANGING

View File

@ -38,7 +38,7 @@ import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fmllegacy.server.ServerLifecycleHooks;
import net.minecraftforge.server.ServerLifecycleHooks;
import javax.annotation.Nonnull;
import java.io.File;

View File

@ -32,7 +32,7 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.ColorHandlerEvent;
import net.minecraftforge.client.event.EntityRenderersEvent;
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.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
@ -76,7 +76,7 @@ public final class ClientRegistry
ModelLoaderRegistry.registerLoader( new ResourceLocation( ComputerCraft.MOD_ID, "turtle" ), TurtleModelLoader.INSTANCE );
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" ) );
}
}

View File

@ -71,12 +71,12 @@ public class DynamicImageButton extends Button
RenderSystem.disableDepthTest();
int yTex = yTexStart;
if( isHovered() ) yTex += yDiffTex;
if( isHoveredOrFocused() ) yTex += yDiffTex;
blit( stack, x, y, xTexStart.getAsInt(), yTex, width, height, textureWidth, textureHeight );
RenderSystem.enableDepthTest();
if( isHovered() ) renderToolTip( stack, mouseX, mouseY );
if( isHovered ) renderToolTip( stack, mouseX, mouseY );
}
@Nonnull

View File

@ -45,8 +45,8 @@ public final class CableHighlightRenderer
{
BlockHitResult hit = event.getTarget();
BlockPos pos = hit.getBlockPos();
Level world = event.getInfo().getEntity().getCommandSenderWorld();
Camera info = event.getInfo();
Level world = event.getCamera().getEntity().getCommandSenderWorld();
Camera info = event.getCamera();
BlockState state = world.getBlockState( pos );
@ -67,9 +67,9 @@ public final class CableHighlightRenderer
double yOffset = pos.getY() - cameraPos.y();
double zOffset = pos.getZ() - cameraPos.z();
VertexConsumer buffer = event.getBuffers().getBuffer( RenderType.lines() );
Matrix4f matrix4f = event.getMatrix().last().pose();
Matrix3f normal = event.getMatrix().last().normal();
VertexConsumer buffer = event.getMultiBufferSource().getBuffer( RenderType.lines() );
Matrix4f matrix4f = event.getPoseStack().last().pose();
Matrix3f normal = event.getPoseStack().last().normal();
// TODO: Can we just accesstransformer out LevelRenderer.renderShape?
shape.forAllEdges( ( x1, y1, z1, x2, y2, z2 ) -> {
float xDelta = (float) (x2 - x1);

View File

@ -48,7 +48,7 @@ public final class ItemPocketRenderer extends ItemMapLikeRenderer
event.setCanceled( true );
INSTANCE.renderItemFirstPerson(
event.getMatrixStack(), event.getBuffers(), event.getLight(),
event.getPoseStack(), event.getMultiBufferSource(), event.getPackedLight(),
event.getHand(), event.getInterpolatedPitch(), event.getEquipProgress(), event.getSwingProgress(), event.getItemStack()
);
}

View File

@ -45,7 +45,7 @@ public final class ItemPrintoutRenderer extends ItemMapLikeRenderer
event.setCanceled( true );
INSTANCE.renderItemFirstPerson(
event.getMatrixStack(), event.getBuffers(), event.getLight(),
event.getPoseStack(), event.getMultiBufferSource(), event.getPackedLight(),
event.getHand(), event.getInterpolatedPitch(), event.getEquipProgress(), event.getSwingProgress(), event.getItemStack()
);
}
@ -63,11 +63,11 @@ public final class ItemPrintoutRenderer extends ItemMapLikeRenderer
@SubscribeEvent
public static void onRenderInFrame( RenderItemInFrameEvent event )
{
ItemStack stack = event.getItem();
ItemStack stack = event.getItemStack();
if( !(stack.getItem() instanceof ItemPrintout) ) return;
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
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.translate( -0.5f, -0.5f, 0.0f );
int light = event.getEntityItemFrame().getType() == EntityType.GLOW_ITEM_FRAME ? 0xf000d2 : event.getLight(); // See getLightVal.
drawPrintout( transform, event.getBuffers(), stack, light );
int light = event.getItemFrameEntity().getType() == EntityType.GLOW_ITEM_FRAME ? 0xf000d2 : event.getPackedLight(); // See getLightVal.
drawPrintout( transform, event.getMultiBufferSource(), stack, light );
}
private static void drawPrintout( PoseStack transform, MultiBufferSource render, ItemStack stack, int light )

View File

@ -41,9 +41,9 @@ public final class MonitorHighlightRenderer
public static void drawHighlight( DrawSelectionEvent.HighlightBlock event )
{
// 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();
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() != monitor.getHeight() - 1 ) faces.remove( monitor.getDown() );
PoseStack transformStack = event.getMatrix();
Vec3 cameraPos = event.getInfo().getPosition();
PoseStack transformStack = event.getPoseStack();
Vec3 cameraPos = event.getCamera().getPosition();
transformStack.pushPose();
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
VertexConsumer buffer = event.getBuffers().getBuffer( RenderType.lines() );
VertexConsumer buffer = event.getMultiBufferSource().getBuffer( RenderType.lines() );
Matrix4f transform = transformStack.last().pose();
Matrix3f normal = transformStack.last().normal();
if( faces.contains( NORTH ) || faces.contains( WEST ) ) line( buffer, transform, normal, 0, 0, 0, UP );

View File

@ -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.LootItemBlockStatePropertyCondition;
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;

View File

@ -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.minecraftforge.event.*;
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.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.HashSet;
@ -84,7 +84,7 @@ public final class CommonHooks
}
@SubscribeEvent
public static void onServerStarting( FMLServerStartingEvent event )
public static void onServerStarting( ServerStartingEvent event )
{
MinecraftServer server = event.getServer();
if( server instanceof DedicatedServer dediServer && dediServer.getProperties().enableJmxMonitoring )
@ -94,7 +94,7 @@ public final class CommonHooks
}
@SubscribeEvent
public static void onServerStarted( FMLServerStartedEvent event )
public static void onServerStarted( ServerStartedEvent event )
{
ComputerCraft.serverComputerRegistry.reset();
WirelessNetwork.resetNetworks();
@ -104,7 +104,7 @@ public final class CommonHooks
}
@SubscribeEvent
public static void onServerStopped( FMLServerStoppedEvent event )
public static void onServerStopped( ServerStoppedEvent event )
{
ComputerCraft.serverComputerRegistry.reset();
WirelessNetwork.resetNetworks();

View File

@ -96,11 +96,11 @@ import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.fmllegacy.RegistryObject;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryBuilder;
import net.minecraftforge.registries.RegistryObject;
import java.util.function.BiFunction;

View File

@ -13,7 +13,7 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.ClientChatEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fmllegacy.server.ServerLifecycleHooks;
import net.minecraftforge.server.ServerLifecycleHooks;
import java.io.File;

View 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.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraftforge.fmllegacy.RegistryObject;
import net.minecraftforge.registries.RegistryObject;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

View File

@ -12,11 +12,11 @@ import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
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.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraftforge.common.util.Constants;
import javax.annotation.Nonnull;
@ -36,7 +36,7 @@ public abstract class TileGeneric extends BlockEntity
setChanged();
BlockPos pos = getBlockPos();
BlockState state = getBlockState();
getLevel().sendBlockUpdated( pos, state, state, Constants.BlockFlags.DEFAULT );
getLevel().sendBlockUpdated( pos, state, state, Block.UPDATE_ALL );
}
@Nonnull
@ -76,7 +76,8 @@ public abstract class TileGeneric extends BlockEntity
@Override
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

View File

@ -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.DirectionProperty;
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.Nullable;

View File

@ -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.phys.HitResult;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.fmllegacy.RegistryObject;
import net.minecraftforge.registries.RegistryObject;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@ -119,7 +119,7 @@ public abstract class BlockComputerBase<T extends TileComputerBase> extends Bloc
@Nonnull
@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 );
if( tile instanceof TileComputerBase )
@ -128,7 +128,7 @@ public abstract class BlockComputerBase<T extends TileComputerBase> extends Bloc
if( !result.isEmpty() ) return result;
}
return super.getPickBlock( state, target, world, pos, player );
return super.getCloneItemStack( state, target, world, pos, player );
}
@Override

View File

@ -388,7 +388,7 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
@Override
public final ClientboundBlockEntityDataPacket getUpdatePacket()
{
return new ClientboundBlockEntityDataPacket( worldPosition, 0, getUpdateTag() );
return ClientboundBlockEntityDataPacket.create( this );
}
@Nonnull

View File

@ -28,7 +28,7 @@ import net.minecraft.server.MinecraftServer;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.level.Level;
import net.minecraftforge.fmllegacy.server.ServerLifecycleHooks;
import net.minecraftforge.server.ServerLifecycleHooks;
import net.minecraftforge.versions.mcp.MCPVersion;
import javax.annotation.Nonnull;

View File

@ -16,11 +16,11 @@ import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.fmllegacy.network.NetworkDirection;
import net.minecraftforge.fmllegacy.network.NetworkEvent;
import net.minecraftforge.fmllegacy.network.NetworkRegistry;
import net.minecraftforge.fmllegacy.network.PacketDistributor;
import net.minecraftforge.fmllegacy.network.simple.SimpleChannel;
import net.minecraftforge.network.NetworkDirection;
import net.minecraftforge.network.NetworkEvent;
import net.minecraftforge.network.NetworkRegistry;
import net.minecraftforge.network.PacketDistributor;
import net.minecraftforge.network.simple.SimpleChannel;
import java.util.function.Function;
import java.util.function.Supplier;

View File

@ -6,7 +6,7 @@
package dan200.computercraft.shared.network;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraftforge.fmllegacy.network.NetworkEvent;
import net.minecraftforge.network.NetworkEvent;
import javax.annotation.Nonnull;

View File

@ -10,7 +10,7 @@ import dan200.computercraft.shared.command.text.TableBuilder;
import dan200.computercraft.shared.network.NetworkMessage;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.chat.Component;
import net.minecraftforge.fmllegacy.network.NetworkEvent;
import net.minecraftforge.network.NetworkEvent;
import javax.annotation.Nonnull;

View File

@ -9,7 +9,7 @@ import dan200.computercraft.shared.computer.core.ComputerState;
import dan200.computercraft.shared.computer.core.ServerComputer;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraftforge.fmllegacy.network.NetworkEvent;
import net.minecraftforge.network.NetworkEvent;
import javax.annotation.Nonnull;

View File

@ -7,7 +7,7 @@ package dan200.computercraft.shared.network.client;
import dan200.computercraft.ComputerCraft;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraftforge.fmllegacy.network.NetworkEvent;
import net.minecraftforge.network.NetworkEvent;
public class ComputerDeletedClientMessage extends ComputerClientMessage
{

View File

@ -6,7 +6,7 @@
package dan200.computercraft.shared.network.client;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraftforge.fmllegacy.network.NetworkEvent;
import net.minecraftforge.network.NetworkEvent;
import javax.annotation.Nonnull;

View File

@ -12,7 +12,7 @@ import net.minecraft.client.player.LocalPlayer;
import net.minecraft.core.BlockPos;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraftforge.fmllegacy.network.NetworkEvent;
import net.minecraftforge.network.NetworkEvent;
import javax.annotation.Nonnull;

View File

@ -13,7 +13,7 @@ import net.minecraft.network.chat.TextComponent;
import net.minecraft.sounds.SoundEvent;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fmllegacy.network.NetworkEvent;
import net.minecraftforge.network.NetworkEvent;
import javax.annotation.Nonnull;

View File

@ -11,7 +11,7 @@ import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fmllegacy.network.NetworkEvent;
import net.minecraftforge.network.NetworkEvent;
import javax.annotation.Nonnull;
import java.util.UUID;

View File

@ -12,7 +12,7 @@ import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fmllegacy.network.NetworkEvent;
import net.minecraftforge.network.NetworkEvent;
import javax.annotation.Nonnull;
import java.util.UUID;

View File

@ -10,7 +10,7 @@ import dan200.computercraft.shared.network.NetworkMessage;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fmllegacy.network.NetworkEvent;
import net.minecraftforge.network.NetworkEvent;
import javax.annotation.Nonnull;
import java.util.UUID;

View File

@ -17,7 +17,7 @@ import dan200.computercraft.shared.UpgradeManager;
import dan200.computercraft.shared.network.NetworkMessage;
import net.minecraft.network.FriendlyByteBuf;
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.RegistryManager;

View File

@ -13,7 +13,7 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.chat.Component;
import net.minecraftforge.fmllegacy.network.NetworkEvent;
import net.minecraftforge.network.NetworkEvent;
import javax.annotation.Nonnull;

View File

@ -12,16 +12,16 @@ import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.inventory.MenuType;
import net.minecraftforge.common.extensions.IForgeContainerType;
import net.minecraftforge.fmllegacy.network.IContainerFactory;
import net.minecraftforge.fmllegacy.network.NetworkHooks;
import net.minecraftforge.common.extensions.IForgeMenuType;
import net.minecraftforge.network.IContainerFactory;
import net.minecraftforge.network.NetworkHooks;
import javax.annotation.Nonnull;
import java.util.function.Consumer;
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.
*/
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 )
{
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 )
@ -60,7 +60,7 @@ public interface ContainerData
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 ) );
}

View File

@ -8,7 +8,7 @@ package dan200.computercraft.shared.network.server;
import dan200.computercraft.shared.computer.core.IContainerComputer;
import dan200.computercraft.shared.computer.core.ServerComputer;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraftforge.fmllegacy.network.NetworkEvent;
import net.minecraftforge.network.NetworkEvent;
import javax.annotation.Nonnull;

View File

@ -10,7 +10,7 @@ import dan200.computercraft.shared.computer.core.IContainerComputer;
import dan200.computercraft.shared.computer.core.ServerComputer;
import dan200.computercraft.shared.network.NetworkMessage;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraftforge.fmllegacy.network.NetworkEvent;
import net.minecraftforge.network.NetworkEvent;
import javax.annotation.Nonnull;

View File

@ -9,7 +9,7 @@ import dan200.computercraft.shared.computer.core.IContainerComputer;
import dan200.computercraft.shared.computer.core.ServerComputer;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.server.level.ServerPlayer;
import net.minecraftforge.fmllegacy.network.NetworkEvent;
import net.minecraftforge.network.NetworkEvent;
import javax.annotation.Nonnull;

View File

@ -9,7 +9,7 @@ import dan200.computercraft.shared.computer.core.IContainerComputer;
import dan200.computercraft.shared.computer.core.InputState;
import dan200.computercraft.shared.computer.core.ServerComputer;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraftforge.fmllegacy.network.NetworkEvent;
import net.minecraftforge.network.NetworkEvent;
import javax.annotation.Nonnull;

View File

@ -9,7 +9,7 @@ import dan200.computercraft.shared.computer.core.IContainerComputer;
import dan200.computercraft.shared.computer.core.InputState;
import dan200.computercraft.shared.computer.core.ServerComputer;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraftforge.fmllegacy.network.NetworkEvent;
import net.minecraftforge.network.NetworkEvent;
import javax.annotation.Nonnull;

View File

@ -10,7 +10,7 @@ import dan200.computercraft.shared.computer.core.ServerComputer;
import dan200.computercraft.shared.util.NBTUtil;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraftforge.fmllegacy.network.NetworkEvent;
import net.minecraftforge.network.NetworkEvent;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

View File

@ -9,7 +9,7 @@ import dan200.computercraft.ComputerCraft;
import dan200.computercraft.shared.computer.core.ServerComputer;
import dan200.computercraft.shared.network.NetworkMessage;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraftforge.fmllegacy.network.NetworkEvent;
import net.minecraftforge.network.NetworkEvent;
import javax.annotation.Nonnull;

View File

@ -14,7 +14,7 @@ import dan200.computercraft.shared.network.NetworkHandler;
import io.netty.handler.codec.DecoderException;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.server.level.ServerPlayer;
import net.minecraftforge.fmllegacy.network.NetworkEvent;
import net.minecraftforge.network.NetworkEvent;
import javax.annotation.Nonnull;
import java.nio.ByteBuffer;

View File

@ -37,9 +37,9 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.fmllegacy.network.NetworkHooks;
import net.minecraftforge.items.IItemHandlerModifiable;
import net.minecraftforge.items.wrapper.InvWrapper;
import net.minecraftforge.network.NetworkHooks;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

View File

@ -60,9 +60,9 @@ public class ItemData
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() ) );

View File

@ -98,7 +98,7 @@ public class BlockCable extends BlockGeneric implements SimpleWaterloggedBlock
}
@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 )
{
@ -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
@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();
boolean cable = state.getValue( CABLE );

View File

@ -346,7 +346,7 @@ public class TileCable extends TileGeneric
for( Direction facing : DirectionUtil.FACINGS )
{
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() );
if( !element.isPresent() ) continue;

View File

@ -306,7 +306,7 @@ public class TileWiredModemFull extends TileGeneric
for( Direction facing : DirectionUtil.FACINGS )
{
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() );
if( !element.isPresent() ) continue;

View File

@ -25,7 +25,7 @@ import net.minecraft.world.level.block.state.properties.DirectionProperty;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraftforge.fmllegacy.RegistryObject;
import net.minecraftforge.registries.RegistryObject;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

View File

@ -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.EnumProperty;
import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.fmllegacy.RegistryObject;
import net.minecraftforge.registries.RegistryObject;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

View File

@ -101,7 +101,7 @@ public final class MonitorWatcher
if( !(world instanceof ServerLevel) ) continue;
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;
}

View File

@ -261,7 +261,7 @@ public class TileMonitor extends TileGeneric
@Override
public final ClientboundBlockEntityDataPacket getUpdatePacket()
{
return new ClientboundBlockEntityDataPacket( worldPosition, 0, getUpdateTag() );
return ClientboundBlockEntityDataPacket.create( this );
}
@Nonnull
@ -398,7 +398,7 @@ public class TileMonitor extends TileGeneric
BlockPos pos = toWorldPos( x, y );
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 );
if( !(tile instanceof TileMonitor monitor) ) return MonitorState.MISSING;

View File

@ -31,10 +31,10 @@ import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.fmllegacy.network.NetworkHooks;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.wrapper.InvWrapper;
import net.minecraftforge.items.wrapper.SidedInvWrapper;
import net.minecraftforge.network.NetworkHooks;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

View File

@ -9,8 +9,7 @@ import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.shared.network.NetworkHandler;
import dan200.computercraft.shared.network.client.SpeakerStopClientMessage;
import net.minecraft.server.MinecraftServer;
import net.minecraftforge.fml.LogicalSide;
import net.minecraftforge.fmllegacy.LogicalSidedProvider;
import net.minecraftforge.server.ServerLifecycleHooks;
import javax.annotation.Nonnull;
import java.util.UUID;
@ -34,7 +33,7 @@ public abstract class UpgradeSpeakerPeripheral extends SpeakerPeripheral
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.
MinecraftServer server = LogicalSidedProvider.INSTANCE.get( LogicalSide.SERVER );
MinecraftServer server = ServerLifecycleHooks.getCurrentServer();
if( server == null || server.isStopped() ) return;
NetworkHandler.sendToAllPlayers( new SpeakerStopClientMessage( source ) );

View File

@ -42,7 +42,7 @@ import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraftforge.fmllegacy.RegistryObject;
import net.minecraftforge.registries.RegistryObject;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

View File

@ -304,7 +304,7 @@ public class TurtleBrain implements ITurtleAccess
}
// 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
if( !world.getWorldBorder().isWithinBounds( pos ) ) return false;

View File

@ -137,7 +137,7 @@ public class TurtleMoveCommand implements ITurtleCommand
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 ) )
{
return TurtleCommandResult.failure( "Cannot pass the world border" );

View File

@ -27,13 +27,13 @@ import net.minecraft.world.item.*;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.item.context.UseOnContext;
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.SignBlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.eventbus.api.Event.Result;
import net.minecraftforge.items.IItemHandler;
@ -321,7 +321,7 @@ public class TurtlePlaceCommand implements ITurtleCommand
}
}
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

View File

@ -17,7 +17,7 @@ import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.item.crafting.RecipeType;
import net.minecraft.world.level.Level;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.fmllegacy.hooks.BasicEventHooks;
import net.minecraftforge.event.ForgeEventFactory;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@ -91,7 +91,7 @@ public class TurtleInventoryCrafting extends CraftingContainer
results.add( result );
result.onCraftedBy( world, player, result.getCount() );
BasicEventHooks.firePlayerCraftingEvent( player, result, this );
ForgeEventFactory.firePlayerCraftingEvent( player, result, this );
ForgeHooks.setCraftingPlayer( player );
NonNullList<ItemStack> remainders = recipe.getRemainingItems( this );

View File

@ -255,7 +255,7 @@ public class TurtleTool extends AbstractTurtleUpgrade
// Destroy the block
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( canHarvest && canBreak )
{

View File

@ -11,7 +11,7 @@ import com.google.gson.reflect.TypeToken;
import dan200.computercraft.ComputerCraft;
import net.minecraft.server.MinecraftServer;
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.Reader;

View File

@ -10,7 +10,8 @@ import dan200.computercraft.ComputerCraft;
import dan200.computercraft.shared.common.TileGeneric;
import net.minecraft.core.BlockPos;
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.minecraftforge.event.TickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
@ -21,7 +22,7 @@ import java.util.Iterator;
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.
*/
@ -58,9 +59,9 @@ public final class TickScheduler
Level world = tile.getLevel();
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 );
}
}
}

View File

@ -48,7 +48,7 @@ public final class WaterloggableHelpers
{
if( state.getValue( WATERLOGGED ) )
{
world.getLiquidTicks().scheduleTick( pos, Fluids.WATER, Fluids.WATER.getTickDelay( world ) );
world.scheduleTick( pos, Fluids.WATER, Fluids.WATER.getTickDelay( world ) );
}
}

View File

@ -1,5 +1,5 @@
modLoader="javafml"
loaderVersion="[37,38)"
loaderVersion="[38,39)"
issueTrackerURL="https://github.com/cc-tweaked/CC-Tweaked/issues"
logoFile="pack.png"
@ -21,6 +21,6 @@ CC: Tweaked is a fork of ComputerCraft, adding programmable computers, turtles a
[[dependencies.computercraft]]
modId="forge"
mandatory=true
versionRange="[37.0.85,38)"
versionRange="[38.0.0,39)"
ordering="NONE"
side="BOTH"

View File

@ -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.FlatLevelGeneratorSettings;
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.fml.common.Mod;
import org.apache.logging.log4j.LogManager;
@ -50,9 +50,9 @@ public final class ClientHooks
}
@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;
ClientHooks.openWorld();
@ -93,7 +93,7 @@ public final class ClientHooks
WorldGenSettings generator = new WorldGenSettings( 0, false, false, withOverworld(
dimensions,
DimensionType.defaultDimensions( dimensions, biomes, registries.registryOrThrow( Registry.NOISE_GENERATOR_SETTINGS_REGISTRY ), 0 ),
DimensionType.defaultDimensions( registries, 0 ),
new FlatLevelSource( flatSettings )
) );

View File

@ -5,9 +5,9 @@
*/
package dan200.computercraft.ingame.mod;
import dan200.computercraft.ingame.api.Times;
import net.minecraft.ChatFormatting;
import net.minecraft.SharedConstants;
import dan200.computercraft.ingame.api.Times;
import net.minecraft.client.Minecraft;
import net.minecraft.commands.CommandSourceStack;
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.minecraftforge.event.RegisterCommandsEvent;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.event.server.ServerStartedEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.loading.FMLLoader;
import net.minecraftforge.fmllegacy.server.ServerLifecycleHooks;
import net.minecraftforge.fmlserverevents.FMLServerStartedEvent;
import net.minecraftforge.server.ServerLifecycleHooks;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -49,7 +49,7 @@ public class TestHooks
}
@SubscribeEvent
public static void onServerStarted( FMLServerStartedEvent event )
public static void onServerStarted( ServerStartedEvent event )
{
MinecraftServer server = event.getServer();
GameRules rules = server.getGameRules();