update fabric/neo api methods
This commit is contained in:
@@ -315,7 +315,16 @@ public class FabricClientProxy implements AbstractModInitializer.IEventProxy
|
|||||||
// networking event //
|
// networking event //
|
||||||
//==================//
|
//==================//
|
||||||
|
|
||||||
#if MC_VER >= MC_1_20_6
|
#if MC_VER < MC_1_20_6
|
||||||
|
ClientPlayNetworking.registerGlobalReceiver(AbstractPluginPacketSender.WRAPPER_PACKET_RESOURCE, (client, handler, buffer, packetSender) ->
|
||||||
|
{
|
||||||
|
AbstractNetworkMessage message = PACKET_SENDER.decodeMessage(buffer);
|
||||||
|
if (message != null)
|
||||||
|
{
|
||||||
|
ClientApi.INSTANCE.pluginMessageReceived(message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
#elif MC_VER <= MC_1_21_11
|
||||||
PayloadTypeRegistry.playS2C().register(CommonPacketPayload.TYPE, new CommonPacketPayload.Codec());
|
PayloadTypeRegistry.playS2C().register(CommonPacketPayload.TYPE, new CommonPacketPayload.Codec());
|
||||||
ClientPlayNetworking.registerGlobalReceiver(CommonPacketPayload.TYPE, (payload, context) ->
|
ClientPlayNetworking.registerGlobalReceiver(CommonPacketPayload.TYPE, (payload, context) ->
|
||||||
{
|
{
|
||||||
@@ -326,13 +335,14 @@ public class FabricClientProxy implements AbstractModInitializer.IEventProxy
|
|||||||
ClientApi.INSTANCE.pluginMessageReceived(payload.message());
|
ClientApi.INSTANCE.pluginMessageReceived(payload.message());
|
||||||
});
|
});
|
||||||
#else
|
#else
|
||||||
ClientPlayNetworking.registerGlobalReceiver(AbstractPluginPacketSender.WRAPPER_PACKET_RESOURCE, (client, handler, buffer, packetSender) ->
|
PayloadTypeRegistry.clientboundPlay().register(CommonPacketPayload.TYPE, new CommonPacketPayload.Codec());
|
||||||
|
ClientPlayNetworking.registerGlobalReceiver(CommonPacketPayload.TYPE, (payload, context) ->
|
||||||
{
|
{
|
||||||
AbstractNetworkMessage message = PACKET_SENDER.decodeMessage(buffer);
|
if (payload.message() == null)
|
||||||
if (message != null)
|
|
||||||
{
|
{
|
||||||
ClientApi.INSTANCE.pluginMessageReceived(message);
|
return;
|
||||||
}
|
}
|
||||||
|
ClientApi.INSTANCE.pluginMessageReceived(payload.message());
|
||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,11 +18,9 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapp
|
|||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
||||||
import com.seibel.distanthorizons.fabric.testing.TestChunkInputReplacerEvent;
|
import com.seibel.distanthorizons.fabric.testing.TestChunkInputReplacerEvent;
|
||||||
import com.seibel.distanthorizons.fabric.testing.TestWorldGenBindingEvent;
|
import com.seibel.distanthorizons.fabric.testing.TestWorldGenBindingEvent;
|
||||||
import net.fabricmc.fabric.api.entity.event.v1.ServerEntityWorldChangeEvents;
|
|
||||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerChunkEvents;
|
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerChunkEvents;
|
||||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
|
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
|
||||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerWorldEvents;
|
|
||||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
|
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
|
||||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
|
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
@@ -39,6 +37,14 @@ import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry;
|
|||||||
import com.seibel.distanthorizons.core.network.messages.AbstractNetworkMessage;
|
import com.seibel.distanthorizons.core.network.messages.AbstractNetworkMessage;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if MC_VER <= MC_1_21_11
|
||||||
|
import net.fabricmc.fabric.api.entity.event.v1.ServerEntityWorldChangeEvents;
|
||||||
|
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerWorldEvents;
|
||||||
|
#else
|
||||||
|
import net.fabricmc.fabric.api.entity.event.v1.ServerEntityLevelChangeEvents;
|
||||||
|
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLevelEvents;
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This handles all events sent to the server,
|
* This handles all events sent to the server,
|
||||||
* and is the starting point for most of the mod.
|
* and is the starting point for most of the mod.
|
||||||
@@ -101,18 +107,31 @@ public class FabricServerProxy implements AbstractModInitializer.IEventProxy
|
|||||||
});
|
});
|
||||||
|
|
||||||
// ServerLevelLoadEvent
|
// ServerLevelLoadEvent
|
||||||
|
#if MC_VER <= MC_1_21_11
|
||||||
ServerWorldEvents.LOAD.register((server, level) ->
|
ServerWorldEvents.LOAD.register((server, level) ->
|
||||||
|
#else
|
||||||
|
ServerLevelEvents.LOAD.register((server, level) ->
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
ServerApi.INSTANCE.serverLevelLoadEvent(this.getServerLevelWrapper(level));
|
ServerApi.INSTANCE.serverLevelLoadEvent(this.getServerLevelWrapper(level));
|
||||||
});
|
});
|
||||||
|
|
||||||
// ServerLevelUnloadEvent
|
// ServerLevelUnloadEvent
|
||||||
|
#if MC_VER <= MC_1_21_11
|
||||||
ServerWorldEvents.UNLOAD.register((server, level) ->
|
ServerWorldEvents.UNLOAD.register((server, level) ->
|
||||||
|
#else
|
||||||
|
ServerLevelEvents.UNLOAD.register((server, level) ->
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
ServerApi.INSTANCE.serverLevelUnloadEvent(this.getServerLevelWrapper(level));
|
ServerApi.INSTANCE.serverLevelUnloadEvent(this.getServerLevelWrapper(level));
|
||||||
});
|
});
|
||||||
|
|
||||||
// ServerChunkLoadEvent
|
// ServerChunkLoadEvent
|
||||||
|
#if MC_VER <= MC_1_21_11
|
||||||
ServerChunkEvents.CHUNK_LOAD.register((server, chunk) ->
|
ServerChunkEvents.CHUNK_LOAD.register((server, chunk) ->
|
||||||
|
#else
|
||||||
|
ServerChunkEvents.CHUNK_LOAD.register((server, chunk, generated) ->
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
ILevelWrapper level = this.getServerLevelWrapper((ServerLevel) chunk.getLevel());
|
ILevelWrapper level = this.getServerLevelWrapper((ServerLevel) chunk.getLevel());
|
||||||
ServerApi.INSTANCE.serverChunkLoadEvent(
|
ServerApi.INSTANCE.serverChunkLoadEvent(
|
||||||
@@ -129,7 +148,12 @@ public class FabricServerProxy implements AbstractModInitializer.IEventProxy
|
|||||||
{
|
{
|
||||||
ServerApi.INSTANCE.serverPlayerDisconnectEvent(this.getServerPlayerWrapper(handler.player));
|
ServerApi.INSTANCE.serverPlayerDisconnectEvent(this.getServerPlayerWrapper(handler.player));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
#if MC_VER <= MC_1_21_11
|
||||||
ServerEntityWorldChangeEvents.AFTER_PLAYER_CHANGE_WORLD.register((player, originLevel, destinationLevel) ->
|
ServerEntityWorldChangeEvents.AFTER_PLAYER_CHANGE_WORLD.register((player, originLevel, destinationLevel) ->
|
||||||
|
#else
|
||||||
|
ServerEntityLevelChangeEvents.AFTER_PLAYER_CHANGE_LEVEL.register((player, originLevel, destinationLevel) ->
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
ServerApi.INSTANCE.serverPlayerLevelChangeEvent(
|
ServerApi.INSTANCE.serverPlayerLevelChangeEvent(
|
||||||
this.getServerPlayerWrapper(player),
|
this.getServerPlayerWrapper(player),
|
||||||
@@ -138,7 +162,16 @@ public class FabricServerProxy implements AbstractModInitializer.IEventProxy
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
#if MC_VER >= MC_1_20_6
|
#if MC_VER < MC_1_20_6
|
||||||
|
ServerPlayNetworking.registerGlobalReceiver(AbstractPluginPacketSender.WRAPPER_PACKET_RESOURCE, (server, serverPlayer, handler, buffer, packetSender) ->
|
||||||
|
{
|
||||||
|
AbstractNetworkMessage message = PACKET_SENDER.decodeMessage(buffer);
|
||||||
|
if (message != null)
|
||||||
|
{
|
||||||
|
ServerApi.INSTANCE.pluginMessageReceived(ServerPlayerWrapper.getWrapper(serverPlayer), message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
#elif MC_VER <= MC_1_21_11
|
||||||
PayloadTypeRegistry.playC2S().register(CommonPacketPayload.TYPE, new CommonPacketPayload.Codec());
|
PayloadTypeRegistry.playC2S().register(CommonPacketPayload.TYPE, new CommonPacketPayload.Codec());
|
||||||
if (this.isDedicatedServer)
|
if (this.isDedicatedServer)
|
||||||
{
|
{
|
||||||
@@ -154,13 +187,19 @@ public class FabricServerProxy implements AbstractModInitializer.IEventProxy
|
|||||||
ServerApi.INSTANCE.pluginMessageReceived(ServerPlayerWrapper.getWrapper(context.player()), payload.message());
|
ServerApi.INSTANCE.pluginMessageReceived(ServerPlayerWrapper.getWrapper(context.player()), payload.message());
|
||||||
});
|
});
|
||||||
#else
|
#else
|
||||||
ServerPlayNetworking.registerGlobalReceiver(AbstractPluginPacketSender.WRAPPER_PACKET_RESOURCE, (server, serverPlayer, handler, buffer, packetSender) ->
|
PayloadTypeRegistry.serverboundPlay().register(CommonPacketPayload.TYPE, new CommonPacketPayload.Codec());
|
||||||
|
if (this.isDedicatedServer)
|
||||||
{
|
{
|
||||||
AbstractNetworkMessage message = PACKET_SENDER.decodeMessage(buffer);
|
PayloadTypeRegistry.clientboundPlay().register(CommonPacketPayload.TYPE, new CommonPacketPayload.Codec());
|
||||||
if (message != null)
|
}
|
||||||
|
|
||||||
|
ServerPlayNetworking.registerGlobalReceiver(CommonPacketPayload.TYPE, (payload, context) ->
|
||||||
|
{
|
||||||
|
if (payload.message() == null)
|
||||||
{
|
{
|
||||||
ServerApi.INSTANCE.pluginMessageReceived(ServerPlayerWrapper.getWrapper(serverPlayer), message);
|
return;
|
||||||
}
|
}
|
||||||
|
ServerApi.INSTANCE.pluginMessageReceived(ServerPlayerWrapper.getWrapper(context.player()), payload.message());
|
||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -218,8 +218,13 @@ public class NeoforgeClientProxy implements AbstractModInitializer.IEventProxy
|
|||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
||||||
|
#if MC_VER <= MC_1_21_11
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void afterLevelEntityRenderEvent(RenderLevelStageEvent.AfterEntities event)
|
public void afterLevelEntityRenderEvent(RenderLevelStageEvent.AfterEntities event)
|
||||||
|
#else
|
||||||
|
@SubscribeEvent
|
||||||
|
public void afterLevelEntityRenderEvent(RenderLevelStageEvent.AfterOpaqueFeatures event)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
#if MC_VER < MC_1_21_9
|
#if MC_VER < MC_1_21_9
|
||||||
ClientApi.RENDER_STATE.clientLevelWrapper = ClientLevelWrapper.getWrapperIfDifferent(ClientApi.RENDER_STATE.clientLevelWrapper, (ClientLevel)event.getLevel());
|
ClientApi.RENDER_STATE.clientLevelWrapper = ClientLevelWrapper.getWrapperIfDifferent(ClientApi.RENDER_STATE.clientLevelWrapper, (ClientLevel)event.getLevel());
|
||||||
|
|||||||
-1
@@ -9,7 +9,6 @@ import com.seibel.distanthorizons.core.logging.DhLogger;
|
|||||||
#else
|
#else
|
||||||
import com.mojang.blaze3d.opengl.GlTexture;
|
import com.mojang.blaze3d.opengl.GlTexture;
|
||||||
import com.mojang.blaze3d.textures.GpuTexture;
|
import com.mojang.blaze3d.textures.GpuTexture;
|
||||||
import net.neoforged.neoforge.client.blaze3d.validation.ValidationGpuTexture;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import java.lang.invoke.MethodHandles;
|
import java.lang.invoke.MethodHandles;
|
||||||
|
|||||||
+9
@@ -7,7 +7,12 @@ public class NeoforgeTextureUnwrapper
|
|||||||
|
|
||||||
import com.mojang.blaze3d.opengl.GlTexture;
|
import com.mojang.blaze3d.opengl.GlTexture;
|
||||||
import com.mojang.blaze3d.textures.GpuTexture;
|
import com.mojang.blaze3d.textures.GpuTexture;
|
||||||
|
|
||||||
|
#if MC_VER <= MC_1_21_11
|
||||||
import net.neoforged.neoforge.client.blaze3d.validation.ValidationGpuTexture;
|
import net.neoforged.neoforge.client.blaze3d.validation.ValidationGpuTexture;
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
public class NeoforgeTextureUnwrapper
|
public class NeoforgeTextureUnwrapper
|
||||||
{
|
{
|
||||||
@@ -21,6 +26,7 @@ public class NeoforgeTextureUnwrapper
|
|||||||
{
|
{
|
||||||
GlTexture glTexture;
|
GlTexture glTexture;
|
||||||
|
|
||||||
|
#if MC_VER <= MC_1_21_11
|
||||||
if (gpuTexture instanceof ValidationGpuTexture)
|
if (gpuTexture instanceof ValidationGpuTexture)
|
||||||
{
|
{
|
||||||
ValidationGpuTexture validationTexture = (ValidationGpuTexture) gpuTexture;
|
ValidationGpuTexture validationTexture = (ValidationGpuTexture) gpuTexture;
|
||||||
@@ -30,6 +36,9 @@ public class NeoforgeTextureUnwrapper
|
|||||||
{
|
{
|
||||||
glTexture = (GlTexture) gpuTexture;
|
glTexture = (GlTexture) gpuTexture;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
glTexture = (GlTexture) gpuTexture;
|
||||||
|
#endif
|
||||||
|
|
||||||
int id = glTexture.glId();
|
int id = glTexture.glId();
|
||||||
return id;
|
return id;
|
||||||
|
|||||||
Reference in New Issue
Block a user