Compare commits
38 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
de388366ca | ||
|
|
b66040bf03 | ||
|
|
47910dbf61 | ||
|
|
f147e801cc | ||
|
|
20a40c1487 | ||
|
|
08bc465d82 | ||
|
|
3352c497e2 | ||
|
|
f58829ea21 | ||
|
|
550940b4ab | ||
|
|
4ca8a885da | ||
|
|
326880d40b | ||
|
|
d4e0b29a06 | ||
|
|
8d8e0dad82 | ||
|
|
e1e122ae9b | ||
|
|
69eb806228 | ||
|
|
08b2a41043 | ||
|
|
6f0c20077a | ||
|
|
21f09b2526 | ||
|
|
9a484df16e | ||
|
|
e79e52cf65 | ||
|
|
d35cb4ed72 | ||
|
|
5cf2e87fe8 | ||
|
|
ef8362e728 | ||
|
|
e3be9c84da | ||
|
|
efdd3277cc | ||
|
|
776d079be0 | ||
|
|
9d6ffc37ca | ||
|
|
af25f681be | ||
|
|
98247bceb2 | ||
|
|
41b518942d | ||
|
|
32db7222b7 | ||
|
|
eadfba05e8 | ||
|
|
00c0c89858 | ||
|
|
59ecfa81e5 | ||
|
|
c4346a4c00 | ||
|
|
3fddd1112b | ||
|
|
ece3ed7ff2 | ||
|
|
162fc1051d |
22
.github/ISSUE_TEMPLATE/blacklist-request.md
vendored
Normal file
22
.github/ISSUE_TEMPLATE/blacklist-request.md
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
---
|
||||
name: Blacklist Request
|
||||
about: Have a block / entity that shouldn't be picked up by Carry On? Report it here.
|
||||
title: "[Blacklist]"
|
||||
labels: Blacklist
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe the problem**
|
||||
What block / entity is causing issues? What problems occur with placement / pickup?
|
||||
|
||||
**ID's to Blacklist**
|
||||
List of block identifiers (namespace:name) to blacklist. You can find identifiers by activating F3 and moving your crosshair over the block
|
||||
-
|
||||
-
|
||||
...
|
||||
|
||||
**Game Information (please complete the following information):**
|
||||
- Minecraft Version:
|
||||
- Mod Loader:
|
||||
- Carry On Version:
|
||||
28
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
28
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
---
|
||||
name: Bug report
|
||||
about: Create a report about a crash or otherwise buggy behavior
|
||||
title: "[Bug]"
|
||||
labels: bug
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1.
|
||||
2.
|
||||
...
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Game Information (please complete the following information):**
|
||||
- Minecraft Version:
|
||||
- Mod Loader:
|
||||
- Carry On Version:
|
||||
|
||||
**Additional context, logs**
|
||||
Add any other context about the problem here. Also include logs if available
|
||||
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for Carry On
|
||||
title: "[Feature Request]"
|
||||
labels: enhancement
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -22,3 +22,6 @@ build
|
|||
eclipse
|
||||
run
|
||||
runs
|
||||
|
||||
# vscode
|
||||
.vscode/*
|
||||
|
|
@ -20,7 +20,7 @@ neoForge {
|
|||
accessTransformers.from(at.absolutePath)
|
||||
}
|
||||
parchment {
|
||||
minecraftVersion = minecraft_version
|
||||
minecraftVersion = parchment_game_version
|
||||
mappingsVersion = parchment_version
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,10 +26,7 @@ import net.minecraft.core.HolderLookup;
|
|||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.core.RegistrySetBuilder;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
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.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
|
@ -111,11 +108,15 @@ public class CarryOnCommon
|
|||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||
if(carry.isCarrying())
|
||||
{
|
||||
// Dumb Fix to sync Carry Data after a respawn with KeepInventory, because we can't sync in the first tick.
|
||||
if(player.tickCount == 1)
|
||||
CarryOnDataManager.setCarryData(player, carry);
|
||||
|
||||
if(carry.getActiveScript().isPresent())
|
||||
{
|
||||
String cmd = carry.getActiveScript().get().scriptEffects().commandLoop();
|
||||
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);
|
||||
}
|
||||
|
||||
Inventory inv = player.getInventory();
|
||||
|
|
@ -153,7 +154,7 @@ public class CarryOnCommon
|
|||
|
||||
public static void onPlayerAttacked(Player player)
|
||||
{
|
||||
if (Constants.COMMON_CONFIG.settings.dropCarriedWhenHit && !player.level().isClientSide)
|
||||
if (Constants.COMMON_CONFIG.settings.dropCarriedWhenHit && !player.level().isClientSide())
|
||||
{
|
||||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||
if (carry.isCarrying())
|
||||
|
|
|
|||
|
|
@ -34,11 +34,11 @@ public class CarryOnCommonClient
|
|||
Player player = mc.player;
|
||||
if(player != null) {
|
||||
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);
|
||||
carry.setKeyPressed(true);
|
||||
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);
|
||||
carry.setKeyPressed(false);
|
||||
CarryOnDataManager.setCarryData(player, carry);
|
||||
|
|
@ -46,20 +46,16 @@ public class CarryOnCommonClient
|
|||
}
|
||||
}
|
||||
|
||||
private static boolean checkMouse()
|
||||
{
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
return (CarryOnKeybinds.carryKey.matchesMouse(0) && mc.mouseHandler.isLeftPressed()) || (CarryOnKeybinds.carryKey.matchesMouse(1) && mc.mouseHandler.isRightPressed()) || (CarryOnKeybinds.carryKey.matchesMouse(3) && mc.mouseHandler.isMiddlePressed());
|
||||
}
|
||||
|
||||
public static void onCarryClientTick()
|
||||
{
|
||||
public static void onCarryClientTick() {
|
||||
Player player = Minecraft.getInstance().player;
|
||||
if(player != null) {
|
||||
if (player != null) {
|
||||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||
if(carry.isCarrying())
|
||||
{
|
||||
player.getInventory().setSelectedSlot(carry.getSelected());
|
||||
if (carry.isCarrying()) {
|
||||
int wantedSlot = carry.getSelected();
|
||||
if (player.getInventory().getSelectedSlot() != wantedSlot) {
|
||||
player.getInventory().setSelectedSlot(wantedSlot);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -68,4 +64,4 @@ public class CarryOnCommonClient
|
|||
{
|
||||
return Minecraft.getInstance().player;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
package tschipp.carryon;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import tschipp.carryon.common.config.CarryConfig;
|
||||
|
|
@ -34,9 +34,10 @@ public class Constants {
|
|||
public static final CarryConfig.Common COMMON_CONFIG = new CarryConfig.Common();
|
||||
public static final CarryConfig.Client CLIENT_CONFIG = new CarryConfig.Client();
|
||||
|
||||
public static final ResourceLocation PACKET_ID_KEY_PRESSED = ResourceLocation.fromNamespaceAndPath(Constants.MOD_ID, "key_pressed");
|
||||
public static final ResourceLocation PACKET_ID_START_RIDING = ResourceLocation.fromNamespaceAndPath(Constants.MOD_ID, "start_riding");
|
||||
public static final ResourceLocation PACKET_ID_SYNC_SCRIPTS = ResourceLocation.fromNamespaceAndPath(Constants.MOD_ID, "sync_scripts");
|
||||
public static final ResourceLocation PACKET_ID_START_RIDING_OTHER = ResourceLocation.fromNamespaceAndPath(Constants.MOD_ID, "start_riding_other");
|
||||
public static final Identifier PACKET_ID_KEY_PRESSED = Identifier.fromNamespaceAndPath(Constants.MOD_ID, "key_pressed");
|
||||
public static final Identifier PACKET_ID_START_RIDING = Identifier.fromNamespaceAndPath(Constants.MOD_ID, "start_riding");
|
||||
public static final Identifier PACKET_ID_SYNC_SCRIPTS = Identifier.fromNamespaceAndPath(Constants.MOD_ID, "sync_scripts");
|
||||
public static final Identifier PACKET_ID_START_RIDING_OTHER = Identifier.fromNamespaceAndPath(Constants.MOD_ID, "start_riding_other");
|
||||
public static final Identifier PACKET_ID_SYNC_CARRY_ON_DATA = Identifier.fromNamespaceAndPath(Constants.MOD_ID, "sync_carry_data");
|
||||
|
||||
}
|
||||
|
|
@ -22,6 +22,8 @@ package tschipp.carryon.client.keybinds;
|
|||
|
||||
import com.mojang.blaze3d.platform.InputConstants;
|
||||
import net.minecraft.client.KeyMapping;
|
||||
import net.minecraft.client.KeyMapping.Category;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import tschipp.carryon.Constants;
|
||||
import tschipp.carryon.networking.serverbound.ServerboundCarryKeyPressedPacket;
|
||||
import tschipp.carryon.platform.Services;
|
||||
|
|
@ -34,10 +36,9 @@ public class CarryOnKeybinds
|
|||
|
||||
public static void registerKeybinds(Consumer<KeyMapping> registrar)
|
||||
{
|
||||
if(Services.PLATFORM.isModLoaded("amecsapi"))
|
||||
carryKey = new ConflictFreeKeyMapping("key.carry.desc", InputConstants.KEY_LSHIFT, "key.carry.category");
|
||||
else
|
||||
carryKey = new ConflictFreeKeyMapping("key.carry.desc", Services.PLATFORM.getPlatformName().equals("Forge") ? InputConstants.KEY_LSHIFT : InputConstants.UNKNOWN.getValue(), "key.carry.category");
|
||||
Category category = Category.register(Identifier.fromNamespaceAndPath(Constants.MOD_ID,"key.carry.category"));
|
||||
|
||||
carryKey = new KeyMapping("key.carry.desc", InputConstants.KEY_LSHIFT, category);
|
||||
|
||||
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, String $$2)
|
||||
{
|
||||
super($$0, $$1, $$2);
|
||||
}
|
||||
|
||||
public ConflictFreeKeyMapping(String $$0, Type $$1, int $$2, String $$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.exceptions.CommandSyntaxException;
|
||||
import com.mojang.datafixers.util.Either;
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.DataResult;
|
||||
import net.minecraft.commands.arguments.blocks.BlockStateParser;
|
||||
import net.minecraft.commands.arguments.blocks.BlockStateParser.BlockResult;
|
||||
|
|
@ -40,22 +39,13 @@ import tschipp.carryon.common.scripting.Matchables.NBTCondition;
|
|||
import javax.annotation.Nullable;
|
||||
import java.util.Map;
|
||||
|
||||
public class ModelOverride
|
||||
{
|
||||
//public static Codec<ModelOverride> CODEC = Codec.STRING.comapFlatMap(ModelOverride::of, override -> override.raw);
|
||||
|
||||
private String raw;
|
||||
public class ModelOverride {
|
||||
private BlockResult parsedBlock;
|
||||
private Type type;
|
||||
private Either<ItemResult, BlockResult> parsedRHS;
|
||||
private Either<ItemStack, BlockState> renderObject;
|
||||
|
||||
private ModelOverride(String raw, BlockResult parsedBlock, Type type, Either<ItemResult, BlockResult> parsedRHS)
|
||||
{
|
||||
this.raw = raw;
|
||||
this.parsedBlock = parsedBlock;
|
||||
this.type = type;
|
||||
this.parsedRHS = parsedRHS;
|
||||
|
||||
parsedRHS.ifLeft(res -> {
|
||||
ItemStack stack = new ItemStack(res.item());
|
||||
|
|
|
|||
|
|
@ -20,68 +20,42 @@
|
|||
|
||||
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.math.Axis;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
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.ShaderDefines;
|
||||
import net.minecraft.client.renderer.SubmitNodeCollector;
|
||||
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.client.renderer.entity.state.EntityRenderState;
|
||||
import net.minecraft.client.renderer.item.ItemStackRenderState;
|
||||
import net.minecraft.client.renderer.rendertype.RenderTypes;
|
||||
import net.minecraft.client.renderer.state.CameraRenderState;
|
||||
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.HumanoidArm;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.InventoryMenu;
|
||||
import net.minecraft.world.item.ItemDisplayContext;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.joml.Matrix4f;
|
||||
import tschipp.carryon.Constants;
|
||||
import tschipp.carryon.common.carry.CarryOnData;
|
||||
import tschipp.carryon.common.carry.CarryOnData.CarryType;
|
||||
import tschipp.carryon.common.carry.CarryOnDataManager;
|
||||
import tschipp.carryon.common.scripting.CarryOnScript;
|
||||
import tschipp.carryon.common.scripting.CarryOnScript.ScriptRender;
|
||||
import tschipp.carryon.platform.Services;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class CarriedObjectRender
|
||||
{
|
||||
|
||||
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)
|
||||
public static boolean draw(Player player, PoseStack matrix, int light, float partialTicks,SubmitNodeCollector nodeCollector, boolean firstPerson)
|
||||
{
|
||||
if(Services.PLATFORM.isModLoaded("firstperson") || Services.PLATFORM.isModLoaded("firstpersonmod"))
|
||||
if(Services.PLATFORM.isModLoaded("firstperson") || Services.PLATFORM.isModLoaded("firstpersonmod") || player == null)
|
||||
return false;
|
||||
|
||||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||
try {
|
||||
if (carry.isCarrying(CarryType.BLOCK))
|
||||
drawFirstPersonBlock(player, buffer, matrix, light, CarryRenderHelper.getRenderState(player));
|
||||
drawBlock(player, matrix, light, CarryRenderHelper.getRenderState(player), nodeCollector, firstPerson, partialTicks);
|
||||
else if (carry.isCarrying(CarryType.ENTITY))
|
||||
drawFirstPersonEntity(player, buffer, matrix, light, partialTicks);
|
||||
drawEntity(player, matrix, light, partialTicks, nodeCollector, firstPerson);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
@ -101,194 +75,59 @@ public class CarriedObjectRender
|
|||
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, float partialTicks)
|
||||
{
|
||||
matrix.pushPose();
|
||||
matrix.scale(2.5f, 2.5f, 2.5f);
|
||||
matrix.translate(0, -0.5, -1);
|
||||
//RenderSystem.enableBlend();
|
||||
//RenderSystem.disableCull();
|
||||
|
||||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||
ItemStackRenderState renderState = new ItemStackRenderState();
|
||||
var layer = renderState.newLayer();
|
||||
layer.setRenderType(RenderType.glint());
|
||||
layer.setRenderType(RenderTypes.glint());
|
||||
|
||||
if (Constants.CLIENT_CONFIG.facePlayer != CarryRenderHelper.isChest(state.getBlock())) {
|
||||
matrix.mulPose(Axis.YP.rotationDegrees(180));
|
||||
matrix.mulPose(Axis.XN.rotationDegrees(8));
|
||||
} else {
|
||||
matrix.mulPose(Axis.XP.rotationDegrees(8));
|
||||
}
|
||||
matrix.pushPose();
|
||||
|
||||
if(carry.getActiveScript().isPresent())
|
||||
CarryRenderHelper.performScriptTransformation(matrix, carry.getActiveScript().get());
|
||||
|
||||
//RenderSystem.setShaderTexture(0, GpuTexture);
|
||||
PoseStack renderPose = CarryRenderHelper.setupBlockTransformations(player, matrix, carry, firstPerson);
|
||||
|
||||
ItemStack renderStack = CarryRenderHelper.getRenderItemStack(player);
|
||||
Minecraft.getInstance().getItemModelResolver().updateForTopItem(renderState, renderStack, ItemDisplayContext.NONE, player.level(), null, 0);
|
||||
renderState.render(matrix, buffer, light, OverlayTexture.NO_OVERLAY);
|
||||
|
||||
|
||||
|
||||
//RenderSystem.enableCull();
|
||||
//RenderSystem.disableBlend();
|
||||
renderState.submit(renderPose, nodeCollector, light, OverlayTexture.NO_OVERLAY, 0);
|
||||
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();
|
||||
|
||||
Entity entity = CarryRenderHelper.getRenderEntity(player);
|
||||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||
|
||||
if (entity != null)
|
||||
{
|
||||
Vec3 playerpos = CarryRenderHelper.getExactPos(player, partialTicks);
|
||||
if (entity == null)
|
||||
return;
|
||||
|
||||
entity.setPos(playerpos.x, playerpos.y, playerpos.z);
|
||||
entity.xRotO = 0.0f;
|
||||
entity.yRotO = 0.0f;
|
||||
entity.setYHeadRot(0.0f);
|
||||
Vec3 playerpos = CarryRenderHelper.getExactPos(player, partialTicks);
|
||||
|
||||
float height = entity.getBbHeight();
|
||||
float width = entity.getBbWidth();
|
||||
entity.setPos(playerpos.x, playerpos.y, playerpos.z);
|
||||
entity.xRotO = 0.0f;
|
||||
entity.yRotO = 0.0f;
|
||||
entity.setYHeadRot(0.0f);
|
||||
|
||||
matrix.pushPose();
|
||||
matrix.scale(0.8f, 0.8f, 0.8f);
|
||||
matrix.mulPose(Axis.YP.rotationDegrees(180));
|
||||
matrix.translate(0.0, -height - .2, width * 1.3 + 0.1);
|
||||
matrix.pushPose();
|
||||
|
||||
manager.setRenderShadow(false);
|
||||
CarryRenderHelper.setupEntityTransformations(player, matrix, carry, firstPerson);
|
||||
|
||||
Optional<CarryOnScript> res = carry.getActiveScript();
|
||||
if(res.isPresent())
|
||||
{
|
||||
CarryOnScript script = res.get();
|
||||
CarryRenderHelper.performScriptTransformation(matrix, script);
|
||||
}
|
||||
if (entity instanceof LivingEntity)
|
||||
((LivingEntity) entity).hurtTime = 0;
|
||||
|
||||
if(Constants.CLIENT_CONFIG.rotateEntitiesSideways)
|
||||
matrix.mulPose(Axis.YP.rotationDegrees(90));
|
||||
try {
|
||||
EntityRenderState renderState = manager.extractEntity(entity, 0);
|
||||
renderState.shadowPieces.clear();
|
||||
renderState.lightCoords = light;
|
||||
manager.submit(renderState, new CameraRenderState(), 0, 0, 0, matrix, nodeCollector);
|
||||
}
|
||||
catch (Exception ignored)
|
||||
{
|
||||
}
|
||||
|
||||
if (entity instanceof LivingEntity)
|
||||
((LivingEntity) entity).hurtTime = 0;
|
||||
|
||||
try {
|
||||
manager.render(entity, 0, 0, 0, 0f, matrix, buffer, light);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
manager.setRenderShadow(true);
|
||||
matrix.popPose();
|
||||
if(!firstPerson)
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
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,111 +0,0 @@
|
|||
//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.vertex.MeshData;
|
||||
//import com.mojang.blaze3d.vertex.VertexFormat;
|
||||
//import net.minecraft.client.renderer.RenderType;
|
||||
//import org.jetbrains.annotations.NotNull;
|
||||
//
|
||||
//import java.util.IdentityHashMap;
|
||||
//import java.util.Map;
|
||||
//
|
||||
////Credit: klikli for the idea and code for this wrapper
|
||||
//public class CarryOnRenderType extends RenderType {
|
||||
//
|
||||
// private static final Map<RenderType, RenderType> remappedTypes = new IdentityHashMap<>();
|
||||
// private final RenderPipeline pipeline;
|
||||
// private final RenderType original;
|
||||
//
|
||||
// private CarryOnRenderType(RenderType original, RenderPipeline pipeline) {
|
||||
// super(String.format("%s_carryon", original.toString()), original.bufferSize(), original.affectsCrumbling(), true, original::setupRenderState, original::clearRenderState);
|
||||
// this.pipeline = pipeline;
|
||||
// this.original = original;
|
||||
// }
|
||||
//
|
||||
// public static RenderType remap(RenderType in) {
|
||||
// return remappedTypes.computeIfAbsent(in, (type) -> {
|
||||
//
|
||||
// //modify the pipeline
|
||||
// var pipeline = toBuilder(in.getRenderPipeline())
|
||||
// .withBlend(BlendFunction.TRANSLUCENT)
|
||||
// .withDepthTestFunction(DepthTestFunction.NO_DEPTH_TEST)
|
||||
// .withCull(false);
|
||||
//
|
||||
// return new CarryOnRenderType(type, pipeline.build());
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// private static RenderPipeline.Builder toBuilder(RenderPipeline pipeline) {
|
||||
// RenderPipeline.Builder builder = RenderPipeline.builder();
|
||||
// builder.withLocation(pipeline.getLocation());
|
||||
// builder.withFragmentShader(pipeline.getFragmentShader());
|
||||
// builder.withVertexShader(pipeline.getVertexShader());
|
||||
//
|
||||
// if (!pipeline.getShaderDefines().isEmpty()) {
|
||||
// for (Map.Entry<String, String> entry : pipeline.getShaderDefines().values().entrySet()) {
|
||||
// try {
|
||||
// int parsed = Integer.parseInt(entry.getValue());
|
||||
// builder.withShaderDefine(entry.getKey(), parsed);
|
||||
// } catch (NumberFormatException e) {
|
||||
// float parsed = Float.parseFloat(entry.getValue());
|
||||
// builder.withShaderDefine(entry.getKey(), parsed);
|
||||
// }
|
||||
// }
|
||||
// for (String flag : pipeline.getShaderDefines().flags()) {
|
||||
// builder.withShaderDefine(flag);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (!pipeline.getSamplers().isEmpty()) {
|
||||
// pipeline.getSamplers().forEach(builder::withSampler);
|
||||
// }
|
||||
//
|
||||
// if (!pipeline.getUniforms().isEmpty()) {
|
||||
// pipeline.getUniforms().forEach(u -> builder.withUniform(u.name(), u.type()));
|
||||
// }
|
||||
//
|
||||
// builder.withDepthTestFunction(pipeline.getDepthTestFunction());
|
||||
// builder.withPolygonMode(pipeline.getPolygonMode());
|
||||
// builder.withCull(pipeline.isCull());
|
||||
// builder.withColorWrite(pipeline.isWriteColor(), pipeline.isWriteAlpha());
|
||||
// builder.withDepthWrite(pipeline.isWriteDepth());
|
||||
// builder.withColorLogic(pipeline.getColorLogic());
|
||||
//
|
||||
// if (pipeline.getBlendFunction().isPresent())
|
||||
// builder.withBlend(pipeline.getBlendFunction().get());
|
||||
// else
|
||||
// builder.withoutBlend();
|
||||
// builder.withVertexFormat(pipeline.getVertexFormat(), pipeline.getVertexFormatMode());
|
||||
// builder.withDepthBias(pipeline.getDepthBiasScaleFactor(), pipeline.getDepthBiasConstant());
|
||||
//
|
||||
// return builder;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void draw(@NotNull MeshData 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
|
||||
// public @NotNull VertexFormat format() {
|
||||
// return this.original.format();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public VertexFormat.@NotNull Mode mode() {
|
||||
// return this.original.mode();
|
||||
// }
|
||||
//}
|
||||
|
|
@ -24,7 +24,6 @@ import com.mojang.blaze3d.vertex.PoseStack;
|
|||
import com.mojang.math.Axis;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.util.ProblemReporter;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntitySpawnReason;
|
||||
|
|
@ -34,6 +33,7 @@ import net.minecraft.world.entity.player.Player;
|
|||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.ChestBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.storage.TagValueInput;
|
||||
import net.minecraft.world.level.storage.ValueInput;
|
||||
|
|
@ -74,91 +74,60 @@ public class CarryRenderHelper
|
|||
return Axis.YP.rotationDegrees(getExactBodyRotationDegrees(entity, partialticks));
|
||||
}
|
||||
|
||||
public static void applyGeneralTransformations(Player player, float partialticks, PoseStack matrix)
|
||||
public static void applyGeneralTransformations(Player player, PoseStack matrix)
|
||||
{
|
||||
int perspective = CarryRenderHelper.getPerspective();
|
||||
Quaternionf playerrot = CarryRenderHelper.getExactBodyRotation(player, partialticks);
|
||||
Vec3 playerpos = CarryRenderHelper.getExactPos(player, partialticks);
|
||||
Vec3 cameraPos = Minecraft.getInstance().gameRenderer.getMainCamera().getPosition();
|
||||
Vec3 offset = playerpos.subtract(cameraPos);
|
||||
Pose pose = player.getPose();
|
||||
|
||||
matrix.pushPose();
|
||||
matrix.translate(offset.x, offset.y, offset.z);
|
||||
|
||||
if (perspective == 2)
|
||||
playerrot.mul(Axis.YP.rotationDegrees(180));
|
||||
matrix.mulPose(playerrot);
|
||||
|
||||
matrix.pushPose();
|
||||
matrix.scale(0.6f, 0.6f, 0.6f);
|
||||
|
||||
if (perspective == 2)
|
||||
matrix.translate(0, 0, -1.35);
|
||||
matrix.translate(0, 0, -1.35);
|
||||
|
||||
if (doSneakCheck(player))
|
||||
{
|
||||
matrix.translate(0, -0.4, 0);
|
||||
}
|
||||
|
||||
if (pose == Pose.SWIMMING)
|
||||
if (pose == Pose.SWIMMING || pose == Pose.FALL_FLYING)
|
||||
{
|
||||
float f = player.getSwimAmount(partialticks);
|
||||
float f3 = player.isInWater() ? -90.0F - player.xRotO : -90.0F;
|
||||
float f4 = Mth.lerp(f, 0.0F, f3);
|
||||
if (perspective == 2)
|
||||
{
|
||||
matrix.translate(0, 0, 1.35);
|
||||
matrix.mulPose(Axis.XP.rotationDegrees(f4));
|
||||
}
|
||||
else
|
||||
matrix.mulPose(Axis.XN.rotationDegrees(f4));
|
||||
|
||||
matrix.translate(0, -1.5, -1.848);
|
||||
if (perspective == 2)
|
||||
matrix.translate(0, 0, 2.38);
|
||||
matrix.translate(0, 0, 2.5);
|
||||
matrix.mulPose(Axis.XP.rotationDegrees(90));
|
||||
}
|
||||
|
||||
if (pose == Pose.FALL_FLYING)
|
||||
{
|
||||
float f1 = player.getFallFlyingTicks() + partialticks;
|
||||
float f2 = Mth.clamp(f1 * f1 / 100.0F, 0.0F, 1.0F);
|
||||
if (!player.isAutoSpinAttack())
|
||||
{
|
||||
if (perspective == 2)
|
||||
matrix.translate(0, 0, 1.35);
|
||||
|
||||
if (perspective == 2)
|
||||
matrix.mulPose(Axis.XP.rotationDegrees(f2 * (-90.0F - player.xRotO)));
|
||||
else
|
||||
matrix.mulPose(Axis.XN.rotationDegrees(f2 * (-90.0F - player.xRotO)));
|
||||
}
|
||||
|
||||
Vec3 viewVector = player.getViewVector(partialticks);
|
||||
Vec3 deltaMovement = player.getDeltaMovement();
|
||||
double d0 = deltaMovement.horizontalDistanceSqr();
|
||||
double d1 = deltaMovement.horizontalDistanceSqr();
|
||||
if (d0 > 0.0D && d1 > 0.0D)
|
||||
{
|
||||
double d2 = (deltaMovement.x * viewVector.x + deltaMovement.z * viewVector.z) / (Math.sqrt(d0) * Math.sqrt(d1));
|
||||
double d3 = deltaMovement.x * viewVector.z - deltaMovement.z * viewVector.x;
|
||||
|
||||
matrix.mulPose(Axis.YP.rotation((float) (Math.signum(d3) * Math.acos(d2))));
|
||||
}
|
||||
|
||||
if (perspective != 2)
|
||||
matrix.translate(0, 0, -1.35);
|
||||
matrix.translate(0, -0.2, 0);
|
||||
}
|
||||
|
||||
matrix.translate(0, 1.6, 0.65);
|
||||
matrix.translate(0, -0.5, 0.65);
|
||||
}
|
||||
|
||||
public static void applyBlockTransformations(Player player, float partialticks, PoseStack matrix, Block block)
|
||||
{
|
||||
int perspective = CarryRenderHelper.getPerspective();
|
||||
public static PoseStack setupBlockTransformations(Player player, PoseStack matrix, CarryOnData carry, boolean firstPerson) {
|
||||
if (firstPerson) {
|
||||
matrix.scale(2.5f, 2.5f, 2.5f);
|
||||
matrix.translate(0, -0.5, -1);
|
||||
|
||||
applyGeneralTransformations(player, partialticks, matrix);
|
||||
if (Constants.CLIENT_CONFIG.facePlayer != CarryRenderHelper.isChest(carry.getBlock().getBlock())) {
|
||||
matrix.mulPose(Axis.YP.rotationDegrees(180));
|
||||
matrix.mulPose(Axis.XN.rotationDegrees(8));
|
||||
} else {
|
||||
matrix.mulPose(Axis.XP.rotationDegrees(8));
|
||||
}
|
||||
carry.getActiveScript().ifPresent(script -> CarryRenderHelper.performScriptTransformation(matrix, script));
|
||||
|
||||
return matrix;
|
||||
} else {
|
||||
CarryRenderHelper.applyBlockTransformations(player, matrix, carry.getBlock().getBlock());
|
||||
carry.getActiveScript().ifPresent(script -> CarryRenderHelper.performScriptTransformation(matrix, script));
|
||||
|
||||
PoseStack.Pose p = matrix.last();
|
||||
PoseStack copy = new PoseStack();
|
||||
copy.mulPose(p.pose());
|
||||
matrix.popPose();
|
||||
|
||||
return copy;
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyBlockTransformations(Player player, PoseStack matrix, Block block)
|
||||
{
|
||||
matrix.mulPose(Axis.ZN.rotationDegrees(180));
|
||||
applyGeneralTransformations(player, matrix);
|
||||
|
||||
if (Constants.CLIENT_CONFIG.facePlayer != CarryRenderHelper.isChest(block))
|
||||
{
|
||||
|
|
@ -167,59 +136,67 @@ public class CarryRenderHelper
|
|||
// matrix.translate(0, 0, -0.4);
|
||||
matrix.mulPose(Axis.YP.rotationDegrees(180));
|
||||
}
|
||||
// if(perspective == 1)
|
||||
// {
|
||||
// matrix.pushPose();
|
||||
// //matrix.mulPose(Axis.YP.rotationDegrees(180));
|
||||
// matrix.popPose();
|
||||
// }
|
||||
|
||||
//else if ((ModList.get().isLoaded("realrender") || ModList.get().isLoaded("rfpr")) && perspective == 0)
|
||||
// matrix.translate(0, 0, 0.4);
|
||||
//matrix.mulPose(Axis.YP.rotationDegrees(180));
|
||||
|
||||
|
||||
|
||||
float height = getRenderHeight(player);
|
||||
float offset = (height - 1f) / 1.2f;
|
||||
matrix.translate(0, -offset, 0);
|
||||
}
|
||||
|
||||
public static void applyEntityTransformations(Player player, float partialticks, PoseStack matrix, Entity entity)
|
||||
public static void setupEntityTransformations(Player player, PoseStack matrix, CarryOnData carry, boolean firstPerson) {
|
||||
|
||||
Entity entity = carry.getEntity(player.level());
|
||||
|
||||
float height = entity.getBbHeight();
|
||||
float width = entity.getBbWidth();
|
||||
|
||||
if(firstPerson) {
|
||||
matrix.mulPose(Axis.YP.rotationDegrees(180));
|
||||
|
||||
matrix.scale(0.8f, 0.8f, 0.8f);
|
||||
matrix.translate(0.0, -height - .2, width * 1.3 + 0.1);
|
||||
|
||||
carry.getActiveScript().ifPresent(script -> CarryRenderHelper.performScriptTransformation(matrix, script));
|
||||
|
||||
if(Constants.CLIENT_CONFIG.rotateEntitiesSideways)
|
||||
matrix.mulPose(Axis.YP.rotationDegrees(90));
|
||||
}
|
||||
else {
|
||||
applyEntityTransformations(player, matrix, entity);
|
||||
|
||||
carry.getActiveScript().ifPresent(script -> CarryRenderHelper.performScriptTransformation(matrix, script));
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyEntityTransformations(Player player, PoseStack matrix, Entity entity)
|
||||
{
|
||||
int perspective = CarryRenderHelper.getPerspective();
|
||||
Pose pose = player.getPose();
|
||||
|
||||
applyGeneralTransformations(player, partialticks, matrix);
|
||||
applyGeneralTransformations(player, matrix);
|
||||
|
||||
if (perspective == 2)
|
||||
matrix.translate(0, -1.6, 0.65);
|
||||
else
|
||||
matrix.translate(0, -1.6, -0.65);
|
||||
matrix.mulPose(Axis.XP.rotationDegrees(180));
|
||||
|
||||
matrix.translate(0, -3.1, -0.65);
|
||||
matrix.scale(1.666f, 1.666f, 1.666f);
|
||||
|
||||
float height = entity.getBbHeight();
|
||||
float width = entity.getBbWidth();
|
||||
float multiplier = height * width;
|
||||
float multiplier = Math.min(9.9f, height * width) ;
|
||||
entity.yo = 0.0f;
|
||||
entity.yRotO = 0.0f;
|
||||
entity.setYHeadRot(0.0f);
|
||||
entity.xo = 0.0f;
|
||||
entity.xRotO = 0.0f;
|
||||
|
||||
if (perspective == 2)
|
||||
matrix.mulPose(Axis.YP.rotationDegrees(180));
|
||||
|
||||
matrix.scale((10 - multiplier) * 0.08f, (10 - multiplier) * 0.08f, (10 - multiplier) * 0.08f);
|
||||
matrix.translate(0.0, height / 2 + -(height / 4) + 1, width - 0.1 < 0.7 ? width - 0.1 + (0.7 - (width - 0.1)) : width - 0.1);
|
||||
|
||||
if(doSneakCheck(player))
|
||||
matrix.translate(0, -0.4, 0);
|
||||
|
||||
if (pose == Pose.SWIMMING || pose == Pose.FALL_FLYING)
|
||||
{
|
||||
matrix.mulPose(Axis.XN.rotationDegrees(90));
|
||||
matrix.translate(0, -0.2 * height, 0);
|
||||
|
||||
if (pose == Pose.FALL_FLYING)
|
||||
matrix.translate(0, 0, 0.2);
|
||||
matrix.mulPose(Axis.XN.rotationDegrees(180));
|
||||
matrix.translate(0, 0.2 * height - 2, -0.5);
|
||||
}
|
||||
|
||||
if(Constants.CLIENT_CONFIG.rotateEntitiesSideways)
|
||||
|
|
@ -463,7 +440,7 @@ public class CarryRenderHelper
|
|||
|
||||
public static boolean isChest(Block block)
|
||||
{
|
||||
return block == Blocks.CHEST || block == Blocks.ENDER_CHEST || block == Blocks.TRAPPED_CHEST;
|
||||
return block == Blocks.CHEST || block == Blocks.ENDER_CHEST || block == Blocks.TRAPPED_CHEST || block instanceof ChestBlock;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
package tschipp.carryon.client.render;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.model.player.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, Minecraft.getInstance().getDeltaTracker().getGameTimeDeltaPartialTick(true), nodeCollector,false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
package tschipp.carryon.client.render;
|
||||
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import tschipp.carryon.common.carry.CarryOnData;
|
||||
|
||||
public interface ICarryOnRenderState {
|
||||
|
|
@ -12,4 +13,8 @@ public interface ICarryOnRenderState {
|
|||
|
||||
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.DataResult;
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
|
|
@ -30,12 +29,16 @@ import net.minecraft.nbt.CompoundTag;
|
|||
import net.minecraft.nbt.NbtOps;
|
||||
import net.minecraft.nbt.NbtUtils;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.network.codec.ByteBufCodecs;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.util.ProblemReporter;
|
||||
import net.minecraft.world.entity.AreaEffectCloud;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntitySpawnReason;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
|
@ -48,6 +51,7 @@ import tschipp.carryon.common.scripting.CarryOnScript;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
public class CarryOnData {
|
||||
|
||||
|
|
@ -58,6 +62,7 @@ public class CarryOnData {
|
|||
private int selectedSlot = 0;
|
||||
private static final ProblemReporter problemReporter = new ProblemReporter.ScopedCollector(Constants.LOG);
|
||||
|
||||
|
||||
public static final Codec<CarryOnData> CODEC = CompoundTag.CODEC.flatXmap(
|
||||
tag -> {
|
||||
try {
|
||||
|
|
@ -75,6 +80,10 @@ public class CarryOnData {
|
|||
}
|
||||
);
|
||||
|
||||
public static final StreamCodec<RegistryFriendlyByteBuf, CarryOnData> STREAM_CODEC = ByteBufCodecs.fromCodecWithRegistries(CODEC);
|
||||
|
||||
public static final String SERIALIZATION_KEY = "CarryOnData";
|
||||
|
||||
public CarryOnData(CompoundTag data)
|
||||
{
|
||||
if(data.contains("type"))
|
||||
|
|
@ -96,6 +105,11 @@ public class CarryOnData {
|
|||
|
||||
}
|
||||
|
||||
public CarryType getType()
|
||||
{
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public CompoundTag getNbt()
|
||||
{
|
||||
nbt.putString("type", type.toString());
|
||||
|
|
@ -194,8 +208,20 @@ public class CarryOnData {
|
|||
this.activeScript = script;
|
||||
}
|
||||
|
||||
public void setCarryingPlayer() {
|
||||
public void setCarryingPlayer(Player 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()
|
||||
|
|
@ -236,11 +262,14 @@ public class CarryOnData {
|
|||
|
||||
public int getTick()
|
||||
{
|
||||
if(!this.nbt.contains("tick"))
|
||||
return -1;
|
||||
return this.nbt.getIntOr("tick", -1);
|
||||
}
|
||||
|
||||
public void setTick(int tick) {
|
||||
this.nbt.putInt("tick", tick);
|
||||
}
|
||||
|
||||
|
||||
public enum CarryType {
|
||||
BLOCK,
|
||||
ENTITY,
|
||||
|
|
|
|||
|
|
@ -20,29 +20,21 @@
|
|||
|
||||
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.world.entity.player.Player;
|
||||
import tschipp.carryon.platform.Services;
|
||||
|
||||
public class CarryOnDataManager {
|
||||
|
||||
public static CarryOnData getCarryData(Player player)
|
||||
{
|
||||
return ((ICarrying)player).getCarryOnData();
|
||||
return Services.PLATFORM.getCarryData(player);
|
||||
}
|
||||
|
||||
public static void setCarryData(Player player, CarryOnData data)
|
||||
{
|
||||
((ICarrying)player).setCarryOnData(data);
|
||||
}
|
||||
|
||||
public interface ICarrying {
|
||||
|
||||
void setCarryOnData(CarryOnData data);
|
||||
|
||||
CarryOnData getCarryOnData();
|
||||
data.setSelected(player.getInventory().getSelectedSlot());
|
||||
data.setTick(player.tickCount);
|
||||
Services.PLATFORM.setCarryData(player, data);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,17 +29,16 @@ import net.minecraft.util.ProblemReporter;
|
|||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.effect.MobEffects;
|
||||
import net.minecraft.world.entity.AgeableMob;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.*;
|
||||
import net.minecraft.world.entity.Entity.RemovalReason;
|
||||
import net.minecraft.world.entity.MobCategory;
|
||||
import net.minecraft.world.entity.TamableAnimal;
|
||||
import net.minecraft.world.entity.animal.Animal;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.DoorBlock;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.Property;
|
||||
import net.minecraft.world.level.storage.TagValueOutput;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import tschipp.carryon.CarryOnCommon;
|
||||
|
|
@ -50,7 +49,6 @@ import tschipp.carryon.common.pickupcondition.PickupConditionHandler;
|
|||
import tschipp.carryon.common.scripting.CarryOnScript;
|
||||
import tschipp.carryon.common.scripting.ScriptManager;
|
||||
import tschipp.carryon.networking.clientbound.ClientboundStartRidingOtherPlayerPacket;
|
||||
import tschipp.carryon.networking.clientbound.ClientboundStartRidingPacket;
|
||||
import tschipp.carryon.platform.Services;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
|
@ -104,13 +102,20 @@ public class PickupHandler {
|
|||
nbt = output.buildResult();
|
||||
}
|
||||
|
||||
Optional<CarryOnScript> result = ScriptManager.inspectBlock(state, level, pos, nbt);
|
||||
boolean overrideChecks = result.map(CarryOnScript::overrideChecks).orElse(false);
|
||||
|
||||
if(!ListHandler.isPermitted(state.getBlock()))
|
||||
return false;
|
||||
|
||||
if(state.getDestroySpeed(level, pos) == -1 && !player.isCreative() && !Constants.COMMON_CONFIG.settings.pickupUnbreakableBlocks)
|
||||
// Reject pickup of Double blocks, if they use the vanilla property
|
||||
if(hasPropertyType(state, DoorBlock.HALF))
|
||||
return false;
|
||||
|
||||
if(blockEntity == null && !Constants.COMMON_CONFIG.settings.pickupAllBlocks)
|
||||
if(!overrideChecks && (state.getDestroySpeed(level, pos) == -1 && !player.isCreative() && !Constants.COMMON_CONFIG.settings.pickupUnbreakableBlocks))
|
||||
return false;
|
||||
|
||||
if(!overrideChecks && (blockEntity == null && !Constants.COMMON_CONFIG.settings.pickupAllBlocks))
|
||||
return false;
|
||||
|
||||
//Check if TE is locked
|
||||
|
|
@ -131,7 +136,6 @@ public class PickupHandler {
|
|||
if(!doPickup)
|
||||
return false;
|
||||
|
||||
Optional<CarryOnScript> result = ScriptManager.inspectBlock(state, level, pos, nbt);
|
||||
if(result.isPresent())
|
||||
{
|
||||
CarryOnScript script = result.get();
|
||||
|
|
@ -142,7 +146,7 @@ public class PickupHandler {
|
|||
|
||||
String cmd = script.scriptEffects().commandInit();
|
||||
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);
|
||||
|
|
@ -154,7 +158,7 @@ public class PickupHandler {
|
|||
level.playSound(null, pos, state.getSoundType().getHitSound(), SoundSource.BLOCKS, 1.0f, 0.5f);
|
||||
player.swing(InteractionHand.MAIN_HAND, true);
|
||||
if (!player.isCreative() || Constants.COMMON_CONFIG.settings.slownessInCreative)
|
||||
player.addEffect(new MobEffectInstance(MobEffects.SLOWNESS, 1000000, CarryOnCommon.potionLevel(carry, player.level()), false, false));
|
||||
player.addEffect(new MobEffectInstance(MobEffects.SLOWNESS, 100000000, CarryOnCommon.potionLevel(carry, player.level()), false, false));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -173,23 +177,29 @@ public class PickupHandler {
|
|||
|
||||
if (entity instanceof TamableAnimal tame)
|
||||
{
|
||||
UUID owner = tame.getOwnerReference().getUUID();
|
||||
UUID playerID = player.getGameProfile().getId();
|
||||
if (owner != null && !owner.equals(playerID))
|
||||
return false;
|
||||
EntityReference<LivingEntity> ref = tame.getOwnerReference();
|
||||
if (ref != null) {
|
||||
UUID owner = ref.getUUID();
|
||||
UUID playerID = player.getGameProfile().id();
|
||||
if (!owner.equals(playerID))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Optional<CarryOnScript> result = ScriptManager.inspectEntity(entity);
|
||||
boolean overrideChecks = result.map(CarryOnScript::overrideChecks).orElse(false);
|
||||
|
||||
if(!ListHandler.isPermitted(entity))
|
||||
{
|
||||
//We can pick up baby animals even if the grown up animal is blacklisted.
|
||||
if(!(entity instanceof AgeableMob ageableMob && Constants.COMMON_CONFIG.settings.allowBabies && (ageableMob.getAge() < 0 || ageableMob.isBaby())))
|
||||
if(!overrideChecks && (!(entity instanceof AgeableMob ageableMob && Constants.COMMON_CONFIG.settings.allowBabies && (ageableMob.getAge() < 0 || ageableMob.isBaby()))))
|
||||
return false;
|
||||
}
|
||||
|
||||
//Non-Creative only guards
|
||||
if(!player.isCreative())
|
||||
{
|
||||
if(!Constants.COMMON_CONFIG.settings.pickupHostileMobs && entity.getType().getCategory() == MobCategory.MONSTER)
|
||||
if(!overrideChecks && (!Constants.COMMON_CONFIG.settings.pickupHostileMobs && entity.getType().getCategory() == MobCategory.MONSTER))
|
||||
return false;
|
||||
|
||||
if(Constants.COMMON_CONFIG.settings.maxEntityHeight < entity.getBbHeight() || Constants.COMMON_CONFIG.settings.maxEntityWidth < entity.getBbWidth())
|
||||
|
|
@ -203,13 +213,12 @@ public class PickupHandler {
|
|||
return false;
|
||||
}
|
||||
|
||||
boolean doPickup = pickupCallback == null ? true : pickupCallback.apply(entity);
|
||||
boolean doPickup = pickupCallback == null || pickupCallback.apply(entity);
|
||||
if(!doPickup)
|
||||
return false;
|
||||
|
||||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||
|
||||
Optional<CarryOnScript> result = ScriptManager.inspectEntity(entity);
|
||||
if(result.isPresent())
|
||||
{
|
||||
CarryOnScript script = result.get();
|
||||
|
|
@ -232,17 +241,17 @@ public class PickupHandler {
|
|||
if (result.isPresent()) {
|
||||
String cmd = result.get().scriptEffects().commandInit();
|
||||
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());
|
||||
carry.setCarryingPlayer();
|
||||
carry.setCarryingPlayer(otherPlayer);
|
||||
player.swing(InteractionHand.MAIN_HAND, true);
|
||||
player.level().playSound(null, player.getOnPos(), SoundEvents.ARMOR_EQUIP_GENERIC.value(), SoundSource.AMBIENT, 1.0f, 0.5f);
|
||||
CarryOnDataManager.setCarryData(player, carry);
|
||||
if (!player.isCreative() || Constants.COMMON_CONFIG.settings.slownessInCreative)
|
||||
player.addEffect(new MobEffectInstance(MobEffects.SLOWNESS, 1000000, CarryOnCommon.potionLevel(carry, player.level()), false, false));
|
||||
player.addEffect(new MobEffectInstance(MobEffects.SLOWNESS, 100000000, CarryOnCommon.potionLevel(carry, player.level()), false, false));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
|
@ -257,7 +266,7 @@ public class PickupHandler {
|
|||
{
|
||||
String cmd = result.get().scriptEffects().commandInit();
|
||||
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);
|
||||
|
|
@ -267,8 +276,16 @@ public class PickupHandler {
|
|||
CarryOnDataManager.setCarryData(player, carry);
|
||||
player.swing(InteractionHand.MAIN_HAND, true);
|
||||
if (!player.isCreative() || Constants.COMMON_CONFIG.settings.slownessInCreative)
|
||||
player.addEffect(new MobEffectInstance(MobEffects.SLOWNESS, 1000000, CarryOnCommon.potionLevel(carry, player.level()), false, false));
|
||||
player.addEffect(new MobEffectInstance(MobEffects.SLOWNESS, 100000000, CarryOnCommon.potionLevel(carry, player.level()), false, false));
|
||||
return true;
|
||||
}
|
||||
|
||||
private static <T extends Comparable<T>> boolean hasPropertyType(BlockState state, Property<T> prop) {
|
||||
for (var p : state.getProperties()) {
|
||||
if(p.getValueClass().equals(prop.getValueClass()))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,29 +22,26 @@ package tschipp.carryon.common.carry;
|
|||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.effect.MobEffects;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.entity.animal.horse.Horse;
|
||||
import net.minecraft.world.entity.animal.equine.Horse;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.GameRules;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
import net.minecraft.world.level.block.state.properties.Property;
|
||||
import net.minecraft.world.level.gamerules.GameRules;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import tschipp.carryon.CarryOnCommon;
|
||||
import tschipp.carryon.Constants;
|
||||
import tschipp.carryon.common.carry.CarryOnData.CarryType;
|
||||
import tschipp.carryon.common.config.ListHandler;
|
||||
|
|
@ -95,11 +92,14 @@ public class PlacementHandler
|
|||
if (!doPlace)
|
||||
return false;
|
||||
|
||||
if(level.isOutsideBuildHeight(pos))
|
||||
return false;
|
||||
|
||||
if (carry.getActiveScript().isPresent()) {
|
||||
ScriptEffects effects = carry.getActiveScript().get().scriptEffects();
|
||||
String cmd = effects.commandPlace();
|
||||
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);
|
||||
|
|
@ -177,7 +177,7 @@ public class PlacementHandler
|
|||
Vec3 placementPos = Vec3.atBottomCenterOf(pos);
|
||||
|
||||
if (carry.isCarrying(CarryType.PLAYER)) {
|
||||
Entity otherPlayer = player.getFirstPassenger();
|
||||
Entity otherPlayer = carry.getCarryingPlayer(level);
|
||||
player.ejectPassengers();
|
||||
Services.PLATFORM.sendPacketToAllPlayers(Constants.PACKET_ID_START_RIDING_OTHER, new ClientboundStartRidingOtherPlayerPacket(player.getId(), otherPlayer.getId(), false), player.level());
|
||||
carry.clear();
|
||||
|
|
@ -199,7 +199,7 @@ public class PlacementHandler
|
|||
ScriptEffects effects = carry.getActiveScript().get().scriptEffects();
|
||||
String cmd = effects.commandPlace();
|
||||
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);
|
||||
|
|
@ -257,20 +257,20 @@ public class PlacementHandler
|
|||
level.addFreshEntity(entityHeld);
|
||||
entityHeld.teleportTo(tempX, tempY, tempZ);
|
||||
}
|
||||
entityHeld.startRiding(topEntity, false);
|
||||
entityHeld.startRiding(topEntity, false,false);
|
||||
} else {
|
||||
if (carry.isCarrying(CarryType.ENTITY)) {
|
||||
entityHeld.setPos(entityClicked.getX(), entityClicked.getY(), entityClicked.getZ());
|
||||
level.addFreshEntity(entityHeld);
|
||||
}
|
||||
entityHeld.startRiding(topEntity, false);
|
||||
entityHeld.startRiding(topEntity, false,false);
|
||||
}
|
||||
|
||||
if (carry.getActiveScript().isPresent()) {
|
||||
ScriptEffects effects = carry.getActiveScript().get().scriptEffects();
|
||||
String cmd = effects.commandPlace();
|
||||
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);
|
||||
|
|
@ -290,7 +290,7 @@ public class PlacementHandler
|
|||
public static void placeCarriedOnDeath(ServerPlayer oldPlayer, ServerPlayer newPlayer, boolean died)
|
||||
{
|
||||
CarryOnData carry = CarryOnDataManager.getCarryData(oldPlayer);
|
||||
if (((ServerLevel) oldPlayer.level()).getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || !died) {
|
||||
if (oldPlayer.level().getGameRules().get(GameRules.KEEP_INVENTORY) || !died) {
|
||||
if (!carry.isCarrying(CarryType.PLAYER)) {
|
||||
CarryOnDataManager.setCarryData(newPlayer, carry);
|
||||
newPlayer.getInventory().setSelectedSlot(oldPlayer.getInventory().getSelectedSlot());
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ import net.minecraft.commands.Commands;
|
|||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.permissions.Permission;
|
||||
import net.minecraft.server.permissions.PermissionLevel;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import tschipp.carryon.Constants;
|
||||
|
|
@ -54,11 +56,11 @@ public class CommandCarryOn
|
|||
|
||||
.then(Commands.literal("clear").executes(cmd -> handleClear(cmd.getSource(), Collections.singleton(cmd.getSource().getPlayerOrException()))))
|
||||
|
||||
.then(Commands.literal("clear").then(Commands.argument("target", EntityArgument.players()).requires(src -> src.hasPermission(2)).executes(cmd -> handleClear(cmd.getSource(), EntityArgument.getPlayers(cmd, "target")))))
|
||||
.then(Commands.literal("clear").then(Commands.argument("target", EntityArgument.players()).requires(src -> src.permissions().hasPermission(new Permission.HasCommandLevel(PermissionLevel.GAMEMASTERS))).executes(cmd -> handleClear(cmd.getSource(), EntityArgument.getPlayers(cmd, "target")))))
|
||||
|
||||
.then(Commands.literal("place").requires(src -> src.hasPermission(2)).executes(cmd -> handlePlace(cmd.getSource(), Collections.singleton(cmd.getSource().getPlayerOrException()))))
|
||||
.then(Commands.literal("place").requires(src -> src.permissions().hasPermission(new Permission.HasCommandLevel(PermissionLevel.GAMEMASTERS))).executes(cmd -> handlePlace(cmd.getSource(), Collections.singleton(cmd.getSource().getPlayerOrException()))))
|
||||
|
||||
.then(Commands.literal("place").then(Commands.argument("target", EntityArgument.players()).requires(src -> src.hasPermission(2)).executes(cmd -> handlePlace(cmd.getSource(), EntityArgument.getPlayers(cmd, "target")))))
|
||||
.then(Commands.literal("place").then(Commands.argument("target", EntityArgument.players()).requires(src -> src.permissions().hasPermission(new Permission.HasCommandLevel(PermissionLevel.GAMEMASTERS))).executes(cmd -> handlePlace(cmd.getSource(), EntityArgument.getPlayers(cmd, "target")))))
|
||||
|
||||
;
|
||||
|
||||
|
|
|
|||
|
|
@ -285,7 +285,7 @@ public class CarryConfig
|
|||
"modern_industrialization:fluid_pipe",
|
||||
"modern_industrialization:*_fluid_pipe",
|
||||
"yigd:*", "domum_ornamentum:*", "connectiblechains:*",
|
||||
"cobblemon:*", "snowrealmagic:*", "forbidden_arcanus:black_hole", "domum_ornamentum:*", "sgjourney:*", "copycats:*", "expandedstorage:*"
|
||||
"cobblemon:*", "snowrealmagic:*", "forbidden_arcanus:black_hole", "domum_ornamentum:*", "sgjourney:*", "copycats:*", "expandedstorage:*", "replication:*"
|
||||
};
|
||||
|
||||
@Property(
|
||||
|
|
@ -302,7 +302,7 @@ public class CarryConfig
|
|||
"animania:hamster", "animania:ferret*", "animania:hedgehog*", "animania:cart",
|
||||
"animania:wagon", "mynko:*", "pixelmon:*", "mocreatures:*", "quark:totem", "vehicle:*",
|
||||
"securitycraft:*", "taterzens:npc", "easy_npc:*", "bodiesbodies:dead_body", "littletiles:*",
|
||||
"connectiblechains:*", "cobblemon:*", "create:*", "swem:*"
|
||||
"connectiblechains:*", "cobblemon:*", "create:*", "swem:*", "toms_mobs:*"
|
||||
};
|
||||
|
||||
@Property(
|
||||
|
|
@ -311,7 +311,8 @@ public class CarryConfig
|
|||
validationRegex = "(#?[a-zA-Z0-9_*]+:[a-zA-Z0-9_*]*(?:\\*|[a-zA-Z0-9_]*)(?:\\*|[a-zA-Z0-9_]*)?)"
|
||||
)
|
||||
public String[] forbiddenStacking = {
|
||||
"minecraft:horse"
|
||||
"minecraft:horse",
|
||||
"minecraft:ender_dragon"
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ package tschipp.carryon.common.config;
|
|||
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
|
|
@ -119,8 +119,8 @@ public class ListHandler {
|
|||
ALLOWED_TILES_TAGS.clear();
|
||||
PROPERTY_EXCEPTION_CLASSES.clear();
|
||||
|
||||
Map<ResourceLocation, TagKey<Block>> blocktags = BuiltInRegistries.BLOCK.listTagIds().collect(Collectors.toMap(t -> t.location(), t -> t));
|
||||
Map<ResourceLocation, TagKey<EntityType<?>>> entitytags = BuiltInRegistries.ENTITY_TYPE.listTagIds().collect(Collectors.toMap(t -> t.location(), t -> t));
|
||||
Map<Identifier, TagKey<Block>> blocktags = BuiltInRegistries.BLOCK.listTagIds().collect(Collectors.toMap(t -> t.location(), t -> t));
|
||||
Map<Identifier, TagKey<EntityType<?>>> entitytags = BuiltInRegistries.ENTITY_TYPE.listTagIds().collect(Collectors.toMap(t -> t.location(), t -> t));
|
||||
|
||||
List<String> forbidden = new ArrayList<>(List.of(Constants.COMMON_CONFIG.blacklist.forbiddenTiles));
|
||||
forbidden.add("#carryon:block_blacklist");
|
||||
|
|
@ -152,7 +152,7 @@ public class ListHandler {
|
|||
continue;
|
||||
String name = propString.substring(0, propString.indexOf("["));
|
||||
String props = propString.substring(propString.indexOf("[") + 1, propString.indexOf("]"));
|
||||
Block blk = BuiltInRegistries.BLOCK.get(ResourceLocation.parse(name)).get().value();
|
||||
Block blk = BuiltInRegistries.BLOCK.get(Identifier.parse(name)).get().value();
|
||||
for(String propName : props.split(",")) {
|
||||
for (Property<?> prop : blk.defaultBlockState().getProperties()) {
|
||||
if (prop.getName().equals(propName))
|
||||
|
|
@ -162,16 +162,16 @@ public class ListHandler {
|
|||
}
|
||||
}
|
||||
|
||||
private static <T> void addTag(String tag, Map<ResourceLocation, TagKey<T>> tagMap, List<TagKey<T>> tags) {
|
||||
private static <T> void addTag(String tag, Map<Identifier, TagKey<T>> tagMap, List<TagKey<T>> tags) {
|
||||
String sub = tag.substring(1);
|
||||
TagKey<T> t = tagMap.get(ResourceLocation.parse(sub));
|
||||
TagKey<T> t = tagMap.get(Identifier.parse(sub));
|
||||
if (t != null)
|
||||
tags.add(t);
|
||||
}
|
||||
|
||||
private static <T> void addWithWildcards(List<String> entries, Set<String> toAddTo, Registry<T> registry, Map<ResourceLocation, TagKey<T>> tags, List<TagKey<T>> toAddTags) {
|
||||
private static <T> void addWithWildcards(List<String> entries, Set<String> toAddTo, Registry<T> registry, Map<Identifier, TagKey<T>> tags, List<TagKey<T>> toAddTags) {
|
||||
|
||||
ResourceLocation[] keys = registry.keySet().toArray(new ResourceLocation[0]);
|
||||
Identifier[] keys = registry.keySet().toArray(new Identifier[0]);
|
||||
for (int i = 0; i < entries.size(); i++)
|
||||
{
|
||||
String curr = entries.get(i);
|
||||
|
|
@ -181,7 +181,7 @@ public class ListHandler {
|
|||
{
|
||||
String[] filter = curr.replace("*", ",").split(",");
|
||||
|
||||
for (ResourceLocation key : keys)
|
||||
for (Identifier key : keys)
|
||||
{
|
||||
|
||||
if (containsAll(key.toString(), filter))
|
||||
|
|
|
|||
|
|
@ -39,12 +39,13 @@ public record CarryOnScript(
|
|||
ScriptObject scriptObject,
|
||||
ScriptConditions scriptConditions,
|
||||
ScriptRender scriptRender,
|
||||
ScriptEffects scriptEffects)
|
||||
ScriptEffects scriptEffects,
|
||||
boolean overrideChecks)
|
||||
{
|
||||
|
||||
public boolean isValid()
|
||||
{
|
||||
return (isBlock() ^ isEntity()) && (scriptConditions != ScriptConditions.EMPTY || scriptRender != ScriptRender.EMPTY || scriptEffects != ScriptEffects.EMPTY);
|
||||
return (isBlock() ^ isEntity()) && (scriptConditions != ScriptConditions.EMPTY || scriptRender != ScriptRender.EMPTY || scriptEffects != ScriptEffects.EMPTY || overrideChecks);
|
||||
}
|
||||
|
||||
public boolean isBlock()
|
||||
|
|
@ -63,7 +64,8 @@ public record CarryOnScript(
|
|||
ScriptObject.CODEC.fieldOf("object").forGetter(CarryOnScript::scriptObject),
|
||||
ScriptConditions.CODEC.optionalFieldOf("conditions", ScriptConditions.EMPTY).forGetter(CarryOnScript::scriptConditions),
|
||||
ScriptRender.CODEC.optionalFieldOf("render", ScriptRender.EMPTY).forGetter(CarryOnScript::scriptRender),
|
||||
ScriptEffects.CODEC.optionalFieldOf("effects", ScriptEffects.EMPTY).forGetter(CarryOnScript::scriptEffects)
|
||||
ScriptEffects.CODEC.optionalFieldOf("effects", ScriptEffects.EMPTY).forGetter(CarryOnScript::scriptEffects),
|
||||
Codec.BOOL.optionalFieldOf("override_checks", false).forGetter(CarryOnScript::overrideChecks)
|
||||
).apply(instance, CarryOnScript::new)
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -22,23 +22,23 @@ package tschipp.carryon.common.scripting;
|
|||
|
||||
import com.mojang.serialization.Codec;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import net.minecraft.advancements.Advancement;
|
||||
import net.minecraft.advancements.AdvancementHolder;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtUtils;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.server.ServerAdvancementManager;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraft.world.scores.Objective;
|
||||
import net.minecraft.world.scores.Score;
|
||||
import net.minecraft.world.scores.Scoreboard;
|
||||
import tschipp.carryon.platform.Services;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public final class Matchables
|
||||
{
|
||||
|
|
@ -127,8 +127,8 @@ public final class Matchables
|
|||
@Override
|
||||
public boolean matches(ServerPlayer player)
|
||||
{
|
||||
ServerAdvancementManager manager = player.getServer().getAdvancements();
|
||||
AdvancementHolder adv = manager.get(ResourceLocation.parse(advancement.isEmpty() ? "" : advancement));
|
||||
ServerAdvancementManager manager = player.level().getServer().getAdvancements();
|
||||
AdvancementHolder adv = manager.get(Identifier.parse(advancement.isEmpty() ? "" : advancement));
|
||||
|
||||
boolean achievement = adv == null ? true : player.getAdvancements().getOrStartProgress(adv).isDone();
|
||||
return achievement;
|
||||
|
|
@ -167,7 +167,7 @@ public final class Matchables
|
|||
if (cond == null || cond.isEmpty())
|
||||
return true;
|
||||
|
||||
Scoreboard score = player.getScoreboard();
|
||||
Scoreboard score = player.level().getScoreboard();
|
||||
String numb;
|
||||
String scorename;
|
||||
int iE = cond.indexOf("=");
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ package tschipp.carryon.common.scripting;
|
|||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.util.ProblemReporter;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
|
|
|
|||
|
|
@ -20,28 +20,21 @@
|
|||
|
||||
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.DataResult;
|
||||
import com.mojang.serialization.JsonOps;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtOps;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.resources.FileToIdConverter;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.server.packs.resources.SimpleJsonResourceReloadListener;
|
||||
import net.minecraft.util.profiling.ProfilerFiller;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import tschipp.carryon.Constants;
|
||||
import tschipp.carryon.common.carry.CarryOnData;
|
||||
import tschipp.carryon.networking.clientbound.ClientboundSyncScriptsPacket;
|
||||
import tschipp.carryon.platform.Services;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
public class ScriptReloadListener extends SimpleJsonResourceReloadListener<CarryOnScript>
|
||||
|
|
@ -52,7 +45,7 @@ public class ScriptReloadListener extends SimpleJsonResourceReloadListener<Carry
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void apply(Map<ResourceLocation, CarryOnScript> scripts, @NotNull ResourceManager resourceManager, @NotNull ProfilerFiller profilerFiller)
|
||||
protected void apply(Map<Identifier, CarryOnScript> scripts, @NotNull ResourceManager resourceManager, @NotNull ProfilerFiller profilerFiller)
|
||||
{
|
||||
ScriptManager.SCRIPTS.clear();
|
||||
|
||||
|
|
|
|||
|
|
@ -4,13 +4,11 @@ import me.shedaniel.clothconfig2.api.ConfigBuilder;
|
|||
import me.shedaniel.clothconfig2.api.ConfigCategory;
|
||||
import me.shedaniel.clothconfig2.api.ConfigEntryBuilder;
|
||||
import me.shedaniel.clothconfig2.impl.builders.SubCategoryBuilder;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import tschipp.carryon.config.AnnotationData;
|
||||
import tschipp.carryon.config.BuiltCategory;
|
||||
import tschipp.carryon.config.BuiltConfig;
|
||||
import tschipp.carryon.config.ConfigLoader;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
|
@ -22,7 +20,7 @@ public record ClothConfigCompat(BuiltConfig client, BuiltConfig common, Runnable
|
|||
public static Screen getConfigScreen(BuiltConfig client, BuiltConfig common, Screen parentScreen, Runnable onSave) {
|
||||
ConfigBuilder builder = ConfigBuilder.create()
|
||||
.setParentScreen(parentScreen)
|
||||
.setTitle(Component.translatable("key.carry.category"));
|
||||
.setTitle(Component.translatable("key.category.carryon.key.carry.category"));
|
||||
|
||||
buildConfigType(client, builder, "Client Config");
|
||||
buildConfigType(common, builder, "Common Config");
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
package tschipp.carryon.mixin;
|
||||
|
||||
import net.minecraft.client.entity.ClientAvatarEntity;
|
||||
import net.minecraft.client.model.player.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 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.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<>(this));
|
||||
}
|
||||
}
|
||||
|
|
@ -48,14 +48,15 @@ public abstract class EntityMixin
|
|||
@Shadow
|
||||
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) {
|
||||
if (force && entity instanceof Player) return true;
|
||||
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)
|
||||
private void onPositionPassenger(Entity entity, MoveFunction move, CallbackInfo ci)
|
||||
{
|
||||
|
|
@ -92,7 +93,7 @@ public abstract class EntityMixin
|
|||
@Inject(method = "onPassengerTurned(Lnet/minecraft/world/entity/Entity;)V", at = @At("HEAD"))
|
||||
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);
|
||||
if(carry.isCarrying(CarryType.PLAYER)) {
|
||||
|
|
|
|||
|
|
@ -23,13 +23,14 @@ public class EntityRendererMixin {
|
|||
shift = At.Shift.AFTER
|
||||
), 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) {
|
||||
|
||||
if (entity instanceof Player player) {
|
||||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||
|
||||
ICarryOnRenderState carryOnRenderState = (ICarryOnRenderState) state;
|
||||
carryOnRenderState.setCarryOnData(carry);
|
||||
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.geom.ModelPart;
|
||||
import net.minecraft.client.renderer.entity.state.HumanoidRenderState;
|
||||
import net.minecraft.client.renderer.entity.state.PlayerRenderState;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
|
|
|||
|
|
@ -32,8 +32,8 @@ 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.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import tschipp.carryon.common.carry.CarryOnData;
|
||||
import tschipp.carryon.common.carry.CarryOnDataManager;
|
||||
|
||||
@Mixin(Inventory.class)
|
||||
|
|
@ -77,9 +77,10 @@ public class InventoryMixin
|
|||
}
|
||||
|
||||
@Inject(method = "setSelectedSlot(I)V", at = @At("HEAD"), cancellable = true)
|
||||
private void onSwapPaint(int $$0, CallbackInfo info)
|
||||
private void onSwapPaint(int slot, CallbackInfo info)
|
||||
{
|
||||
if(CarryOnDataManager.getCarryData(player).isCarrying())
|
||||
CarryOnData data = CarryOnDataManager.getCarryData(player);
|
||||
if(data.isCarrying() && data.getSelected() != slot)
|
||||
info.cancel();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,15 +25,27 @@ import net.minecraft.client.Minecraft;
|
|||
import net.minecraft.world.entity.player.Inventory;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import tschipp.carryon.common.carry.CarryOnDataManager;
|
||||
|
||||
@Mixin(Minecraft.class)
|
||||
public class MinecraftMixin
|
||||
{
|
||||
@WrapWithCondition(method = "handleKeybinds()V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/player/Inventory;setSelectedSlot(I)V", ordinal = 0))
|
||||
private boolean allowSlotSelection(Inventory inv,int slot)
|
||||
{
|
||||
return !CarryOnDataManager.getCarryData(inv.player).isCarrying();
|
||||
}
|
||||
public class MinecraftMixin {
|
||||
|
||||
@WrapWithCondition(
|
||||
method = "handleKeybinds()V",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/entity/player/Inventory;setSelectedSlot(I)V",
|
||||
ordinal = 0
|
||||
)
|
||||
)
|
||||
private boolean allowSlotSelection(Inventory inv, int slot) {
|
||||
boolean carrying = CarryOnDataManager.getCarryData(inv.player).isCarrying();
|
||||
|
||||
// Allow if not carrying
|
||||
if (!carrying) return true;
|
||||
|
||||
// Block only if trying to switch away
|
||||
return inv.getSelectedSlot() == slot;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,78 +20,49 @@
|
|||
|
||||
package tschipp.carryon.mixin;
|
||||
|
||||
|
||||
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.world.effect.MobEffects;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
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.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
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.common.carry.CarryOnData;
|
||||
import tschipp.carryon.common.carry.CarryOnData.CarryType;
|
||||
import tschipp.carryon.common.carry.CarryOnDataManager;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Mixin(Player.class)
|
||||
public abstract class PlayerMixin extends LivingEntity implements CarryOnDataManager.ICarrying {
|
||||
|
||||
@Unique
|
||||
private static final EntityDataAccessor<CompoundTag> CARRY_DATA_KEY = SynchedEntityData.defineId(Player.class, EntityDataSerializers.COMPOUND_TAG);
|
||||
|
||||
@Override
|
||||
public void setCarryOnData(CarryOnData data)
|
||||
{
|
||||
data.setSelected(this.getInventory().getSelectedSlot());
|
||||
CompoundTag nbt = data.getNbt();
|
||||
nbt.putInt("tick", tickCount);
|
||||
this.getEntityData().set(CARRY_DATA_KEY, nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarryOnData getCarryOnData()
|
||||
{
|
||||
CompoundTag data = this.getEntityData().get(CARRY_DATA_KEY);
|
||||
return new CarryOnData(data.copy());
|
||||
}
|
||||
|
||||
@Shadow
|
||||
public abstract Inventory getInventory();
|
||||
|
||||
public abstract class PlayerMixin extends LivingEntity {
|
||||
|
||||
private PlayerMixin(EntityType<? extends LivingEntity> type, Level level) {
|
||||
super(type, level);
|
||||
}
|
||||
|
||||
|
||||
@Inject(method = "defineSynchedData(Lnet/minecraft/network/syncher/SynchedEntityData$Builder;)V", at = @At("RETURN"))
|
||||
private void onDefineSynchedData(SynchedEntityData.Builder builder, CallbackInfo ci) {
|
||||
builder.define(CARRY_DATA_KEY, new CompoundTag());
|
||||
}
|
||||
|
||||
|
||||
@Inject(method = "addAdditionalSaveData(Lnet/minecraft/world/level/storage/ValueOutput;)V", at = @At("RETURN"))
|
||||
private void onAddAdditionalSaveData(ValueOutput output, CallbackInfo ci)
|
||||
{
|
||||
CarryOnData carry = CarryOnDataManager.getCarryData((Player)(Object)this);
|
||||
output.store("CarryOnData", CarryOnData.CODEC, carry);
|
||||
}
|
||||
|
||||
//We leave this in here to ensure cross-compatibility if world are upgraded from <1.21.8. Should be removed in the future.
|
||||
@Inject(method = "readAdditionalSaveData(Lnet/minecraft/world/level/storage/ValueInput;)V", at = @At("RETURN"))
|
||||
private void onReadAdditionalSaveData(ValueInput input, CallbackInfo ci)
|
||||
{
|
||||
Optional<CarryOnData> res = input.read("CarryOnData", CarryOnData.CODEC);
|
||||
res.ifPresent(this::setCarryOnData);
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
package tschipp.carryon.mixin;
|
||||
|
||||
import net.minecraft.client.renderer.entity.state.PlayerRenderState;
|
||||
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.Unique;
|
||||
import tschipp.carryon.client.render.ICarryOnRenderState;
|
||||
import tschipp.carryon.common.carry.CarryOnData;
|
||||
|
||||
@Mixin(PlayerRenderState.class)
|
||||
@Mixin(HumanoidRenderState.class)
|
||||
public class PlayerRenderStateMixin implements ICarryOnRenderState {
|
||||
|
||||
@Unique
|
||||
|
|
@ -15,6 +16,10 @@ public class PlayerRenderStateMixin implements ICarryOnRenderState {
|
|||
@Unique
|
||||
public float renderWidth = 0f;
|
||||
|
||||
|
||||
@Unique
|
||||
public Player player = null;
|
||||
|
||||
@Unique
|
||||
@Override
|
||||
public CarryOnData getCarryOnData() {
|
||||
|
|
@ -38,4 +43,14 @@ public class PlayerRenderStateMixin implements ICarryOnRenderState {
|
|||
public void setRenderWidth(float val) {
|
||||
renderWidth = val;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayer(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,12 +20,7 @@
|
|||
|
||||
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.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
||||
public interface PacketBase extends CustomPacketPayload {
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public record ClientboundStartRidingOtherPlayerPacket(int mount, int rider, bool
|
|||
|
||||
if(mount != null && rider != null)
|
||||
if(ride)
|
||||
rider.startRiding(mount, true);
|
||||
rider.startRiding(mount, true,true);
|
||||
else
|
||||
rider.stopRiding();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,12 +20,10 @@
|
|||
|
||||
package tschipp.carryon.networking.clientbound;
|
||||
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.network.codec.ByteBufCodecs;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import tschipp.carryon.Constants;
|
||||
|
|
|
|||
|
|
@ -1,6 +0,0 @@
|
|||
package tschipp.carryon.networking.clientbound;
|
||||
|
||||
import tschipp.carryon.common.carry.CarryOnData;
|
||||
|
||||
public record ClientboundSyncCarryDataPacket(CarryOnData data) {
|
||||
}
|
||||
|
|
@ -22,16 +22,12 @@ package tschipp.carryon.networking.clientbound;
|
|||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.DataResult;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtOps;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.network.codec.ByteBufCodecs;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import tschipp.carryon.Constants;
|
||||
import tschipp.carryon.common.scripting.CarryOnScript;
|
||||
|
|
|
|||
|
|
@ -20,20 +20,15 @@
|
|||
|
||||
package tschipp.carryon.networking.serverbound;
|
||||
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.network.codec.ByteBufCodecs;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
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 tschipp.carryon.Constants;
|
||||
import tschipp.carryon.common.carry.CarryOnData;
|
||||
import tschipp.carryon.common.carry.CarryOnDataManager;
|
||||
import tschipp.carryon.networking.PacketBase;
|
||||
import tschipp.carryon.networking.clientbound.ClientboundStartRidingPacket;
|
||||
import tschipp.carryon.networking.clientbound.ClientboundSyncScriptsPacket;
|
||||
|
||||
public record ServerboundCarryKeyPressedPacket(boolean pressed) implements PacketBase
|
||||
{
|
||||
|
|
|
|||
|
|
@ -20,20 +20,18 @@
|
|||
|
||||
package tschipp.carryon.platform.services;
|
||||
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import tschipp.carryon.common.carry.CarryOnData;
|
||||
import tschipp.carryon.config.BuiltConfig;
|
||||
import tschipp.carryon.networking.PacketBase;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
public interface IPlatformHelper {
|
||||
|
||||
|
|
@ -65,13 +63,17 @@ public interface IPlatformHelper {
|
|||
|
||||
<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);
|
||||
|
||||
void sendPacketToServer(ResourceLocation id, PacketBase packet);
|
||||
void sendPacketToServer(Identifier id, PacketBase packet);
|
||||
|
||||
void sendPacketToPlayer(ResourceLocation id, PacketBase packet, ServerPlayer player);
|
||||
void sendPacketToPlayer(Identifier id, PacketBase packet, ServerPlayer player);
|
||||
|
||||
default void sendPacketToAllPlayers(ResourceLocation id, PacketBase packet, ServerLevel level) {
|
||||
default void sendPacketToAllPlayers(Identifier id, PacketBase packet, ServerLevel level) {
|
||||
for(ServerPlayer p : level.players())
|
||||
sendPacketToPlayer(id, packet, p);
|
||||
}
|
||||
|
||||
CarryOnData getCarryData(Player player);
|
||||
|
||||
void setCarryData(Player player, CarryOnData data);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,5 +12,5 @@
|
|||
"carryon.category.custompickupconditions.custompickupconditionsentities": "Benutzerdefinierte Bedingungen für Entitäten",
|
||||
|
||||
"key.carry.desc": "Carry",
|
||||
"key.carry.category": "Carry On"
|
||||
"key.category.carryon.key.carry.category": "Carry On"
|
||||
}
|
||||
|
|
@ -12,5 +12,5 @@
|
|||
"carryon.category.custompickupconditions.custompickupconditionsentities": "suoᴉʇᴉpuoƆ dnʞɔᴉԀ ʎʇᴉʇuƎ ɯoʇsnƆ",
|
||||
|
||||
"key.carry.desc": "ʎɹɹɐƆ",
|
||||
"key.carry.category": "uO ʎɹɹɐƆ"
|
||||
"key.category.carryon.key.carry.category": "uO ʎɹɹɐƆ"
|
||||
}
|
||||
|
|
@ -12,5 +12,5 @@
|
|||
"carryon.category.custompickupconditions.custompickupconditionsentities": "Custom Entity Pickup Conditions",
|
||||
|
||||
"key.carry.desc": "Carry",
|
||||
"key.carry.category": "Carry On"
|
||||
"key.category.carryon.key.carry.category": "Carry On"
|
||||
}
|
||||
|
|
@ -12,5 +12,5 @@
|
|||
"carryon.category.custompickupconditions.custompickupconditionsentities": "Condiciones Personalizadas de Recogida de Entidades",
|
||||
|
||||
"key.carry.desc": "Cargar",
|
||||
"key.carry.category": "Carry On"
|
||||
"key.category.carryon.key.carry.category": "Carry On"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,5 +12,5 @@
|
|||
"carryon.category.custompickupconditions.custompickupconditionsentities": "Condiciones Personalizadas para Recoger Entidades",
|
||||
|
||||
"key.carry.desc": "Recoger",
|
||||
"key.carry.category": "Carry On"
|
||||
"key.category.carryon.key.carry.category": "Carry On"
|
||||
}
|
||||
|
|
@ -12,5 +12,5 @@
|
|||
"carryon.category.custompickupconditions.custompickupconditionsentities": "Customizar condiciones para recoger entidades",
|
||||
|
||||
"key.carry.desc": "Agarrar",
|
||||
"key.carry.category": "Carry On"
|
||||
"key.category.carryon.key.carry.category": "Carry On"
|
||||
}
|
||||
|
|
@ -12,5 +12,5 @@
|
|||
"carryon.category.custompickupconditions.custompickupconditionsentities": "Conditions de ramassage d'entités personalisés",
|
||||
|
||||
"key.carry.desc": "Saisir",
|
||||
"key.carry.category": "Carry On"
|
||||
"key.category.carryon.key.carry.category": "Carry On"
|
||||
}
|
||||
|
|
@ -12,5 +12,5 @@
|
|||
"carryon.category.custompickupconditions.custompickupconditionsentities": "Egyedi entitás felvételi feltételek",
|
||||
|
||||
"key.carry.desc": "Cipelés",
|
||||
"key.carry.category": "Carry On"
|
||||
"key.category.carryon.key.carry.category": "Carry On"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,5 +12,5 @@
|
|||
"carryon.category.custompickupconditions.custompickupconditionsentities": "Condizioni di prelievo entità personalizzate",
|
||||
|
||||
"key.carry.desc": "Afferra",
|
||||
"key.carry.category": "Carry On Mod"
|
||||
"key.category.carryon.key.carry.category": "Carry On Mod"
|
||||
}
|
||||
|
|
@ -12,5 +12,5 @@
|
|||
"carryon.category.custompickupconditions.custompickupconditionsentities": "カスタムエンティティ持ち上げ条件",
|
||||
|
||||
"key.carry.desc": "Carry",
|
||||
"key.carry.category": "Carry On"
|
||||
"key.category.carryon.key.carry.category": "Carry On"
|
||||
}
|
||||
|
|
@ -12,5 +12,5 @@
|
|||
"carryon.category.custompickupconditions.custompickupconditionsentities": "맞춤형 개체 들기 조건",
|
||||
|
||||
"key.carry.desc": "들고 나르기",
|
||||
"key.carry.category": "Carry On"
|
||||
"key.category.carryon.key.carry.category": "Carry On"
|
||||
}
|
||||
|
|
@ -12,5 +12,5 @@
|
|||
"carryon.category.custompickupconditions.custompickupconditionsentities": "Пользовательские условия поднятия сущности",
|
||||
|
||||
"key.carry.desc": "Поднять",
|
||||
"key.carry.category": "Carry On"
|
||||
"key.category.carryon.key.carry.category": "Carry On"
|
||||
}
|
||||
|
|
@ -13,5 +13,5 @@
|
|||
"carryon.category.custompickupconditions.custompickupconditionsentities": "Özel Varlık Alma Durumları",
|
||||
|
||||
"key.carry.desc": "Taşı",
|
||||
"key.carry.category": "Carry On"
|
||||
"key.category.carryon.key.carry.category": "Carry On"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,5 +12,5 @@
|
|||
"carryon.category.custompickupconditions.custompickupconditionsentities": "Користувацькі умови підбору сутностей",
|
||||
|
||||
"key.carry.desc": "Нести",
|
||||
"key.carry.category": "Carry On"
|
||||
"key.category.carryon.key.carry.category": "Carry On"
|
||||
}
|
||||
|
|
@ -12,5 +12,5 @@
|
|||
"carryon.category.custompickupconditions.custompickupconditionsentities": "自定义抱起实体条件",
|
||||
|
||||
"key.carry.desc": "抱起",
|
||||
"key.carry.category": "搬运"
|
||||
"key.category.carryon.key.carry.category": "搬运"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,5 +12,5 @@
|
|||
"carryon.category.custompickupconditions.custompickupconditionsentities": "自訂實體拾取條件",
|
||||
|
||||
"key.carry.desc": "攜帶",
|
||||
"key.carry.category": "Carry On"
|
||||
"key.category.carryon.key.carry.category": "Carry On"
|
||||
}
|
||||
|
|
@ -9,10 +9,11 @@
|
|||
"PlayerMixin"
|
||||
],
|
||||
"client": [
|
||||
"AvatarRendererMixin",
|
||||
"EntityRendererMixin",
|
||||
"HumanoidModelMixin",
|
||||
"MinecraftMixin",
|
||||
"PlayerRenderStateMixin",
|
||||
"EntityRendererMixin"
|
||||
"PlayerRenderStateMixin"
|
||||
],
|
||||
"server": [
|
||||
],
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
plugins {
|
||||
id 'multiloader-loader'
|
||||
id 'fabric-loom' version '1.10-SNAPSHOT'
|
||||
id 'fabric-loom' version "${loom_version}"
|
||||
}
|
||||
|
||||
repositories {
|
||||
|
|
@ -32,7 +32,7 @@ dependencies {
|
|||
modApi("me.shedaniel.cloth:cloth-config-fabric:${cloth_config_version}") {
|
||||
exclude(group: "net.fabricmc.fabric-api")
|
||||
}
|
||||
modApi "com.terraformersmc:modmenu:15.0.0-beta.3"
|
||||
modApi "com.terraformersmc:modmenu:17.0.0-beta.1"
|
||||
}
|
||||
|
||||
loom {
|
||||
|
|
|
|||
|
|
@ -23,20 +23,13 @@ package tschipp.carryon;
|
|||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
|
||||
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.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import tschipp.carryon.client.keybinds.CarryOnKeybinds;
|
||||
import tschipp.carryon.events.ClientEvents;
|
||||
import tschipp.carryon.networking.PacketBase;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class CarryOnFabricClientMod implements ClientModInitializer
|
||||
{
|
||||
|
|
|
|||
|
|
@ -21,13 +21,36 @@
|
|||
package tschipp.carryon;
|
||||
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.attachment.v1.AttachmentRegistry;
|
||||
import net.fabricmc.fabric.api.attachment.v1.AttachmentType;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import tschipp.carryon.common.carry.CarryOnData;
|
||||
import tschipp.carryon.config.fabric.ConfigLoaderImpl;
|
||||
import tschipp.carryon.events.CommonEvents;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class CarryOnFabricMod implements ModInitializer {
|
||||
|
||||
|
||||
public static final AttachmentType<CarryOnData> CARRY_ON_DATA_ATTACHMENT_TYPE = AttachmentRegistry.create(
|
||||
Identifier.fromNamespaceAndPath(Constants.MOD_ID, "carry_on_data"),
|
||||
builder -> builder
|
||||
.initializer(() -> new CarryOnData(new CompoundTag()))
|
||||
.persistent(CarryOnData.CODEC)
|
||||
.syncWith(CarryOnData.STREAM_CODEC, (t, p) ->{
|
||||
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() && !p.isRemoved() && player.tickCount > 0;
|
||||
})
|
||||
|
||||
|
||||
|
||||
);
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
|
||||
package tschipp.carryon.compat;
|
||||
|
||||
import net.fabricmc.fabric.api.event.Event;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
|
@ -39,6 +38,7 @@ public class ArchitecturyCompat {
|
|||
private static Method PLACE_BLOCK;
|
||||
private static Method IS_FALSE;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static void setup( ) {
|
||||
try {
|
||||
Class BlockEvent = Class.forName("dev.architectury.event.events.common.BlockEvent");
|
||||
|
|
|
|||
|
|
@ -23,8 +23,6 @@ package tschipp.carryon.config.fabric;
|
|||
import com.google.gson.*;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
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.config.*;
|
||||
|
||||
|
|
@ -32,7 +30,10 @@ import java.io.File;
|
|||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ConfigLoaderImpl {
|
||||
|
||||
|
|
@ -149,6 +150,7 @@ public class ConfigLoaderImpl {
|
|||
builder.add(category.category, categoryJson);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static void buildProperty(JsonObject builder, PropertyData data) throws IllegalAccessException {
|
||||
AnnotationData annotationData = data.getData();
|
||||
builder.addProperty("//"+data.getId(), annotationData.description());
|
||||
|
|
|
|||
|
|
@ -20,11 +20,8 @@
|
|||
|
||||
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.rendering.v1.WorldRenderEvents;
|
||||
import tschipp.carryon.CarryOnCommonClient;
|
||||
import tschipp.carryon.client.render.CarriedObjectRender;
|
||||
|
||||
public class ClientEvents {
|
||||
|
||||
|
|
@ -34,10 +31,6 @@ public class ClientEvents {
|
|||
CarryOnCommonClient.checkForKeybinds();
|
||||
CarryOnCommonClient.onCarryClientTick();
|
||||
});
|
||||
|
||||
WorldRenderEvents.LAST.register(event -> {
|
||||
CarriedObjectRender.drawThirdPerson(event.tickCounter().getGameTimeDeltaPartialTick(true), new PoseStack().last().pose());
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
package tschipp.carryon.events;
|
||||
|
||||
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
|
||||
import net.fabricmc.fabric.api.entity.event.v1.ServerLivingEntityEvents;
|
||||
import net.fabricmc.fabric.api.entity.event.v1.ServerPlayerEvents;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.CommonLifecycleEvents;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||
|
|
@ -55,7 +56,7 @@ public class CommonEvents {
|
|||
|
||||
UseBlockCallback.EVENT.register((player, world, hand, hitResult) -> {
|
||||
|
||||
if(world.isClientSide)
|
||||
if(world.isClientSide())
|
||||
return InteractionResult.PASS;
|
||||
|
||||
BlockPos pos = hitResult.getBlockPos();
|
||||
|
|
@ -96,7 +97,7 @@ public class CommonEvents {
|
|||
|
||||
UseEntityCallback.EVENT.register((player, level, hand, entity, hitResult) -> {
|
||||
|
||||
if(level.isClientSide)
|
||||
if(level.isClientSide())
|
||||
return InteractionResult.PASS;
|
||||
|
||||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||
|
|
@ -132,12 +133,10 @@ public class CommonEvents {
|
|||
CarryOnCommon.onCarryTick(player);
|
||||
});
|
||||
|
||||
|
||||
ServerPlayerEvents.COPY_FROM.register(((oldPlayer, newPlayer, alive) -> {
|
||||
PlacementHandler.placeCarriedOnDeath(oldPlayer, newPlayer, !alive);
|
||||
}));
|
||||
|
||||
|
||||
PlayerBlockBreakEvents.BEFORE.register(((world, player, pos, state, blockEntity) -> {
|
||||
if(!CarryOnCommon.onTryBreakBlock(player))
|
||||
return false;
|
||||
|
|
@ -160,7 +159,19 @@ public class CommonEvents {
|
|||
CarryOnCommon.onRiderDisconnected(handler.getPlayer());
|
||||
});
|
||||
|
||||
//TODO: drop carried when attacked
|
||||
ServerLivingEntityEvents.ALLOW_DEATH.register((entity, damageSource, damageAmount) -> {
|
||||
if(entity instanceof ServerPlayer sp) {
|
||||
CarryOnCommon.onRiderDisconnected(sp);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
ServerLivingEntityEvents.ALLOW_DAMAGE.register((entity, source, amount) -> {
|
||||
if(entity instanceof ServerPlayer sp) {
|
||||
CarryOnCommon.onPlayerAttacked(sp);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,31 +21,24 @@
|
|||
package tschipp.carryon.mixin;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.player.AbstractClientPlayer;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.ItemInHandRenderer;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderBuffers;
|
||||
import net.minecraft.client.renderer.SubmitNodeCollector;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
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.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import tschipp.carryon.client.render.CarriedObjectRender;
|
||||
import tschipp.carryon.client.render.CarryRenderHelper;
|
||||
import tschipp.carryon.platform.Services;
|
||||
|
||||
@Mixin(ItemInHandRenderer.class)
|
||||
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)
|
||||
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)
|
||||
@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 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();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,9 +34,10 @@ import tschipp.carryon.common.carry.CarryOnDataManager;
|
|||
@Mixin(Screen.class)
|
||||
public class ScreenMixin
|
||||
{
|
||||
@Inject(at = @At(value = "TAIL"), method = "init(Lnet/minecraft/client/Minecraft;II)V")
|
||||
private void onInit(Minecraft mc, int i, int j, CallbackInfo ci)
|
||||
@Inject(at = @At(value = "TAIL"), method = "init(II)V")
|
||||
private void onInit(int width, int height, CallbackInfo ci)
|
||||
{
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
Player player = mc.player;
|
||||
if((Object)this instanceof AbstractContainerScreen && player != null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -20,28 +20,25 @@
|
|||
|
||||
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.ServerPlayNetworking;
|
||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking.PlayPayloadHandler;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
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.resources.ResourceLocation;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import tschipp.carryon.CarryOnFabricClientMod;
|
||||
import tschipp.carryon.CarryOnFabricMod;
|
||||
import tschipp.carryon.common.carry.CarryOnData;
|
||||
import tschipp.carryon.config.BuiltConfig;
|
||||
import tschipp.carryon.config.fabric.ConfigLoaderImpl;
|
||||
import tschipp.carryon.networking.PacketBase;
|
||||
import tschipp.carryon.platform.services.IPlatformHelper;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class FabricPlatformHelper implements IPlatformHelper {
|
||||
|
||||
|
|
@ -67,6 +64,7 @@ public class FabricPlatformHelper implements IPlatformHelper {
|
|||
ConfigLoaderImpl.registerConfig(cfg);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@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)
|
||||
{
|
||||
|
|
@ -79,6 +77,7 @@ public class FabricPlatformHelper implements IPlatformHelper {
|
|||
});
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@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)
|
||||
{
|
||||
|
|
@ -91,14 +90,25 @@ public class FabricPlatformHelper implements IPlatformHelper {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void sendPacketToServer(ResourceLocation id, PacketBase packet)
|
||||
public void sendPacketToServer(Identifier id, PacketBase packet)
|
||||
{
|
||||
CarryOnFabricClientMod.sendPacketToServer(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPacketToPlayer(ResourceLocation id, PacketBase packet, ServerPlayer player)
|
||||
public void sendPacketToPlayer(Identifier id, PacketBase packet, ServerPlayer player)
|
||||
{
|
||||
ServerPlayNetworking.send(player, packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarryOnData getCarryData(Player player) {
|
||||
CarryOnData data = player.getAttachedOrCreate(CarryOnFabricMod.CARRY_ON_DATA_ATTACHMENT_TYPE);
|
||||
return data.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCarryData(Player player, CarryOnData data) {
|
||||
player.setAttached(CarryOnFabricMod.CARRY_ON_DATA_ATTACHMENT_TYPE, data);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,15 +21,15 @@
|
|||
package tschipp.carryon.scripting;
|
||||
|
||||
import net.fabricmc.fabric.api.resource.IdentifiableResourceReloadListener;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import tschipp.carryon.Constants;
|
||||
import tschipp.carryon.common.scripting.ScriptReloadListener;
|
||||
|
||||
public class IdentifiableScriptReloadListener extends ScriptReloadListener implements IdentifiableResourceReloadListener
|
||||
{
|
||||
@Override
|
||||
public ResourceLocation getFabricId()
|
||||
public Identifier getFabricId()
|
||||
{
|
||||
return ResourceLocation.fromNamespaceAndPath(Constants.MOD_ID, "carryon_scripts");
|
||||
return Identifier.fromNamespaceAndPath(Constants.MOD_ID, "carryon_scripts");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,8 +36,8 @@
|
|||
"depends": {
|
||||
"fabricloader": ">=${fabric_loader_version}",
|
||||
"fabric-api": "*",
|
||||
"minecraft": "${minecraft_version}",
|
||||
"java": ">=21"
|
||||
"minecraft": "${minecraft_version_range_fabric}",
|
||||
"java": ">=${java_version}"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
plugins {
|
||||
id 'multiloader-loader'
|
||||
id 'net.minecraftforge.gradle' version '[6.0.36,6.2)'
|
||||
id 'net.minecraftforge.gradle' version '[6.0.46,6.2)'
|
||||
id 'org.spongepowered.mixin' version '0.7-SNAPSHOT'
|
||||
id 'org.parchmentmc.librarian.forgegradle' version '1.+'
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
package tschipp.carryon;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraftforge.eventbus.api.listener.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||
|
|
@ -29,6 +29,8 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
|||
import net.minecraftforge.network.ChannelBuilder;
|
||||
import net.minecraftforge.network.SimpleChannel;
|
||||
import tschipp.carryon.config.forge.ConfigLoaderImpl;
|
||||
import tschipp.carryon.networking.ClientboundSyncCarryDataPacket;
|
||||
import tschipp.carryon.platform.Services;
|
||||
|
||||
@Mod(Constants.MOD_ID)
|
||||
@EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
|
|
@ -50,10 +52,17 @@ public class CarryOnForge {
|
|||
@SubscribeEvent
|
||||
public static void setup(final FMLCommonSetupEvent event)
|
||||
{
|
||||
network = ChannelBuilder.named(ResourceLocation.fromNamespaceAndPath(Constants.MOD_ID, "carryonpackets")).simpleChannel();
|
||||
network = ChannelBuilder.named(Identifier.fromNamespaceAndPath(Constants.MOD_ID, "carryonpackets")).simpleChannel();
|
||||
|
||||
CarryOnCommon.registerServerPackets();
|
||||
CarryOnCommon.registerClientPackets();
|
||||
|
||||
Services.PLATFORM.registerClientboundPacket(
|
||||
ClientboundSyncCarryDataPacket.TYPE,
|
||||
ClientboundSyncCarryDataPacket.class,
|
||||
ClientboundSyncCarryDataPacket.CODEC,
|
||||
ClientboundSyncCarryDataPacket::handle
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package tschipp.carryon.carry;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import tschipp.carryon.common.carry.CarryOnData;
|
||||
|
||||
public class CarryOnDataCapability implements ICarryOnDataCapability {
|
||||
|
||||
private CarryOnData data;
|
||||
|
||||
public CarryOnDataCapability() {
|
||||
this.data = new CarryOnData(new CompoundTag());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarryOnData getCarryData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCarryData(CarryOnData data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
package tschipp.carryon.carry;
|
||||
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtOps;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.CapabilityManager;
|
||||
import net.minecraftforge.common.capabilities.CapabilityToken;
|
||||
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import tschipp.carryon.common.carry.CarryOnData;
|
||||
|
||||
public class CarryOnDataCapabilityProvider implements ICapabilitySerializable<CompoundTag> {
|
||||
|
||||
public static final Capability<ICarryOnDataCapability> CARRY_ON_DATA_CAPABILITY = CapabilityManager.get(new CapabilityToken<ICarryOnDataCapability>() {});
|
||||
|
||||
private final CarryOnDataCapability impl = new CarryOnDataCapability();
|
||||
private final LazyOptional<ICarryOnDataCapability> opt = LazyOptional.of(() -> impl);
|
||||
|
||||
@Override
|
||||
public @NotNull <T> LazyOptional<T> getCapability(@NotNull Capability<T> cap, @Nullable Direction side) {
|
||||
return cap == CARRY_ON_DATA_CAPABILITY ? opt.cast() : LazyOptional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag serializeNBT(HolderLookup.Provider registryAccess) {
|
||||
return (CompoundTag) CarryOnData.CODEC.encodeStart(NbtOps.INSTANCE, impl.getCarryData()).getOrThrow();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserializeNBT(HolderLookup.Provider registryAccess, CompoundTag nbt) {
|
||||
CarryOnData data = CarryOnData.CODEC.parse(NbtOps.INSTANCE, nbt).getOrThrow();
|
||||
impl.setCarryData(data);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package tschipp.carryon.carry;
|
||||
|
||||
import net.minecraftforge.common.capabilities.AutoRegisterCapability;
|
||||
import tschipp.carryon.common.carry.CarryOnData;
|
||||
|
||||
@AutoRegisterCapability
|
||||
public interface ICarryOnDataCapability {
|
||||
|
||||
CarryOnData getCarryData();
|
||||
|
||||
void setCarryData(CarryOnData data);
|
||||
|
||||
}
|
||||
|
|
@ -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,23 +22,18 @@ package tschipp.carryon.config.forge;
|
|||
|
||||
import com.electronwill.nightconfig.core.AbstractConfig;
|
||||
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.util.LogicalSidedProvider;
|
||||
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.config.IConfigSpec;
|
||||
import net.minecraftforge.fml.config.ModConfig;
|
||||
import net.minecraftforge.fml.event.config.ModConfigEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.loading.FMLServiceProvider;
|
||||
import net.minecraftforge.server.ServerLifecycleHooks;
|
||||
import tschipp.carryon.Constants;
|
||||
import tschipp.carryon.config.*;
|
||||
import tschipp.carryon.config.AnnotationData;
|
||||
import tschipp.carryon.config.BuiltCategory;
|
||||
import tschipp.carryon.config.BuiltConfig;
|
||||
import tschipp.carryon.config.PropertyData;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
|
@ -119,6 +114,7 @@ public class ConfigLoaderImpl {
|
|||
builder.pop();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static void buildProperty(ForgeConfigSpec.Builder builder, PropertyData data) throws IllegalAccessException {
|
||||
AnnotationData annotationData = data.getData();
|
||||
builder.comment(annotationData.description());
|
||||
|
|
|
|||
|
|
@ -23,14 +23,12 @@ package tschipp.carryon.events;
|
|||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
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.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.client.event.RenderHandEvent;
|
||||
import net.minecraftforge.client.event.ScreenEvent;
|
||||
import net.minecraftforge.event.TickEvent.ClientTickEvent;
|
||||
import net.minecraftforge.event.TickEvent.Phase;
|
||||
import net.minecraftforge.eventbus.api.listener.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import tschipp.carryon.CarryOnCommonClient;
|
||||
|
|
@ -47,24 +45,14 @@ public class ClientEvents {
|
|||
public static boolean renderHand(RenderHandEvent event)
|
||||
{
|
||||
Player player = Minecraft.getInstance().player;
|
||||
MultiBufferSource buffer = event.getMultiBufferSource();
|
||||
PoseStack matrix = event.getPoseStack();
|
||||
int light = event.getPackedLight();
|
||||
float partialTicks = event.getPartialTick();
|
||||
|
||||
SubmitNodeCollector nodes =event.getNodeCollector();
|
||||
//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
|
||||
public static boolean onGuiInit(ScreenEvent.Init.Pre event)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
package tschipp.carryon.events;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
|
|
@ -29,16 +30,13 @@ import net.minecraft.world.entity.Mob;
|
|||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.ServerLevelAccessor;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.BlockSnapshot;
|
||||
import net.minecraftforge.common.util.Result;
|
||||
import net.minecraftforge.event.AddReloadListenerEvent;
|
||||
import net.minecraftforge.event.OnDatapackSyncEvent;
|
||||
import net.minecraftforge.event.RegisterCommandsEvent;
|
||||
import net.minecraftforge.event.TagsUpdatedEvent;
|
||||
import net.minecraftforge.event.TickEvent.Phase;
|
||||
import net.minecraftforge.event.*;
|
||||
import net.minecraftforge.event.TickEvent.ServerTickEvent;
|
||||
import net.minecraftforge.event.entity.EntityJoinLevelEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingAttackEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||
import net.minecraftforge.event.entity.living.MobSpawnEvent.FinalizeSpawn;
|
||||
import net.minecraftforge.event.entity.player.AttackEntityEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
|
|
@ -51,9 +49,9 @@ import net.minecraftforge.event.level.BlockEvent.EntityPlaceEvent;
|
|||
import net.minecraftforge.eventbus.api.listener.Priority;
|
||||
import net.minecraftforge.eventbus.api.listener.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import oshi.jna.platform.mac.SystemB;
|
||||
import tschipp.carryon.CarryOnCommon;
|
||||
import tschipp.carryon.Constants;
|
||||
import tschipp.carryon.carry.CarryOnDataCapabilityProvider;
|
||||
import tschipp.carryon.common.carry.CarryOnData;
|
||||
import tschipp.carryon.common.carry.CarryOnData.CarryType;
|
||||
import tschipp.carryon.common.carry.CarryOnDataManager;
|
||||
|
|
@ -61,6 +59,8 @@ import tschipp.carryon.common.carry.PickupHandler;
|
|||
import tschipp.carryon.common.carry.PlacementHandler;
|
||||
import tschipp.carryon.common.scripting.ScriptReloadListener;
|
||||
import tschipp.carryon.config.ConfigLoader;
|
||||
import tschipp.carryon.networking.ClientboundSyncCarryDataPacket;
|
||||
import tschipp.carryon.platform.Services;
|
||||
|
||||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE, modid = Constants.MOD_ID)
|
||||
public class CommonEvents
|
||||
|
|
@ -72,7 +72,7 @@ public class CommonEvents
|
|||
Level level = event.getLevel();
|
||||
BlockPos pos = event.getPos();
|
||||
|
||||
if (level.isClientSide)
|
||||
if (level.isClientSide())
|
||||
return false;
|
||||
|
||||
boolean success = false;
|
||||
|
|
@ -95,7 +95,7 @@ public class CommonEvents
|
|||
} else {
|
||||
PlacementHandler.tryPlaceEntity((ServerPlayer) player, pos, event.getFace(), (pPos, toPlace) -> {
|
||||
if (toPlace instanceof Mob mob) {
|
||||
FinalizeSpawn checkSpawn = new FinalizeSpawn(mob, (ServerLevelAccessor) level, pPos.x, pPos.y, pPos.z, level.getCurrentDifficultyAt(new BlockPos((int) pPos.x, (int) pPos.y, (int) pPos.z)), EntitySpawnReason.EVENT, null, null, null);
|
||||
FinalizeSpawn checkSpawn = new FinalizeSpawn(mob, (ServerLevelAccessor) level, pPos.x, pPos.y, pPos.z, ((ServerLevelAccessor) level).getCurrentDifficultyAt(new BlockPos((int) pPos.x, (int) pPos.y, (int) pPos.z)), EntitySpawnReason.EVENT, null, null, null);
|
||||
return !FinalizeSpawn.BUS.post(checkSpawn);
|
||||
}
|
||||
return true;
|
||||
|
|
@ -120,7 +120,7 @@ public class CommonEvents
|
|||
Level level = event.getLevel();
|
||||
Entity target = event.getTarget();
|
||||
|
||||
if (level.isClientSide)
|
||||
if (level.isClientSide())
|
||||
return false;
|
||||
|
||||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||
|
|
@ -171,15 +171,23 @@ public class CommonEvents
|
|||
@SubscribeEvent
|
||||
public static void onServerTick(ServerTickEvent.Post event)
|
||||
{
|
||||
for (ServerPlayer player : event.getServer().getPlayerList().getPlayers())
|
||||
for (ServerPlayer player : event.server().getPlayerList().getPlayers())
|
||||
CarryOnCommon.onCarryTick(player);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onClone(Clone event)
|
||||
{
|
||||
if (!event.getOriginal().level().isClientSide)
|
||||
PlacementHandler.placeCarriedOnDeath((ServerPlayer) event.getOriginal(), (ServerPlayer) event.getEntity(), event.isWasDeath());
|
||||
if (!event.getOriginal().level().isClientSide()) {
|
||||
Player newPlayer = event.getEntity();
|
||||
Player oldPlayer = event.getOriginal();
|
||||
oldPlayer.reviveCaps();
|
||||
|
||||
PlacementHandler.placeCarriedOnDeath((ServerPlayer) oldPlayer, (ServerPlayer) newPlayer, event.isWasDeath());
|
||||
|
||||
oldPlayer.invalidateCaps();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
|
@ -214,4 +222,32 @@ public class CommonEvents
|
|||
CarryOnCommon.onRiderDisconnected(player);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onAttachCapabilities(AttachCapabilitiesEvent.Entities event) {
|
||||
if (event.getObject() instanceof Player) {
|
||||
event.addCapability(Identifier.fromNamespaceAndPath(Constants.MOD_ID, "carry_on_data"), new CarryOnDataCapabilityProvider());
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onStartTracking(PlayerEvent.StartTracking event) {
|
||||
if(event.getEntity() instanceof ServerPlayer sp && event.getTarget() instanceof ServerPlayer target) {
|
||||
Services.PLATFORM.sendPacketToPlayer(Constants.PACKET_ID_SYNC_CARRY_ON_DATA, new ClientboundSyncCarryDataPacket(sp.getId(), CarryOnDataManager.getCarryData(sp)), target);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onJoinWorld(EntityJoinLevelEvent event) {
|
||||
if (event.getEntity() instanceof ServerPlayer sp) {
|
||||
Services.PLATFORM.sendPacketToPlayer(Constants.PACKET_ID_SYNC_CARRY_ON_DATA, new ClientboundSyncCarryDataPacket(sp.getId(), CarryOnDataManager.getCarryData(sp)), sp);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onPlayerDie(LivingDeathEvent event) {
|
||||
if(event.getEntity() instanceof ServerPlayer sp) {
|
||||
CarryOnCommon.onRiderDisconnected(sp);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,10 +24,8 @@ import net.minecraftforge.eventbus.api.listener.SubscribeEvent;
|
|||
import net.minecraftforge.fml.InterModComms;
|
||||
import net.minecraftforge.fml.InterModComms.IMCMessage;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent;
|
||||
import tschipp.carryon.Constants;
|
||||
import tschipp.carryon.client.modeloverride.ModelOverrideHandler;
|
||||
import tschipp.carryon.common.config.ListHandler;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
|
|
|||
|
|
@ -21,17 +21,13 @@
|
|||
package tschipp.carryon.events;
|
||||
|
||||
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.eventbus.api.listener.SubscribeEvent;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import tschipp.carryon.Constants;
|
||||
import tschipp.carryon.client.keybinds.CarryOnKeybinds;
|
||||
import tschipp.carryon.compat.ClothConfigCompatForge;
|
||||
import tschipp.carryon.config.BuiltConfig;
|
||||
import tschipp.carryon.config.forge.ConfigLoaderImpl;
|
||||
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)
|
||||
public class ModClientEvents
|
||||
{
|
||||
@SubscribeEvent
|
||||
public static void registerKeybinds(RegisterKeyMappingsEvent event)
|
||||
{
|
||||
CarryOnKeybinds.registerKeybinds(event::register);
|
||||
static{
|
||||
RegisterKeyMappingsEvent.BUS.addListener((e)->CarryOnKeybinds.registerKeybinds(e::register));
|
||||
}
|
||||
|
||||
|
||||
@SubscribeEvent
|
||||
public static void clientSetup(FMLClientSetupEvent event)
|
||||
{
|
||||
if(Services.PLATFORM.isModLoaded("cloth_config")) {
|
||||
|
||||
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)));
|
||||
ConfigLoaderImpl.CONFIGS.values().toArray(new BuiltConfig[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
package tschipp.carryon.networking;
|
||||
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.network.codec.ByteBufCodecs;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import tschipp.carryon.Constants;
|
||||
import tschipp.carryon.common.carry.CarryOnData;
|
||||
import tschipp.carryon.common.carry.CarryOnDataManager;
|
||||
|
||||
public record ClientboundSyncCarryDataPacket(int iden, CarryOnData data) implements PacketBase {
|
||||
|
||||
public static final StreamCodec<RegistryFriendlyByteBuf, ClientboundSyncCarryDataPacket> CODEC = StreamCodec.composite(
|
||||
ByteBufCodecs.INT, ClientboundSyncCarryDataPacket::iden,
|
||||
CarryOnData.STREAM_CODEC, ClientboundSyncCarryDataPacket::data,
|
||||
ClientboundSyncCarryDataPacket::new
|
||||
);
|
||||
|
||||
public static final CustomPacketPayload.Type<ClientboundSyncCarryDataPacket> TYPE = new Type<>(Constants.PACKET_ID_SYNC_CARRY_ON_DATA);
|
||||
|
||||
@Override
|
||||
public void handle(Player player) {
|
||||
Entity e = player.level().getEntity(this.iden);
|
||||
if(e instanceof Player p) {
|
||||
CarryOnDataManager.setCarryData(p, data);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type<? extends CustomPacketPayload> type() {
|
||||
return TYPE;
|
||||
}
|
||||
}
|
||||
|
|
@ -21,26 +21,29 @@
|
|||
package tschipp.carryon.platform;
|
||||
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraftforge.event.network.CustomPayloadEvent;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.fml.loading.FMLLoader;
|
||||
import net.minecraftforge.network.NetworkDirection;
|
||||
import net.minecraftforge.network.PacketDistributor;
|
||||
import tschipp.carryon.CarryOnCommonClient;
|
||||
import tschipp.carryon.CarryOnForge;
|
||||
import tschipp.carryon.Constants;
|
||||
import tschipp.carryon.carry.CarryOnDataCapability;
|
||||
import tschipp.carryon.carry.CarryOnDataCapabilityProvider;
|
||||
import tschipp.carryon.common.carry.CarryOnData;
|
||||
import tschipp.carryon.config.BuiltConfig;
|
||||
import tschipp.carryon.config.forge.ConfigLoaderImpl;
|
||||
import tschipp.carryon.networking.ClientboundSyncCarryDataPacket;
|
||||
import tschipp.carryon.networking.PacketBase;
|
||||
import tschipp.carryon.platform.services.IPlatformHelper;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class ForgePlatformHelper implements IPlatformHelper {
|
||||
|
||||
|
|
@ -67,6 +70,7 @@ public class ForgePlatformHelper implements IPlatformHelper {
|
|||
ConfigLoaderImpl.registerConfig(cfg);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@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)
|
||||
{
|
||||
|
|
@ -83,6 +87,7 @@ public class ForgePlatformHelper implements IPlatformHelper {
|
|||
CarryOnForge.network.messageBuilder(clazz).codec((StreamCodec<FriendlyByteBuf, T>) codec).consumerMainThread(serverHandler).add();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@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)
|
||||
{
|
||||
|
|
@ -101,14 +106,29 @@ public class ForgePlatformHelper implements IPlatformHelper {
|
|||
|
||||
|
||||
@Override
|
||||
public void sendPacketToServer(ResourceLocation id, PacketBase packet)
|
||||
public void sendPacketToServer(Identifier id, PacketBase packet)
|
||||
{
|
||||
CarryOnForge.network.send(packet, PacketDistributor.SERVER.noArg());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPacketToPlayer(ResourceLocation id, PacketBase packet, ServerPlayer player)
|
||||
public void sendPacketToPlayer(Identifier id, PacketBase packet, ServerPlayer player)
|
||||
{
|
||||
CarryOnForge.network.send(packet, PacketDistributor.PLAYER.with(player));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarryOnData getCarryData(Player player) {
|
||||
var cap = player.getCapability(CarryOnDataCapabilityProvider.CARRY_ON_DATA_CAPABILITY).orElse(new CarryOnDataCapability());
|
||||
return cap.getCarryData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCarryData(Player player, CarryOnData data) {
|
||||
var cap = player.getCapability(CarryOnDataCapabilityProvider.CARRY_ON_DATA_CAPABILITY).orElse(new CarryOnDataCapability());
|
||||
cap.setCarryData(data);
|
||||
if(!player.level().isClientSide()) {
|
||||
sendPacketToAllPlayers(Constants.PACKET_ID_SYNC_CARRY_ON_DATA, new ClientboundSyncCarryDataPacket(player.getId(), data), (ServerLevel) player.level());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
"mixins": [
|
||||
],
|
||||
"client": [
|
||||
"ParticleEngineMixin"
|
||||
],
|
||||
"server": [
|
||||
],
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ neoForge {
|
|||
accessTransformers.from(at.absolutePath)
|
||||
}
|
||||
parchment {
|
||||
minecraftVersion = minecraft_version
|
||||
minecraftVersion = parchment_game_version
|
||||
mappingsVersion = parchment_version
|
||||
}
|
||||
runs {
|
||||
|
|
@ -47,7 +47,7 @@ neoForge {
|
|||
|
||||
|
||||
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' }
|
||||
|
|
|
|||
|
|
@ -20,20 +20,34 @@
|
|||
|
||||
package tschipp.carryon;
|
||||
|
||||
import net.neoforged.bus.api.IEventBus;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.neoforged.fml.ModContainer;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.neoforged.neoforge.client.gui.ConfigurationScreen;
|
||||
import net.neoforged.neoforge.common.NeoForge;
|
||||
import net.neoforged.neoforge.attachment.AttachmentType;
|
||||
import net.neoforged.neoforge.network.event.RegisterPayloadHandlersEvent;
|
||||
import net.neoforged.neoforge.network.registration.PayloadRegistrar;
|
||||
import net.neoforged.neoforge.registries.DeferredRegister;
|
||||
import net.neoforged.neoforge.registries.NeoForgeRegistries;
|
||||
import tschipp.carryon.carry.CarryOnDataSyncHandler;
|
||||
import tschipp.carryon.common.carry.CarryOnData;
|
||||
import tschipp.carryon.config.neoforge.ConfigLoaderImpl;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@Mod(Constants.MOD_ID)
|
||||
public class CarryOnNeoForge {
|
||||
|
||||
private static final DeferredRegister<AttachmentType<?>> ATTACHMENT_TYPES = DeferredRegister.create(NeoForgeRegistries.ATTACHMENT_TYPES, Constants.MOD_ID);
|
||||
|
||||
public static final Supplier<AttachmentType<CarryOnData>> CARRY_ON_DATA_ATTACHMENT = ATTACHMENT_TYPES.register(
|
||||
"carry_on_data",
|
||||
() -> AttachmentType.builder(() -> new CarryOnData(new CompoundTag()))
|
||||
.sync(new CarryOnDataSyncHandler())
|
||||
.serialize(CarryOnData.CODEC.fieldOf(CarryOnData.SERIALIZATION_KEY))
|
||||
.build()
|
||||
);
|
||||
|
||||
public CarryOnNeoForge(ModContainer container) {
|
||||
|
||||
// This method is invoked by the Forge mod loader when it is ready
|
||||
|
|
@ -45,6 +59,8 @@ public class CarryOnNeoForge {
|
|||
container.getEventBus().addListener(this::registerPackets);
|
||||
|
||||
ConfigLoaderImpl.initialize(container);
|
||||
|
||||
ATTACHMENT_TYPES.register(container.getEventBus());
|
||||
}
|
||||
|
||||
private void setup(final FMLCommonSetupEvent event)
|
||||
|
|
@ -57,6 +73,8 @@ public class CarryOnNeoForge {
|
|||
|
||||
CarryOnCommon.registerServerPackets(registrar);
|
||||
CarryOnCommon.registerClientPackets(registrar);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -4,9 +4,11 @@ import net.neoforged.api.distmarker.Dist;
|
|||
import net.neoforged.fml.ModContainer;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
import net.neoforged.neoforge.client.gui.IConfigScreenFactory;
|
||||
import net.neoforged.neoforge.client.network.ClientPacketDistributor;
|
||||
import tschipp.carryon.compat.ClothConfigCompatNeo;
|
||||
import tschipp.carryon.config.BuiltConfig;
|
||||
import tschipp.carryon.config.neoforge.ConfigLoaderImpl;
|
||||
import tschipp.carryon.networking.PacketBase;
|
||||
import tschipp.carryon.platform.Services;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
|
@ -24,4 +26,8 @@ public class CarryOnNeoForgeClient {
|
|||
}
|
||||
}
|
||||
|
||||
public static void sendPacketToServer(PacketBase packet) {
|
||||
ClientPacketDistributor.sendToServer(packet);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
package tschipp.carryon.carry;
|
||||
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.neoforged.neoforge.attachment.AttachmentSyncHandler;
|
||||
import net.neoforged.neoforge.attachment.IAttachmentHolder;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import tschipp.carryon.common.carry.CarryOnData;
|
||||
|
||||
public class CarryOnDataSyncHandler implements AttachmentSyncHandler<CarryOnData> {
|
||||
@Override
|
||||
public void write(RegistryFriendlyByteBuf registryFriendlyByteBuf, CarryOnData carryOnData, boolean b) {
|
||||
CarryOnData.STREAM_CODEC.encode(registryFriendlyByteBuf, carryOnData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable CarryOnData read(IAttachmentHolder iAttachmentHolder, RegistryFriendlyByteBuf registryFriendlyByteBuf, @Nullable CarryOnData carryOnData) {
|
||||
return CarryOnData.STREAM_CODEC.decode(registryFriendlyByteBuf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sendToPlayer(IAttachmentHolder holder, ServerPlayer to) {
|
||||
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 || player.isRemoved())
|
||||
return false;
|
||||
return AttachmentSyncHandler.super.sendToPlayer(holder, to);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,18 +1,11 @@
|
|||
package tschipp.carryon.compat;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.neoforged.fml.ModContainer;
|
||||
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.neoforge.ConfigLoaderImpl;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public record ClothConfigCompatNeo(BuiltConfig client, BuiltConfig common) implements IConfigScreenFactory {
|
||||
|
||||
|
|
|
|||
|
|
@ -22,25 +22,19 @@ package tschipp.carryon.config.neoforge;
|
|||
|
||||
import com.electronwill.nightconfig.core.AbstractConfig;
|
||||
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.fml.ModContainer;
|
||||
import net.neoforged.fml.ModLoadingContext;
|
||||
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.event.config.ModConfigEvent;
|
||||
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.config.*;
|
||||
import tschipp.carryon.config.AnnotationData;
|
||||
import tschipp.carryon.config.BuiltCategory;
|
||||
import tschipp.carryon.config.BuiltConfig;
|
||||
import tschipp.carryon.config.PropertyData;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@EventBusSubscriber(modid = Constants.MOD_ID)
|
||||
public class ConfigLoaderImpl {
|
||||
|
|
@ -120,6 +114,7 @@ public class ConfigLoaderImpl {
|
|||
builder.pop();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static void buildProperty(ModConfigSpec.Builder builder, PropertyData data) throws IllegalAccessException {
|
||||
AnnotationData annotationData = data.getData();
|
||||
builder.comment(annotationData.description());
|
||||
|
|
|
|||
|
|
@ -23,16 +23,13 @@ package tschipp.carryon.events;
|
|||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
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.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.api.distmarker.OnlyIn;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
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.RenderHandEvent;
|
||||
import net.neoforged.neoforge.client.event.RenderLevelStageEvent;
|
||||
import net.neoforged.neoforge.client.event.ScreenEvent;
|
||||
import tschipp.carryon.CarryOnCommonClient;
|
||||
import tschipp.carryon.Constants;
|
||||
|
|
@ -44,28 +41,19 @@ import tschipp.carryon.common.carry.CarryOnDataManager;
|
|||
@EventBusSubscriber(modid = Constants.MOD_ID, value = Dist.CLIENT)
|
||||
public class ClientEvents {
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@SubscribeEvent
|
||||
public static void renderHand(RenderHandEvent event)
|
||||
{
|
||||
Player player = Minecraft.getInstance().player;
|
||||
MultiBufferSource buffer = event.getMultiBufferSource();
|
||||
PoseStack matrix = event.getPoseStack();
|
||||
int light = event.getPackedLight();
|
||||
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);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@SubscribeEvent
|
||||
public static void onRenderLevel(RenderLevelStageEvent.AfterParticles event)
|
||||
{
|
||||
CarriedObjectRender.drawThirdPerson(event.getPartialTick().getGameTimeDeltaPartialTick(true), event.getPoseStack().last().pose());
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@SubscribeEvent
|
||||
public static void onGuiInit(ScreenEvent.Init.Pre event)
|
||||
{
|
||||
|
|
@ -89,7 +77,6 @@ public class ClientEvents {
|
|||
}
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@SubscribeEvent
|
||||
public static void onClientTick(ClientTickEvent.Post event)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
package tschipp.carryon.events;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.util.TriState;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
|
|
@ -31,14 +31,16 @@ import net.minecraft.world.entity.Mob;
|
|||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.ServerLevelAccessor;
|
||||
import net.neoforged.bus.api.Event;
|
||||
import net.neoforged.bus.api.EventPriority;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.common.EventBusSubscriber;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
import net.neoforged.neoforge.common.NeoForge;
|
||||
import net.neoforged.neoforge.common.util.BlockSnapshot;
|
||||
import net.neoforged.neoforge.event.*;
|
||||
import net.neoforged.neoforge.event.AddServerReloadListenersEvent;
|
||||
import net.neoforged.neoforge.event.OnDatapackSyncEvent;
|
||||
import net.neoforged.neoforge.event.RegisterCommandsEvent;
|
||||
import net.neoforged.neoforge.event.TagsUpdatedEvent;
|
||||
import net.neoforged.neoforge.event.entity.living.LivingDeathEvent;
|
||||
import net.neoforged.neoforge.event.entity.living.MobSpawnEvent;
|
||||
import net.neoforged.neoforge.event.entity.player.AttackEntityEvent;
|
||||
import net.neoforged.neoforge.event.entity.player.PlayerEvent;
|
||||
|
|
@ -68,7 +70,7 @@ public class CommonEvents
|
|||
Level level = event.getLevel();
|
||||
BlockPos pos = event.getPos();
|
||||
|
||||
if (level.isClientSide)
|
||||
if (level.isClientSide())
|
||||
return;
|
||||
|
||||
boolean success = false;
|
||||
|
|
@ -122,7 +124,7 @@ public class CommonEvents
|
|||
Level level = event.getLevel();
|
||||
Entity target = event.getTarget();
|
||||
|
||||
if (level.isClientSide)
|
||||
if (level.isClientSide())
|
||||
return;
|
||||
|
||||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||
|
|
@ -150,7 +152,7 @@ public class CommonEvents
|
|||
@SubscribeEvent
|
||||
public static void onDatapackRegister(AddServerReloadListenersEvent event)
|
||||
{
|
||||
event.addListener(ResourceLocation.fromNamespaceAndPath(Constants.MOD_ID, "scripts"), new ScriptReloadListener());
|
||||
event.addListener(Identifier.fromNamespaceAndPath(Constants.MOD_ID, "scripts"), new ScriptReloadListener());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
|
@ -180,7 +182,7 @@ public class CommonEvents
|
|||
@SubscribeEvent
|
||||
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());
|
||||
}
|
||||
|
||||
|
|
@ -219,4 +221,11 @@ public class CommonEvents
|
|||
CarryOnCommon.onRiderDisconnected(player);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onPlayerDie(LivingDeathEvent event) {
|
||||
if(event.getEntity() instanceof ServerPlayer sp) {
|
||||
CarryOnCommon.onRiderDisconnected(sp);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,10 +24,8 @@ import net.neoforged.bus.api.EventPriority;
|
|||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.InterModComms;
|
||||
import net.neoforged.fml.common.EventBusSubscriber;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
import net.neoforged.fml.event.lifecycle.InterModProcessEvent;
|
||||
import tschipp.carryon.Constants;
|
||||
import tschipp.carryon.client.modeloverride.ModelOverrideHandler;
|
||||
import tschipp.carryon.common.config.ListHandler;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
|
|
|||
|
|
@ -21,10 +21,8 @@
|
|||
package tschipp.carryon.events;
|
||||
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.api.distmarker.OnlyIn;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.common.EventBusSubscriber;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
import net.neoforged.neoforge.client.event.RegisterKeyMappingsEvent;
|
||||
import tschipp.carryon.Constants;
|
||||
import tschipp.carryon.client.keybinds.CarryOnKeybinds;
|
||||
|
|
@ -32,7 +30,6 @@ import tschipp.carryon.client.keybinds.CarryOnKeybinds;
|
|||
@EventBusSubscriber(modid = Constants.MOD_ID, value = Dist.CLIENT)
|
||||
public class ModClientEvents
|
||||
{
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@SubscribeEvent
|
||||
public static void registerKeybinds(RegisterKeyMappingsEvent event)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -20,14 +20,11 @@
|
|||
|
||||
package tschipp.carryon.platform;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
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.resources.ResourceLocation;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.neoforged.fml.ModList;
|
||||
|
|
@ -36,14 +33,15 @@ import net.neoforged.neoforge.network.PacketDistributor;
|
|||
import net.neoforged.neoforge.network.handling.IPayloadHandler;
|
||||
import net.neoforged.neoforge.network.registration.PayloadRegistrar;
|
||||
import tschipp.carryon.CarryOnCommonClient;
|
||||
import tschipp.carryon.CarryOnNeoForge;
|
||||
import tschipp.carryon.CarryOnNeoForgeClient;
|
||||
import tschipp.carryon.common.carry.CarryOnData;
|
||||
import tschipp.carryon.config.BuiltConfig;
|
||||
import tschipp.carryon.config.neoforge.ConfigLoaderImpl;
|
||||
import tschipp.carryon.networking.PacketBase;
|
||||
import tschipp.carryon.networking.serverbound.ServerboundCarryKeyPressedPacket;
|
||||
import tschipp.carryon.platform.services.IPlatformHelper;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class NeoForgePlatformHelper implements IPlatformHelper {
|
||||
|
||||
|
|
@ -62,7 +60,7 @@ public class NeoForgePlatformHelper implements IPlatformHelper {
|
|||
@Override
|
||||
public boolean isDevelopmentEnvironment() {
|
||||
|
||||
return !FMLLoader.isProduction();
|
||||
return !FMLLoader.getCurrent().isProduction();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -70,6 +68,7 @@ public class NeoForgePlatformHelper implements IPlatformHelper {
|
|||
ConfigLoaderImpl.registerConfig(cfg);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@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) {
|
||||
PayloadRegistrar registrar = (PayloadRegistrar) args[0];
|
||||
|
|
@ -83,6 +82,7 @@ public class NeoForgePlatformHelper implements IPlatformHelper {
|
|||
registrar.playToServer(type, (StreamCodec<RegistryFriendlyByteBuf, T>)codec, serverHandler);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@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)
|
||||
{
|
||||
|
|
@ -99,12 +99,22 @@ public class NeoForgePlatformHelper implements IPlatformHelper {
|
|||
|
||||
|
||||
@Override
|
||||
public void sendPacketToServer(ResourceLocation id, PacketBase packet) {
|
||||
PacketDistributor.sendToServer(packet);
|
||||
public void sendPacketToServer(Identifier id, PacketBase packet) {
|
||||
CarryOnNeoForgeClient.sendPacketToServer(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPacketToPlayer(ResourceLocation id, PacketBase packet, ServerPlayer player) {
|
||||
public void sendPacketToPlayer(Identifier id, PacketBase packet, ServerPlayer player) {
|
||||
PacketDistributor.sendToPlayer(player, packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarryOnData getCarryData(Player player) {
|
||||
return player.getData(CarryOnNeoForge.CARRY_ON_DATA_ATTACHMENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCarryData(Player player, CarryOnData data) {
|
||||
player.setData(CarryOnNeoForge.CARRY_ON_DATA_ATTACHMENT, data);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
plugins {
|
||||
// see https://fabricmc.net/develop/ for new versions
|
||||
id 'fabric-loom' version '1.10-SNAPSHOT' apply false
|
||||
id 'fabric-loom' version "${loom_version}" apply false
|
||||
// see https://projects.neoforged.net/neoforged/moddevgradle for new versions
|
||||
id 'net.neoforged.moddev' version '2.0.62-beta' apply false
|
||||
id 'net.neoforged.moddev' version "${mod_dev_version}" apply false
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@ plugins {
|
|||
}
|
||||
|
||||
base {
|
||||
archivesName = "${mod_id}-${project.name}-${minecraft_version}"
|
||||
archivesName = "${mod_id}-${project.name.toLowerCase()}-${minecraft_version}"
|
||||
}
|
||||
|
||||
java {
|
||||
|
|
@ -100,7 +100,8 @@ processResources {
|
|||
"forge_version": forge_version,
|
||||
"forge_loader_version_range": forge_loader_version_range,
|
||||
'credits' : credits,
|
||||
'java_version' : java_version
|
||||
'java_version' : java_version,
|
||||
'minecraft_version_range_fabric' : minecraft_version_range_fabric,
|
||||
]
|
||||
|
||||
var jsonExpandProps = expandProps.collectEntries {
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user