Merge branch '1.21.9' of github.com:Hanro50/CarryOn into Hanro50-1.21.9
# Conflicts: # Common/src/main/java/tschipp/carryon/CarryOnCommon.java # Common/src/main/java/tschipp/carryon/CarryOnCommonClient.java # Common/src/main/java/tschipp/carryon/client/keybinds/ConflictFreeKeyMapping.java # Common/src/main/java/tschipp/carryon/client/render/CarriedObjectRender.java # Common/src/main/java/tschipp/carryon/mixin/AvatarRenderStateMixin.java # Common/src/main/java/tschipp/carryon/mixin/HumanoidModelMixin.java # Common/src/main/resources/carryon.mixins.json # Fabric/build.gradle # build.gradle # gradle.properties
This commit is contained in:
commit
d4e0b29a06
71
.vscode/launch.json
vendored
Normal file
71
.vscode/launch.json
vendored
Normal file
|
|
@ -0,0 +1,71 @@
|
||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"type": "java",
|
||||||
|
"request": "launch",
|
||||||
|
"name": "NeoForge Client (:NeoForge)",
|
||||||
|
"presentation": {
|
||||||
|
"group": "Mod Development - NeoForge",
|
||||||
|
"order": 0
|
||||||
|
},
|
||||||
|
"projectName": "NeoForge",
|
||||||
|
"mainClass": "net.neoforged.devlaunch.Main",
|
||||||
|
"args": [
|
||||||
|
"@/home/hanro/Documents/GitHub/CarryOn/NeoForge/build/moddev/clientRunProgramArgs.txt"
|
||||||
|
],
|
||||||
|
"vmArgs": [
|
||||||
|
"@/home/hanro/Documents/GitHub/CarryOn/NeoForge/build/moddev/clientRunVmArgs.txt",
|
||||||
|
"-Dfml.modFolders\u003dcarryon%%/home/hanro/Documents/GitHub/CarryOn/NeoForge/bin/main"
|
||||||
|
],
|
||||||
|
"cwd": "${workspaceFolder}/NeoForge/run",
|
||||||
|
"env": {},
|
||||||
|
"console": "internalConsole",
|
||||||
|
"shortenCommandLine": "none"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "java",
|
||||||
|
"request": "launch",
|
||||||
|
"name": "NeoForge Data (:NeoForge)",
|
||||||
|
"presentation": {
|
||||||
|
"group": "Mod Development - NeoForge",
|
||||||
|
"order": 1
|
||||||
|
},
|
||||||
|
"projectName": "NeoForge",
|
||||||
|
"mainClass": "net.neoforged.devlaunch.Main",
|
||||||
|
"args": [
|
||||||
|
"@/home/hanro/Documents/GitHub/CarryOn/NeoForge/build/moddev/dataRunProgramArgs.txt"
|
||||||
|
],
|
||||||
|
"vmArgs": [
|
||||||
|
"@/home/hanro/Documents/GitHub/CarryOn/NeoForge/build/moddev/dataRunVmArgs.txt",
|
||||||
|
"-Dfml.modFolders\u003dcarryon%%/home/hanro/Documents/GitHub/CarryOn/NeoForge/bin/main"
|
||||||
|
],
|
||||||
|
"cwd": "${workspaceFolder}/NeoForge/run",
|
||||||
|
"env": {},
|
||||||
|
"console": "internalConsole",
|
||||||
|
"shortenCommandLine": "none"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "java",
|
||||||
|
"request": "launch",
|
||||||
|
"name": "NeoForge Server (:NeoForge)",
|
||||||
|
"presentation": {
|
||||||
|
"group": "Mod Development - NeoForge",
|
||||||
|
"order": 2
|
||||||
|
},
|
||||||
|
"projectName": "NeoForge",
|
||||||
|
"mainClass": "net.neoforged.devlaunch.Main",
|
||||||
|
"args": [
|
||||||
|
"@/home/hanro/Documents/GitHub/CarryOn/NeoForge/build/moddev/serverRunProgramArgs.txt"
|
||||||
|
],
|
||||||
|
"vmArgs": [
|
||||||
|
"@/home/hanro/Documents/GitHub/CarryOn/NeoForge/build/moddev/serverRunVmArgs.txt",
|
||||||
|
"-Dfml.modFolders\u003dcarryon%%/home/hanro/Documents/GitHub/CarryOn/NeoForge/bin/main"
|
||||||
|
],
|
||||||
|
"cwd": "${workspaceFolder}/NeoForge/run",
|
||||||
|
"env": {},
|
||||||
|
"console": "internalConsole",
|
||||||
|
"shortenCommandLine": "none"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -20,7 +20,7 @@ neoForge {
|
||||||
accessTransformers.from(at.absolutePath)
|
accessTransformers.from(at.absolutePath)
|
||||||
}
|
}
|
||||||
parchment {
|
parchment {
|
||||||
minecraftVersion = minecraft_version
|
minecraftVersion = parchment_game_version
|
||||||
mappingsVersion = parchment_version
|
mappingsVersion = parchment_version
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,10 +26,7 @@ import net.minecraft.core.HolderLookup;
|
||||||
import net.minecraft.core.RegistryAccess;
|
import net.minecraft.core.RegistryAccess;
|
||||||
import net.minecraft.core.RegistrySetBuilder;
|
import net.minecraft.core.RegistrySetBuilder;
|
||||||
import net.minecraft.core.registries.BuiltInRegistries;
|
import net.minecraft.core.registries.BuiltInRegistries;
|
||||||
import net.minecraft.core.registries.Registries;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.world.effect.MobEffectInstance;
|
|
||||||
import net.minecraft.world.effect.MobEffects;
|
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
|
@ -108,8 +105,6 @@ public class CarryOnCommon
|
||||||
|
|
||||||
public static void onCarryTick(ServerPlayer player)
|
public static void onCarryTick(ServerPlayer player)
|
||||||
{
|
{
|
||||||
//TODO: Remove
|
|
||||||
System.out.println(player.getGameProfile());
|
|
||||||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||||
if(carry.isCarrying())
|
if(carry.isCarrying())
|
||||||
{
|
{
|
||||||
|
|
@ -117,7 +112,7 @@ public class CarryOnCommon
|
||||||
{
|
{
|
||||||
String cmd = carry.getActiveScript().get().scriptEffects().commandLoop();
|
String cmd = carry.getActiveScript().get().scriptEffects().commandLoop();
|
||||||
if(!cmd.isEmpty())
|
if(!cmd.isEmpty())
|
||||||
player.level().getServer().getCommands().performPrefixedCommand(player.level().getServer().createCommandSourceStack(), "/execute as " + player.getGameProfile() + " run " + cmd);
|
player.level().getServer().getCommands().performPrefixedCommand(player.level().getServer().createCommandSourceStack(), "/execute as " + player.getGameProfile().name() + " run " + cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
Inventory inv = player.getInventory();
|
Inventory inv = player.getInventory();
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,6 @@
|
||||||
package tschipp.carryon;
|
package tschipp.carryon;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.input.MouseButtonEvent;
|
|
||||||
import net.minecraft.client.input.MouseButtonInfo;
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import tschipp.carryon.client.keybinds.CarryOnKeybinds;
|
import tschipp.carryon.client.keybinds.CarryOnKeybinds;
|
||||||
import tschipp.carryon.common.carry.CarryOnData;
|
import tschipp.carryon.common.carry.CarryOnData;
|
||||||
|
|
@ -36,11 +34,11 @@ public class CarryOnCommonClient
|
||||||
Player player = mc.player;
|
Player player = mc.player;
|
||||||
if(player != null) {
|
if(player != null) {
|
||||||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||||
if ((CarryOnKeybinds.carryKey.isUnbound() ? player.isShiftKeyDown() : (CarryOnKeybinds.carryKey.isDown() || checkMouse())) && !carry.isKeyPressed()) {
|
if ((CarryOnKeybinds.carryKey.isUnbound() ? player.isShiftKeyDown() : (CarryOnKeybinds.carryKey.isDown())) && !carry.isKeyPressed()) {
|
||||||
CarryOnKeybinds.onCarryKey(true);
|
CarryOnKeybinds.onCarryKey(true);
|
||||||
carry.setKeyPressed(true);
|
carry.setKeyPressed(true);
|
||||||
CarryOnDataManager.setCarryData(player, carry);
|
CarryOnDataManager.setCarryData(player, carry);
|
||||||
} else if (!(CarryOnKeybinds.carryKey.isUnbound() ? player.isShiftKeyDown() : (CarryOnKeybinds.carryKey.isDown() || checkMouse()) ) && carry.isKeyPressed()) {
|
} else if (!(CarryOnKeybinds.carryKey.isUnbound() ? player.isShiftKeyDown() : (CarryOnKeybinds.carryKey.isDown() ) ) && carry.isKeyPressed()) {
|
||||||
CarryOnKeybinds.onCarryKey(false);
|
CarryOnKeybinds.onCarryKey(false);
|
||||||
carry.setKeyPressed(false);
|
carry.setKeyPressed(false);
|
||||||
CarryOnDataManager.setCarryData(player, carry);
|
CarryOnDataManager.setCarryData(player, carry);
|
||||||
|
|
@ -48,11 +46,6 @@ public class CarryOnCommonClient
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean checkMouse()
|
|
||||||
{
|
|
||||||
Minecraft mc = Minecraft.getInstance();
|
|
||||||
return (CarryOnKeybinds.carryKey.matchesMouse(new MouseButtonEvent(0,0, new MouseButtonInfo(0,0))) && mc.mouseHandler.isLeftPressed()) || (CarryOnKeybinds.carryKey.matchesMouse(new MouseButtonEvent(0,0, new MouseButtonInfo(1,0))) || CarryOnKeybinds.carryKey.matchesMouse(new MouseButtonEvent(0,0, new MouseButtonInfo(3,0))) && mc.mouseHandler.isMiddlePressed());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void onCarryClientTick()
|
public static void onCarryClientTick()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -22,11 +22,13 @@ package tschipp.carryon.client.keybinds;
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.InputConstants;
|
import com.mojang.blaze3d.platform.InputConstants;
|
||||||
import net.minecraft.client.KeyMapping;
|
import net.minecraft.client.KeyMapping;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import tschipp.carryon.Constants;
|
import tschipp.carryon.Constants;
|
||||||
import tschipp.carryon.networking.serverbound.ServerboundCarryKeyPressedPacket;
|
import tschipp.carryon.networking.serverbound.ServerboundCarryKeyPressedPacket;
|
||||||
import tschipp.carryon.platform.Services;
|
import tschipp.carryon.platform.Services;
|
||||||
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
import net.minecraft.client.KeyMapping.Category;
|
||||||
|
|
||||||
public class CarryOnKeybinds
|
public class CarryOnKeybinds
|
||||||
{
|
{
|
||||||
|
|
@ -34,10 +36,13 @@ public class CarryOnKeybinds
|
||||||
|
|
||||||
public static void registerKeybinds(Consumer<KeyMapping> registrar)
|
public static void registerKeybinds(Consumer<KeyMapping> registrar)
|
||||||
{
|
{
|
||||||
|
Category category = Category.register(ResourceLocation.withDefaultNamespace("key.carry.category"));
|
||||||
|
|
||||||
|
|
||||||
if(Services.PLATFORM.isModLoaded("amecsapi"))
|
if(Services.PLATFORM.isModLoaded("amecsapi"))
|
||||||
carryKey = new ConflictFreeKeyMapping("key.carry.desc", InputConstants.KEY_LSHIFT, "key.carry.category");
|
carryKey = new KeyMapping("key.carry.desc", InputConstants.KEY_LSHIFT, category);
|
||||||
else
|
else
|
||||||
carryKey = new ConflictFreeKeyMapping("key.carry.desc", Services.PLATFORM.getPlatformName().equals("Forge") ? InputConstants.KEY_LSHIFT : InputConstants.UNKNOWN.getValue(), "key.carry.category");
|
carryKey = new KeyMapping("key.carry.desc", Services.PLATFORM.getPlatformName().equals("Forge") ? InputConstants.KEY_LSHIFT : InputConstants.UNKNOWN.getValue(), category);
|
||||||
|
|
||||||
registrar.accept(carryKey);
|
registrar.accept(carryKey);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,43 +0,0 @@
|
||||||
/*
|
|
||||||
* GNU Lesser General Public License v3
|
|
||||||
* Copyright (C) 2024 Tschipp
|
|
||||||
* mrtschipp@gmail.com
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with this program; if not, write to the Free Software Foundation,
|
|
||||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package tschipp.carryon.client.keybinds;
|
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.InputConstants.Type;
|
|
||||||
import net.minecraft.client.KeyMapping;
|
|
||||||
|
|
||||||
public class ConflictFreeKeyMapping extends KeyMapping
|
|
||||||
{
|
|
||||||
public ConflictFreeKeyMapping(String $$0, int $$1, Category $$2)
|
|
||||||
{
|
|
||||||
super($$0, $$1, $$2);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ConflictFreeKeyMapping(String $$0, Type $$1, int $$2, Category $$3)
|
|
||||||
{
|
|
||||||
super($$0, $$1, $$2, $$3);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean same(KeyMapping $$0)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -23,7 +23,6 @@ package tschipp.carryon.client.modeloverride;
|
||||||
import com.mojang.brigadier.StringReader;
|
import com.mojang.brigadier.StringReader;
|
||||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||||
import com.mojang.datafixers.util.Either;
|
import com.mojang.datafixers.util.Either;
|
||||||
import com.mojang.serialization.Codec;
|
|
||||||
import com.mojang.serialization.DataResult;
|
import com.mojang.serialization.DataResult;
|
||||||
import net.minecraft.commands.arguments.blocks.BlockStateParser;
|
import net.minecraft.commands.arguments.blocks.BlockStateParser;
|
||||||
import net.minecraft.commands.arguments.blocks.BlockStateParser.BlockResult;
|
import net.minecraft.commands.arguments.blocks.BlockStateParser.BlockResult;
|
||||||
|
|
@ -40,22 +39,13 @@ import tschipp.carryon.common.scripting.Matchables.NBTCondition;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class ModelOverride
|
public class ModelOverride {
|
||||||
{
|
|
||||||
//public static Codec<ModelOverride> CODEC = Codec.STRING.comapFlatMap(ModelOverride::of, override -> override.raw);
|
|
||||||
|
|
||||||
private String raw;
|
|
||||||
private BlockResult parsedBlock;
|
private BlockResult parsedBlock;
|
||||||
private Type type;
|
|
||||||
private Either<ItemResult, BlockResult> parsedRHS;
|
|
||||||
private Either<ItemStack, BlockState> renderObject;
|
private Either<ItemStack, BlockState> renderObject;
|
||||||
|
|
||||||
private ModelOverride(String raw, BlockResult parsedBlock, Type type, Either<ItemResult, BlockResult> parsedRHS)
|
private ModelOverride(String raw, BlockResult parsedBlock, Type type, Either<ItemResult, BlockResult> parsedRHS)
|
||||||
{
|
{
|
||||||
this.raw = raw;
|
|
||||||
this.parsedBlock = parsedBlock;
|
this.parsedBlock = parsedBlock;
|
||||||
this.type = type;
|
|
||||||
this.parsedRHS = parsedRHS;
|
|
||||||
|
|
||||||
parsedRHS.ifLeft(res -> {
|
parsedRHS.ifLeft(res -> {
|
||||||
ItemStack stack = new ItemStack(res.item());
|
ItemStack stack = new ItemStack(res.item());
|
||||||
|
|
|
||||||
|
|
@ -20,35 +20,23 @@
|
||||||
|
|
||||||
package tschipp.carryon.client.render;
|
package tschipp.carryon.client.render;
|
||||||
|
|
||||||
import com.mojang.blaze3d.pipeline.BlendFunction;
|
|
||||||
import com.mojang.blaze3d.pipeline.RenderPipeline;
|
|
||||||
import com.mojang.blaze3d.pipeline.RenderTarget;
|
|
||||||
import com.mojang.blaze3d.platform.DepthTestFunction;
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
|
||||||
import com.mojang.blaze3d.textures.GpuTexture;
|
|
||||||
import com.mojang.blaze3d.vertex.*;
|
import com.mojang.blaze3d.vertex.*;
|
||||||
import com.mojang.math.Axis;
|
import com.mojang.math.Axis;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.MultiBufferSource;
|
|
||||||
import net.minecraft.client.renderer.MultiBufferSource.BufferSource;
|
|
||||||
import net.minecraft.client.renderer.RenderType;
|
import net.minecraft.client.renderer.RenderType;
|
||||||
import net.minecraft.client.renderer.ShaderDefines;
|
import net.minecraft.client.renderer.SubmitNodeCollector;
|
||||||
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
|
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
|
||||||
import net.minecraft.client.renderer.item.ItemStackRenderState;
|
import net.minecraft.client.renderer.item.ItemStackRenderState;
|
||||||
|
import net.minecraft.client.renderer.state.CameraRenderState;
|
||||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||||
import net.minecraft.client.renderer.texture.TextureAtlas;
|
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.HumanoidArm;
|
import net.minecraft.world.entity.HumanoidArm;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.inventory.InventoryMenu;
|
|
||||||
import net.minecraft.world.item.ItemDisplayContext;
|
import net.minecraft.world.item.ItemDisplayContext;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.joml.Matrix4f;
|
|
||||||
import tschipp.carryon.Constants;
|
import tschipp.carryon.Constants;
|
||||||
import tschipp.carryon.common.carry.CarryOnData;
|
import tschipp.carryon.common.carry.CarryOnData;
|
||||||
import tschipp.carryon.common.carry.CarryOnData.CarryType;
|
import tschipp.carryon.common.carry.CarryOnData.CarryType;
|
||||||
|
|
@ -61,27 +49,17 @@ import java.util.*;
|
||||||
|
|
||||||
public class CarriedObjectRender
|
public class CarriedObjectRender
|
||||||
{
|
{
|
||||||
|
public static boolean draw(Player player, PoseStack matrix, int light, float partialTicks,SubmitNodeCollector nodeCollector, boolean firstPerson)
|
||||||
private static final SequencedMap<RenderType, ByteBufferBuilder> builders = new LinkedHashMap<>(Map.of(
|
|
||||||
RenderType.glint(), new ByteBufferBuilder(RenderType.glint().bufferSize()),
|
|
||||||
RenderType.armorEntityGlint(), new ByteBufferBuilder(RenderType.armorEntityGlint().bufferSize()),
|
|
||||||
RenderType.glintTranslucent(), new ByteBufferBuilder(RenderType.glintTranslucent().bufferSize()),
|
|
||||||
RenderType.entityGlint(), new ByteBufferBuilder(RenderType.entityGlint().bufferSize())
|
|
||||||
//RenderType.entityGlintDirect(), new ByteBufferBuilder(RenderType.entityGlintDirect().bufferSize())
|
|
||||||
));
|
|
||||||
|
|
||||||
|
|
||||||
public static boolean drawFirstPerson(Player player, MultiBufferSource buffer, PoseStack matrix, int light, float partialTicks)
|
|
||||||
{
|
{
|
||||||
if(Services.PLATFORM.isModLoaded("firstperson") || Services.PLATFORM.isModLoaded("firstpersonmod"))
|
if(Services.PLATFORM.isModLoaded("firstperson") || Services.PLATFORM.isModLoaded("firstpersonmod") || player == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||||
try {
|
try {
|
||||||
if (carry.isCarrying(CarryType.BLOCK))
|
if (carry.isCarrying(CarryType.BLOCK))
|
||||||
drawFirstPersonBlock(player, buffer, matrix, light, CarryRenderHelper.getRenderState(player));
|
drawBlock(player, matrix, light, CarryRenderHelper.getRenderState(player), nodeCollector, firstPerson);
|
||||||
else if (carry.isCarrying(CarryType.ENTITY))
|
else if (carry.isCarrying(CarryType.ENTITY))
|
||||||
drawFirstPersonEntity(player, buffer, matrix, light, partialTicks);
|
drawEntity(player, matrix, light, partialTicks,nodeCollector, firstPerson);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|
@ -101,13 +79,18 @@ public class CarriedObjectRender
|
||||||
return carry.isCarrying();
|
return carry.isCarrying();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void drawFirstPersonBlock(Player player, MultiBufferSource buffer, PoseStack matrix, int light, BlockState state)
|
private static void drawBlock(Player player, PoseStack matrix, int light, BlockState state,SubmitNodeCollector nodeCollector, boolean firstPerson)
|
||||||
{
|
{
|
||||||
matrix.pushPose();
|
matrix.pushPose();
|
||||||
|
if (firstPerson){
|
||||||
matrix.scale(2.5f, 2.5f, 2.5f);
|
matrix.scale(2.5f, 2.5f, 2.5f);
|
||||||
matrix.translate(0, -0.5, -1);
|
matrix.translate(0, -0.5, -1);
|
||||||
//RenderSystem.enableBlend();
|
}else{
|
||||||
//RenderSystem.disableCull();
|
matrix.scale(0.6f, 0.6f, 0.6f);
|
||||||
|
matrix.translate(0, 0.5, -0.8);
|
||||||
|
matrix.mulPose(Axis.ZN.rotationDegrees(180));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||||
ItemStackRenderState renderState = new ItemStackRenderState();
|
ItemStackRenderState renderState = new ItemStackRenderState();
|
||||||
|
|
@ -124,21 +107,15 @@ public class CarriedObjectRender
|
||||||
if(carry.getActiveScript().isPresent())
|
if(carry.getActiveScript().isPresent())
|
||||||
CarryRenderHelper.performScriptTransformation(matrix, carry.getActiveScript().get());
|
CarryRenderHelper.performScriptTransformation(matrix, carry.getActiveScript().get());
|
||||||
|
|
||||||
//RenderSystem.setShaderTexture(0, GpuTexture);
|
|
||||||
|
|
||||||
ItemStack renderStack = CarryRenderHelper.getRenderItemStack(player);
|
ItemStack renderStack = CarryRenderHelper.getRenderItemStack(player);
|
||||||
Minecraft.getInstance().getItemModelResolver().updateForTopItem(renderState, renderStack, ItemDisplayContext.NONE, player.level(), null, 0);
|
Minecraft.getInstance().getItemModelResolver().updateForTopItem(renderState, renderStack, ItemDisplayContext.NONE, player.level(), null, 0);
|
||||||
renderState.submit(matrix, buffer, light, OverlayTexture.NO_OVERLAY);
|
renderState.submit(matrix, nodeCollector, light, OverlayTexture.NO_OVERLAY, 0);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//RenderSystem.enableCull();
|
|
||||||
//RenderSystem.disableBlend();
|
|
||||||
matrix.popPose();
|
matrix.popPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void drawFirstPersonEntity(Player player, MultiBufferSource buffer, PoseStack matrix, int light, float partialTicks) {
|
private static void drawEntity(Player player, PoseStack matrix, int light, float partialTicks,SubmitNodeCollector nodeCollector, boolean firstPerson) {
|
||||||
EntityRenderDispatcher manager = Minecraft.getInstance().getEntityRenderDispatcher();
|
EntityRenderDispatcher manager = Minecraft.getInstance().getEntityRenderDispatcher();
|
||||||
|
|
||||||
Entity entity = CarryRenderHelper.getRenderEntity(player);
|
Entity entity = CarryRenderHelper.getRenderEntity(player);
|
||||||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||||
|
|
||||||
|
|
@ -153,13 +130,17 @@ public class CarriedObjectRender
|
||||||
|
|
||||||
float height = entity.getBbHeight();
|
float height = entity.getBbHeight();
|
||||||
float width = entity.getBbWidth();
|
float width = entity.getBbWidth();
|
||||||
|
|
||||||
matrix.pushPose();
|
matrix.pushPose();
|
||||||
matrix.scale(0.8f, 0.8f, 0.8f);
|
|
||||||
matrix.mulPose(Axis.YP.rotationDegrees(180));
|
matrix.mulPose(Axis.YP.rotationDegrees(180));
|
||||||
|
if (firstPerson){
|
||||||
|
matrix.scale(0.8f, 0.8f, 0.8f);
|
||||||
matrix.translate(0.0, -height - .2, width * 1.3 + 0.1);
|
matrix.translate(0.0, -height - .2, width * 1.3 + 0.1);
|
||||||
|
}else{
|
||||||
manager.setRenderShadow(false);
|
float multiplier = Math.min(9.9f, height * width) ;
|
||||||
|
matrix.scale((10 - multiplier) * 0.08f, (10 - multiplier) * 0.08f, (10 - multiplier) * 0.08f);
|
||||||
|
matrix.translate(0.0, height / 2 + -(height / 4) + 0.5f, width - 0.1 < 0.7 ? width - 0.1 + (0.7 - (width - 0.1)) : width - 0.1);
|
||||||
|
matrix.mulPose(Axis.ZN.rotationDegrees(180));
|
||||||
|
}
|
||||||
|
|
||||||
Optional<CarryOnScript> res = carry.getActiveScript();
|
Optional<CarryOnScript> res = carry.getActiveScript();
|
||||||
if(res.isPresent())
|
if(res.isPresent())
|
||||||
|
|
@ -175,120 +156,13 @@ public class CarriedObjectRender
|
||||||
((LivingEntity) entity).hurtTime = 0;
|
((LivingEntity) entity).hurtTime = 0;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
manager.render(entity, 0, 0, 0, 0f, matrix, buffer, light);
|
manager.submit(manager.extractEntity(entity, 0), new CameraRenderState(), 0, 0, 0, matrix, nodeCollector);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
manager.setRenderShadow(true);
|
|
||||||
matrix.popPose();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// RenderSystem.disableAlphaTest();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Draws the third person view of entities and blocks
|
|
||||||
* @param partialticks
|
|
||||||
* @param mat
|
|
||||||
*/
|
|
||||||
public static void drawThirdPerson(float partialticks, Matrix4f mat) {
|
|
||||||
Minecraft mc = Minecraft.getInstance();
|
|
||||||
Level level = mc.level;
|
|
||||||
int light = 0;
|
|
||||||
int perspective = CarryRenderHelper.getPerspective();
|
|
||||||
EntityRenderDispatcher manager = mc.getEntityRenderDispatcher();
|
|
||||||
|
|
||||||
PoseStack matrix = new PoseStack();
|
|
||||||
matrix.mulPose(mat);
|
|
||||||
|
|
||||||
//RenderSystem.enableBlend();
|
|
||||||
//RenderSystem.disableCull();
|
|
||||||
//RenderSystem.disableDepthTest();
|
|
||||||
|
|
||||||
BufferSource buffer = MultiBufferSource.immediateWithBuffers(builders, builders.get(RenderType.glint()));
|
|
||||||
ItemStackRenderState renderState = new ItemStackRenderState();
|
|
||||||
var layer = renderState.newLayer();
|
|
||||||
layer.setRenderType(RenderType.glint());
|
|
||||||
|
|
||||||
for (Player player : level.players())
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
|
|
||||||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
|
||||||
|
|
||||||
if (perspective == 0 && player == mc.player && !(Services.PLATFORM.isModLoaded("firstperson") || Services.PLATFORM.isModLoaded("firstpersonmod") || Services.PLATFORM.isModLoaded("realcamera")))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
light = manager.getPackedLightCoords(player, partialticks);
|
|
||||||
|
|
||||||
if (carry.isCarrying(CarryType.BLOCK)) {
|
|
||||||
BlockState state = CarryRenderHelper.getRenderState(player);
|
|
||||||
|
|
||||||
CarryRenderHelper.applyBlockTransformations(player, partialticks, matrix, state.getBlock());
|
|
||||||
|
|
||||||
ItemStack renderItemStack = CarryRenderHelper.getRenderItemStack(player);
|
|
||||||
|
|
||||||
mc.getItemModelResolver().updateForTopItem(renderState, renderItemStack, ItemDisplayContext.NONE, level, null, 0);
|
|
||||||
|
|
||||||
Optional<CarryOnScript> res = carry.getActiveScript();
|
|
||||||
res.ifPresent(script -> CarryRenderHelper.performScriptTransformation(matrix, script));
|
|
||||||
|
|
||||||
//RenderSystem.setShaderTexture(0, TextureAtlas.LOCATION_BLOCKS);
|
|
||||||
//RenderSystem.enableCull();
|
|
||||||
|
|
||||||
PoseStack.Pose p = matrix.last();
|
|
||||||
PoseStack copy = new PoseStack();
|
|
||||||
copy.mulPose(p.pose());
|
|
||||||
matrix.popPose();
|
|
||||||
|
|
||||||
//RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
|
||||||
|
|
||||||
renderState.render(copy, buffer, light, OverlayTexture.NO_OVERLAY);
|
|
||||||
|
|
||||||
matrix.popPose();
|
|
||||||
} else if (carry.isCarrying(CarryType.ENTITY)) {
|
|
||||||
Entity entity = CarryRenderHelper.getRenderEntity(player);
|
|
||||||
|
|
||||||
if (entity != null) {
|
|
||||||
CarryRenderHelper.applyEntityTransformations(player, partialticks, matrix, entity);
|
|
||||||
|
|
||||||
manager.setRenderShadow(false);
|
|
||||||
|
|
||||||
Optional<CarryOnScript> res = carry.getActiveScript();
|
|
||||||
res.ifPresent(script -> CarryRenderHelper.performScriptTransformation(matrix, script));
|
|
||||||
|
|
||||||
if (entity instanceof LivingEntity le)
|
|
||||||
le.hurtTime = 0;
|
|
||||||
|
|
||||||
//RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
|
||||||
|
|
||||||
manager.render(entity, 0, 0, 0, 0f, matrix, buffer, light);
|
|
||||||
matrix.popPose();
|
|
||||||
manager.setRenderShadow(true);
|
|
||||||
matrix.popPose();
|
matrix.popPose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
buffer.endLastBatch();
|
|
||||||
|
|
||||||
buffer.endBatch(RenderType.entitySolid(TextureAtlas.LOCATION_BLOCKS));
|
|
||||||
buffer.endBatch(RenderType.entityCutout(TextureAtlas.LOCATION_BLOCKS));
|
|
||||||
buffer.endBatch(RenderType.entityCutoutNoCull(TextureAtlas.LOCATION_BLOCKS));
|
|
||||||
buffer.endBatch(RenderType.entitySmoothCutout(TextureAtlas.LOCATION_BLOCKS));
|
|
||||||
|
|
||||||
//RenderSystem.enableDepthTest();
|
|
||||||
//RenderSystem.enableCull();
|
|
||||||
//RenderSystem.disableBlend();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,49 +1,48 @@
|
||||||
//package tschipp.carryon.client.render;
|
// package tschipp.carryon.client.render;
|
||||||
//
|
|
||||||
//import com.mojang.blaze3d.pipeline.BlendFunction;
|
// import com.mojang.blaze3d.pipeline.BlendFunction;
|
||||||
//import com.mojang.blaze3d.pipeline.RenderPipeline;
|
// import com.mojang.blaze3d.pipeline.RenderPipeline;
|
||||||
//import com.mojang.blaze3d.pipeline.RenderTarget;
|
// import com.mojang.blaze3d.platform.DepthTestFunction;
|
||||||
//import com.mojang.blaze3d.platform.DepthTestFunction;
|
// import com.mojang.blaze3d.vertex.MeshData;
|
||||||
//import com.mojang.blaze3d.vertex.MeshData;
|
// import com.mojang.blaze3d.vertex.VertexFormat;
|
||||||
//import com.mojang.blaze3d.vertex.VertexFormat;
|
// import net.minecraft.client.renderer.RenderType;
|
||||||
//import net.minecraft.client.renderer.RenderType;
|
// import org.jetbrains.annotations.NotNull;
|
||||||
//import org.jetbrains.annotations.NotNull;
|
|
||||||
//
|
// import java.util.IdentityHashMap;
|
||||||
//import java.util.IdentityHashMap;
|
// import java.util.Map;
|
||||||
//import java.util.Map;
|
|
||||||
//
|
// //Credit: klikli for the idea and code for this wrapper
|
||||||
////Credit: klikli for the idea and code for this wrapper
|
// public class CarryOnRenderType extends RenderType {
|
||||||
//public class CarryOnRenderType extends RenderType {
|
|
||||||
//
|
|
||||||
// private static final Map<RenderType, RenderType> remappedTypes = new IdentityHashMap<>();
|
// private static final Map<RenderType, RenderType> remappedTypes = new IdentityHashMap<>();
|
||||||
// private final RenderPipeline pipeline;
|
// private final RenderPipeline pipeline;
|
||||||
// private final RenderType original;
|
// private final RenderType original;
|
||||||
//
|
|
||||||
// private CarryOnRenderType(RenderType original, RenderPipeline pipeline) {
|
// private CarryOnRenderType(RenderType original, RenderPipeline pipeline) {
|
||||||
// super(String.format("%s_carryon", original.toString()), original.bufferSize(), original.affectsCrumbling(), true, original::setupRenderState, original::clearRenderState);
|
// super(String.format("%s_carryon", original.toString()), original.bufferSize(), original.affectsCrumbling(), true, original::setupRenderState, original::clearRenderState);
|
||||||
// this.pipeline = pipeline;
|
// this.pipeline = pipeline;
|
||||||
// this.original = original;
|
// this.original = original;
|
||||||
// }
|
// }
|
||||||
//
|
|
||||||
// public static RenderType remap(RenderType in) {
|
// public static RenderType remap(RenderType in) {
|
||||||
// return remappedTypes.computeIfAbsent(in, (type) -> {
|
// return remappedTypes.computeIfAbsent(in, (type) -> {
|
||||||
//
|
|
||||||
// //modify the pipeline
|
// //modify the pipeline
|
||||||
// var pipeline = toBuilder(in.getRenderPipeline())
|
// var pipeline = toBuilder(in.pipeline())
|
||||||
// .withBlend(BlendFunction.TRANSLUCENT)
|
// .withBlend(BlendFunction.TRANSLUCENT)
|
||||||
// .withDepthTestFunction(DepthTestFunction.NO_DEPTH_TEST)
|
// .withDepthTestFunction(DepthTestFunction.NO_DEPTH_TEST)
|
||||||
// .withCull(false);
|
// .withCull(false);
|
||||||
//
|
|
||||||
// return new CarryOnRenderType(type, pipeline.build());
|
// return new CarryOnRenderType(type, pipeline.build());
|
||||||
// });
|
// });
|
||||||
// }
|
// }
|
||||||
//
|
|
||||||
// private static RenderPipeline.Builder toBuilder(RenderPipeline pipeline) {
|
// private static RenderPipeline.Builder toBuilder(RenderPipeline pipeline) {
|
||||||
// RenderPipeline.Builder builder = RenderPipeline.builder();
|
// RenderPipeline.Builder builder = RenderPipeline.builder();
|
||||||
// builder.withLocation(pipeline.getLocation());
|
// builder.withLocation(pipeline.getLocation());
|
||||||
// builder.withFragmentShader(pipeline.getFragmentShader());
|
// builder.withFragmentShader(pipeline.getFragmentShader());
|
||||||
// builder.withVertexShader(pipeline.getVertexShader());
|
// builder.withVertexShader(pipeline.getVertexShader());
|
||||||
//
|
|
||||||
// if (!pipeline.getShaderDefines().isEmpty()) {
|
// if (!pipeline.getShaderDefines().isEmpty()) {
|
||||||
// for (Map.Entry<String, String> entry : pipeline.getShaderDefines().values().entrySet()) {
|
// for (Map.Entry<String, String> entry : pipeline.getShaderDefines().values().entrySet()) {
|
||||||
// try {
|
// try {
|
||||||
|
|
@ -58,54 +57,52 @@
|
||||||
// builder.withShaderDefine(flag);
|
// builder.withShaderDefine(flag);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//
|
|
||||||
// if (!pipeline.getSamplers().isEmpty()) {
|
// if (!pipeline.getSamplers().isEmpty()) {
|
||||||
// pipeline.getSamplers().forEach(builder::withSampler);
|
// pipeline.getSamplers().forEach(builder::withSampler);
|
||||||
// }
|
// }
|
||||||
//
|
|
||||||
// if (!pipeline.getUniforms().isEmpty()) {
|
// if (!pipeline.getUniforms().isEmpty()) {
|
||||||
// pipeline.getUniforms().forEach(u -> builder.withUniform(u.name(), u.type()));
|
// pipeline.getUniforms().forEach(u -> builder.withUniform(u.name(), u.type()));
|
||||||
// }
|
// }
|
||||||
//
|
|
||||||
// builder.withDepthTestFunction(pipeline.getDepthTestFunction());
|
// builder.withDepthTestFunction(pipeline.getDepthTestFunction());
|
||||||
// builder.withPolygonMode(pipeline.getPolygonMode());
|
// builder.withPolygonMode(pipeline.getPolygonMode());
|
||||||
// builder.withCull(pipeline.isCull());
|
// builder.withCull(pipeline.isCull());
|
||||||
// builder.withColorWrite(pipeline.isWriteColor(), pipeline.isWriteAlpha());
|
// builder.withColorWrite(pipeline.isWriteColor(), pipeline.isWriteAlpha());
|
||||||
// builder.withDepthWrite(pipeline.isWriteDepth());
|
// builder.withDepthWrite(pipeline.isWriteDepth());
|
||||||
// builder.withColorLogic(pipeline.getColorLogic());
|
// builder.withColorLogic(pipeline.getColorLogic());
|
||||||
//
|
|
||||||
// if (pipeline.getBlendFunction().isPresent())
|
// if (pipeline.getBlendFunction().isPresent())
|
||||||
// builder.withBlend(pipeline.getBlendFunction().get());
|
// builder.withBlend(pipeline.getBlendFunction().get());
|
||||||
// else
|
// else
|
||||||
// builder.withoutBlend();
|
// builder.withoutBlend();
|
||||||
// builder.withVertexFormat(pipeline.getVertexFormat(), pipeline.getVertexFormatMode());
|
// builder.withVertexFormat(pipeline.getVertexFormat(), pipeline.getVertexFormatMode());
|
||||||
// builder.withDepthBias(pipeline.getDepthBiasScaleFactor(), pipeline.getDepthBiasConstant());
|
// builder.withDepthBias(pipeline.getDepthBiasScaleFactor(), pipeline.getDepthBiasConstant());
|
||||||
//
|
|
||||||
// return builder;
|
// return builder;
|
||||||
// }
|
// }
|
||||||
//
|
|
||||||
// @Override
|
// @Override
|
||||||
// public void draw(@NotNull MeshData meshData) {
|
// public void draw(@NotNull MeshData meshData) {
|
||||||
// this.original.draw(meshData);
|
// this.original.draw(meshData);
|
||||||
// }
|
// }
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public @NotNull RenderTarget getRenderTarget() {
|
|
||||||
// return this.original.getRenderTarget();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public @NotNull RenderPipeline getRenderPipeline() {
|
|
||||||
// return this.pipeline; //get our own modified pipeline
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
// @Override
|
||||||
// public @NotNull VertexFormat format() {
|
// public @NotNull VertexFormat format() {
|
||||||
// return this.original.format();
|
// return this.original.format();
|
||||||
// }
|
// }
|
||||||
//
|
|
||||||
// @Override
|
// @Override
|
||||||
// public VertexFormat.@NotNull Mode mode() {
|
// public VertexFormat.@NotNull Mode mode() {
|
||||||
// return this.original.mode();
|
// return this.original.mode();
|
||||||
// }
|
// }
|
||||||
//}
|
|
||||||
|
// @Override
|
||||||
|
// public RenderPipeline pipeline() {
|
||||||
|
// return this.pipeline; //get our own modified pipeline
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
|
||||||
|
|
@ -156,7 +156,7 @@ public class CarryRenderHelper
|
||||||
|
|
||||||
public static void applyBlockTransformations(Player player, float partialticks, PoseStack matrix, Block block)
|
public static void applyBlockTransformations(Player player, float partialticks, PoseStack matrix, Block block)
|
||||||
{
|
{
|
||||||
int perspective = CarryRenderHelper.getPerspective();
|
//int perspective = CarryRenderHelper.getPerspective();
|
||||||
|
|
||||||
applyGeneralTransformations(player, partialticks, matrix);
|
applyGeneralTransformations(player, partialticks, matrix);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
package tschipp.carryon.client.render;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
|
||||||
|
import net.minecraft.client.model.PlayerModel;
|
||||||
|
import net.minecraft.client.renderer.SubmitNodeCollector;
|
||||||
|
import net.minecraft.client.renderer.entity.RenderLayerParent;
|
||||||
|
import net.minecraft.client.renderer.entity.layers.RenderLayer;
|
||||||
|
import net.minecraft.client.renderer.entity.state.AvatarRenderState;
|
||||||
|
|
||||||
|
public class CarryingItemRenderLayer<M extends PlayerModel> extends RenderLayer<AvatarRenderState, M> {
|
||||||
|
public CarryingItemRenderLayer(RenderLayerParent<AvatarRenderState, M> renderer) {
|
||||||
|
super(renderer);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void submit(PoseStack poseStack, SubmitNodeCollector nodeCollector, int packedLight,
|
||||||
|
AvatarRenderState renderState, float yRot, float xRot) {
|
||||||
|
if (renderState instanceof ICarryOnRenderState carryOnRenderState){
|
||||||
|
CarriedObjectRender.draw(carryOnRenderState.getPlayer(), poseStack, packedLight, 0, nodeCollector,false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package tschipp.carryon.client.render;
|
package tschipp.carryon.client.render;
|
||||||
|
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
import tschipp.carryon.common.carry.CarryOnData;
|
import tschipp.carryon.common.carry.CarryOnData;
|
||||||
|
|
||||||
public interface ICarryOnRenderState {
|
public interface ICarryOnRenderState {
|
||||||
|
|
@ -12,4 +13,8 @@ public interface ICarryOnRenderState {
|
||||||
|
|
||||||
void setRenderWidth(float val);
|
void setRenderWidth(float val);
|
||||||
|
|
||||||
|
Player getPlayer();
|
||||||
|
|
||||||
|
void setPlayer(Player player);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@ package tschipp.carryon.common.carry;
|
||||||
|
|
||||||
import com.mojang.serialization.Codec;
|
import com.mojang.serialization.Codec;
|
||||||
import com.mojang.serialization.DataResult;
|
import com.mojang.serialization.DataResult;
|
||||||
import com.mojang.serialization.MapCodec;
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.HolderLookup;
|
import net.minecraft.core.HolderLookup;
|
||||||
import net.minecraft.core.registries.BuiltInRegistries;
|
import net.minecraft.core.registries.BuiltInRegistries;
|
||||||
|
|
@ -39,6 +38,7 @@ import net.minecraft.world.entity.AreaEffectCloud;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.EntitySpawnReason;
|
import net.minecraft.world.entity.EntitySpawnReason;
|
||||||
import net.minecraft.world.entity.EntityType;
|
import net.minecraft.world.entity.EntityType;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
|
@ -50,8 +50,8 @@ import tschipp.carryon.Constants;
|
||||||
import tschipp.carryon.common.scripting.CarryOnScript;
|
import tschipp.carryon.common.scripting.CarryOnScript;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class CarryOnData {
|
public class CarryOnData {
|
||||||
|
|
||||||
|
|
@ -105,6 +105,11 @@ public class CarryOnData {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CarryType getType()
|
||||||
|
{
|
||||||
|
return this.type;
|
||||||
|
}
|
||||||
|
|
||||||
public CompoundTag getNbt()
|
public CompoundTag getNbt()
|
||||||
{
|
{
|
||||||
nbt.putString("type", type.toString());
|
nbt.putString("type", type.toString());
|
||||||
|
|
@ -203,8 +208,20 @@ public class CarryOnData {
|
||||||
this.activeScript = script;
|
this.activeScript = script;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCarryingPlayer() {
|
public void setCarryingPlayer(Player player)
|
||||||
|
{
|
||||||
this.type = CarryType.PLAYER;
|
this.type = CarryType.PLAYER;
|
||||||
|
nbt.putString("player", player.getStringUUID().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Player getCarryingPlayer(Level level)
|
||||||
|
{
|
||||||
|
if(this.type != CarryType.PLAYER)
|
||||||
|
throw new IllegalStateException("Called getCarryingPlayer on data that contained " + this.type);
|
||||||
|
if(!nbt.contains("player"))
|
||||||
|
return null;
|
||||||
|
UUID uuid = UUID.fromString(nbt.getString("player").get());
|
||||||
|
return level.getServer().getPlayerList().getPlayer(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCarrying()
|
public boolean isCarrying()
|
||||||
|
|
|
||||||
|
|
@ -20,11 +20,6 @@
|
||||||
|
|
||||||
package tschipp.carryon.common.carry;
|
package tschipp.carryon.common.carry;
|
||||||
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
|
||||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
|
||||||
import net.minecraft.network.syncher.SynchedEntityData;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import tschipp.carryon.platform.Services;
|
import tschipp.carryon.platform.Services;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,8 @@ import net.minecraft.world.effect.MobEffects;
|
||||||
import net.minecraft.world.entity.AgeableMob;
|
import net.minecraft.world.entity.AgeableMob;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.Entity.RemovalReason;
|
import net.minecraft.world.entity.Entity.RemovalReason;
|
||||||
|
import net.minecraft.world.entity.EntityReference;
|
||||||
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.world.entity.MobCategory;
|
import net.minecraft.world.entity.MobCategory;
|
||||||
import net.minecraft.world.entity.TamableAnimal;
|
import net.minecraft.world.entity.TamableAnimal;
|
||||||
import net.minecraft.world.entity.animal.Animal;
|
import net.minecraft.world.entity.animal.Animal;
|
||||||
|
|
@ -50,7 +52,6 @@ import tschipp.carryon.common.pickupcondition.PickupConditionHandler;
|
||||||
import tschipp.carryon.common.scripting.CarryOnScript;
|
import tschipp.carryon.common.scripting.CarryOnScript;
|
||||||
import tschipp.carryon.common.scripting.ScriptManager;
|
import tschipp.carryon.common.scripting.ScriptManager;
|
||||||
import tschipp.carryon.networking.clientbound.ClientboundStartRidingOtherPlayerPacket;
|
import tschipp.carryon.networking.clientbound.ClientboundStartRidingOtherPlayerPacket;
|
||||||
import tschipp.carryon.networking.clientbound.ClientboundStartRidingPacket;
|
|
||||||
import tschipp.carryon.platform.Services;
|
import tschipp.carryon.platform.Services;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
@ -142,7 +143,7 @@ public class PickupHandler {
|
||||||
|
|
||||||
String cmd = script.scriptEffects().commandInit();
|
String cmd = script.scriptEffects().commandInit();
|
||||||
if(!cmd.isEmpty())
|
if(!cmd.isEmpty())
|
||||||
player.getServer().getCommands().performPrefixedCommand(player.getServer().createCommandSourceStack(), "/execute as " + player.getGameProfile().getName() + " run " + cmd);
|
player.level().getServer().getCommands().performPrefixedCommand(player.level().getServer().createCommandSourceStack(), "/execute as " + player.getGameProfile().name() + " run " + cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
carry.setBlock(state, blockEntity, player, pos);
|
carry.setBlock(state, blockEntity, player, pos);
|
||||||
|
|
@ -173,11 +174,14 @@ public class PickupHandler {
|
||||||
|
|
||||||
if (entity instanceof TamableAnimal tame)
|
if (entity instanceof TamableAnimal tame)
|
||||||
{
|
{
|
||||||
UUID owner = tame.getOwnerReference().getUUID();
|
EntityReference<LivingEntity> ref = tame.getOwnerReference();
|
||||||
UUID playerID = player.getGameProfile().getId();
|
if (ref != null) {
|
||||||
if (owner != null && !owner.equals(playerID))
|
UUID owner = ref.getUUID();
|
||||||
|
UUID playerID = player.getGameProfile().id();
|
||||||
|
if (!owner.equals(playerID))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(!ListHandler.isPermitted(entity))
|
if(!ListHandler.isPermitted(entity))
|
||||||
{
|
{
|
||||||
|
|
@ -232,12 +236,12 @@ public class PickupHandler {
|
||||||
if (result.isPresent()) {
|
if (result.isPresent()) {
|
||||||
String cmd = result.get().scriptEffects().commandInit();
|
String cmd = result.get().scriptEffects().commandInit();
|
||||||
if (!cmd.isEmpty())
|
if (!cmd.isEmpty())
|
||||||
player.getServer().getCommands().performPrefixedCommand(player.getServer().createCommandSourceStack(), "/execute as " + player.getGameProfile().getName() + " run " + cmd);
|
player.level().getServer().getCommands().performPrefixedCommand(player.level().getServer().createCommandSourceStack(), "/execute as " + player.getGameProfile().name() + " run " + cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
otherPlayer.startRiding(player, true);
|
otherPlayer.startRiding(player, true, false);
|
||||||
Services.PLATFORM.sendPacketToAllPlayers(Constants.PACKET_ID_START_RIDING_OTHER, new ClientboundStartRidingOtherPlayerPacket(player.getId(), otherPlayer.getId(), true), player.level());
|
Services.PLATFORM.sendPacketToAllPlayers(Constants.PACKET_ID_START_RIDING_OTHER, new ClientboundStartRidingOtherPlayerPacket(player.getId(), otherPlayer.getId(), true), player.level());
|
||||||
carry.setCarryingPlayer();
|
carry.setCarryingPlayer(otherPlayer);
|
||||||
player.swing(InteractionHand.MAIN_HAND, true);
|
player.swing(InteractionHand.MAIN_HAND, true);
|
||||||
player.level().playSound(null, player.getOnPos(), SoundEvents.ARMOR_EQUIP_GENERIC.value(), SoundSource.AMBIENT, 1.0f, 0.5f);
|
player.level().playSound(null, player.getOnPos(), SoundEvents.ARMOR_EQUIP_GENERIC.value(), SoundSource.AMBIENT, 1.0f, 0.5f);
|
||||||
CarryOnDataManager.setCarryData(player, carry);
|
CarryOnDataManager.setCarryData(player, carry);
|
||||||
|
|
@ -257,7 +261,7 @@ public class PickupHandler {
|
||||||
{
|
{
|
||||||
String cmd = result.get().scriptEffects().commandInit();
|
String cmd = result.get().scriptEffects().commandInit();
|
||||||
if(!cmd.isEmpty())
|
if(!cmd.isEmpty())
|
||||||
player.getServer().getCommands().performPrefixedCommand(player.getServer().createCommandSourceStack(), "/execute as " + player.getGameProfile().getName() + " run " + cmd);
|
player.level().getServer().getCommands().performPrefixedCommand(player.level().getServer().createCommandSourceStack(), "/execute as " + player.getGameProfile().name() + " run " + cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
carry.setEntity(entity);
|
carry.setEntity(entity);
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,6 @@ import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.sounds.SoundEvents;
|
import net.minecraft.sounds.SoundEvents;
|
||||||
import net.minecraft.sounds.SoundSource;
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.effect.MobEffectInstance;
|
|
||||||
import net.minecraft.world.effect.MobEffects;
|
import net.minecraft.world.effect.MobEffects;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.Mob;
|
import net.minecraft.world.entity.Mob;
|
||||||
|
|
@ -44,7 +43,6 @@ import net.minecraft.world.level.block.state.properties.Property;
|
||||||
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.minecraft.world.phys.shapes.CollisionContext;
|
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||||
import tschipp.carryon.CarryOnCommon;
|
|
||||||
import tschipp.carryon.Constants;
|
import tschipp.carryon.Constants;
|
||||||
import tschipp.carryon.common.carry.CarryOnData.CarryType;
|
import tschipp.carryon.common.carry.CarryOnData.CarryType;
|
||||||
import tschipp.carryon.common.config.ListHandler;
|
import tschipp.carryon.common.config.ListHandler;
|
||||||
|
|
@ -99,7 +97,7 @@ public class PlacementHandler
|
||||||
ScriptEffects effects = carry.getActiveScript().get().scriptEffects();
|
ScriptEffects effects = carry.getActiveScript().get().scriptEffects();
|
||||||
String cmd = effects.commandPlace();
|
String cmd = effects.commandPlace();
|
||||||
if (!cmd.isEmpty())
|
if (!cmd.isEmpty())
|
||||||
player.getServer().getCommands().performPrefixedCommand(player.getServer().createCommandSourceStack(), "/execute as " + player.getGameProfile().getName() + " run " + cmd);
|
player.level().getServer().getCommands().performPrefixedCommand(player.level().getServer().createCommandSourceStack(), "/execute as " + player.getGameProfile().name() + " run " + cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
level.setBlockAndUpdate(pos, state);
|
level.setBlockAndUpdate(pos, state);
|
||||||
|
|
@ -177,7 +175,7 @@ public class PlacementHandler
|
||||||
Vec3 placementPos = Vec3.atBottomCenterOf(pos);
|
Vec3 placementPos = Vec3.atBottomCenterOf(pos);
|
||||||
|
|
||||||
if (carry.isCarrying(CarryType.PLAYER)) {
|
if (carry.isCarrying(CarryType.PLAYER)) {
|
||||||
Entity otherPlayer = player.getFirstPassenger();
|
Entity otherPlayer = carry.getCarryingPlayer(level);
|
||||||
player.ejectPassengers();
|
player.ejectPassengers();
|
||||||
Services.PLATFORM.sendPacketToAllPlayers(Constants.PACKET_ID_START_RIDING_OTHER, new ClientboundStartRidingOtherPlayerPacket(player.getId(), otherPlayer.getId(), false), player.level());
|
Services.PLATFORM.sendPacketToAllPlayers(Constants.PACKET_ID_START_RIDING_OTHER, new ClientboundStartRidingOtherPlayerPacket(player.getId(), otherPlayer.getId(), false), player.level());
|
||||||
carry.clear();
|
carry.clear();
|
||||||
|
|
@ -199,7 +197,7 @@ public class PlacementHandler
|
||||||
ScriptEffects effects = carry.getActiveScript().get().scriptEffects();
|
ScriptEffects effects = carry.getActiveScript().get().scriptEffects();
|
||||||
String cmd = effects.commandPlace();
|
String cmd = effects.commandPlace();
|
||||||
if (!cmd.isEmpty())
|
if (!cmd.isEmpty())
|
||||||
player.getServer().getCommands().performPrefixedCommand(player.getServer().createCommandSourceStack(), "/execute as " + player.getGameProfile().getName() + " run " + cmd);
|
player.level().getServer().getCommands().performPrefixedCommand(player.level().getServer().createCommandSourceStack(), "/execute as " + player.getGameProfile().name() + " run " + cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
level.addFreshEntity(entity);
|
level.addFreshEntity(entity);
|
||||||
|
|
@ -257,20 +255,20 @@ public class PlacementHandler
|
||||||
level.addFreshEntity(entityHeld);
|
level.addFreshEntity(entityHeld);
|
||||||
entityHeld.teleportTo(tempX, tempY, tempZ);
|
entityHeld.teleportTo(tempX, tempY, tempZ);
|
||||||
}
|
}
|
||||||
entityHeld.startRiding(topEntity, false);
|
entityHeld.startRiding(topEntity, false,false);
|
||||||
} else {
|
} else {
|
||||||
if (carry.isCarrying(CarryType.ENTITY)) {
|
if (carry.isCarrying(CarryType.ENTITY)) {
|
||||||
entityHeld.setPos(entityClicked.getX(), entityClicked.getY(), entityClicked.getZ());
|
entityHeld.setPos(entityClicked.getX(), entityClicked.getY(), entityClicked.getZ());
|
||||||
level.addFreshEntity(entityHeld);
|
level.addFreshEntity(entityHeld);
|
||||||
}
|
}
|
||||||
entityHeld.startRiding(topEntity, false);
|
entityHeld.startRiding(topEntity, false,false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (carry.getActiveScript().isPresent()) {
|
if (carry.getActiveScript().isPresent()) {
|
||||||
ScriptEffects effects = carry.getActiveScript().get().scriptEffects();
|
ScriptEffects effects = carry.getActiveScript().get().scriptEffects();
|
||||||
String cmd = effects.commandPlace();
|
String cmd = effects.commandPlace();
|
||||||
if (!cmd.isEmpty())
|
if (!cmd.isEmpty())
|
||||||
player.getServer().getCommands().performPrefixedCommand(player.getServer().createCommandSourceStack(), "/execute as " + player.getGameProfile().getName() + " run " + cmd);
|
player.level().getServer().getCommands().performPrefixedCommand(player.level().getServer().createCommandSourceStack(), "/execute as " + player.getGameProfile().name() + " run " + cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
player.swing(InteractionHand.MAIN_HAND, true);
|
player.swing(InteractionHand.MAIN_HAND, true);
|
||||||
|
|
|
||||||
|
|
@ -22,10 +22,8 @@ package tschipp.carryon.common.scripting;
|
||||||
|
|
||||||
import com.mojang.serialization.Codec;
|
import com.mojang.serialization.Codec;
|
||||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||||
import net.minecraft.advancements.Advancement;
|
|
||||||
import net.minecraft.advancements.AdvancementHolder;
|
import net.minecraft.advancements.AdvancementHolder;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.registries.BuiltInRegistries;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.nbt.NbtUtils;
|
import net.minecraft.nbt.NbtUtils;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
@ -34,7 +32,6 @@ import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.world.effect.MobEffectInstance;
|
import net.minecraft.world.effect.MobEffectInstance;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.minecraft.world.scores.Objective;
|
import net.minecraft.world.scores.Objective;
|
||||||
import net.minecraft.world.scores.Score;
|
|
||||||
import net.minecraft.world.scores.Scoreboard;
|
import net.minecraft.world.scores.Scoreboard;
|
||||||
import tschipp.carryon.platform.Services;
|
import tschipp.carryon.platform.Services;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@ package tschipp.carryon.common.scripting;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.registries.BuiltInRegistries;
|
import net.minecraft.core.registries.BuiltInRegistries;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.nbt.Tag;
|
|
||||||
import net.minecraft.util.ProblemReporter;
|
import net.minecraft.util.ProblemReporter;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
|
|
|
||||||
|
|
@ -20,13 +20,8 @@
|
||||||
|
|
||||||
package tschipp.carryon.common.scripting;
|
package tschipp.carryon.common.scripting;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.GsonBuilder;
|
|
||||||
import com.google.gson.JsonElement;
|
|
||||||
import com.mojang.serialization.Codec;
|
import com.mojang.serialization.Codec;
|
||||||
import com.mojang.serialization.DataResult;
|
import com.mojang.serialization.DataResult;
|
||||||
import com.mojang.serialization.JsonOps;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
import net.minecraft.nbt.NbtOps;
|
import net.minecraft.nbt.NbtOps;
|
||||||
import net.minecraft.nbt.Tag;
|
import net.minecraft.nbt.Tag;
|
||||||
import net.minecraft.resources.FileToIdConverter;
|
import net.minecraft.resources.FileToIdConverter;
|
||||||
|
|
@ -37,11 +32,9 @@ import net.minecraft.server.packs.resources.SimpleJsonResourceReloadListener;
|
||||||
import net.minecraft.util.profiling.ProfilerFiller;
|
import net.minecraft.util.profiling.ProfilerFiller;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import tschipp.carryon.Constants;
|
import tschipp.carryon.Constants;
|
||||||
import tschipp.carryon.common.carry.CarryOnData;
|
|
||||||
import tschipp.carryon.networking.clientbound.ClientboundSyncScriptsPacket;
|
import tschipp.carryon.networking.clientbound.ClientboundSyncScriptsPacket;
|
||||||
import tschipp.carryon.platform.Services;
|
import tschipp.carryon.platform.Services;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class ScriptReloadListener extends SimpleJsonResourceReloadListener<CarryOnScript>
|
public class ScriptReloadListener extends SimpleJsonResourceReloadListener<CarryOnScript>
|
||||||
|
|
|
||||||
|
|
@ -4,13 +4,11 @@ import me.shedaniel.clothconfig2.api.ConfigBuilder;
|
||||||
import me.shedaniel.clothconfig2.api.ConfigCategory;
|
import me.shedaniel.clothconfig2.api.ConfigCategory;
|
||||||
import me.shedaniel.clothconfig2.api.ConfigEntryBuilder;
|
import me.shedaniel.clothconfig2.api.ConfigEntryBuilder;
|
||||||
import me.shedaniel.clothconfig2.impl.builders.SubCategoryBuilder;
|
import me.shedaniel.clothconfig2.impl.builders.SubCategoryBuilder;
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import tschipp.carryon.config.AnnotationData;
|
import tschipp.carryon.config.AnnotationData;
|
||||||
import tschipp.carryon.config.BuiltCategory;
|
import tschipp.carryon.config.BuiltCategory;
|
||||||
import tschipp.carryon.config.BuiltConfig;
|
import tschipp.carryon.config.BuiltConfig;
|
||||||
import tschipp.carryon.config.ConfigLoader;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,15 @@
|
||||||
package tschipp.carryon.mixin;
|
package tschipp.carryon.mixin;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.entity.state.AvatarRenderState;
|
import net.minecraft.client.renderer.entity.state.HumanoidRenderState;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Unique;
|
import org.spongepowered.asm.mixin.Unique;
|
||||||
import tschipp.carryon.client.render.ICarryOnRenderState;
|
import tschipp.carryon.client.render.ICarryOnRenderState;
|
||||||
import tschipp.carryon.common.carry.CarryOnData;
|
import tschipp.carryon.common.carry.CarryOnData;
|
||||||
|
|
||||||
@Mixin(AvatarRenderState.class)
|
@Mixin(HumanoidRenderState.class)
|
||||||
public class AvatarRenderStateMixin implements ICarryOnRenderState {
|
public class PlayerRenderStateMixin implements ICarryOnRenderState {
|
||||||
|
|
||||||
@Unique
|
@Unique
|
||||||
public CarryOnData carryOnData = null;
|
public CarryOnData carryOnData = null;
|
||||||
|
|
@ -15,6 +17,10 @@ public class AvatarRenderStateMixin implements ICarryOnRenderState {
|
||||||
@Unique
|
@Unique
|
||||||
public float renderWidth = 0f;
|
public float renderWidth = 0f;
|
||||||
|
|
||||||
|
|
||||||
|
@Unique
|
||||||
|
public Player player = null;
|
||||||
|
|
||||||
@Unique
|
@Unique
|
||||||
@Override
|
@Override
|
||||||
public CarryOnData getCarryOnData() {
|
public CarryOnData getCarryOnData() {
|
||||||
|
|
@ -38,4 +44,14 @@ public class AvatarRenderStateMixin implements ICarryOnRenderState {
|
||||||
public void setRenderWidth(float val) {
|
public void setRenderWidth(float val) {
|
||||||
renderWidth = val;
|
renderWidth = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Player getPlayer() {
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPlayer(Player player) {
|
||||||
|
this.player = player;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
package tschipp.carryon.mixin;
|
||||||
|
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import net.minecraft.client.entity.ClientAvatarEntity;
|
||||||
|
import net.minecraft.client.model.PlayerModel;
|
||||||
|
import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
||||||
|
import net.minecraft.client.renderer.entity.EntityRendererProvider.Context;
|
||||||
|
import net.minecraft.client.renderer.entity.LivingEntityRenderer;
|
||||||
|
import net.minecraft.client.renderer.entity.player.AvatarRenderer;
|
||||||
|
import net.minecraft.client.renderer.entity.state.AvatarRenderState;
|
||||||
|
import net.minecraft.world.entity.Avatar;
|
||||||
|
import tschipp.carryon.client.render.CarryingItemRenderLayer;
|
||||||
|
|
||||||
|
@Mixin(AvatarRenderer.class)
|
||||||
|
public abstract class AvatarRendererMixin<AvatarlikeEntity extends Avatar & ClientAvatarEntity> extends LivingEntityRenderer<AvatarlikeEntity, AvatarRenderState, PlayerModel> {
|
||||||
|
|
||||||
|
public AvatarRendererMixin(Context context, PlayerModel model, float shadowRadius) {
|
||||||
|
super(context, model, shadowRadius);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(method = "<init>(Lnet/minecraft/client/renderer/entity/EntityRendererProvider$Context;Z)V", at = @At("RETURN"))
|
||||||
|
public void init(EntityRendererProvider.Context context, boolean slim, CallbackInfo info) {
|
||||||
|
//Player
|
||||||
|
this.addLayer(new CarryingItemRenderLayer<PlayerModel>(this));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -20,7 +20,6 @@
|
||||||
|
|
||||||
package tschipp.carryon.mixin;
|
package tschipp.carryon.mixin;
|
||||||
|
|
||||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
|
|
@ -35,6 +34,9 @@ import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||||
|
|
||||||
import tschipp.carryon.Constants;
|
import tschipp.carryon.Constants;
|
||||||
import tschipp.carryon.common.carry.CarryOnData;
|
import tschipp.carryon.common.carry.CarryOnData;
|
||||||
import tschipp.carryon.common.carry.CarryOnData.CarryType;
|
import tschipp.carryon.common.carry.CarryOnData.CarryType;
|
||||||
|
|
@ -48,14 +50,15 @@ public abstract class EntityMixin
|
||||||
@Shadow
|
@Shadow
|
||||||
public boolean hasPassenger(Entity pEntity) {throw new IllegalStateException("EntityMixin application failed");}
|
public boolean hasPassenger(Entity pEntity) {throw new IllegalStateException("EntityMixin application failed");}
|
||||||
|
|
||||||
@Shadow public abstract void onPassengerTurned(Entity $$0);
|
|
||||||
|
|
||||||
@ModifyExpressionValue(method = "startRiding(Lnet/minecraft/world/entity/Entity;Z)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/EntityType;canSerialize()Z"))
|
@ModifyExpressionValue(method = "startRiding(Lnet/minecraft/world/entity/Entity;ZZ)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/EntityType;canSerialize()Z"))
|
||||||
private boolean onStartRidingCheck(boolean original, Entity entity, boolean force) {
|
private boolean onStartRidingCheck(boolean original, Entity entity, boolean force) {
|
||||||
if (force && entity instanceof Player) return true;
|
if (force && entity instanceof Player) return true;
|
||||||
return original;
|
return original;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Shadow public abstract void onPassengerTurned(Entity $$0);
|
||||||
|
|
||||||
@Inject(method = "positionRider(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/entity/Entity$MoveFunction;)V", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "positionRider(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/entity/Entity$MoveFunction;)V", at = @At("HEAD"), cancellable = true)
|
||||||
private void onPositionPassenger(Entity entity, MoveFunction move, CallbackInfo ci)
|
private void onPositionPassenger(Entity entity, MoveFunction move, CallbackInfo ci)
|
||||||
{
|
{
|
||||||
|
|
@ -92,7 +95,7 @@ public abstract class EntityMixin
|
||||||
@Inject(method = "onPassengerTurned(Lnet/minecraft/world/entity/Entity;)V", at = @At("HEAD"))
|
@Inject(method = "onPassengerTurned(Lnet/minecraft/world/entity/Entity;)V", at = @At("HEAD"))
|
||||||
private void onPassengerTurned(Entity toUpdate, CallbackInfo ci)
|
private void onPassengerTurned(Entity toUpdate, CallbackInfo ci)
|
||||||
{
|
{
|
||||||
if((Object)this instanceof Player thisPlayer && toUpdate instanceof Player otherPlayer)
|
if((Object)this instanceof Player thisPlayer && toUpdate instanceof Player)
|
||||||
{
|
{
|
||||||
CarryOnData carry = CarryOnDataManager.getCarryData(thisPlayer);
|
CarryOnData carry = CarryOnDataManager.getCarryData(thisPlayer);
|
||||||
if(carry.isCarrying(CarryType.PLAYER)) {
|
if(carry.isCarrying(CarryType.PLAYER)) {
|
||||||
|
|
|
||||||
|
|
@ -23,13 +23,14 @@ public class EntityRendererMixin {
|
||||||
shift = At.Shift.AFTER
|
shift = At.Shift.AFTER
|
||||||
), method = "createRenderState(Lnet/minecraft/world/entity/Entity;F)Lnet/minecraft/client/renderer/entity/state/EntityRenderState;")
|
), method = "createRenderState(Lnet/minecraft/world/entity/Entity;F)Lnet/minecraft/client/renderer/entity/state/EntityRenderState;")
|
||||||
private void onCreateRenderState(Entity entity, float $$1, CallbackInfoReturnable<EntityRenderState> cir, @Local(ordinal = 0) EntityRenderState state) {
|
private void onCreateRenderState(Entity entity, float $$1, CallbackInfoReturnable<EntityRenderState> cir, @Local(ordinal = 0) EntityRenderState state) {
|
||||||
|
|
||||||
if (entity instanceof Player player) {
|
if (entity instanceof Player player) {
|
||||||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||||
|
|
||||||
ICarryOnRenderState carryOnRenderState = (ICarryOnRenderState) state;
|
ICarryOnRenderState carryOnRenderState = (ICarryOnRenderState) state;
|
||||||
carryOnRenderState.setCarryOnData(carry);
|
carryOnRenderState.setCarryOnData(carry);
|
||||||
carryOnRenderState.setRenderWidth(CarryRenderHelper.getRenderWidth(player));
|
carryOnRenderState.setRenderWidth(CarryRenderHelper.getRenderWidth(player));
|
||||||
|
|
||||||
|
carryOnRenderState.setPlayer(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@ package tschipp.carryon.mixin;
|
||||||
import net.minecraft.client.model.HumanoidModel;
|
import net.minecraft.client.model.HumanoidModel;
|
||||||
import net.minecraft.client.model.geom.ModelPart;
|
import net.minecraft.client.model.geom.ModelPart;
|
||||||
import net.minecraft.client.renderer.entity.state.HumanoidRenderState;
|
import net.minecraft.client.renderer.entity.state.HumanoidRenderState;
|
||||||
import net.minecraft.client.renderer.entity.state.AvatarRenderState;
|
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@ package tschipp.carryon.mixin;
|
||||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||||
import net.minecraft.core.NonNullList;
|
import net.minecraft.core.NonNullList;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
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.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
|
@ -33,7 +32,6 @@ import org.spongepowered.asm.mixin.Shadow;
|
||||||
import org.spongepowered.asm.mixin.Unique;
|
import org.spongepowered.asm.mixin.Unique;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
import tschipp.carryon.common.carry.CarryOnData;
|
import tschipp.carryon.common.carry.CarryOnData;
|
||||||
import tschipp.carryon.common.carry.CarryOnDataManager;
|
import tschipp.carryon.common.carry.CarryOnDataManager;
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@ import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
|
||||||
import tschipp.carryon.common.carry.CarryOnDataManager;
|
import tschipp.carryon.common.carry.CarryOnDataManager;
|
||||||
|
|
||||||
@Mixin(Minecraft.class)
|
@Mixin(Minecraft.class)
|
||||||
|
|
|
||||||
|
|
@ -20,26 +20,20 @@
|
||||||
|
|
||||||
package tschipp.carryon.mixin;
|
package tschipp.carryon.mixin;
|
||||||
|
|
||||||
|
import net.minecraft.world.effect.MobEffects;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
|
||||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
|
||||||
import net.minecraft.network.syncher.SynchedEntityData;
|
|
||||||
import net.minecraft.world.entity.EntityType;
|
import net.minecraft.world.entity.EntityType;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
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.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.storage.ValueInput;
|
import net.minecraft.world.level.storage.ValueInput;
|
||||||
import net.minecraft.world.level.storage.ValueOutput;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
|
||||||
import org.spongepowered.asm.mixin.Unique;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
import tschipp.carryon.common.carry.CarryOnData;
|
import tschipp.carryon.common.carry.CarryOnData;
|
||||||
import tschipp.carryon.common.carry.CarryOnDataManager;
|
import tschipp.carryon.common.carry.CarryOnDataManager;
|
||||||
|
import tschipp.carryon.common.carry.CarryOnData.CarryType;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
|
@ -58,4 +52,17 @@ public abstract class PlayerMixin extends LivingEntity {
|
||||||
res.ifPresent(data -> CarryOnDataManager.setCarryData((Player)((Object)this), data));
|
res.ifPresent(data -> CarryOnDataManager.setCarryData((Player)((Object)this), data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stopRiding() {
|
||||||
|
Entity entity = this.getVehicle();
|
||||||
|
if (entity instanceof Player && entity.getPassengers().size() < 2){
|
||||||
|
CarryOnData carry = CarryOnDataManager.getCarryData((Player) entity);
|
||||||
|
if (carry.getType() == CarryType.PLAYER){
|
||||||
|
carry.clear();
|
||||||
|
((Player) entity).removeEffect(MobEffects.SLOWNESS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
super.stopRiding();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,12 +20,7 @@
|
||||||
|
|
||||||
package tschipp.carryon.networking;
|
package tschipp.carryon.networking;
|
||||||
|
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
|
||||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
|
||||||
import net.minecraft.network.codec.StreamCodec;
|
|
||||||
import net.minecraft.network.protocol.Packet;
|
|
||||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
|
||||||
public interface PacketBase extends CustomPacketPayload {
|
public interface PacketBase extends CustomPacketPayload {
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ public record ClientboundStartRidingOtherPlayerPacket(int mount, int rider, bool
|
||||||
|
|
||||||
if(mount != null && rider != null)
|
if(mount != null && rider != null)
|
||||||
if(ride)
|
if(ride)
|
||||||
rider.startRiding(mount, true);
|
rider.startRiding(mount, true,true);
|
||||||
else
|
else
|
||||||
rider.stopRiding();
|
rider.stopRiding();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,12 +20,10 @@
|
||||||
|
|
||||||
package tschipp.carryon.networking.clientbound;
|
package tschipp.carryon.networking.clientbound;
|
||||||
|
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
|
||||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||||
import net.minecraft.network.codec.ByteBufCodecs;
|
import net.minecraft.network.codec.ByteBufCodecs;
|
||||||
import net.minecraft.network.codec.StreamCodec;
|
import net.minecraft.network.codec.StreamCodec;
|
||||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import tschipp.carryon.Constants;
|
import tschipp.carryon.Constants;
|
||||||
|
|
|
||||||
|
|
@ -22,16 +22,12 @@ package tschipp.carryon.networking.clientbound;
|
||||||
|
|
||||||
import com.mojang.serialization.Codec;
|
import com.mojang.serialization.Codec;
|
||||||
import com.mojang.serialization.DataResult;
|
import com.mojang.serialization.DataResult;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
import net.minecraft.nbt.NbtOps;
|
import net.minecraft.nbt.NbtOps;
|
||||||
import net.minecraft.nbt.Tag;
|
import net.minecraft.nbt.Tag;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
|
||||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||||
import net.minecraft.network.codec.ByteBufCodecs;
|
import net.minecraft.network.codec.ByteBufCodecs;
|
||||||
import net.minecraft.network.codec.StreamCodec;
|
import net.minecraft.network.codec.StreamCodec;
|
||||||
import net.minecraft.network.protocol.Packet;
|
|
||||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import tschipp.carryon.Constants;
|
import tschipp.carryon.Constants;
|
||||||
import tschipp.carryon.common.scripting.CarryOnScript;
|
import tschipp.carryon.common.scripting.CarryOnScript;
|
||||||
|
|
|
||||||
|
|
@ -20,20 +20,15 @@
|
||||||
|
|
||||||
package tschipp.carryon.networking.serverbound;
|
package tschipp.carryon.networking.serverbound;
|
||||||
|
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
|
||||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||||
import net.minecraft.network.codec.ByteBufCodecs;
|
import net.minecraft.network.codec.ByteBufCodecs;
|
||||||
import net.minecraft.network.codec.StreamCodec;
|
import net.minecraft.network.codec.StreamCodec;
|
||||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import tschipp.carryon.Constants;
|
import tschipp.carryon.Constants;
|
||||||
import tschipp.carryon.common.carry.CarryOnData;
|
import tschipp.carryon.common.carry.CarryOnData;
|
||||||
import tschipp.carryon.common.carry.CarryOnDataManager;
|
import tschipp.carryon.common.carry.CarryOnDataManager;
|
||||||
import tschipp.carryon.networking.PacketBase;
|
import tschipp.carryon.networking.PacketBase;
|
||||||
import tschipp.carryon.networking.clientbound.ClientboundStartRidingPacket;
|
|
||||||
import tschipp.carryon.networking.clientbound.ClientboundSyncScriptsPacket;
|
|
||||||
|
|
||||||
public record ServerboundCarryKeyPressedPacket(boolean pressed) implements PacketBase
|
public record ServerboundCarryKeyPressedPacket(boolean pressed) implements PacketBase
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,7 @@
|
||||||
|
|
||||||
package tschipp.carryon.platform.services;
|
package tschipp.carryon.platform.services;
|
||||||
|
|
||||||
import net.minecraft.core.HolderLookup;
|
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
|
||||||
import net.minecraft.network.codec.StreamCodec;
|
import net.minecraft.network.codec.StreamCodec;
|
||||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
@ -30,12 +28,10 @@ import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import tschipp.carryon.common.carry.CarryOnData;
|
import tschipp.carryon.common.carry.CarryOnData;
|
||||||
import tschipp.carryon.common.carry.CarryOnDataManager;
|
|
||||||
import tschipp.carryon.config.BuiltConfig;
|
import tschipp.carryon.config.BuiltConfig;
|
||||||
import tschipp.carryon.networking.PacketBase;
|
import tschipp.carryon.networking.PacketBase;
|
||||||
|
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
public interface IPlatformHelper {
|
public interface IPlatformHelper {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,9 @@
|
||||||
"client": [
|
"client": [
|
||||||
"HumanoidModelMixin",
|
"HumanoidModelMixin",
|
||||||
"MinecraftMixin",
|
"MinecraftMixin",
|
||||||
"AvatarRenderStateMixin",
|
"PlayerRenderStateMixin",
|
||||||
"EntityRendererMixin"
|
"EntityRendererMixin",
|
||||||
|
"AvatarRendererMixin"
|
||||||
],
|
],
|
||||||
"server": [
|
"server": [
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
plugins {
|
plugins {
|
||||||
id 'multiloader-loader'
|
id 'multiloader-loader'
|
||||||
id 'fabric-loom' version '1.11-SNAPSHOT'
|
id 'fabric-loom' version "${loom_version}"
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
|
@ -32,7 +32,7 @@ dependencies {
|
||||||
modApi("me.shedaniel.cloth:cloth-config-fabric:${cloth_config_version}") {
|
modApi("me.shedaniel.cloth:cloth-config-fabric:${cloth_config_version}") {
|
||||||
exclude(group: "net.fabricmc.fabric-api")
|
exclude(group: "net.fabricmc.fabric-api")
|
||||||
}
|
}
|
||||||
modApi "com.terraformersmc:modmenu:15.0.0-beta.3"
|
modApi "com.terraformersmc:modmenu:16.0.0-rc.1"
|
||||||
}
|
}
|
||||||
|
|
||||||
loom {
|
loom {
|
||||||
|
|
|
||||||
|
|
@ -23,20 +23,13 @@ package tschipp.carryon;
|
||||||
import net.fabricmc.api.ClientModInitializer;
|
import net.fabricmc.api.ClientModInitializer;
|
||||||
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
|
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
|
||||||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
||||||
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs;
|
|
||||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
|
|
||||||
import net.minecraft.core.RegistryAccess;
|
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
|
||||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
|
||||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import tschipp.carryon.client.keybinds.CarryOnKeybinds;
|
import tschipp.carryon.client.keybinds.CarryOnKeybinds;
|
||||||
import tschipp.carryon.events.ClientEvents;
|
import tschipp.carryon.events.ClientEvents;
|
||||||
import tschipp.carryon.networking.PacketBase;
|
import tschipp.carryon.networking.PacketBase;
|
||||||
|
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
public class CarryOnFabricClientMod implements ClientModInitializer
|
public class CarryOnFabricClientMod implements ClientModInitializer
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -22,14 +22,13 @@ package tschipp.carryon;
|
||||||
|
|
||||||
import net.fabricmc.api.ModInitializer;
|
import net.fabricmc.api.ModInitializer;
|
||||||
import net.fabricmc.fabric.api.attachment.v1.AttachmentRegistry;
|
import net.fabricmc.fabric.api.attachment.v1.AttachmentRegistry;
|
||||||
import net.fabricmc.fabric.api.attachment.v1.AttachmentSyncPredicate;
|
|
||||||
import net.fabricmc.fabric.api.attachment.v1.AttachmentType;
|
import net.fabricmc.fabric.api.attachment.v1.AttachmentType;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import tschipp.carryon.common.carry.CarryOnData;
|
import tschipp.carryon.common.carry.CarryOnData;
|
||||||
import tschipp.carryon.config.fabric.ConfigLoaderImpl;
|
import tschipp.carryon.config.fabric.ConfigLoaderImpl;
|
||||||
import tschipp.carryon.events.CommonEvents;
|
import tschipp.carryon.events.CommonEvents;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class CarryOnFabricMod implements ModInitializer {
|
public class CarryOnFabricMod implements ModInitializer {
|
||||||
|
|
@ -39,8 +38,15 @@ public class CarryOnFabricMod implements ModInitializer {
|
||||||
builder -> builder
|
builder -> builder
|
||||||
.initializer(() -> new CarryOnData(new CompoundTag()))
|
.initializer(() -> new CarryOnData(new CompoundTag()))
|
||||||
.persistent(CarryOnData.CODEC)
|
.persistent(CarryOnData.CODEC)
|
||||||
.syncWith(CarryOnData.STREAM_CODEC, (t, p) -> p.connection != null)
|
.syncWith(CarryOnData.STREAM_CODEC, (t, p) ->{
|
||||||
.copyOnDeath()
|
ServerPlayer player = (ServerPlayer) t;
|
||||||
|
// the isAlive check avoids us syncing attachment data about dead players. Which causes a disconnect
|
||||||
|
// player.tickCount > 0 avoids us syncing attachment data about players the instant they spawn.
|
||||||
|
// Which also causes a disconnect as the player entity may not be synced yet.
|
||||||
|
return p.connection != null && player.isAlive() && player.tickCount > 0;
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@
|
||||||
|
|
||||||
package tschipp.carryon.compat;
|
package tschipp.carryon.compat;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.event.Event;
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
|
@ -39,6 +38,7 @@ public class ArchitecturyCompat {
|
||||||
private static Method PLACE_BLOCK;
|
private static Method PLACE_BLOCK;
|
||||||
private static Method IS_FALSE;
|
private static Method IS_FALSE;
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
private static void setup( ) {
|
private static void setup( ) {
|
||||||
try {
|
try {
|
||||||
Class BlockEvent = Class.forName("dev.architectury.event.events.common.BlockEvent");
|
Class BlockEvent = Class.forName("dev.architectury.event.events.common.BlockEvent");
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,6 @@ package tschipp.carryon.config.fabric;
|
||||||
import com.google.gson.*;
|
import com.google.gson.*;
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import tschipp.carryon.Constants;
|
|
||||||
import tschipp.carryon.common.config.CarryConfig;
|
|
||||||
import tschipp.carryon.common.config.ListHandler;
|
import tschipp.carryon.common.config.ListHandler;
|
||||||
import tschipp.carryon.config.*;
|
import tschipp.carryon.config.*;
|
||||||
|
|
||||||
|
|
@ -149,6 +147,7 @@ public class ConfigLoaderImpl {
|
||||||
builder.add(category.category, categoryJson);
|
builder.add(category.category, categoryJson);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
private static void buildProperty(JsonObject builder, PropertyData data) throws IllegalAccessException {
|
private static void buildProperty(JsonObject builder, PropertyData data) throws IllegalAccessException {
|
||||||
AnnotationData annotationData = data.getData();
|
AnnotationData annotationData = data.getData();
|
||||||
builder.addProperty("//"+data.getId(), annotationData.description());
|
builder.addProperty("//"+data.getId(), annotationData.description());
|
||||||
|
|
|
||||||
|
|
@ -20,11 +20,8 @@
|
||||||
|
|
||||||
package tschipp.carryon.events;
|
package tschipp.carryon.events;
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
|
||||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
||||||
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents;
|
|
||||||
import tschipp.carryon.CarryOnCommonClient;
|
import tschipp.carryon.CarryOnCommonClient;
|
||||||
import tschipp.carryon.client.render.CarriedObjectRender;
|
|
||||||
|
|
||||||
public class ClientEvents {
|
public class ClientEvents {
|
||||||
|
|
||||||
|
|
@ -34,10 +31,6 @@ public class ClientEvents {
|
||||||
CarryOnCommonClient.checkForKeybinds();
|
CarryOnCommonClient.checkForKeybinds();
|
||||||
CarryOnCommonClient.onCarryClientTick();
|
CarryOnCommonClient.onCarryClientTick();
|
||||||
});
|
});
|
||||||
|
|
||||||
WorldRenderEvents.LAST.register(event -> {
|
|
||||||
CarriedObjectRender.drawThirdPerson(event.tickCounter().getGameTimeDeltaPartialTick(true), new PoseStack().last().pose());
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
package tschipp.carryon.events;
|
package tschipp.carryon.events;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
|
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
|
||||||
import net.fabricmc.fabric.api.entity.event.v1.ServerPlayerEvents;
|
import net.fabricmc.fabric.api.entity.event.v1.ServerLivingEntityEvents;
|
||||||
import net.fabricmc.fabric.api.event.lifecycle.v1.CommonLifecycleEvents;
|
import net.fabricmc.fabric.api.event.lifecycle.v1.CommonLifecycleEvents;
|
||||||
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;
|
||||||
|
|
@ -33,6 +33,7 @@ import net.minecraft.core.Direction;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.server.packs.PackType;
|
import net.minecraft.server.packs.PackType;
|
||||||
import net.minecraft.world.InteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
|
import net.minecraft.world.level.GameRules;
|
||||||
import tschipp.carryon.CarryOnCommon;
|
import tschipp.carryon.CarryOnCommon;
|
||||||
import tschipp.carryon.common.carry.CarryOnData;
|
import tschipp.carryon.common.carry.CarryOnData;
|
||||||
import tschipp.carryon.common.carry.CarryOnData.CarryType;
|
import tschipp.carryon.common.carry.CarryOnData.CarryType;
|
||||||
|
|
@ -55,7 +56,7 @@ public class CommonEvents {
|
||||||
|
|
||||||
UseBlockCallback.EVENT.register((player, world, hand, hitResult) -> {
|
UseBlockCallback.EVENT.register((player, world, hand, hitResult) -> {
|
||||||
|
|
||||||
if(world.isClientSide)
|
if(world.isClientSide())
|
||||||
return InteractionResult.PASS;
|
return InteractionResult.PASS;
|
||||||
|
|
||||||
BlockPos pos = hitResult.getBlockPos();
|
BlockPos pos = hitResult.getBlockPos();
|
||||||
|
|
@ -96,7 +97,7 @@ public class CommonEvents {
|
||||||
|
|
||||||
UseEntityCallback.EVENT.register((player, level, hand, entity, hitResult) -> {
|
UseEntityCallback.EVENT.register((player, level, hand, entity, hitResult) -> {
|
||||||
|
|
||||||
if(level.isClientSide)
|
if(level.isClientSide())
|
||||||
return InteractionResult.PASS;
|
return InteractionResult.PASS;
|
||||||
|
|
||||||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||||
|
|
@ -132,10 +133,12 @@ public class CommonEvents {
|
||||||
CarryOnCommon.onCarryTick(player);
|
CarryOnCommon.onCarryTick(player);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ServerLivingEntityEvents.AFTER_DEATH.register((entity, damageSource)->{
|
||||||
ServerPlayerEvents.COPY_FROM.register(((oldPlayer, newPlayer, alive) -> {
|
if (!(entity instanceof ServerPlayer)) return;
|
||||||
PlacementHandler.placeCarriedOnDeath(oldPlayer, newPlayer, !alive);
|
var player = (ServerPlayer) entity;
|
||||||
}));
|
var carry = CarryOnDataManager.getCarryData(player);
|
||||||
|
if (carry.isCarrying(CarryType.PLAYER) || !player.level().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY)) PlacementHandler.placeCarried(player);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
PlayerBlockBreakEvents.BEFORE.register(((world, player, pos, state, blockEntity) -> {
|
PlayerBlockBreakEvents.BEFORE.register(((world, player, pos, state, blockEntity) -> {
|
||||||
|
|
|
||||||
|
|
@ -21,31 +21,24 @@
|
||||||
package tschipp.carryon.mixin;
|
package tschipp.carryon.mixin;
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.player.AbstractClientPlayer;
|
import net.minecraft.client.player.AbstractClientPlayer;
|
||||||
import net.minecraft.client.renderer.GameRenderer;
|
|
||||||
import net.minecraft.client.renderer.ItemInHandRenderer;
|
import net.minecraft.client.renderer.ItemInHandRenderer;
|
||||||
import net.minecraft.client.renderer.MultiBufferSource;
|
import net.minecraft.client.renderer.SubmitNodeCollector;
|
||||||
import net.minecraft.client.renderer.RenderBuffers;
|
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
import tschipp.carryon.client.render.CarriedObjectRender;
|
import tschipp.carryon.client.render.CarriedObjectRender;
|
||||||
import tschipp.carryon.client.render.CarryRenderHelper;
|
|
||||||
import tschipp.carryon.platform.Services;
|
|
||||||
|
|
||||||
@Mixin(ItemInHandRenderer.class)
|
@Mixin(ItemInHandRenderer.class)
|
||||||
public class ItemInHandRendererMixin
|
public class ItemInHandRendererMixin
|
||||||
{
|
{
|
||||||
@Inject(at = @At(value = "HEAD"), method = "renderArmWithItem(Lnet/minecraft/client/player/AbstractClientPlayer;FFLnet/minecraft/world/InteractionHand;FLnet/minecraft/world/item/ItemStack;FLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V", cancellable = true)
|
@Inject(at = @At(value = "HEAD"), method = "renderArmWithItem(Lnet/minecraft/client/player/AbstractClientPlayer;FFLnet/minecraft/world/InteractionHand;FLnet/minecraft/world/item/ItemStack;FLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;I)V", cancellable = true)
|
||||||
private void onRenderHand(AbstractClientPlayer player, float partialTicks, float pitch, InteractionHand hand, float pSwingProgress, ItemStack pStack, float pEquippedProgress, PoseStack poseStack, MultiBufferSource buffer, int light, CallbackInfo ci)
|
private void renderArmWithItem(AbstractClientPlayer player, float partialTick, float pitch, InteractionHand hand, float swingProgress, ItemStack item, float equippedProgress, PoseStack poseStack, SubmitNodeCollector nodeCollector, int packedLight, CallbackInfo ci)
|
||||||
{
|
{
|
||||||
if(CarryRenderHelper.getPerspective() == 0 && CarriedObjectRender.drawFirstPerson(player, buffer, poseStack, light, partialTicks))
|
if(CarriedObjectRender.draw(player, poseStack, packedLight, partialTick,nodeCollector,true))
|
||||||
ci.cancel();
|
ci.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,17 +20,12 @@
|
||||||
|
|
||||||
package tschipp.carryon.platform;
|
package tschipp.carryon.platform;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs;
|
|
||||||
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry;
|
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry;
|
||||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
|
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
|
||||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking.PlayPayloadHandler;
|
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||||
import net.minecraft.network.codec.StreamCodec;
|
import net.minecraft.network.codec.StreamCodec;
|
||||||
import net.minecraft.network.codec.StreamDecoder;
|
|
||||||
import net.minecraft.network.codec.StreamMemberEncoder;
|
|
||||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
|
@ -44,7 +39,6 @@ import tschipp.carryon.networking.PacketBase;
|
||||||
import tschipp.carryon.platform.services.IPlatformHelper;
|
import tschipp.carryon.platform.services.IPlatformHelper;
|
||||||
|
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
public class FabricPlatformHelper implements IPlatformHelper {
|
public class FabricPlatformHelper implements IPlatformHelper {
|
||||||
|
|
||||||
|
|
@ -70,6 +64,7 @@ public class FabricPlatformHelper implements IPlatformHelper {
|
||||||
ConfigLoaderImpl.registerConfig(cfg);
|
ConfigLoaderImpl.registerConfig(cfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public <T extends PacketBase, B extends FriendlyByteBuf> void registerServerboundPacket(CustomPacketPayload.Type<T> type, Class<T> clazz, StreamCodec<B, T> codec, BiConsumer<T, Player> handler, Object... args)
|
public <T extends PacketBase, B extends FriendlyByteBuf> void registerServerboundPacket(CustomPacketPayload.Type<T> type, Class<T> clazz, StreamCodec<B, T> codec, BiConsumer<T, Player> handler, Object... args)
|
||||||
{
|
{
|
||||||
|
|
@ -82,6 +77,7 @@ public class FabricPlatformHelper implements IPlatformHelper {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public <T extends PacketBase, B extends FriendlyByteBuf> void registerClientboundPacket(CustomPacketPayload.Type<T> type, Class<T> clazz, StreamCodec<B, T> codec, BiConsumer<T, Player> handler, Object... args)
|
public <T extends PacketBase, B extends FriendlyByteBuf> void registerClientboundPacket(CustomPacketPayload.Type<T> type, Class<T> clazz, StreamCodec<B, T> codec, BiConsumer<T, Player> handler, Object... args)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,6 @@ import net.minecraftforge.network.ChannelBuilder;
|
||||||
import net.minecraftforge.network.SimpleChannel;
|
import net.minecraftforge.network.SimpleChannel;
|
||||||
import tschipp.carryon.config.forge.ConfigLoaderImpl;
|
import tschipp.carryon.config.forge.ConfigLoaderImpl;
|
||||||
import tschipp.carryon.networking.ClientboundSyncCarryDataPacket;
|
import tschipp.carryon.networking.ClientboundSyncCarryDataPacket;
|
||||||
import tschipp.carryon.networking.clientbound.ClientboundStartRidingPacket;
|
|
||||||
import tschipp.carryon.platform.Services;
|
import tschipp.carryon.platform.Services;
|
||||||
|
|
||||||
@Mod(Constants.MOD_ID)
|
@Mod(Constants.MOD_ID)
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ package tschipp.carryon.carry;
|
||||||
|
|
||||||
import net.minecraftforge.common.capabilities.AutoRegisterCapability;
|
import net.minecraftforge.common.capabilities.AutoRegisterCapability;
|
||||||
import tschipp.carryon.common.carry.CarryOnData;
|
import tschipp.carryon.common.carry.CarryOnData;
|
||||||
import tschipp.carryon.common.carry.CarryOnDataManager;
|
|
||||||
|
|
||||||
@AutoRegisterCapability
|
@AutoRegisterCapability
|
||||||
public interface ICarryOnDataCapability {
|
public interface ICarryOnDataCapability {
|
||||||
|
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
package tschipp.carryon.compat;
|
|
||||||
|
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
|
||||||
import tschipp.carryon.config.BuiltConfig;
|
|
||||||
import tschipp.carryon.config.forge.ConfigLoaderImpl;
|
|
||||||
|
|
||||||
public class ClothConfigCompatForge {
|
|
||||||
|
|
||||||
// public static Screen createScreen(BuiltConfig client, BuiltConfig common, Screen screen) {
|
|
||||||
//
|
|
||||||
// return ClothConfigCompat.getConfigScreen(client, common, screen, () -> {
|
|
||||||
// ConfigLoaderImpl.saveConfig(client); ConfigLoaderImpl.saveConfig(common);});
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -22,21 +22,13 @@ package tschipp.carryon.config.forge;
|
||||||
|
|
||||||
import com.electronwill.nightconfig.core.AbstractConfig;
|
import com.electronwill.nightconfig.core.AbstractConfig;
|
||||||
import com.electronwill.nightconfig.core.UnmodifiableConfig;
|
import com.electronwill.nightconfig.core.UnmodifiableConfig;
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
import net.minecraftforge.common.ForgeConfigSpec;
|
import net.minecraftforge.common.ForgeConfigSpec;
|
||||||
import net.minecraftforge.common.util.LogicalSidedProvider;
|
|
||||||
import net.minecraftforge.eventbus.api.listener.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.listener.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.LogicalSide;
|
|
||||||
import net.minecraftforge.fml.ModLoadingContext;
|
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.config.IConfigSpec;
|
import net.minecraftforge.fml.config.IConfigSpec;
|
||||||
import net.minecraftforge.fml.config.ModConfig;
|
import net.minecraftforge.fml.config.ModConfig;
|
||||||
import net.minecraftforge.fml.event.config.ModConfigEvent;
|
import net.minecraftforge.fml.event.config.ModConfigEvent;
|
||||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||||
import net.minecraftforge.fml.loading.FMLServiceProvider;
|
|
||||||
import net.minecraftforge.server.ServerLifecycleHooks;
|
|
||||||
import tschipp.carryon.Constants;
|
import tschipp.carryon.Constants;
|
||||||
import tschipp.carryon.config.*;
|
import tschipp.carryon.config.*;
|
||||||
|
|
||||||
|
|
@ -119,6 +111,7 @@ public class ConfigLoaderImpl {
|
||||||
builder.pop();
|
builder.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
private static void buildProperty(ForgeConfigSpec.Builder builder, PropertyData data) throws IllegalAccessException {
|
private static void buildProperty(ForgeConfigSpec.Builder builder, PropertyData data) throws IllegalAccessException {
|
||||||
AnnotationData annotationData = data.getData();
|
AnnotationData annotationData = data.getData();
|
||||||
builder.comment(annotationData.description());
|
builder.comment(annotationData.description());
|
||||||
|
|
|
||||||
|
|
@ -23,14 +23,12 @@ package tschipp.carryon.events;
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||||
import net.minecraft.client.renderer.MultiBufferSource;
|
import net.minecraft.client.renderer.SubmitNodeCollector;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
|
||||||
import net.minecraftforge.client.event.RenderHandEvent;
|
import net.minecraftforge.client.event.RenderHandEvent;
|
||||||
import net.minecraftforge.client.event.ScreenEvent;
|
import net.minecraftforge.client.event.ScreenEvent;
|
||||||
import net.minecraftforge.event.TickEvent.ClientTickEvent;
|
import net.minecraftforge.event.TickEvent.ClientTickEvent;
|
||||||
import net.minecraftforge.event.TickEvent.Phase;
|
|
||||||
import net.minecraftforge.eventbus.api.listener.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.listener.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import tschipp.carryon.CarryOnCommonClient;
|
import tschipp.carryon.CarryOnCommonClient;
|
||||||
|
|
@ -47,24 +45,14 @@ public class ClientEvents {
|
||||||
public static boolean renderHand(RenderHandEvent event)
|
public static boolean renderHand(RenderHandEvent event)
|
||||||
{
|
{
|
||||||
Player player = Minecraft.getInstance().player;
|
Player player = Minecraft.getInstance().player;
|
||||||
MultiBufferSource buffer = event.getMultiBufferSource();
|
|
||||||
PoseStack matrix = event.getPoseStack();
|
PoseStack matrix = event.getPoseStack();
|
||||||
int light = event.getPackedLight();
|
int light = event.getPackedLight();
|
||||||
float partialTicks = event.getPartialTick();
|
float partialTicks = event.getPartialTick();
|
||||||
|
SubmitNodeCollector nodes =event.getNodeCollector();
|
||||||
//If true, cancels event
|
//If true, cancels event
|
||||||
return CarriedObjectRender.drawFirstPerson(player, buffer, matrix, light, partialTicks) && CarryRenderHelper.getPerspective() == 0;
|
return CarriedObjectRender.draw(player, matrix, light, partialTicks,nodes,true) && CarryRenderHelper.getPerspective() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
@SubscribeEvent
|
|
||||||
public static void onRenderLevel(Render event)
|
|
||||||
{
|
|
||||||
if(event.getStage() == Stage.AFTER_PARTICLES)
|
|
||||||
CarriedObjectRender.drawThirdPerson(Minecraft.getInstance().getTimer().getGameTimeDeltaPartialTick(true), event.getPoseStack());
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static boolean onGuiInit(ScreenEvent.Init.Pre event)
|
public static boolean onGuiInit(ScreenEvent.Init.Pre event)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -30,11 +30,9 @@ import net.minecraft.world.entity.Mob;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.ServerLevelAccessor;
|
import net.minecraft.world.level.ServerLevelAccessor;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import net.minecraftforge.common.util.BlockSnapshot;
|
import net.minecraftforge.common.util.BlockSnapshot;
|
||||||
import net.minecraftforge.common.util.Result;
|
import net.minecraftforge.common.util.Result;
|
||||||
import net.minecraftforge.event.*;
|
import net.minecraftforge.event.*;
|
||||||
import net.minecraftforge.event.TickEvent.Phase;
|
|
||||||
import net.minecraftforge.event.TickEvent.ServerTickEvent;
|
import net.minecraftforge.event.TickEvent.ServerTickEvent;
|
||||||
import net.minecraftforge.event.entity.EntityJoinLevelEvent;
|
import net.minecraftforge.event.entity.EntityJoinLevelEvent;
|
||||||
import net.minecraftforge.event.entity.living.LivingAttackEvent;
|
import net.minecraftforge.event.entity.living.LivingAttackEvent;
|
||||||
|
|
@ -50,7 +48,6 @@ import net.minecraftforge.event.level.BlockEvent.EntityPlaceEvent;
|
||||||
import net.minecraftforge.eventbus.api.listener.Priority;
|
import net.minecraftforge.eventbus.api.listener.Priority;
|
||||||
import net.minecraftforge.eventbus.api.listener.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.listener.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import oshi.jna.platform.mac.SystemB;
|
|
||||||
import tschipp.carryon.CarryOnCommon;
|
import tschipp.carryon.CarryOnCommon;
|
||||||
import tschipp.carryon.Constants;
|
import tschipp.carryon.Constants;
|
||||||
import tschipp.carryon.carry.CarryOnDataCapabilityProvider;
|
import tschipp.carryon.carry.CarryOnDataCapabilityProvider;
|
||||||
|
|
@ -74,7 +71,7 @@ public class CommonEvents
|
||||||
Level level = event.getLevel();
|
Level level = event.getLevel();
|
||||||
BlockPos pos = event.getPos();
|
BlockPos pos = event.getPos();
|
||||||
|
|
||||||
if (level.isClientSide)
|
if (level.isClientSide())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
|
|
@ -122,7 +119,7 @@ public class CommonEvents
|
||||||
Level level = event.getLevel();
|
Level level = event.getLevel();
|
||||||
Entity target = event.getTarget();
|
Entity target = event.getTarget();
|
||||||
|
|
||||||
if (level.isClientSide)
|
if (level.isClientSide())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||||
|
|
@ -173,14 +170,14 @@ public class CommonEvents
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onServerTick(ServerTickEvent.Post event)
|
public static void onServerTick(ServerTickEvent.Post event)
|
||||||
{
|
{
|
||||||
for (ServerPlayer player : event.getServer().getPlayerList().getPlayers())
|
for (ServerPlayer player : event.server().getPlayerList().getPlayers())
|
||||||
CarryOnCommon.onCarryTick(player);
|
CarryOnCommon.onCarryTick(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onClone(Clone event)
|
public static void onClone(Clone event)
|
||||||
{
|
{
|
||||||
if (!event.getOriginal().level().isClientSide) {
|
if (!event.getOriginal().level().isClientSide()) {
|
||||||
Player newPlayer = event.getEntity();
|
Player newPlayer = event.getEntity();
|
||||||
Player oldPlayer = event.getOriginal();
|
Player oldPlayer = event.getOriginal();
|
||||||
oldPlayer.reviveCaps();
|
oldPlayer.reviveCaps();
|
||||||
|
|
@ -226,7 +223,7 @@ public class CommonEvents
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onAttachCapabilities(AttachCapabilitiesEvent.Entities event) {
|
public static void onAttachCapabilities(AttachCapabilitiesEvent.Entities event) {
|
||||||
if (event.getObject() instanceof Player player) {
|
if (event.getObject() instanceof Player) {
|
||||||
event.addCapability(ResourceLocation.fromNamespaceAndPath(Constants.MOD_ID, "carry_on_data"), new CarryOnDataCapabilityProvider());
|
event.addCapability(ResourceLocation.fromNamespaceAndPath(Constants.MOD_ID, "carry_on_data"), new CarryOnDataCapabilityProvider());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,10 +24,8 @@ import net.minecraftforge.eventbus.api.listener.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.InterModComms;
|
import net.minecraftforge.fml.InterModComms;
|
||||||
import net.minecraftforge.fml.InterModComms.IMCMessage;
|
import net.minecraftforge.fml.InterModComms.IMCMessage;
|
||||||
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.InterModProcessEvent;
|
import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent;
|
||||||
import tschipp.carryon.Constants;
|
import tschipp.carryon.Constants;
|
||||||
import tschipp.carryon.client.modeloverride.ModelOverrideHandler;
|
|
||||||
import tschipp.carryon.common.config.ListHandler;
|
import tschipp.carryon.common.config.ListHandler;
|
||||||
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
|
||||||
|
|
@ -21,17 +21,13 @@
|
||||||
package tschipp.carryon.events;
|
package tschipp.carryon.events;
|
||||||
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
|
||||||
import net.minecraftforge.client.ConfigScreenHandler;
|
|
||||||
import net.minecraftforge.client.event.RegisterKeyMappingsEvent;
|
import net.minecraftforge.client.event.RegisterKeyMappingsEvent;
|
||||||
import net.minecraftforge.eventbus.api.listener.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.listener.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.ModLoadingContext;
|
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
|
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||||
import tschipp.carryon.Constants;
|
import tschipp.carryon.Constants;
|
||||||
import tschipp.carryon.client.keybinds.CarryOnKeybinds;
|
import tschipp.carryon.client.keybinds.CarryOnKeybinds;
|
||||||
import tschipp.carryon.compat.ClothConfigCompatForge;
|
|
||||||
import tschipp.carryon.config.BuiltConfig;
|
import tschipp.carryon.config.BuiltConfig;
|
||||||
import tschipp.carryon.config.forge.ConfigLoaderImpl;
|
import tschipp.carryon.config.forge.ConfigLoaderImpl;
|
||||||
import tschipp.carryon.platform.Services;
|
import tschipp.carryon.platform.Services;
|
||||||
|
|
@ -39,20 +35,15 @@ import tschipp.carryon.platform.Services;
|
||||||
@Mod.EventBusSubscriber(bus = Bus.MOD, modid = Constants.MOD_ID, value=Dist.CLIENT)
|
@Mod.EventBusSubscriber(bus = Bus.MOD, modid = Constants.MOD_ID, value=Dist.CLIENT)
|
||||||
public class ModClientEvents
|
public class ModClientEvents
|
||||||
{
|
{
|
||||||
@SubscribeEvent
|
static{
|
||||||
public static void registerKeybinds(RegisterKeyMappingsEvent event)
|
RegisterKeyMappingsEvent.BUS.addListener((e)->CarryOnKeybinds.registerKeybinds(e::register));
|
||||||
{
|
|
||||||
CarryOnKeybinds.registerKeybinds(event::register);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void clientSetup(FMLClientSetupEvent event)
|
public static void clientSetup(FMLClientSetupEvent event)
|
||||||
{
|
{
|
||||||
if(Services.PLATFORM.isModLoaded("cloth_config")) {
|
if(Services.PLATFORM.isModLoaded("cloth_config")) {
|
||||||
|
ConfigLoaderImpl.CONFIGS.values().toArray(new BuiltConfig[0]);
|
||||||
BuiltConfig[] configs = ConfigLoaderImpl.CONFIGS.values().toArray(new BuiltConfig[0]);
|
|
||||||
//ModLoadingContext.get().registerExtensionPoint(ConfigScreenHandler.ConfigScreenFactory.class, () -> new ConfigScreenHandler.ConfigScreenFactory((mc, prevScreen) -> ClothConfigCompatForge.createScreen(configs[1], configs[0], prevScreen)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,47 +0,0 @@
|
||||||
/*
|
|
||||||
* GNU Lesser General Public License v3
|
|
||||||
* Copyright (C) 2024 Tschipp
|
|
||||||
* mrtschipp@gmail.com
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with this program; if not, write to the Free Software Foundation,
|
|
||||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package tschipp.carryon.mixin;
|
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
|
||||||
import net.minecraft.client.Camera;
|
|
||||||
import net.minecraft.client.particle.ParticleEngine;
|
|
||||||
import net.minecraft.client.renderer.LightTexture;
|
|
||||||
import net.minecraft.client.renderer.MultiBufferSource;
|
|
||||||
import net.minecraft.client.renderer.culling.Frustum;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
import tschipp.carryon.client.render.CarriedObjectRender;
|
|
||||||
|
|
||||||
@Mixin(ParticleEngine.class)
|
|
||||||
public class ParticleEngineMixin
|
|
||||||
{
|
|
||||||
//I am injecting into a lambda, lord help me
|
|
||||||
|
|
||||||
@Inject(method = "render(Lnet/minecraft/client/Camera;FLnet/minecraft/client/renderer/MultiBufferSource$BufferSource;Lnet/minecraft/client/renderer/culling/Frustum;)V",
|
|
||||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/MultiBufferSource$BufferSource;endBatch()V",
|
|
||||||
shift = At.Shift.AFTER))
|
|
||||||
private void onRenderLevel(Camera p_107340_, float partialTick, MultiBufferSource.BufferSource p_377798_, Frustum frustum, CallbackInfo ci)
|
|
||||||
{
|
|
||||||
CarriedObjectRender.drawThirdPerson(partialTick, new PoseStack().last().pose());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -9,7 +9,6 @@ import net.minecraft.world.entity.player.Player;
|
||||||
import tschipp.carryon.Constants;
|
import tschipp.carryon.Constants;
|
||||||
import tschipp.carryon.common.carry.CarryOnData;
|
import tschipp.carryon.common.carry.CarryOnData;
|
||||||
import tschipp.carryon.common.carry.CarryOnDataManager;
|
import tschipp.carryon.common.carry.CarryOnDataManager;
|
||||||
import tschipp.carryon.networking.clientbound.ClientboundStartRidingPacket;
|
|
||||||
|
|
||||||
public record ClientboundSyncCarryDataPacket(int iden, CarryOnData data) implements PacketBase {
|
public record ClientboundSyncCarryDataPacket(int iden, CarryOnData data) implements PacketBase {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@
|
||||||
package tschipp.carryon.platform;
|
package tschipp.carryon.platform;
|
||||||
|
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
|
||||||
import net.minecraft.network.codec.StreamCodec;
|
import net.minecraft.network.codec.StreamCodec;
|
||||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
@ -31,14 +30,12 @@ import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraftforge.event.network.CustomPayloadEvent;
|
import net.minecraftforge.event.network.CustomPayloadEvent;
|
||||||
import net.minecraftforge.fml.ModList;
|
import net.minecraftforge.fml.ModList;
|
||||||
import net.minecraftforge.fml.loading.FMLLoader;
|
import net.minecraftforge.fml.loading.FMLLoader;
|
||||||
import net.minecraftforge.network.NetworkDirection;
|
|
||||||
import net.minecraftforge.network.PacketDistributor;
|
import net.minecraftforge.network.PacketDistributor;
|
||||||
import tschipp.carryon.CarryOnCommonClient;
|
import tschipp.carryon.CarryOnCommonClient;
|
||||||
import tschipp.carryon.CarryOnForge;
|
import tschipp.carryon.CarryOnForge;
|
||||||
import tschipp.carryon.Constants;
|
import tschipp.carryon.Constants;
|
||||||
import tschipp.carryon.carry.CarryOnDataCapability;
|
import tschipp.carryon.carry.CarryOnDataCapability;
|
||||||
import tschipp.carryon.carry.CarryOnDataCapabilityProvider;
|
import tschipp.carryon.carry.CarryOnDataCapabilityProvider;
|
||||||
import tschipp.carryon.carry.ICarryOnDataCapability;
|
|
||||||
import tschipp.carryon.common.carry.CarryOnData;
|
import tschipp.carryon.common.carry.CarryOnData;
|
||||||
import tschipp.carryon.config.BuiltConfig;
|
import tschipp.carryon.config.BuiltConfig;
|
||||||
import tschipp.carryon.config.forge.ConfigLoaderImpl;
|
import tschipp.carryon.config.forge.ConfigLoaderImpl;
|
||||||
|
|
@ -47,7 +44,6 @@ import tschipp.carryon.networking.PacketBase;
|
||||||
import tschipp.carryon.platform.services.IPlatformHelper;
|
import tschipp.carryon.platform.services.IPlatformHelper;
|
||||||
|
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
public class ForgePlatformHelper implements IPlatformHelper {
|
public class ForgePlatformHelper implements IPlatformHelper {
|
||||||
|
|
||||||
|
|
@ -74,6 +70,7 @@ public class ForgePlatformHelper implements IPlatformHelper {
|
||||||
ConfigLoaderImpl.registerConfig(cfg);
|
ConfigLoaderImpl.registerConfig(cfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public <T extends PacketBase, B extends FriendlyByteBuf> void registerServerboundPacket(CustomPacketPayload.Type<T> type, Class<T> clazz, StreamCodec<B, T> codec, BiConsumer<T, Player> handler, Object... args)
|
public <T extends PacketBase, B extends FriendlyByteBuf> void registerServerboundPacket(CustomPacketPayload.Type<T> type, Class<T> clazz, StreamCodec<B, T> codec, BiConsumer<T, Player> handler, Object... args)
|
||||||
{
|
{
|
||||||
|
|
@ -90,6 +87,7 @@ public class ForgePlatformHelper implements IPlatformHelper {
|
||||||
CarryOnForge.network.messageBuilder(clazz).codec((StreamCodec<FriendlyByteBuf, T>) codec).consumerMainThread(serverHandler).add();
|
CarryOnForge.network.messageBuilder(clazz).codec((StreamCodec<FriendlyByteBuf, T>) codec).consumerMainThread(serverHandler).add();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public <T extends PacketBase, B extends FriendlyByteBuf> void registerClientboundPacket(CustomPacketPayload.Type<T> type, Class<T> clazz, StreamCodec<B, T> codec, BiConsumer<T, Player> handler, Object... args)
|
public <T extends PacketBase, B extends FriendlyByteBuf> void registerClientboundPacket(CustomPacketPayload.Type<T> type, Class<T> clazz, StreamCodec<B, T> codec, BiConsumer<T, Player> handler, Object... args)
|
||||||
{
|
{
|
||||||
|
|
@ -129,7 +127,7 @@ public class ForgePlatformHelper implements IPlatformHelper {
|
||||||
public void setCarryData(Player player, CarryOnData data) {
|
public void setCarryData(Player player, CarryOnData data) {
|
||||||
var cap = player.getCapability(CarryOnDataCapabilityProvider.CARRY_ON_DATA_CAPABILITY).orElse(new CarryOnDataCapability());
|
var cap = player.getCapability(CarryOnDataCapabilityProvider.CARRY_ON_DATA_CAPABILITY).orElse(new CarryOnDataCapability());
|
||||||
cap.setCarryData(data);
|
cap.setCarryData(data);
|
||||||
if(!player.level().isClientSide) {
|
if(!player.level().isClientSide()) {
|
||||||
sendPacketToAllPlayers(Constants.PACKET_ID_SYNC_SCRIPTS, new ClientboundSyncCarryDataPacket(player.getId(), data), (ServerLevel) player.level());
|
sendPacketToAllPlayers(Constants.PACKET_ID_SYNC_SCRIPTS, new ClientboundSyncCarryDataPacket(player.getId(), data), (ServerLevel) player.level());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
"mixins": [
|
"mixins": [
|
||||||
],
|
],
|
||||||
"client": [
|
"client": [
|
||||||
"ParticleEngineMixin"
|
|
||||||
],
|
],
|
||||||
"server": [
|
"server": [
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ neoForge {
|
||||||
accessTransformers.from(at.absolutePath)
|
accessTransformers.from(at.absolutePath)
|
||||||
}
|
}
|
||||||
parchment {
|
parchment {
|
||||||
minecraftVersion = minecraft_version
|
minecraftVersion = parchment_game_version
|
||||||
mappingsVersion = parchment_version
|
mappingsVersion = parchment_version
|
||||||
}
|
}
|
||||||
runs {
|
runs {
|
||||||
|
|
@ -47,7 +47,7 @@ neoForge {
|
||||||
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
api "me.shedaniel.cloth:cloth-config-neoforge:${cloth_config_version}"
|
compileOnly "me.shedaniel.cloth:cloth-config-neoforge:${cloth_config_version}"
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceSets.main.resources { srcDir 'src/generated/resources' }
|
sourceSets.main.resources { srcDir 'src/generated/resources' }
|
||||||
|
|
|
||||||
|
|
@ -21,14 +21,10 @@
|
||||||
package tschipp.carryon;
|
package tschipp.carryon;
|
||||||
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.neoforged.bus.api.IEventBus;
|
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
|
||||||
import net.neoforged.fml.ModContainer;
|
import net.neoforged.fml.ModContainer;
|
||||||
import net.neoforged.fml.common.Mod;
|
import net.neoforged.fml.common.Mod;
|
||||||
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
|
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||||
import net.neoforged.neoforge.attachment.AttachmentType;
|
import net.neoforged.neoforge.attachment.AttachmentType;
|
||||||
import net.neoforged.neoforge.client.gui.ConfigurationScreen;
|
|
||||||
import net.neoforged.neoforge.common.NeoForge;
|
|
||||||
import net.neoforged.neoforge.network.event.RegisterPayloadHandlersEvent;
|
import net.neoforged.neoforge.network.event.RegisterPayloadHandlersEvent;
|
||||||
import net.neoforged.neoforge.network.registration.PayloadRegistrar;
|
import net.neoforged.neoforge.network.registration.PayloadRegistrar;
|
||||||
import net.neoforged.neoforge.registries.DeferredRegister;
|
import net.neoforged.neoforge.registries.DeferredRegister;
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,11 @@ public class CarryOnDataSyncHandler implements AttachmentSyncHandler<CarryOnData
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean sendToPlayer(IAttachmentHolder holder, ServerPlayer to) {
|
public boolean sendToPlayer(IAttachmentHolder holder, ServerPlayer to) {
|
||||||
if (to.connection == null)
|
ServerPlayer player = (ServerPlayer) holder;
|
||||||
|
// the isAlive check avoids us syncing attachment data about dead players. Which causes a disconnect
|
||||||
|
// player.tickCount <= 0 avoids us syncing attachment data about players the instant they spawn.
|
||||||
|
// Which also causes a disconnect as the player entity may not be synced yet.
|
||||||
|
if (to.connection == null || !player.isAlive() || player.tickCount <= 0)
|
||||||
return false;
|
return false;
|
||||||
return AttachmentSyncHandler.super.sendToPlayer(holder, to);
|
return AttachmentSyncHandler.super.sendToPlayer(holder, to);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,11 @@
|
||||||
package tschipp.carryon.compat;
|
package tschipp.carryon.compat;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
import net.minecraft.network.chat.Component;
|
|
||||||
import net.neoforged.fml.ModContainer;
|
import net.neoforged.fml.ModContainer;
|
||||||
import net.neoforged.neoforge.client.gui.IConfigScreenFactory;
|
import net.neoforged.neoforge.client.gui.IConfigScreenFactory;
|
||||||
import tschipp.carryon.config.AnnotationData;
|
|
||||||
import tschipp.carryon.config.BuiltCategory;
|
|
||||||
import tschipp.carryon.config.BuiltConfig;
|
import tschipp.carryon.config.BuiltConfig;
|
||||||
import tschipp.carryon.config.neoforge.ConfigLoaderImpl;
|
import tschipp.carryon.config.neoforge.ConfigLoaderImpl;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
public record ClothConfigCompatNeo(BuiltConfig client, BuiltConfig common) implements IConfigScreenFactory {
|
public record ClothConfigCompatNeo(BuiltConfig client, BuiltConfig common) implements IConfigScreenFactory {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,25 +22,16 @@ package tschipp.carryon.config.neoforge;
|
||||||
|
|
||||||
import com.electronwill.nightconfig.core.AbstractConfig;
|
import com.electronwill.nightconfig.core.AbstractConfig;
|
||||||
import com.electronwill.nightconfig.core.UnmodifiableConfig;
|
import com.electronwill.nightconfig.core.UnmodifiableConfig;
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.neoforged.api.distmarker.Dist;
|
|
||||||
import net.neoforged.bus.api.IEventBus;
|
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
import net.neoforged.fml.ModContainer;
|
import net.neoforged.fml.ModContainer;
|
||||||
import net.neoforged.fml.ModLoadingContext;
|
|
||||||
import net.neoforged.fml.common.EventBusSubscriber;
|
import net.neoforged.fml.common.EventBusSubscriber;
|
||||||
import net.neoforged.fml.common.Mod;
|
|
||||||
import net.neoforged.fml.config.IConfigSpec;
|
|
||||||
import net.neoforged.fml.config.ModConfig;
|
import net.neoforged.fml.config.ModConfig;
|
||||||
import net.neoforged.fml.event.config.ModConfigEvent;
|
import net.neoforged.fml.event.config.ModConfigEvent;
|
||||||
import net.neoforged.neoforge.common.ModConfigSpec;
|
import net.neoforged.neoforge.common.ModConfigSpec;
|
||||||
import net.neoforged.neoforge.common.NeoForge;
|
|
||||||
import net.neoforged.neoforge.server.ServerLifecycleHooks;
|
|
||||||
import tschipp.carryon.Constants;
|
import tschipp.carryon.Constants;
|
||||||
import tschipp.carryon.config.*;
|
import tschipp.carryon.config.*;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
@EventBusSubscriber(modid = Constants.MOD_ID)
|
@EventBusSubscriber(modid = Constants.MOD_ID)
|
||||||
public class ConfigLoaderImpl {
|
public class ConfigLoaderImpl {
|
||||||
|
|
@ -120,6 +111,7 @@ public class ConfigLoaderImpl {
|
||||||
builder.pop();
|
builder.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
private static void buildProperty(ModConfigSpec.Builder builder, PropertyData data) throws IllegalAccessException {
|
private static void buildProperty(ModConfigSpec.Builder builder, PropertyData data) throws IllegalAccessException {
|
||||||
AnnotationData annotationData = data.getData();
|
AnnotationData annotationData = data.getData();
|
||||||
builder.comment(annotationData.description());
|
builder.comment(annotationData.description());
|
||||||
|
|
|
||||||
|
|
@ -23,15 +23,13 @@ package tschipp.carryon.events;
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||||
import net.minecraft.client.renderer.MultiBufferSource;
|
import net.minecraft.client.renderer.SubmitNodeCollector;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.neoforged.api.distmarker.Dist;
|
import net.neoforged.api.distmarker.Dist;
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
import net.neoforged.fml.common.EventBusSubscriber;
|
import net.neoforged.fml.common.EventBusSubscriber;
|
||||||
import net.neoforged.fml.common.Mod;
|
|
||||||
import net.neoforged.neoforge.client.event.ClientTickEvent;
|
import net.neoforged.neoforge.client.event.ClientTickEvent;
|
||||||
import net.neoforged.neoforge.client.event.RenderHandEvent;
|
import net.neoforged.neoforge.client.event.RenderHandEvent;
|
||||||
import net.neoforged.neoforge.client.event.RenderLevelStageEvent;
|
|
||||||
import net.neoforged.neoforge.client.event.ScreenEvent;
|
import net.neoforged.neoforge.client.event.ScreenEvent;
|
||||||
import tschipp.carryon.CarryOnCommonClient;
|
import tschipp.carryon.CarryOnCommonClient;
|
||||||
import tschipp.carryon.Constants;
|
import tschipp.carryon.Constants;
|
||||||
|
|
@ -47,21 +45,15 @@ public class ClientEvents {
|
||||||
public static void renderHand(RenderHandEvent event)
|
public static void renderHand(RenderHandEvent event)
|
||||||
{
|
{
|
||||||
Player player = Minecraft.getInstance().player;
|
Player player = Minecraft.getInstance().player;
|
||||||
MultiBufferSource buffer = event.getMultiBufferSource();
|
|
||||||
PoseStack matrix = event.getPoseStack();
|
PoseStack matrix = event.getPoseStack();
|
||||||
int light = event.getPackedLight();
|
int light = event.getPackedLight();
|
||||||
float partialTicks = event.getPartialTick();
|
float partialTicks = event.getPartialTick();
|
||||||
|
SubmitNodeCollector nodes =event.getSubmitNodeCollector();
|
||||||
|
|
||||||
if(CarriedObjectRender.drawFirstPerson(player, buffer, matrix, light, partialTicks) && CarryRenderHelper.getPerspective() == 0)
|
if(CarriedObjectRender.draw(player, matrix, light, partialTicks,nodes,true) && CarryRenderHelper.getPerspective() == 0)
|
||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public static void onRenderLevel(RenderLevelStageEvent.AfterParticles event)
|
|
||||||
{
|
|
||||||
CarriedObjectRender.drawThirdPerson(event.getPartialTick().getGameTimeDeltaPartialTick(true), event.getPoseStack().last().pose());
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onGuiInit(ScreenEvent.Init.Pre event)
|
public static void onGuiInit(ScreenEvent.Init.Pre event)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -31,11 +31,9 @@ import net.minecraft.world.entity.Mob;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.ServerLevelAccessor;
|
import net.minecraft.world.level.ServerLevelAccessor;
|
||||||
import net.neoforged.bus.api.Event;
|
|
||||||
import net.neoforged.bus.api.EventPriority;
|
import net.neoforged.bus.api.EventPriority;
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
import net.neoforged.fml.common.EventBusSubscriber;
|
import net.neoforged.fml.common.EventBusSubscriber;
|
||||||
import net.neoforged.fml.common.Mod;
|
|
||||||
import net.neoforged.neoforge.common.NeoForge;
|
import net.neoforged.neoforge.common.NeoForge;
|
||||||
import net.neoforged.neoforge.common.util.BlockSnapshot;
|
import net.neoforged.neoforge.common.util.BlockSnapshot;
|
||||||
import net.neoforged.neoforge.event.*;
|
import net.neoforged.neoforge.event.*;
|
||||||
|
|
@ -68,7 +66,7 @@ public class CommonEvents
|
||||||
Level level = event.getLevel();
|
Level level = event.getLevel();
|
||||||
BlockPos pos = event.getPos();
|
BlockPos pos = event.getPos();
|
||||||
|
|
||||||
if (level.isClientSide)
|
if (level.isClientSide())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
|
|
@ -122,7 +120,7 @@ public class CommonEvents
|
||||||
Level level = event.getLevel();
|
Level level = event.getLevel();
|
||||||
Entity target = event.getTarget();
|
Entity target = event.getTarget();
|
||||||
|
|
||||||
if (level.isClientSide)
|
if (level.isClientSide())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||||
|
|
@ -180,7 +178,7 @@ public class CommonEvents
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onClone(PlayerEvent.Clone event)
|
public static void onClone(PlayerEvent.Clone event)
|
||||||
{
|
{
|
||||||
if (!event.getOriginal().level().isClientSide)
|
if (!event.getOriginal().level().isClientSide())
|
||||||
PlacementHandler.placeCarriedOnDeath((ServerPlayer) event.getOriginal(), (ServerPlayer) event.getEntity(), event.isWasDeath());
|
PlacementHandler.placeCarriedOnDeath((ServerPlayer) event.getOriginal(), (ServerPlayer) event.getEntity(), event.isWasDeath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,10 +24,8 @@ import net.neoforged.bus.api.EventPriority;
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
import net.neoforged.fml.InterModComms;
|
import net.neoforged.fml.InterModComms;
|
||||||
import net.neoforged.fml.common.EventBusSubscriber;
|
import net.neoforged.fml.common.EventBusSubscriber;
|
||||||
import net.neoforged.fml.common.Mod;
|
|
||||||
import net.neoforged.fml.event.lifecycle.InterModProcessEvent;
|
import net.neoforged.fml.event.lifecycle.InterModProcessEvent;
|
||||||
import tschipp.carryon.Constants;
|
import tschipp.carryon.Constants;
|
||||||
import tschipp.carryon.client.modeloverride.ModelOverrideHandler;
|
|
||||||
import tschipp.carryon.common.config.ListHandler;
|
import tschipp.carryon.common.config.ListHandler;
|
||||||
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
|
||||||
|
|
@ -21,10 +21,8 @@
|
||||||
package tschipp.carryon.events;
|
package tschipp.carryon.events;
|
||||||
|
|
||||||
import net.neoforged.api.distmarker.Dist;
|
import net.neoforged.api.distmarker.Dist;
|
||||||
import net.neoforged.api.distmarker.OnlyIn;
|
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
import net.neoforged.fml.common.EventBusSubscriber;
|
import net.neoforged.fml.common.EventBusSubscriber;
|
||||||
import net.neoforged.fml.common.Mod;
|
|
||||||
import net.neoforged.neoforge.client.event.RegisterKeyMappingsEvent;
|
import net.neoforged.neoforge.client.event.RegisterKeyMappingsEvent;
|
||||||
import tschipp.carryon.Constants;
|
import tschipp.carryon.Constants;
|
||||||
import tschipp.carryon.client.keybinds.CarryOnKeybinds;
|
import tschipp.carryon.client.keybinds.CarryOnKeybinds;
|
||||||
|
|
|
||||||
|
|
@ -20,12 +20,10 @@
|
||||||
|
|
||||||
package tschipp.carryon.platform;
|
package tschipp.carryon.platform;
|
||||||
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||||
import net.minecraft.network.codec.StreamCodec;
|
import net.minecraft.network.codec.StreamCodec;
|
||||||
import net.minecraft.network.codec.StreamDecoder;
|
|
||||||
import net.minecraft.network.codec.StreamMemberEncoder;
|
|
||||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
|
@ -45,7 +43,6 @@ import tschipp.carryon.networking.PacketBase;
|
||||||
import tschipp.carryon.platform.services.IPlatformHelper;
|
import tschipp.carryon.platform.services.IPlatformHelper;
|
||||||
|
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
public class NeoForgePlatformHelper implements IPlatformHelper {
|
public class NeoForgePlatformHelper implements IPlatformHelper {
|
||||||
|
|
||||||
|
|
@ -64,7 +61,7 @@ public class NeoForgePlatformHelper implements IPlatformHelper {
|
||||||
@Override
|
@Override
|
||||||
public boolean isDevelopmentEnvironment() {
|
public boolean isDevelopmentEnvironment() {
|
||||||
|
|
||||||
return !FMLLoader.isProduction();
|
return !FMLLoader.getCurrent().isProduction();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -72,6 +69,7 @@ public class NeoForgePlatformHelper implements IPlatformHelper {
|
||||||
ConfigLoaderImpl.registerConfig(cfg);
|
ConfigLoaderImpl.registerConfig(cfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public <T extends PacketBase, B extends FriendlyByteBuf> void registerServerboundPacket(CustomPacketPayload.Type<T> type, Class<T> clazz, StreamCodec<B, T> codec, BiConsumer<T, Player> handler, Object... args) {
|
public <T extends PacketBase, B extends FriendlyByteBuf> void registerServerboundPacket(CustomPacketPayload.Type<T> type, Class<T> clazz, StreamCodec<B, T> codec, BiConsumer<T, Player> handler, Object... args) {
|
||||||
PayloadRegistrar registrar = (PayloadRegistrar) args[0];
|
PayloadRegistrar registrar = (PayloadRegistrar) args[0];
|
||||||
|
|
@ -85,6 +83,7 @@ public class NeoForgePlatformHelper implements IPlatformHelper {
|
||||||
registrar.playToServer(type, (StreamCodec<RegistryFriendlyByteBuf, T>)codec, serverHandler);
|
registrar.playToServer(type, (StreamCodec<RegistryFriendlyByteBuf, T>)codec, serverHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public <T extends PacketBase, B extends FriendlyByteBuf> void registerClientboundPacket(CustomPacketPayload.Type<T> type, Class<T> clazz, StreamCodec<B, T> codec, BiConsumer<T, Player> handler, Object... args)
|
public <T extends PacketBase, B extends FriendlyByteBuf> void registerClientboundPacket(CustomPacketPayload.Type<T> type, Class<T> clazz, StreamCodec<B, T> codec, BiConsumer<T, Player> handler, Object... args)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
plugins {
|
plugins {
|
||||||
// see https://fabricmc.net/develop/ for new versions
|
// see https://fabricmc.net/develop/ for new versions
|
||||||
id 'fabric-loom' version '1.11-SNAPSHOT' apply false
|
id 'fabric-loom' version "${loom_version}" apply false
|
||||||
// see https://projects.neoforged.net/neoforged/moddevgradle for new versions
|
// see https://projects.neoforged.net/neoforged/moddevgradle for new versions
|
||||||
id 'net.neoforged.moddev' version "${mod_dev_version}" apply false
|
id 'net.neoforged.moddev' version "${mod_dev_version}" apply false
|
||||||
}
|
}
|
||||||
|
|
@ -14,6 +14,7 @@ minecraft_version_range=[1.21.9, 1.22)
|
||||||
neo_form_version=1.21.9-20250930.151910
|
neo_form_version=1.21.9-20250930.151910
|
||||||
java_version=21
|
java_version=21
|
||||||
parchment_version=2025.10.05
|
parchment_version=2025.10.05
|
||||||
|
parchment_game_version=1.21.9
|
||||||
mod_dev_version=2.0.115
|
mod_dev_version=2.0.115
|
||||||
# Forge
|
# Forge
|
||||||
forge_version= 59.0.5
|
forge_version= 59.0.5
|
||||||
|
|
@ -25,6 +26,7 @@ parchment_mappings=2025.10.05-1.21.9
|
||||||
fabric_version=0.134.0+1.21.9
|
fabric_version=0.134.0+1.21.9
|
||||||
fabric_loader_version=0.17.3
|
fabric_loader_version=0.17.3
|
||||||
parchment_mappings_fabric=1.21.9:2025.10.05
|
parchment_mappings_fabric=1.21.9:2025.10.05
|
||||||
|
loom_version=1.11-SNAPSHOT
|
||||||
|
|
||||||
# Neoforge
|
# Neoforge
|
||||||
neoforge_version=21.9.16-beta
|
neoforge_version=21.9.16-beta
|
||||||
|
|
@ -37,5 +39,5 @@ neogradle.subsystems.parchment.mappingsVersion=2025.10.05
|
||||||
org.gradle.jvmargs=-Xmx3G
|
org.gradle.jvmargs=-Xmx3G
|
||||||
org.gradle.daemon=false
|
org.gradle.daemon=false
|
||||||
|
|
||||||
mixinextras_version=0.3.6
|
mixinextras_version=0.5.0
|
||||||
cloth_config_version=20.0.149
|
cloth_config_version=20.0.148
|
||||||
|
|
@ -12,6 +12,7 @@ pluginManagement {
|
||||||
}
|
}
|
||||||
filter {
|
filter {
|
||||||
includeGroup('net.fabricmc')
|
includeGroup('net.fabricmc')
|
||||||
|
includeGroup('net.fabricmc.unpick')
|
||||||
includeGroup('fabric-loom')
|
includeGroup('fabric-loom')
|
||||||
includeGroup('net.fabricmc.unpick')
|
includeGroup('net.fabricmc.unpick')
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user