started work on 1.20.6
This commit is contained in:
parent
75ca33bb8d
commit
b574f5b509
|
|
@ -22,6 +22,11 @@ package tschipp.carryon;
|
||||||
|
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
|
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.server.level.ServerPlayer;
|
||||||
import net.minecraft.world.effect.MobEffectInstance;
|
import net.minecraft.world.effect.MobEffectInstance;
|
||||||
import net.minecraft.world.effect.MobEffects;
|
import net.minecraft.world.effect.MobEffects;
|
||||||
|
|
@ -42,6 +47,14 @@ import tschipp.carryon.platform.Services;
|
||||||
|
|
||||||
public class CarryOnCommon
|
public class CarryOnCommon
|
||||||
{
|
{
|
||||||
|
public static final RegistrySetBuilder BUILDER = new RegistrySetBuilder();
|
||||||
|
|
||||||
|
public static HolderLookup.Provider createLookup() {
|
||||||
|
RegistryAccess.Frozen registryaccess$frozen = RegistryAccess.fromRegistryOfRegistries(BuiltInRegistries.REGISTRY);
|
||||||
|
HolderLookup.Provider holderlookup$provider = BUILDER.build(registryaccess$frozen);
|
||||||
|
return holderlookup$provider;
|
||||||
|
}
|
||||||
|
|
||||||
public static void registerServerPackets(Object... args)
|
public static void registerServerPackets(Object... args)
|
||||||
{
|
{
|
||||||
Services.PLATFORM.registerServerboundPacket(
|
Services.PLATFORM.registerServerboundPacket(
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ import net.minecraft.commands.arguments.blocks.BlockStateParser;
|
||||||
import net.minecraft.commands.arguments.blocks.BlockStateParser.BlockResult;
|
import net.minecraft.commands.arguments.blocks.BlockStateParser.BlockResult;
|
||||||
import net.minecraft.commands.arguments.item.ItemParser;
|
import net.minecraft.commands.arguments.item.ItemParser;
|
||||||
import net.minecraft.commands.arguments.item.ItemParser.ItemResult;
|
import net.minecraft.commands.arguments.item.ItemParser.ItemResult;
|
||||||
|
import net.minecraft.core.HolderLookup;
|
||||||
import net.minecraft.core.registries.BuiltInRegistries;
|
import net.minecraft.core.registries.BuiltInRegistries;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
|
@ -41,7 +42,7 @@ import java.util.Map;
|
||||||
|
|
||||||
public class ModelOverride
|
public class ModelOverride
|
||||||
{
|
{
|
||||||
public static Codec<ModelOverride> CODEC = Codec.STRING.comapFlatMap(ModelOverride::of, override -> override.raw);
|
//public static Codec<ModelOverride> CODEC = Codec.STRING.comapFlatMap(ModelOverride::of, override -> override.raw);
|
||||||
|
|
||||||
private String raw;
|
private String raw;
|
||||||
private BlockResult parsedBlock;
|
private BlockResult parsedBlock;
|
||||||
|
|
@ -58,8 +59,8 @@ public class ModelOverride
|
||||||
|
|
||||||
parsedRHS.ifLeft(res -> {
|
parsedRHS.ifLeft(res -> {
|
||||||
ItemStack stack = new ItemStack(res.item());
|
ItemStack stack = new ItemStack(res.item());
|
||||||
if(res.nbt() != null)
|
if(res.components() != null)
|
||||||
stack.setTag(res.nbt());
|
stack.applyComponents(res.components());
|
||||||
this.renderObject = Either.left(stack);
|
this.renderObject = Either.left(stack);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -69,7 +70,7 @@ public class ModelOverride
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DataResult<ModelOverride> of(String str)
|
public static DataResult<ModelOverride> of(String str, HolderLookup.Provider provider)
|
||||||
{
|
{
|
||||||
if(!str.contains("->"))
|
if(!str.contains("->"))
|
||||||
return DataResult.error(() -> str + " must contain -> Arrow!");
|
return DataResult.error(() -> str + " must contain -> Arrow!");
|
||||||
|
|
@ -98,7 +99,7 @@ public class ModelOverride
|
||||||
Either<ItemResult, BlockResult> either;
|
Either<ItemResult, BlockResult> either;
|
||||||
try {
|
try {
|
||||||
if(type == Type.ITEM)
|
if(type == Type.ITEM)
|
||||||
either = Either.left(ItemParser.parseForItem(BuiltInRegistries.ITEM.asLookup(), new StringReader(to)));
|
either = Either.left(new ItemParser(provider).parse(new StringReader(to)));
|
||||||
else
|
else
|
||||||
either = Either.right(BlockStateParser.parseForBlock(BuiltInRegistries.BLOCK.asLookup(), to, true));
|
either = Either.right(BlockStateParser.parseForBlock(BuiltInRegistries.BLOCK.asLookup(), to, true));
|
||||||
}catch (CommandSyntaxException e) {
|
}catch (CommandSyntaxException e) {
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
package tschipp.carryon.client.modeloverride;
|
package tschipp.carryon.client.modeloverride;
|
||||||
|
|
||||||
import com.mojang.serialization.DataResult;
|
import com.mojang.serialization.DataResult;
|
||||||
|
import net.minecraft.core.HolderLookup;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import tschipp.carryon.Constants;
|
import tschipp.carryon.Constants;
|
||||||
|
|
@ -34,13 +35,13 @@ public class ModelOverrideHandler
|
||||||
{
|
{
|
||||||
private static List<ModelOverride> OVERRIDES = new ArrayList<>();
|
private static List<ModelOverride> OVERRIDES = new ArrayList<>();
|
||||||
|
|
||||||
public static void initModelOverrides()
|
public static void initModelOverrides(HolderLookup.Provider provider)
|
||||||
{
|
{
|
||||||
OVERRIDES.clear();
|
OVERRIDES.clear();
|
||||||
|
|
||||||
for(String ov : Constants.CLIENT_CONFIG.modelOverrides)
|
for(String ov : Constants.CLIENT_CONFIG.modelOverrides)
|
||||||
{
|
{
|
||||||
addFromString(ov);
|
addFromString(ov, provider);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -54,9 +55,9 @@ public class ModelOverrideHandler
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addFromString(String str)
|
public static void addFromString(String str, HolderLookup.Provider provider)
|
||||||
{
|
{
|
||||||
DataResult<ModelOverride> res = ModelOverride.of(str);
|
DataResult<ModelOverride> res = ModelOverride.of(str, provider);
|
||||||
if(res.result().isPresent())
|
if(res.result().isPresent())
|
||||||
{
|
{
|
||||||
ModelOverride override = res.result().get();
|
ModelOverride override = res.result().get();
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
import org.joml.Matrix4f;
|
||||||
import tschipp.carryon.Constants;
|
import tschipp.carryon.Constants;
|
||||||
import tschipp.carryon.common.carry.CarryOnData;
|
import tschipp.carryon.common.carry.CarryOnData;
|
||||||
import tschipp.carryon.common.carry.CarryOnData.CarryType;
|
import tschipp.carryon.common.carry.CarryOnData.CarryType;
|
||||||
|
|
@ -175,15 +176,18 @@ public class CarriedObjectRender
|
||||||
/**
|
/**
|
||||||
* Draws the third person view of entities and blocks
|
* Draws the third person view of entities and blocks
|
||||||
* @param partialticks
|
* @param partialticks
|
||||||
* @param matrix
|
* @param mat
|
||||||
*/
|
*/
|
||||||
public static void drawThirdPerson(float partialticks, PoseStack matrix) {
|
public static void drawThirdPerson(float partialticks, Matrix4f mat) {
|
||||||
Minecraft mc = Minecraft.getInstance();
|
Minecraft mc = Minecraft.getInstance();
|
||||||
Level level = mc.level;
|
Level level = mc.level;
|
||||||
int light = 0;
|
int light = 0;
|
||||||
int perspective = CarryRenderHelper.getPerspective();
|
int perspective = CarryRenderHelper.getPerspective();
|
||||||
EntityRenderDispatcher manager = mc.getEntityRenderDispatcher();
|
EntityRenderDispatcher manager = mc.getEntityRenderDispatcher();
|
||||||
|
|
||||||
|
PoseStack matrix = new PoseStack();
|
||||||
|
matrix.mulPose(mat);
|
||||||
|
|
||||||
RenderSystem.enableBlend();
|
RenderSystem.enableBlend();
|
||||||
RenderSystem.disableCull();
|
RenderSystem.disableCull();
|
||||||
RenderSystem.disableDepthTest();
|
RenderSystem.disableDepthTest();
|
||||||
|
|
@ -222,7 +226,7 @@ public class CarriedObjectRender
|
||||||
|
|
||||||
PoseStack.Pose p = matrix.last();
|
PoseStack.Pose p = matrix.last();
|
||||||
PoseStack copy = new PoseStack();
|
PoseStack copy = new PoseStack();
|
||||||
copy.mulPoseMatrix(p.pose());
|
copy.mulPose(p.pose());
|
||||||
matrix.popPose();
|
matrix.popPose();
|
||||||
|
|
||||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ package tschipp.carryon.common.carry;
|
||||||
|
|
||||||
import com.mojang.serialization.DataResult;
|
import com.mojang.serialization.DataResult;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.core.HolderLookup;
|
||||||
import net.minecraft.core.registries.BuiltInRegistries;
|
import net.minecraft.core.registries.BuiltInRegistries;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.nbt.NbtOps;
|
import net.minecraft.nbt.NbtOps;
|
||||||
|
|
@ -63,7 +64,7 @@ public class CarryOnData {
|
||||||
if(data.contains("activeScript"))
|
if(data.contains("activeScript"))
|
||||||
{
|
{
|
||||||
DataResult<CarryOnScript> res = CarryOnScript.CODEC.parse(NbtOps.INSTANCE, data.get("activeScript"));
|
DataResult<CarryOnScript> res = CarryOnScript.CODEC.parse(NbtOps.INSTANCE, data.get("activeScript"));
|
||||||
this.activeScript = res.getOrThrow(false, (s) -> {throw new RuntimeException("Failed to decode activeScript during CarryOnData serialization: " + s);});
|
this.activeScript = res.getOrThrow((s) -> {throw new RuntimeException("Failed to decode activeScript during CarryOnData serialization: " + s);});
|
||||||
}
|
}
|
||||||
|
|
||||||
if(data.contains("selected"))
|
if(data.contains("selected"))
|
||||||
|
|
@ -78,7 +79,7 @@ public class CarryOnData {
|
||||||
if(activeScript != null)
|
if(activeScript != null)
|
||||||
{
|
{
|
||||||
DataResult<Tag> res = CarryOnScript.CODEC.encodeStart(NbtOps.INSTANCE, activeScript);
|
DataResult<Tag> res = CarryOnScript.CODEC.encodeStart(NbtOps.INSTANCE, activeScript);
|
||||||
Tag tag = res.getOrThrow(false, (s) -> {throw new RuntimeException("Failed to encode activeScript during CarryOnData serialization: " + s);});
|
Tag tag = res.getOrThrow((s) -> {throw new RuntimeException("Failed to encode activeScript during CarryOnData serialization: " + s);});
|
||||||
nbt.put("activeScript", tag);
|
nbt.put("activeScript", tag);
|
||||||
}
|
}
|
||||||
nbt.putInt("selected", this.selectedSlot);
|
nbt.putInt("selected", this.selectedSlot);
|
||||||
|
|
@ -106,7 +107,7 @@ public class CarryOnData {
|
||||||
|
|
||||||
if(tile != null)
|
if(tile != null)
|
||||||
{
|
{
|
||||||
CompoundTag tileData = tile.saveWithId();
|
CompoundTag tileData = tile.saveWithId(tile.getLevel().registryAccess());
|
||||||
nbt.put("tile", tileData);
|
nbt.put("tile", tileData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -120,7 +121,7 @@ public class CarryOnData {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public BlockEntity getBlockEntity(BlockPos pos)
|
public BlockEntity getBlockEntity(BlockPos pos, HolderLookup.Provider lookup)
|
||||||
{
|
{
|
||||||
if(this.type != CarryType.BLOCK)
|
if(this.type != CarryType.BLOCK)
|
||||||
throw new IllegalStateException("Called getBlockEntity on data that contained " + this.type);
|
throw new IllegalStateException("Called getBlockEntity on data that contained " + this.type);
|
||||||
|
|
@ -128,7 +129,7 @@ public class CarryOnData {
|
||||||
if(!nbt.contains("tile"))
|
if(!nbt.contains("tile"))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return BlockEntity.loadStatic(pos, this.getBlock(), nbt.getCompound("tile"));
|
return BlockEntity.loadStatic(pos, this.getBlock(), nbt.getCompound("tile"), lookup);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEntity(Entity entity)
|
public void setEntity(Entity entity)
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ public class PickupHandler {
|
||||||
BlockState state = level.getBlockState(pos);
|
BlockState state = level.getBlockState(pos);
|
||||||
CompoundTag nbt = null;
|
CompoundTag nbt = null;
|
||||||
if(blockEntity != null)
|
if(blockEntity != null)
|
||||||
nbt = blockEntity.saveWithId();
|
nbt = blockEntity.saveWithId(level.registryAccess());
|
||||||
|
|
||||||
if(!ListHandler.isPermitted(state.getBlock()))
|
if(!ListHandler.isPermitted(state.getBlock()))
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -228,7 +228,7 @@ public class PickupHandler {
|
||||||
Services.PLATFORM.sendPacketToPlayer(Constants.PACKET_ID_START_RIDING, new ClientboundStartRidingPacket(otherPlayer.getId(), true), player);
|
Services.PLATFORM.sendPacketToPlayer(Constants.PACKET_ID_START_RIDING, new ClientboundStartRidingPacket(otherPlayer.getId(), true), player);
|
||||||
carry.setCarryingPlayer();
|
carry.setCarryingPlayer();
|
||||||
player.swing(InteractionHand.MAIN_HAND, true);
|
player.swing(InteractionHand.MAIN_HAND, true);
|
||||||
player.level().playSound(null, player.getOnPos(), SoundEvents.ARMOR_EQUIP_GENERIC, SoundSource.AMBIENT, 1.0f, 0.5f);
|
player.level().playSound(null, player.getOnPos(), SoundEvents.ARMOR_EQUIP_GENERIC.value(), SoundSource.AMBIENT, 1.0f, 0.5f);
|
||||||
CarryOnDataManager.setCarryData(player, carry);
|
CarryOnDataManager.setCarryData(player, carry);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
@ -250,7 +250,7 @@ public class PickupHandler {
|
||||||
carry.setEntity(entity);
|
carry.setEntity(entity);
|
||||||
entity.remove(RemovalReason.UNLOADED_WITH_PLAYER);
|
entity.remove(RemovalReason.UNLOADED_WITH_PLAYER);
|
||||||
|
|
||||||
player.level().playSound(null, player.getOnPos(), SoundEvents.ARMOR_EQUIP_GENERIC, SoundSource.AMBIENT, 1.0f, 0.5f);
|
player.level().playSound(null, player.getOnPos(), SoundEvents.ARMOR_EQUIP_GENERIC.value(), SoundSource.AMBIENT, 1.0f, 0.5f);
|
||||||
CarryOnDataManager.setCarryData(player, carry);
|
CarryOnDataManager.setCarryData(player, carry);
|
||||||
player.swing(InteractionHand.MAIN_HAND, true);
|
player.swing(InteractionHand.MAIN_HAND, true);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ public class PlacementHandler
|
||||||
|
|
||||||
context = new BlockPlaceContext(player, InteractionHand.MAIN_HAND, ItemStack.EMPTY, BlockHitResult.miss(player.position(), facing, pos));
|
context = new BlockPlaceContext(player, InteractionHand.MAIN_HAND, ItemStack.EMPTY, BlockHitResult.miss(player.position(), facing, pos));
|
||||||
|
|
||||||
BlockEntity blockEntity = carry.getBlockEntity(pos);
|
BlockEntity blockEntity = carry.getBlockEntity(pos, level.registryAccess());
|
||||||
|
|
||||||
state = getPlacementState(state, player, context, pos);
|
state = getPlacementState(state, player, context, pos);
|
||||||
|
|
||||||
|
|
@ -295,7 +295,7 @@ public class PlacementHandler
|
||||||
BlockPlaceContext context = new BlockPlaceContext(player, InteractionHand.MAIN_HAND, ItemStack.EMPTY, BlockHitResult.miss(Vec3.atCenterOf(player.blockPosition()), Direction.DOWN, player.blockPosition()));
|
BlockPlaceContext context = new BlockPlaceContext(player, InteractionHand.MAIN_HAND, ItemStack.EMPTY, BlockHitResult.miss(Vec3.atCenterOf(player.blockPosition()), Direction.DOWN, player.blockPosition()));
|
||||||
BlockState state = getPlacementState(carry.getBlock(), player, context, player.blockPosition());
|
BlockState state = getPlacementState(carry.getBlock(), player, context, player.blockPosition());
|
||||||
BlockPos pos = getDeathPlacementPos(state, player);
|
BlockPos pos = getDeathPlacementPos(state, player);
|
||||||
BlockEntity blockEntity = carry.getBlockEntity(pos);
|
BlockEntity blockEntity = carry.getBlockEntity(pos, player.level().registryAccess());
|
||||||
player.level().setBlock(pos, state, 3);
|
player.level().setBlock(pos, state, 3);
|
||||||
if (blockEntity != null)
|
if (blockEntity != null)
|
||||||
player.level().setBlockEntity(blockEntity);
|
player.level().setBlockEntity(blockEntity);
|
||||||
|
|
|
||||||
|
|
@ -263,7 +263,7 @@ public final class Matchables
|
||||||
for (MobEffectInstance effect : fx)
|
for (MobEffectInstance effect : fx)
|
||||||
{
|
{
|
||||||
int amp = effect.getAmplifier();
|
int amp = effect.getAmplifier();
|
||||||
String name = BuiltInRegistries.MOB_EFFECT.getKey(effect.getEffect()).toString();
|
String name = effect.getEffect().getRegisteredName();
|
||||||
|
|
||||||
if (names.contains(name))
|
if (names.contains(name))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ public class ScriptReloadListener extends SimpleJsonResourceReloadListener
|
||||||
if (player != null)
|
if (player != null)
|
||||||
{
|
{
|
||||||
DataResult<Tag> result = Codec.list(CarryOnScript.CODEC).encodeStart(NbtOps.INSTANCE, ScriptManager.SCRIPTS);
|
DataResult<Tag> result = Codec.list(CarryOnScript.CODEC).encodeStart(NbtOps.INSTANCE, ScriptManager.SCRIPTS);
|
||||||
Tag tag = result.getOrThrow(false, s -> {throw new RuntimeException("Error while synching Carry On Scripts: " + s);});
|
Tag tag = result.getOrThrow(s -> {throw new RuntimeException("Error while synching Carry On Scripts: " + s);});
|
||||||
|
|
||||||
Services.PLATFORM.sendPacketToPlayer(Constants.PACKET_ID_SYNC_SCRIPTS, new ClientboundSyncScriptsPacket(tag), player);
|
Services.PLATFORM.sendPacketToPlayer(Constants.PACKET_ID_SYNC_SCRIPTS, new ClientboundSyncScriptsPacket(tag), player);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ package tschipp.carryon.config;
|
||||||
|
|
||||||
//Many Thanks to ThatGravyBoat for this template!
|
//Many Thanks to ThatGravyBoat for this template!
|
||||||
|
|
||||||
|
import net.minecraft.core.HolderLookup;
|
||||||
import tschipp.carryon.client.modeloverride.ModelOverrideHandler;
|
import tschipp.carryon.client.modeloverride.ModelOverrideHandler;
|
||||||
import tschipp.carryon.common.config.ListHandler;
|
import tschipp.carryon.common.config.ListHandler;
|
||||||
import tschipp.carryon.common.pickupcondition.PickupConditionHandler;
|
import tschipp.carryon.common.pickupcondition.PickupConditionHandler;
|
||||||
|
|
@ -53,10 +54,10 @@ public class ConfigLoader {
|
||||||
Services.PLATFORM.registerConfig(config);
|
Services.PLATFORM.registerConfig(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onConfigLoaded() {
|
public static void onConfigLoaded(HolderLookup.Provider provider) {
|
||||||
ListHandler.initConfigLists();
|
ListHandler.initConfigLists();
|
||||||
PickupConditionHandler.initPickupConditions();
|
PickupConditionHandler.initPickupConditions();
|
||||||
ModelOverrideHandler.initModelOverrides();
|
ModelOverrideHandler.initModelOverrides(provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BuiltCategory buildCategory(String categoryDesc, Object object) throws IllegalAccessException {
|
public static BuiltCategory buildCategory(String categoryDesc, Object object) throws IllegalAccessException {
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ package tschipp.carryon.mixin;
|
||||||
|
|
||||||
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.network.syncher.SynchedEntityData;
|
||||||
import net.minecraft.world.entity.EntityType;
|
import net.minecraft.world.entity.EntityType;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
|
@ -40,9 +41,9 @@ public abstract class PlayerMixin extends LivingEntity {
|
||||||
super(type, level);
|
super(type, level);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "defineSynchedData()V", at = @At("RETURN"))
|
@Inject(method = "defineSynchedData(Lnet/minecraft/network/syncher/SynchedEntityData$Builder;)V", at = @At("RETURN"))
|
||||||
private void onDefineSynchedData(CallbackInfo info) {
|
private void onDefineSynchedData(SynchedEntityData.Builder builder, CallbackInfo ci) {
|
||||||
this.entityData.define(CarryOnDataManager.CARRY_DATA_KEY, new CompoundTag());
|
builder.define(CarryOnDataManager.CARRY_DATA_KEY, new CompoundTag());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "addAdditionalSaveData(Lnet/minecraft/nbt/CompoundTag;)V", at = @At("RETURN"))
|
@Inject(method = "addAdditionalSaveData(Lnet/minecraft/nbt/CompoundTag;)V", at = @At("RETURN"))
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ public record ClientboundSyncScriptsPacket(Tag serialized) implements PacketBase
|
||||||
public void handle(Player player)
|
public void handle(Player player)
|
||||||
{
|
{
|
||||||
DataResult<List<CarryOnScript>> res = Codec.list(CarryOnScript.CODEC).parse(NbtOps.INSTANCE, serialized);
|
DataResult<List<CarryOnScript>> res = Codec.list(CarryOnScript.CODEC).parse(NbtOps.INSTANCE, serialized);
|
||||||
List<CarryOnScript> scripts = res.getOrThrow(false, (s) -> {throw new RuntimeException("Failed deserializing carry on scripts on the client: " + s);});
|
List<CarryOnScript> scripts = res.getOrThrow((s) -> {throw new RuntimeException("Failed deserializing carry on scripts on the client: " + s);});
|
||||||
ScriptManager.SCRIPTS.clear();
|
ScriptManager.SCRIPTS.clear();
|
||||||
ScriptManager.SCRIPTS.addAll(scripts);
|
ScriptManager.SCRIPTS.addAll(scripts);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
package tschipp.carryon.platform.services;
|
package tschipp.carryon.platform.services;
|
||||||
|
|
||||||
|
import net.minecraft.core.HolderLookup;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
|
@ -63,5 +64,4 @@ public interface IPlatformHelper {
|
||||||
void sendPacketToServer(ResourceLocation id, PacketBase packet);
|
void sendPacketToServer(ResourceLocation id, PacketBase packet);
|
||||||
|
|
||||||
void sendPacketToPlayer(ResourceLocation id, PacketBase packet, ServerPlayer player);
|
void sendPacketToPlayer(ResourceLocation id, PacketBase packet, ServerPlayer player);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ plugins {
|
||||||
id 'java'
|
id 'java'
|
||||||
id 'maven-publish'
|
id 'maven-publish'
|
||||||
id 'idea'
|
id 'idea'
|
||||||
id 'fabric-loom' version '1.5-SNAPSHOT'
|
id 'fabric-loom' version '1.6-SNAPSHOT'
|
||||||
}
|
}
|
||||||
base {
|
base {
|
||||||
archivesName = "${mod_id}-fabric-${minecraft_version}"
|
archivesName = "${mod_id}-fabric-${minecraft_version}"
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ public class CommonEvents {
|
||||||
|
|
||||||
CommonLifecycleEvents.TAGS_LOADED.register((registries, client) -> {
|
CommonLifecycleEvents.TAGS_LOADED.register((registries, client) -> {
|
||||||
if(!client)
|
if(!client)
|
||||||
ConfigLoader.onConfigLoaded();
|
ConfigLoader.onConfigLoaded(registries);
|
||||||
});
|
});
|
||||||
|
|
||||||
UseBlockCallback.EVENT.register((player, world, hand, hitResult) -> {
|
UseBlockCallback.EVENT.register((player, world, hand, hitResult) -> {
|
||||||
|
|
|
||||||
|
|
@ -119,6 +119,9 @@ dependencies {
|
||||||
filename = filename.substring(0, lastDash) + ":" + filename.substring(lastDash+1, filename.length());
|
filename = filename.substring(0, lastDash) + ":" + filename.substring(lastDash+1, filename.length());
|
||||||
implementation fg.deobf("blank:${filename}")
|
implementation fg.deobf("blank:${filename}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Hack fix for now, force jopt-simple to be exactly 5.0.4 because Mojang ships that version, but some transitive dependencies request 6.0+
|
||||||
|
implementation('net.sf.jopt-simple:jopt-simple:5.0.4') { version { strictly '5.0.4' } }
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType(JavaCompile).configureEach {
|
tasks.withType(JavaCompile).configureEach {
|
||||||
|
|
|
||||||
|
|
@ -22,13 +22,21 @@ package tschipp.carryon.config.forge;
|
||||||
|
|
||||||
import com.electronwill.nightconfig.core.AbstractConfig;
|
import com.electronwill.nightconfig.core.AbstractConfig;
|
||||||
import com.electronwill.nightconfig.core.UnmodifiableConfig;
|
import com.electronwill.nightconfig.core.UnmodifiableConfig;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.common.ForgeConfigSpec;
|
import net.minecraftforge.common.ForgeConfigSpec;
|
||||||
|
import net.minecraftforge.common.util.LogicalSidedProvider;
|
||||||
import net.minecraftforge.eventbus.api.IEventBus;
|
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.ModLoadingContext;
|
||||||
import net.minecraftforge.fml.config.IConfigSpec;
|
import net.minecraftforge.fml.config.IConfigSpec;
|
||||||
import net.minecraftforge.fml.config.ModConfig;
|
import net.minecraftforge.fml.config.ModConfig;
|
||||||
import net.minecraftforge.fml.event.config.ModConfigEvent;
|
import net.minecraftforge.fml.event.config.ModConfigEvent;
|
||||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||||
|
import net.minecraftforge.fml.loading.FMLServiceProvider;
|
||||||
|
import net.minecraftforge.server.ServerLifecycleHooks;
|
||||||
import tschipp.carryon.config.*;
|
import tschipp.carryon.config.*;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
@ -52,12 +60,27 @@ public class ConfigLoaderImpl {
|
||||||
|
|
||||||
public static void onConfigLoad(ModConfigEvent.Loading loading) {
|
public static void onConfigLoad(ModConfigEvent.Loading loading) {
|
||||||
loadConfig(loading.getConfig().getSpec());
|
loadConfig(loading.getConfig().getSpec());
|
||||||
ConfigLoader.onConfigLoaded();
|
|
||||||
|
|
||||||
|
DistExecutor.safeRunWhenOn(Dist.CLIENT, () -> () -> {
|
||||||
|
ConfigLoader.onConfigLoaded(Minecraft.getInstance().level.registryAccess());
|
||||||
|
});
|
||||||
|
|
||||||
|
DistExecutor.safeRunWhenOn(Dist.DEDICATED_SERVER, () -> () -> {
|
||||||
|
ConfigLoader.onConfigLoaded(ServerLifecycleHooks.getCurrentServer().registryAccess());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onConfigReload(ModConfigEvent.Reloading loading) {
|
public static void onConfigReload(ModConfigEvent.Reloading loading) {
|
||||||
loadConfig(loading.getConfig().getSpec());
|
loadConfig(loading.getConfig().getSpec());
|
||||||
ConfigLoader.onConfigLoaded();
|
|
||||||
|
DistExecutor.safeRunWhenOn(Dist.CLIENT, () -> () -> {
|
||||||
|
ConfigLoader.onConfigLoaded(Minecraft.getInstance().level.registryAccess());
|
||||||
|
});
|
||||||
|
|
||||||
|
DistExecutor.safeRunWhenOn(Dist.DEDICATED_SERVER, () -> () -> {
|
||||||
|
ConfigLoader.onConfigLoaded(ServerLifecycleHooks.getCurrentServer().registryAccess());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void loadConfig(IConfigSpec<ForgeConfigSpec> spec) {
|
private static void loadConfig(IConfigSpec<ForgeConfigSpec> spec) {
|
||||||
|
|
|
||||||
|
|
@ -93,13 +93,9 @@ public class ClientEvents {
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onClientTick(ClientTickEvent event)
|
public static void onClientTick(ClientTickEvent.Post event)
|
||||||
{
|
{
|
||||||
if(event.phase == Phase.END)
|
CarryOnCommonClient.checkForKeybinds();
|
||||||
{
|
CarryOnCommonClient.onCarryClientTick();
|
||||||
CarryOnCommonClient.checkForKeybinds();
|
|
||||||
CarryOnCommonClient.onCarryClientTick();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -172,15 +172,14 @@ public class CommonEvents
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onTagsUpdate(TagsUpdatedEvent event)
|
public static void onTagsUpdate(TagsUpdatedEvent event)
|
||||||
{
|
{
|
||||||
ConfigLoader.onConfigLoaded();
|
ConfigLoader.onConfigLoaded(event.getRegistryAccess());
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onServerTick(ServerTickEvent event)
|
public static void onServerTick(ServerTickEvent.Post event)
|
||||||
{
|
{
|
||||||
if (event.phase == Phase.END)
|
for (ServerPlayer player : event.getServer().getPlayerList().getPlayers())
|
||||||
for (ServerPlayer player : event.getServer().getPlayerList().getPlayers())
|
CarryOnCommon.onCarryTick(player);
|
||||||
CarryOnCommon.onCarryTick(player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ public class ModBusEvents {
|
||||||
ListHandler.addAllowedStacking(str);
|
ListHandler.addAllowedStacking(str);
|
||||||
break;
|
break;
|
||||||
case "addModelOverride":
|
case "addModelOverride":
|
||||||
ModelOverrideHandler.addFromString(str);
|
//ModelOverrideHandler.addFromString(str, event);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
plugins {
|
plugins {
|
||||||
id 'idea'
|
id 'idea'
|
||||||
id 'maven-publish'
|
id 'maven-publish'
|
||||||
id 'net.neoforged.gradle.userdev' version '7.0.81'
|
id 'net.neoforged.gradle.userdev' version '7.0.142'
|
||||||
id 'java-library'
|
id 'java-library'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,11 @@ package tschipp.carryon.config.neoforge;
|
||||||
|
|
||||||
import com.electronwill.nightconfig.core.AbstractConfig;
|
import com.electronwill.nightconfig.core.AbstractConfig;
|
||||||
import com.electronwill.nightconfig.core.UnmodifiableConfig;
|
import com.electronwill.nightconfig.core.UnmodifiableConfig;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.neoforged.api.distmarker.Dist;
|
||||||
import net.neoforged.bus.api.IEventBus;
|
import net.neoforged.bus.api.IEventBus;
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
|
import net.neoforged.fml.DistExecutor;
|
||||||
import net.neoforged.fml.ModLoadingContext;
|
import net.neoforged.fml.ModLoadingContext;
|
||||||
import net.neoforged.fml.common.Mod;
|
import net.neoforged.fml.common.Mod;
|
||||||
import net.neoforged.fml.config.IConfigSpec;
|
import net.neoforged.fml.config.IConfigSpec;
|
||||||
|
|
@ -54,12 +57,24 @@ public class ConfigLoaderImpl {
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onConfigLoad(ModConfigEvent.Loading loading) {
|
public static void onConfigLoad(ModConfigEvent.Loading loading) {
|
||||||
loadConfig(loading.getConfig().getSpec());
|
loadConfig(loading.getConfig().getSpec());
|
||||||
ConfigLoader.onConfigLoaded();
|
DistExecutor.safeRunWhenOn(Dist.CLIENT, () -> () -> {
|
||||||
|
ConfigLoader.onConfigLoaded(Minecraft.getInstance().level.registryAccess());
|
||||||
|
});
|
||||||
|
|
||||||
|
DistExecutor.safeRunWhenOn(Dist.DEDICATED_SERVER, () -> () -> {
|
||||||
|
ConfigLoader.onConfigLoaded(ServerLifecycleHooks.getCurrentServer().registryAccess());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onConfigReload(ModConfigEvent.Reloading loading) {
|
public static void onConfigReload(ModConfigEvent.Reloading loading) {
|
||||||
loadConfig(loading.getConfig().getSpec());
|
loadConfig(loading.getConfig().getSpec());
|
||||||
ConfigLoader.onConfigLoaded();
|
DistExecutor.safeRunWhenOn(Dist.CLIENT, () -> () -> {
|
||||||
|
ConfigLoader.onConfigLoaded(Minecraft.getInstance().level.registryAccess());
|
||||||
|
});
|
||||||
|
|
||||||
|
DistExecutor.safeRunWhenOn(Dist.DEDICATED_SERVER, () -> () -> {
|
||||||
|
ConfigLoader.onConfigLoaded(ServerLifecycleHooks.getCurrentServer().registryAccess());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void loadConfig(IConfigSpec<ModConfigSpec> spec) {
|
private static void loadConfig(IConfigSpec<ModConfigSpec> spec) {
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ subprojects {
|
||||||
|
|
||||||
apply plugin: 'java'
|
apply plugin: 'java'
|
||||||
|
|
||||||
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
|
java.toolchain.languageVersion = JavaLanguageVersion.of(21)
|
||||||
java.withSourcesJar()
|
java.withSourcesJar()
|
||||||
java.withJavadocJar()
|
java.withJavadocJar()
|
||||||
|
|
||||||
|
|
@ -55,7 +55,7 @@ subprojects {
|
||||||
tasks.withType(JavaCompile).configureEach {
|
tasks.withType(JavaCompile).configureEach {
|
||||||
|
|
||||||
it.options.encoding = 'UTF-8'
|
it.options.encoding = 'UTF-8'
|
||||||
it.options.release = 17
|
it.options.release = 21
|
||||||
}
|
}
|
||||||
|
|
||||||
processResources {
|
processResources {
|
||||||
|
|
|
||||||
|
|
@ -1,33 +1,33 @@
|
||||||
# Project
|
# Project
|
||||||
version=2.1.3
|
version=2.1.4
|
||||||
group=tschipp.carryon
|
group=tschipp.carryon
|
||||||
|
|
||||||
# Common
|
# Common
|
||||||
minecraft_version=1.20.4
|
minecraft_version=1.20.6
|
||||||
mod_name=Carry On
|
mod_name=Carry On
|
||||||
mod_author=Tschipp, PurpliciousCow
|
mod_author=Tschipp, PurpliciousCow
|
||||||
mod_id=carryon
|
mod_id=carryon
|
||||||
license=GNU LGPLv3
|
license=GNU LGPLv3
|
||||||
credits=
|
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.
|
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.20.4, 1.21)
|
minecraft_version_range=[1.20.6, 1.21)
|
||||||
# Forge
|
# Forge
|
||||||
forge_version=49.0.30
|
forge_version=50.1.7
|
||||||
forge_loader_version_range=[49,)
|
forge_loader_version_range=[49,)
|
||||||
forge_version_range=[49,)
|
forge_version_range=[49,)
|
||||||
parchment_mappings=1.20.3-2023.12.31-1.20.4
|
parchment_mappings=2024.06.16-1.20.6
|
||||||
//forge_ats_enabled=true
|
//forge_ats_enabled=true
|
||||||
|
|
||||||
# Fabric
|
# Fabric
|
||||||
fabric_version=0.96.3+1.20.4
|
fabric_version=0.100.2+1.20.6
|
||||||
fabric_loader_version=0.15.7
|
fabric_loader_version=0.15.11
|
||||||
parchment_mappings_fabric=1.20.3:2023.12.31
|
parchment_mappings_fabric=1.20.6:2024.06.16
|
||||||
|
|
||||||
# Neoforge
|
# Neoforge
|
||||||
neoforge_version=20.4.163-beta
|
neoforge_version=20.6.119
|
||||||
neoforge_loader_version_range=[2,)
|
neoforge_loader_version_range=[2,)
|
||||||
neogradle.subsystems.parchment.minecraftVersion=1.20.3
|
neogradle.subsystems.parchment.minecraftVersion=1.20.6
|
||||||
neogradle.subsystems.parchment.mappingsVersion=2023.12.31
|
neogradle.subsystems.parchment.mappingsVersion=2024.06.16
|
||||||
|
|
||||||
|
|
||||||
# Gradle
|
# Gradle
|
||||||
|
|
|
||||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
3
gradle/wrapper/gradle-wrapper.properties
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
|
|
@ -1,7 +1,6 @@
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
validateDistributionUrl=true
|
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user