Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
08bf927526 | ||
|
|
eab2ef67b7 | ||
|
|
5342c4daa5 | ||
|
|
685352762a | ||
|
|
0d901782c3 | ||
|
|
0cc6233d2c | ||
|
|
10a8845805 | ||
|
|
d98332f614 | ||
|
|
dd30dc26b8 | ||
|
|
22077c032c | ||
|
|
6097b048a4 | ||
|
|
df553315a7 | ||
|
|
1905c9a655 | ||
|
|
38ae4d8adb | ||
|
|
9a4569b529 | ||
|
|
3ee972b4d0 | ||
|
|
5deb39e0c6 |
|
|
@ -26,7 +26,6 @@ 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;
|
||||
|
|
@ -40,7 +39,9 @@ import tschipp.carryon.common.carry.CarryOnDataManager;
|
|||
import tschipp.carryon.common.carry.PlacementHandler;
|
||||
import tschipp.carryon.common.command.CommandCarryOn;
|
||||
import tschipp.carryon.config.ConfigLoader;
|
||||
import tschipp.carryon.networking.clientbound.ClientboundStartRidingOtherPlayerPacket;
|
||||
import tschipp.carryon.networking.clientbound.ClientboundStartRidingPacket;
|
||||
import tschipp.carryon.networking.clientbound.ClientboundSyncCarryDataPacket;
|
||||
import tschipp.carryon.networking.clientbound.ClientboundSyncScriptsPacket;
|
||||
import tschipp.carryon.networking.serverbound.ServerboundCarryKeyPressedPacket;
|
||||
import tschipp.carryon.platform.Services;
|
||||
|
|
@ -83,6 +84,22 @@ public class CarryOnCommon
|
|||
ClientboundSyncScriptsPacket::handle,
|
||||
args
|
||||
);
|
||||
|
||||
Services.PLATFORM.registerClientboundPacket(
|
||||
ClientboundStartRidingOtherPlayerPacket.TYPE,
|
||||
ClientboundStartRidingOtherPlayerPacket.class,
|
||||
ClientboundStartRidingOtherPlayerPacket.CODEC,
|
||||
ClientboundStartRidingOtherPlayerPacket::handle,
|
||||
args
|
||||
);
|
||||
|
||||
Services.PLATFORM.registerClientboundPacket(
|
||||
ClientboundSyncCarryDataPacket.TYPE,
|
||||
ClientboundSyncCarryDataPacket.class,
|
||||
ClientboundSyncCarryDataPacket.CODEC,
|
||||
ClientboundSyncCarryDataPacket::handle,
|
||||
args
|
||||
);
|
||||
}
|
||||
|
||||
public static void registerConfig()
|
||||
|
|
@ -102,6 +119,10 @@ public class CarryOnCommon
|
|||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||
if(carry.isCarrying())
|
||||
{
|
||||
//Dirty Hack to sync carry data 1 tick after respawning
|
||||
if(player.tickCount == 1)
|
||||
CarryOnDataManager.setCarryData(player, carry);
|
||||
|
||||
if(carry.getActiveScript().isPresent())
|
||||
{
|
||||
String cmd = carry.getActiveScript().get().scriptEffects().commandLoop();
|
||||
|
|
@ -160,8 +181,18 @@ public class CarryOnCommon
|
|||
}
|
||||
}
|
||||
|
||||
public static void onRiderDisconnected(Player rider)
|
||||
{
|
||||
if(rider.getVehicle() instanceof ServerPlayer vehicle) {
|
||||
CarryOnData data = CarryOnDataManager.getCarryData(vehicle);
|
||||
if(data.isCarrying(CarryType.PLAYER)) {
|
||||
PlacementHandler.placeCarried(vehicle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static int potionLevel(CarryOnData carry, Level level)
|
||||
|
||||
public static int potionLevel(CarryOnData carry, Level level)
|
||||
{
|
||||
if(carry.isCarrying(CarryType.PLAYER))
|
||||
return 1;
|
||||
|
|
|
|||
|
|
@ -37,5 +37,7 @@ public class Constants {
|
|||
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 ResourceLocation PACKET_ID_SYNC_CARRY_ON_DATA = ResourceLocation.fromNamespaceAndPath(Constants.MOD_ID, "sync_carry_data");
|
||||
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -21,10 +21,8 @@
|
|||
package tschipp.carryon.client.render;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||
import com.mojang.blaze3d.vertex.ByteBufferBuilder;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.Tesselator;
|
||||
import com.mojang.math.Axis;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
package tschipp.carryon.common.carry;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.DataResult;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
|
|
@ -28,6 +29,9 @@ 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.world.entity.AreaEffectCloud;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
|
|
@ -49,6 +53,28 @@ public class CarryOnData {
|
|||
private CarryOnScript activeScript;
|
||||
private int selectedSlot = 0;
|
||||
|
||||
|
||||
public static final Codec<CarryOnData> CODEC = CompoundTag.CODEC.flatXmap(
|
||||
tag -> {
|
||||
try {
|
||||
return DataResult.success(new CarryOnData(tag));
|
||||
} catch (Exception e) {
|
||||
return DataResult.error(e::getMessage);
|
||||
}
|
||||
},
|
||||
carry -> {
|
||||
try {
|
||||
return DataResult.success(carry.getNbt());
|
||||
} catch (Exception e) {
|
||||
return DataResult.error(e::getMessage);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
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"))
|
||||
|
|
@ -213,6 +239,11 @@ public class CarryOnData {
|
|||
return this.nbt.getInt("tick");
|
||||
}
|
||||
|
||||
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().selected);
|
||||
data.setTick(player.tickCount);
|
||||
Services.PLATFORM.setCarryData(player, data);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,10 +22,13 @@ package tschipp.carryon.common.carry;
|
|||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
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.AgeableMob;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.Entity.RemovalReason;
|
||||
|
|
@ -38,13 +41,14 @@ import net.minecraft.world.level.Level;
|
|||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import tschipp.carryon.CarryOnCommon;
|
||||
import tschipp.carryon.Constants;
|
||||
import tschipp.carryon.common.config.ListHandler;
|
||||
import tschipp.carryon.common.pickupcondition.PickupCondition;
|
||||
import tschipp.carryon.common.pickupcondition.PickupConditionHandler;
|
||||
import tschipp.carryon.common.scripting.CarryOnScript;
|
||||
import tschipp.carryon.common.scripting.ScriptManager;
|
||||
import tschipp.carryon.networking.clientbound.ClientboundStartRidingPacket;
|
||||
import tschipp.carryon.networking.clientbound.ClientboundStartRidingOtherPlayerPacket;
|
||||
import tschipp.carryon.platform.Services;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
|
@ -85,7 +89,7 @@ public class PickupHandler {
|
|||
|
||||
public static boolean tryPickUpBlock(ServerPlayer player, BlockPos pos, Level level, @Nullable BiFunction<BlockState, BlockPos, Boolean> pickupCallback)
|
||||
{
|
||||
if(!canCarryGeneral(player, Vec3.atCenterOf(pos)))
|
||||
if(!canCarryGeneral(player, Vec3.atCenterOf(pos))) //Necessary
|
||||
return false;
|
||||
|
||||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||
|
|
@ -95,13 +99,16 @@ public class PickupHandler {
|
|||
if(blockEntity != null)
|
||||
nbt = blockEntity.saveWithId(level.registryAccess());
|
||||
|
||||
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)
|
||||
if(!overrideChecks && (state.getDestroySpeed(level, pos) == -1 && !player.isCreative() && !Constants.COMMON_CONFIG.settings.pickupUnbreakableBlocks))
|
||||
return false;
|
||||
|
||||
if(blockEntity == null && !Constants.COMMON_CONFIG.settings.pickupAllBlocks)
|
||||
if(!overrideChecks && (blockEntity == null && !Constants.COMMON_CONFIG.settings.pickupAllBlocks))
|
||||
return false;
|
||||
|
||||
//Check if TE is locked
|
||||
|
|
@ -122,7 +129,6 @@ public class PickupHandler {
|
|||
if(!doPickup)
|
||||
return false;
|
||||
|
||||
Optional<CarryOnScript> result = ScriptManager.inspectBlock(state, level, pos, nbt);
|
||||
if(result.isPresent())
|
||||
{
|
||||
CarryOnScript script = result.get();
|
||||
|
|
@ -144,6 +150,8 @@ public class PickupHandler {
|
|||
CarryOnDataManager.setCarryData(player, carry);
|
||||
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.MOVEMENT_SLOWDOWN, 100000000, CarryOnCommon.potionLevel(carry, player.level()), false, false));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -168,17 +176,20 @@ public class PickupHandler {
|
|||
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())
|
||||
|
|
@ -198,7 +209,6 @@ public class PickupHandler {
|
|||
|
||||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||
|
||||
Optional<CarryOnScript> result = ScriptManager.inspectEntity(entity);
|
||||
if(result.isPresent())
|
||||
{
|
||||
CarryOnScript script = result.get();
|
||||
|
|
@ -224,12 +234,14 @@ public class PickupHandler {
|
|||
player.getServer().getCommands().performPrefixedCommand(player.getServer().createCommandSourceStack(), "/execute as " + player.getGameProfile().getName() + " run " + cmd);
|
||||
}
|
||||
|
||||
otherPlayer.startRiding(player);
|
||||
Services.PLATFORM.sendPacketToPlayer(Constants.PACKET_ID_START_RIDING, new ClientboundStartRidingPacket(otherPlayer.getId(), true), player);
|
||||
otherPlayer.startRiding(player, true);
|
||||
Services.PLATFORM.sendPacketToAllPlayers(Constants.PACKET_ID_START_RIDING_OTHER, new ClientboundStartRidingOtherPlayerPacket(player.getId(), otherPlayer.getId(), true), (ServerLevel) player.level());
|
||||
carry.setCarryingPlayer();
|
||||
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.MOVEMENT_SLOWDOWN, 100000000, CarryOnCommon.potionLevel(carry, player.level()), false, false));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
|
@ -253,6 +265,8 @@ public class PickupHandler {
|
|||
player.level().playSound(null, player.getOnPos(), SoundEvents.ARMOR_EQUIP_GENERIC.value(), SoundSource.AMBIENT, 1.0f, 0.5f);
|
||||
CarryOnDataManager.setCarryData(player, carry);
|
||||
player.swing(InteractionHand.MAIN_HAND, true);
|
||||
if (!player.isCreative() || Constants.COMMON_CONFIG.settings.slownessInCreative)
|
||||
player.addEffect(new MobEffectInstance(MobEffects.MOVEMENT_SLOWDOWN, 100000000, CarryOnCommon.potionLevel(carry, player.level()), false, false));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ 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.MobEffects;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.entity.animal.horse.Horse;
|
||||
|
|
@ -46,6 +47,8 @@ import tschipp.carryon.Constants;
|
|||
import tschipp.carryon.common.carry.CarryOnData.CarryType;
|
||||
import tschipp.carryon.common.config.ListHandler;
|
||||
import tschipp.carryon.common.scripting.CarryOnScript.ScriptEffects;
|
||||
import tschipp.carryon.networking.clientbound.ClientboundStartRidingOtherPlayerPacket;
|
||||
import tschipp.carryon.platform.Services;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -109,6 +112,8 @@ public class PlacementHandler
|
|||
player.playSound(state.getSoundType().getPlaceSound(), 1.0f, 0.5f);
|
||||
level.playSound(null, pos, state.getSoundType().getPlaceSound(), SoundSource.BLOCKS, 1.0f, 0.5f);
|
||||
player.swing(InteractionHand.MAIN_HAND, true);
|
||||
if (!player.isCreative() || Constants.COMMON_CONFIG.settings.slownessInCreative)
|
||||
player.removeEffect(MobEffects.MOVEMENT_SLOWDOWN);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -173,12 +178,13 @@ public class PlacementHandler
|
|||
if (carry.isCarrying(CarryType.PLAYER)) {
|
||||
Entity otherPlayer = player.getFirstPassenger();
|
||||
player.ejectPassengers();
|
||||
Services.PLATFORM.sendPacketToAllPlayers(Constants.PACKET_ID_START_RIDING_OTHER, new ClientboundStartRidingOtherPlayerPacket(player.getId(), otherPlayer.getId(), false), player.serverLevel());
|
||||
carry.clear();
|
||||
CarryOnDataManager.setCarryData(player, carry);
|
||||
if (otherPlayer == null)
|
||||
return true;
|
||||
otherPlayer.teleportTo(placementPos.x, placementPos.y, placementPos.z);
|
||||
otherPlayer.teleportTo(placementPos.x, placementPos.y, placementPos.z);
|
||||
player.swing(InteractionHand.MAIN_HAND, true);
|
||||
if (!player.isCreative() || Constants.COMMON_CONFIG.settings.slownessInCreative)
|
||||
player.removeEffect(MobEffects.MOVEMENT_SLOWDOWN);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -203,6 +209,8 @@ public class PlacementHandler
|
|||
player.swing(InteractionHand.MAIN_HAND, true);
|
||||
carry.clear();
|
||||
CarryOnDataManager.setCarryData(player, carry);
|
||||
if (!player.isCreative() || Constants.COMMON_CONFIG.settings.slownessInCreative)
|
||||
player.removeEffect(MobEffects.MOVEMENT_SLOWDOWN);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -222,6 +230,8 @@ public class PlacementHandler
|
|||
else
|
||||
entityHeld = player.getFirstPassenger();
|
||||
|
||||
if(entityHeld == null)
|
||||
return;
|
||||
|
||||
double sizeHeldEntity = entityHeld.getBbHeight() * entityHeld.getBbWidth();
|
||||
double distance = entityClicked.blockPosition().distSqr(player.blockPosition());
|
||||
|
|
|
|||
|
|
@ -271,7 +271,15 @@ public class CarryConfig
|
|||
"cookingforblockheads:fruit_basket", "cookingforblockheads:cooking_table", "cookingforblockheads:fridge", "cookingforblockheads:sink",
|
||||
"chipped:*", "irons_spellbooks:*", "create*:*", "simple_pipes:*", "libmultipart:*", "quark:tiny_potato", "ait:*",
|
||||
"vampirism:*", "extrastorage:*", "relics:researching_table", "sophisticatedstorage:*chest",
|
||||
"powah:*", "advancementtrophies:trophy", "mekanismgenerators:heat_generator", "mna:filler_block", "create_enchantment_industry:*", "graveyard:*", "immersivepetroleum:*", "tardis:interior_door", "cuffed:*"
|
||||
"powah:*", "advancementtrophies:trophy", "mekanismgenerators:heat_generator", "mna:filler_block", "create_enchantment_industry:*", "graveyard:*", "immersivepetroleum:*",
|
||||
"tardis:interior_door", "cuffed:*", "littletiles:*",
|
||||
"butchersdelight:*", "irons_spellbooks:*", "extended_drawers:*", "functionalstorage:*", "sophisticatedstorage:*", "farmersdelight:*",
|
||||
"modern_industrialization:*_cable",
|
||||
"modern_industrialization:item_pipe",
|
||||
"modern_industrialization:*_item_pipe",
|
||||
"modern_industrialization:fluid_pipe",
|
||||
"modern_industrialization:*_fluid_pipe",
|
||||
"snowrealmagic:*"
|
||||
};
|
||||
|
||||
@Property(
|
||||
|
|
@ -280,12 +288,13 @@ public class CarryConfig
|
|||
)
|
||||
public String[] forbiddenEntities = {
|
||||
"#c:capturing_not_supported", "#c:teleporting_not_supported",
|
||||
"minecraft:end_crystal", "minecraft:ender_dragon", "minecraft:ghast",
|
||||
"minecraft:shulker", "minecraft:leash_knot", "minecraft:armor_stand",
|
||||
"minecraft:item_frame", "minecraft:painting", "minecraft:shulker_bullet",
|
||||
"minecraft:end_crystal", "minecraft:ender_dragon", "minecraft:ghast", "minecraft:fireball", "minecraft:small_fireball", "minecraft:whither_skull",
|
||||
"minecraft:shulker", "minecraft:leash_knot", "minecraft:armor_stand", "minecraft:whither_skull_dangerous", "minecraft:dragon_fireball",
|
||||
"minecraft:item_frame", "minecraft:painting", "minecraft:shulker_bullet", "minecraft:evoker_fangs", "minecraft:glow_item_frame", "minecraft:tnt", "minecraft:trident", "minecraft:arrow", "minecraft:spectral_arrow",
|
||||
"minecraft:interaction", "minecraft:marker", "minecraft:block_display", "minecraft:item_display", "minecraft:text_display",
|
||||
"animania:hamster", "animania:ferret*", "animania:hedgehog*", "animania:cart",
|
||||
"animania:wagon", "mynko:*", "pixelmon:*", "mocreatures:*", "quark:totem", "vehicle:*",
|
||||
"securitycraft:*", "taterzens:npc", "easy_npc:*", "bodiesbodies:dead_body"
|
||||
"securitycraft:*", "taterzens:npc", "easy_npc:*", "bodiesbodies:dead_body", "littletiles:*"
|
||||
};
|
||||
|
||||
@Property(
|
||||
|
|
|
|||
|
|
@ -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,10 +22,8 @@ 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;
|
||||
|
|
@ -34,11 +32,13 @@ 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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ import net.minecraft.server.packs.resources.ResourceManager;
|
|||
import net.minecraft.server.packs.resources.SimpleJsonResourceReloadListener;
|
||||
import net.minecraft.util.profiling.ProfilerFiller;
|
||||
import tschipp.carryon.Constants;
|
||||
import tschipp.carryon.common.carry.CarryOnData;
|
||||
import tschipp.carryon.networking.clientbound.ClientboundSyncScriptsPacket;
|
||||
import tschipp.carryon.platform.Services;
|
||||
|
||||
|
|
@ -73,7 +72,7 @@ public class ScriptReloadListener extends SimpleJsonResourceReloadListener
|
|||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Collections.sort(ScriptManager.SCRIPTS, (s1, s2) -> Long.compare(s2.priority(), s1.priority()));
|
||||
ScriptManager.SCRIPTS.sort((s1, s2) -> Long.compare(s2.priority(), s1.priority()));
|
||||
}
|
||||
|
||||
public static void syncScriptsWithClient(ServerPlayer player)
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
package tschipp.carryon.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
|
|
@ -49,6 +50,13 @@ public abstract class EntityMixin
|
|||
|
||||
@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"))
|
||||
private boolean onStartRidingCheck(boolean original, Entity entity, boolean force) {
|
||||
if (force && entity instanceof Player) return true;
|
||||
return original;
|
||||
}*/
|
||||
|
||||
@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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ 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.CarryOnDataManager;
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ 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)
|
||||
|
|
|
|||
|
|
@ -22,74 +22,32 @@ 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.nbt.NbtOps;
|
||||
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 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.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().selected);
|
||||
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/nbt/CompoundTag;)V", at = @At("RETURN"))
|
||||
private void onAddAdditionalSaveData(CompoundTag tag, CallbackInfo info)
|
||||
{
|
||||
CarryOnData carry = CarryOnDataManager.getCarryData((Player)(Object)this);
|
||||
tag.put("CarryOnData", carry.getNbt());
|
||||
}
|
||||
|
||||
@Inject(method = "readAdditionalSaveData(Lnet/minecraft/nbt/CompoundTag;)V", at = @At("RETURN"))
|
||||
private void onReadAdditionalSaveData(CompoundTag tag, CallbackInfo info)
|
||||
{
|
||||
if (tag.contains("CarryOnData")) {
|
||||
CarryOnData data = new CarryOnData(tag.getCompound("CarryOnData"));
|
||||
setCarryOnData(data);
|
||||
}
|
||||
Optional<CarryOnData> res = CarryOnData.CODEC.parse(NbtOps.INSTANCE, tag.get(CarryOnData.SERIALIZATION_KEY)).result();
|
||||
res.ifPresent(data -> CarryOnDataManager.setCarryData((Player)((Object)this), data));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* 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.networking.clientbound;
|
||||
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.network.codec.ByteBufCodecs;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import tschipp.carryon.Constants;
|
||||
import tschipp.carryon.networking.PacketBase;
|
||||
|
||||
public record ClientboundStartRidingOtherPlayerPacket(int mount, int rider, boolean ride) implements PacketBase
|
||||
{
|
||||
public static final StreamCodec<RegistryFriendlyByteBuf, ClientboundStartRidingOtherPlayerPacket> CODEC = StreamCodec.composite(
|
||||
ByteBufCodecs.INT, ClientboundStartRidingOtherPlayerPacket::mount,
|
||||
ByteBufCodecs.INT, ClientboundStartRidingOtherPlayerPacket::rider,
|
||||
ByteBufCodecs.BOOL, ClientboundStartRidingOtherPlayerPacket::ride,
|
||||
ClientboundStartRidingOtherPlayerPacket::new
|
||||
);
|
||||
|
||||
public static final Type<ClientboundStartRidingOtherPlayerPacket> TYPE = new Type<>(Constants.PACKET_ID_START_RIDING_OTHER);
|
||||
|
||||
@Override
|
||||
public void handle(Player player)
|
||||
{
|
||||
Entity mount = player.level().getEntity(this.mount);
|
||||
Entity rider = player.level().getEntity(this.rider);
|
||||
|
||||
if(mount != null && rider != null)
|
||||
if(ride)
|
||||
rider.startRiding(mount, true);
|
||||
else
|
||||
rider.stopRiding();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type<ClientboundStartRidingOtherPlayerPacket> type() {
|
||||
return TYPE;
|
||||
}
|
||||
}
|
||||
|
|
@ -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 +1,37 @@
|
|||
package tschipp.carryon.networking.clientbound;
|
||||
|
||||
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;
|
||||
import tschipp.carryon.networking.PacketBase;
|
||||
|
||||
public record ClientboundSyncCarryDataPacket(CarryOnData data) {
|
||||
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) {
|
||||
p.getInventory().selected = data.getSelected();
|
||||
CarryOnDataManager.setCarryData(p, data);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type<? extends CustomPacketPayload> type() {
|
||||
return TYPE;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,19 +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.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 {
|
||||
|
||||
|
|
@ -67,4 +66,14 @@ public interface IPlatformHelper {
|
|||
void sendPacketToServer(ResourceLocation id, PacketBase packet);
|
||||
|
||||
void sendPacketToPlayer(ResourceLocation id, PacketBase packet, ServerPlayer player);
|
||||
|
||||
default void sendPacketToAllPlayers(ResourceLocation id, PacketBase packet, ServerLevel level) {
|
||||
for(ServerPlayer p : level.players())
|
||||
sendPacketToPlayer(id, packet, p);
|
||||
}
|
||||
|
||||
CarryOnData getCarryData(Player player);
|
||||
|
||||
void setCarryData(Player player, CarryOnData data);
|
||||
|
||||
}
|
||||
|
|
|
|||
16
Common/src/main/resources/assets/carryon/lang/de_de.json
Normal file
16
Common/src/main/resources/assets/carryon/lang/de_de.json
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"carryon.category.settings": "Einstellungen",
|
||||
"carryon.category.blacklist": "Blacklist",
|
||||
"carryon.category.modeloverrides": "Modellüberschreibungen (Fortgeschritten)",
|
||||
"carryon.category.custompickupconditions": "Benutzerdefinierte Bedingungen (Fortgeschritten)",
|
||||
"carryon.category.whitelist": "Whitelist",
|
||||
|
||||
"carryon.general.modeloverrides.modeloverrides": "Modellüberschreibungen",
|
||||
"carryon.general.blacklist.forbiddenentities": "Entitäten, die Spieler nicht aufheben dürfen",
|
||||
"carryon.general.blacklist.forbiddentiles": "Blöcke, die Spieler nicht aufheben dürfen",
|
||||
"carryon.category.custompickupconditions.custompickupconditionsblocks": "Benutzerdefinierte Bedingungen für Blöcke",
|
||||
"carryon.category.custompickupconditions.custompickupconditionsentities": "Benutzerdefinierte Bedingungen für Entitäten",
|
||||
|
||||
"key.carry.desc": "Carry",
|
||||
"key.carry.category": "Carry On"
|
||||
}
|
||||
16
Common/src/main/resources/assets/carryon/lang/ja_jp.json
Normal file
16
Common/src/main/resources/assets/carryon/lang/ja_jp.json
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"carryon.category.settings": "設定",
|
||||
"carryon.category.blacklist": "ブラックリスト",
|
||||
"carryon.category.modeloverrides": "モデルの上書き(上級)",
|
||||
"carryon.category.custompickupconditions": "カスタム持ち上げ条件(上級)",
|
||||
"carryon.category.whitelist": "ホワイトリスト",
|
||||
|
||||
"carryon.general.modeloverrides.modeloverrides": "モデルの上書き",
|
||||
"carryon.general.blacklist.forbiddenentities": "プレイヤーが持ち上げられないエンティティ",
|
||||
"carryon.general.blacklist.forbiddentiles": "プレーヤーが持ち上げられないブロック",
|
||||
"carryon.category.custompickupconditions.custompickupconditionsblocks": "カスタムブロック持ち上げ条件",
|
||||
"carryon.category.custompickupconditions.custompickupconditionsentities": "カスタムエンティティ持ち上げ条件",
|
||||
|
||||
"key.carry.desc": "Carry",
|
||||
"key.carry.category": "Carry On"
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
"__comment__": "Translated by @alpeerkaraca",
|
||||
"carryon.category.settings": "Ayarlar",
|
||||
"carryon.category.blacklist": "Kara Liste",
|
||||
"carryon.category.modeloverrides": "Modellerin Üzerine Yaz (Gelişmiş)",
|
||||
"carryon.category.modeloverrides": "Üzerine Yazılan Modeller (Gelişmiş)",
|
||||
"carryon.category.custompickupconditions": "Özel Yerden Alma Durumları (Gelişmiş)",
|
||||
"carryon.category.whitelist": "Beyaz Liste",
|
||||
|
||||
|
|
@ -12,6 +12,6 @@
|
|||
"carryon.category.custompickupconditions.custompickupconditionsblocks": "Özel Blok Alma Durumları",
|
||||
"carryon.category.custompickupconditions.custompickupconditionsentities": "Özel Varlık Alma Durumları",
|
||||
|
||||
"key.carry.desc": "Taşı Taşı",
|
||||
"key.carry.category": "Taşımaya Devam Et"
|
||||
"key.carry.desc": "Taşı",
|
||||
"key.carry.category": "Carry On"
|
||||
}
|
||||
16
Common/src/main/resources/assets/carryon/lang/zh_cn.json
Normal file
16
Common/src/main/resources/assets/carryon/lang/zh_cn.json
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"carryon.category.settings": "设置",
|
||||
"carryon.category.blacklist": "黑名单",
|
||||
"carryon.category.modeloverrides": "模型覆盖(高级设置)",
|
||||
"carryon.category.custompickupconditions": "自定义抱起条件(高级设置)",
|
||||
"carryon.category.whitelist": "白名单",
|
||||
|
||||
"carryon.general.modeloverrides.modeloverrides": "模型覆盖",
|
||||
"carryon.general.blacklist.forbiddenentities": "玩家不能抱起的实体",
|
||||
"carryon.general.blacklist.forbiddentiles": "玩家不能抱起的方块",
|
||||
"carryon.category.custompickupconditions.custompickupconditionsblocks": "自定义抱起方块条件",
|
||||
"carryon.category.custompickupconditions.custompickupconditionsentities": "自定义抱起实体条件",
|
||||
|
||||
"key.carry.desc": "抱起",
|
||||
"key.carry.category": "搬运"
|
||||
}
|
||||
16
Common/src/main/resources/assets/carryon/lang/zh_tw.json
Normal file
16
Common/src/main/resources/assets/carryon/lang/zh_tw.json
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"carryon.category.settings": "設定",
|
||||
"carryon.category.blacklist": "黑名單",
|
||||
"carryon.category.modeloverrides": "模型覆蓋(進階)",
|
||||
"carryon.category.custompickupconditions": "自訂拾取條件(進階)",
|
||||
"carryon.category.whitelist": "白名單",
|
||||
|
||||
"carryon.general.modeloverrides.modeloverrides": "模型覆蓋",
|
||||
"carryon.general.blacklist.forbiddenentities": "玩家無法拾取的實體",
|
||||
"carryon.general.blacklist.forbiddentiles": "玩家無法拾取的方塊",
|
||||
"carryon.category.custompickupconditions.custompickupconditionsblocks": "自訂方塊拾取條件",
|
||||
"carryon.category.custompickupconditions.custompickupconditionsentities": "自訂實體拾取條件",
|
||||
|
||||
"key.carry.desc": "攜帶",
|
||||
"key.carry.category": "Carry On"
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@ plugins {
|
|||
id 'java'
|
||||
id 'maven-publish'
|
||||
id 'idea'
|
||||
id 'fabric-loom' version '1.6-SNAPSHOT'
|
||||
id 'fabric-loom' version '1.7-SNAPSHOT'
|
||||
}
|
||||
base {
|
||||
archivesName = "${mod_id}-fabric-${minecraft_version}"
|
||||
|
|
|
|||
|
|
@ -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,6 +21,11 @@
|
|||
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.ResourceLocation;
|
||||
import tschipp.carryon.common.carry.CarryOnData;
|
||||
import tschipp.carryon.config.fabric.ConfigLoaderImpl;
|
||||
import tschipp.carryon.events.CommonEvents;
|
||||
|
||||
|
|
@ -28,6 +33,21 @@ import java.io.IOException;
|
|||
|
||||
public class CarryOnFabricMod implements ModInitializer {
|
||||
|
||||
/* public static final AttachmentType<CarryOnData> CARRY_ON_DATA_ATTACHMENT_TYPE = AttachmentRegistry.create(
|
||||
ResourceLocation.fromNamespaceAndPath(Constants.MOD_ID, "carry_on_data"),
|
||||
builder -> builder
|
||||
.initializer(() -> new CarryOnData(new CompoundTag()))
|
||||
.persistent(CarryOnData.CODEC)
|
||||
.syncWith(CarryOnData.STREAM_CODEC, (t, p) -> p.connection != null)
|
||||
.copyOnDeath()
|
||||
|
||||
); */
|
||||
|
||||
public static final AttachmentType<CarryOnData> CARRY_ON_DATA_ATTACHMENT_TYPE = AttachmentRegistry.<CarryOnData>builder()
|
||||
.initializer(() -> new CarryOnData(new CompoundTag()))
|
||||
.persistent(CarryOnData.CODEC)
|
||||
.buildAndRegister(ResourceLocation.fromNamespaceAndPath(Constants.MOD_ID, "carry_on_data"));
|
||||
|
||||
@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;
|
||||
|
|
|
|||
|
|
@ -21,11 +21,14 @@
|
|||
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;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
|
||||
import net.fabricmc.fabric.api.event.player.*;
|
||||
import net.fabricmc.fabric.api.networking.v1.EntityTrackingEvents;
|
||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
|
||||
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
|
|
@ -33,6 +36,7 @@ import net.minecraft.server.level.ServerPlayer;
|
|||
import net.minecraft.server.packs.PackType;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import tschipp.carryon.CarryOnCommon;
|
||||
import tschipp.carryon.Constants;
|
||||
import tschipp.carryon.common.carry.CarryOnData;
|
||||
import tschipp.carryon.common.carry.CarryOnData.CarryType;
|
||||
import tschipp.carryon.common.carry.CarryOnDataManager;
|
||||
|
|
@ -41,6 +45,8 @@ import tschipp.carryon.common.carry.PlacementHandler;
|
|||
import tschipp.carryon.common.scripting.ScriptReloadListener;
|
||||
import tschipp.carryon.compat.ArchitecturyCompat;
|
||||
import tschipp.carryon.config.ConfigLoader;
|
||||
import tschipp.carryon.networking.clientbound.ClientboundSyncCarryDataPacket;
|
||||
import tschipp.carryon.platform.Services;
|
||||
import tschipp.carryon.scripting.IdentifiableScriptReloadListener;
|
||||
|
||||
public class CommonEvents {
|
||||
|
|
@ -155,7 +161,35 @@ public class CommonEvents {
|
|||
return InteractionResult.PASS;
|
||||
}));
|
||||
|
||||
//TODO: drop carried when attacked
|
||||
ServerPlayConnectionEvents.DISCONNECT.register((handler, server) -> {
|
||||
CarryOnCommon.onRiderDisconnected(handler.getPlayer());
|
||||
});
|
||||
|
||||
EntityTrackingEvents.START_TRACKING.register(((trackedEntity, player) -> {
|
||||
if(trackedEntity instanceof ServerPlayer sp) {
|
||||
Services.PLATFORM.sendPacketToPlayer(Constants.PACKET_ID_SYNC_CARRY_ON_DATA, new ClientboundSyncCarryDataPacket(sp.getId(), CarryOnDataManager.getCarryData(sp)), player);
|
||||
}
|
||||
}));
|
||||
|
||||
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> {
|
||||
if(handler.getPlayer() instanceof ServerPlayer sp) {
|
||||
Services.PLATFORM.sendPacketToPlayer(Constants.PACKET_ID_SYNC_CARRY_ON_DATA, new ClientboundSyncCarryDataPacket(sp.getId(), CarryOnDataManager.getCarryData(sp)), sp);
|
||||
}
|
||||
});
|
||||
|
||||
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,23 +21,17 @@
|
|||
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.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
|
||||
|
|
|
|||
|
|
@ -20,28 +20,28 @@
|
|||
|
||||
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.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import tschipp.carryon.CarryOnFabricClientMod;
|
||||
import tschipp.carryon.CarryOnFabricMod;
|
||||
import tschipp.carryon.Constants;
|
||||
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.networking.clientbound.ClientboundSyncCarryDataPacket;
|
||||
import tschipp.carryon.platform.services.IPlatformHelper;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class FabricPlatformHelper implements IPlatformHelper {
|
||||
|
||||
|
|
@ -101,4 +101,18 @@ public class FabricPlatformHelper implements IPlatformHelper {
|
|||
{
|
||||
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);
|
||||
if(!player.level().isClientSide) {
|
||||
sendPacketToAllPlayers(Constants.PACKET_ID_SYNC_CARRY_ON_DATA, new ClientboundSyncCarryDataPacket(player.getId(), data), (ServerLevel) player.level());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ minecraft {
|
|||
taskName 'Client'
|
||||
property 'mixin.env.remapRefMap', 'true'
|
||||
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
|
||||
//args "-mixin.config=${mod_id}.mixins.json", "-mixin.config=${mod_id}.forge.mixins.json"
|
||||
args "-mixin.config=${mod_id}.mixins.json", "-mixin.config=${mod_id}.forge.mixins.json"
|
||||
mods {
|
||||
modClientRun {
|
||||
source sourceSets.main
|
||||
|
|
@ -66,7 +66,7 @@ minecraft {
|
|||
taskName 'Server'
|
||||
property 'mixin.env.remapRefMap', 'true'
|
||||
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
|
||||
//args "-mixin.config=${mod_id}.mixins.json", "-mixin.config=${mod_id}.forge.mixins.json"
|
||||
args "-mixin.config=${mod_id}.mixins.json", "-mixin.config=${mod_id}.forge.mixins.json"
|
||||
mods {
|
||||
modServerRun {
|
||||
source sourceSets.main
|
||||
|
|
@ -82,7 +82,7 @@ minecraft {
|
|||
taskName 'Data'
|
||||
property 'mixin.env.remapRefMap', 'true'
|
||||
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
|
||||
//args "-mixin.config=${mod_id}.mixins.json", "-mixin.config=${mod_id}.forge.mixins.json"
|
||||
args "-mixin.config=${mod_id}.mixins.json", "-mixin.config=${mod_id}.forge.mixins.json"
|
||||
mods {
|
||||
modDataRun {
|
||||
source sourceSets.main
|
||||
|
|
@ -144,6 +144,13 @@ processResources {
|
|||
from project(":Common").sourceSets.main.resources
|
||||
}
|
||||
|
||||
tasks.named('jar', Jar).configure {
|
||||
manifest {
|
||||
attributes([
|
||||
"MixinConfigs" : "${mod_id}.mixins.json,${mod_id}.forge.mixins.json"
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
}
|
||||
|
|
@ -22,22 +22,17 @@ 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.IEventBus;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
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.config.*;
|
||||
import tschipp.carryon.config.AnnotationData;
|
||||
import tschipp.carryon.config.BuiltCategory;
|
||||
import tschipp.carryon.config.BuiltConfig;
|
||||
import tschipp.carryon.config.PropertyData;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
|
|
|||
|
|
@ -26,13 +26,11 @@ import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
|||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
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.RenderLevelStageEvent;
|
||||
import net.minecraftforge.client.event.RenderLevelStageEvent.Stage;
|
||||
import net.minecraftforge.client.event.ScreenEvent;
|
||||
import net.minecraftforge.event.TickEvent.ClientTickEvent;
|
||||
import net.minecraftforge.event.TickEvent.Phase;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import tschipp.carryon.CarryOnCommonClient;
|
||||
|
|
@ -42,7 +40,7 @@ import tschipp.carryon.client.render.CarryRenderHelper;
|
|||
import tschipp.carryon.common.carry.CarryOnData;
|
||||
import tschipp.carryon.common.carry.CarryOnDataManager;
|
||||
|
||||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE, modid = Constants.MOD_ID)
|
||||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE, modid = Constants.MOD_ID, value = Dist.CLIENT)
|
||||
public class ClientEvents {
|
||||
|
||||
@SubscribeEvent
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
package tschipp.carryon.events;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
|
|
@ -31,15 +32,14 @@ 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.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;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent.BreakSpeed;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent.Clone;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
|
|
@ -53,6 +53,7 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
|
|||
import net.minecraftforge.fml.common.Mod;
|
||||
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;
|
||||
|
|
@ -60,6 +61,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.clientbound.ClientboundSyncCarryDataPacket;
|
||||
import tschipp.carryon.platform.Services;
|
||||
|
||||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE, modid = Constants.MOD_ID)
|
||||
public class CommonEvents
|
||||
|
|
@ -185,8 +188,16 @@ public class CommonEvents
|
|||
@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
|
||||
|
|
@ -218,4 +229,38 @@ public class CommonEvents
|
|||
CarryOnCommon.onPlayerAttacked(player);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onPlayerLoggedOut(PlayerEvent.PlayerLoggedOutEvent event) {
|
||||
if(event.getEntity() instanceof ServerPlayer player)
|
||||
CarryOnCommon.onRiderDisconnected(player);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onAttachCapabilities(AttachCapabilitiesEvent<Entity> event) {
|
||||
if (event.getObject() instanceof Player player) {
|
||||
event.addCapability(ResourceLocation.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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,10 +25,8 @@ import net.minecraftforge.eventbus.api.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,7 +21,6 @@
|
|||
package tschipp.carryon.events;
|
||||
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.client.event.RegisterKeyMappingsEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
|
@ -29,7 +28,7 @@ import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
|
|||
import tschipp.carryon.Constants;
|
||||
import tschipp.carryon.client.keybinds.CarryOnKeybinds;
|
||||
|
||||
@Mod.EventBusSubscriber(bus = Bus.MOD, modid = Constants.MOD_ID)
|
||||
@Mod.EventBusSubscriber(bus = Bus.MOD, modid = Constants.MOD_ID, value = Dist.CLIENT)
|
||||
public class ModClientEvents
|
||||
{
|
||||
@SubscribeEvent
|
||||
|
|
|
|||
|
|
@ -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.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.PacketBase;
|
||||
import tschipp.carryon.networking.clientbound.ClientboundSyncCarryDataPacket;
|
||||
import tschipp.carryon.platform.services.IPlatformHelper;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class ForgePlatformHelper implements IPlatformHelper {
|
||||
|
||||
|
|
@ -111,4 +114,19 @@ public class ForgePlatformHelper implements IPlatformHelper {
|
|||
{
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
plugins {
|
||||
id 'idea'
|
||||
id 'maven-publish'
|
||||
id 'net.neoforged.gradle.userdev' version '7.0.145'
|
||||
id 'net.neoforged.gradle.userdev' version '7.0.160'
|
||||
id 'java-library'
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,19 +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.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.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))
|
||||
.serialize(CarryOnData.CODEC)
|
||||
.build()
|
||||
);
|
||||
|
||||
public CarryOnNeoForge(ModContainer container) {
|
||||
|
||||
// This method is invoked by the Forge mod loader when it is ready
|
||||
|
|
@ -44,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)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
package tschipp.carryon;
|
||||
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.fml.ModContainer;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
import net.neoforged.neoforge.network.PacketDistributor;
|
||||
import tschipp.carryon.networking.PacketBase;
|
||||
|
||||
@Mod(value = Constants.MOD_ID, dist = Dist.CLIENT)
|
||||
public class CarryOnNeoForgeClient {
|
||||
|
||||
public CarryOnNeoForgeClient(ModContainer container) {
|
||||
|
||||
}
|
||||
|
||||
public static void sendPacketToServer(PacketBase packet) {
|
||||
PacketDistributor.sendToServer(packet);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package tschipp.carryon.carry;
|
||||
|
||||
/*
|
||||
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) {
|
||||
if (to.connection == null)
|
||||
return false;
|
||||
return AttachmentSyncHandler.super.sendToPlayer(holder, to);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
|
@ -22,22 +22,17 @@ 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.*;
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ 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;
|
||||
|
|
|
|||
|
|
@ -29,15 +29,18 @@ import net.minecraft.world.entity.MobSpawnType;
|
|||
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.common.util.TriState;
|
||||
import net.neoforged.neoforge.event.*;
|
||||
import net.neoforged.neoforge.event.AddReloadListenerEvent;
|
||||
import net.neoforged.neoforge.event.OnDatapackSyncEvent;
|
||||
import net.neoforged.neoforge.event.RegisterCommandsEvent;
|
||||
import net.neoforged.neoforge.event.TagsUpdatedEvent;
|
||||
import net.neoforged.neoforge.event.entity.EntityJoinLevelEvent;
|
||||
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;
|
||||
|
|
@ -53,6 +56,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.clientbound.ClientboundSyncCarryDataPacket;
|
||||
import tschipp.carryon.platform.Services;
|
||||
|
||||
@EventBusSubscriber(bus = EventBusSubscriber.Bus.GAME, modid = Constants.MOD_ID)
|
||||
public class CommonEvents
|
||||
|
|
@ -212,4 +217,31 @@ public class CommonEvents
|
|||
CarryOnCommon.onPlayerAttacked(player);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onPlayerLoggedOut(PlayerEvent.PlayerLoggedOutEvent event) {
|
||||
if(event.getEntity() instanceof ServerPlayer player)
|
||||
CarryOnCommon.onRiderDisconnected(player);
|
||||
}
|
||||
|
||||
@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.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;
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ 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;
|
||||
|
|
|
|||
|
|
@ -20,14 +20,12 @@
|
|||
|
||||
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.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.neoforged.fml.ModList;
|
||||
|
|
@ -36,14 +34,17 @@ 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.Constants;
|
||||
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.networking.clientbound.ClientboundSyncCarryDataPacket;
|
||||
import tschipp.carryon.platform.services.IPlatformHelper;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class NeoForgePlatformHelper implements IPlatformHelper {
|
||||
|
||||
|
|
@ -100,11 +101,24 @@ public class NeoForgePlatformHelper implements IPlatformHelper {
|
|||
|
||||
@Override
|
||||
public void sendPacketToServer(ResourceLocation id, PacketBase packet) {
|
||||
PacketDistributor.sendToServer(packet);
|
||||
CarryOnNeoForgeClient.sendPacketToServer(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPacketToPlayer(ResourceLocation 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);
|
||||
if(!player.level().isClientSide) {
|
||||
sendPacketToAllPlayers(Constants.PACKET_ID_SYNC_CARRY_ON_DATA, new ClientboundSyncCarryDataPacket(player.getId(), data), (ServerLevel) player.level());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
11
build.gradle
11
build.gradle
|
|
@ -11,6 +11,17 @@ subprojects {
|
|||
java.withSourcesJar()
|
||||
java.withJavadocJar()
|
||||
|
||||
configurations.all {
|
||||
resolutionStrategy {
|
||||
// Force the version of ASM that NeoForge wants (9.8 in your error log)
|
||||
force 'org.ow2.asm:asm-analysis:9.8'
|
||||
force 'org.ow2.asm:asm:9.8'
|
||||
force 'org.ow2.asm:asm-tree:9.8'
|
||||
force 'org.ow2.asm:asm-commons:9.8'
|
||||
force 'org.ow2.asm:asm-util:9.8'
|
||||
}
|
||||
}
|
||||
|
||||
jar {
|
||||
from(rootProject.file("LICENSE")) {
|
||||
rename { "${it}_${mod_id}" }
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# Project
|
||||
version=2.2.2
|
||||
version=2.2.4
|
||||
group=tschipp.carryon
|
||||
|
||||
# Common
|
||||
|
|
@ -10,21 +10,21 @@ mod_id=carryon
|
|||
license=GNU LGPLv3
|
||||
credits=
|
||||
description=Carry On is a simple mod that improves game interaction by allowing players to pick up, carry, and place single block Tile Entities using only their empty hands.
|
||||
minecraft_version_range=[1.21, 1.22)
|
||||
minecraft_version_range=[1.21.1, 1.21.2)
|
||||
# Forge
|
||||
forge_version=52.0.4
|
||||
forge_version=52.1.0
|
||||
forge_loader_version_range=[52,)
|
||||
forge_version_range=[52,)
|
||||
parchment_mappings=2024.07.28-1.21
|
||||
//forge_ats_enabled=true
|
||||
|
||||
# Fabric
|
||||
fabric_version=0.102.1+1.21.1
|
||||
fabric_version=0.116.7+1.21.1
|
||||
fabric_loader_version=0.16.2
|
||||
parchment_mappings_fabric=1.21:2024.07.28
|
||||
|
||||
# Neoforge
|
||||
neoforge_version=21.1.20
|
||||
neoforge_version=21.1.217
|
||||
neoforge_loader_version_range=[4,)
|
||||
neogradle.subsystems.parchment.minecraftVersion=1.21
|
||||
neogradle.subsystems.parchment.mappingsVersion=2024.07.28
|
||||
|
|
|
|||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
Loading…
Reference in New Issue
Block a user