Updated to 1.21.3
This commit is contained in:
parent
d3ab092d4f
commit
058b547c30
|
|
@ -81,7 +81,7 @@ public class ModelOverride
|
|||
BlockResult res;
|
||||
|
||||
try {
|
||||
res = BlockStateParser.parseForBlock(BuiltInRegistries.BLOCK.asLookup(), from, true);
|
||||
res = BlockStateParser.parseForBlock(BuiltInRegistries.BLOCK, from, true);
|
||||
} catch (Exception e) {
|
||||
return DataResult.error(() -> "Error while parsing " + from + ":" + e.getMessage());
|
||||
}
|
||||
|
|
@ -101,7 +101,7 @@ public class ModelOverride
|
|||
if(type == Type.ITEM)
|
||||
either = Either.left(new ItemParser(provider).parse(new StringReader(to)));
|
||||
else
|
||||
either = Either.right(BlockStateParser.parseForBlock(BuiltInRegistries.BLOCK.asLookup(), to, true));
|
||||
either = Either.right(BlockStateParser.parseForBlock(BuiltInRegistries.BLOCK, to, true));
|
||||
}catch (CommandSyntaxException e) {
|
||||
String finalTo = to;
|
||||
return DataResult.error(() -> "Error while parsing " + finalTo + ":" + e.getMessage());
|
||||
|
|
|
|||
|
|
@ -63,8 +63,8 @@ public class CarriedObjectRender
|
|||
RenderType.glint(), new ByteBufferBuilder(RenderType.glint().bufferSize()),
|
||||
RenderType.armorEntityGlint(), new ByteBufferBuilder(RenderType.armorEntityGlint().bufferSize()),
|
||||
RenderType.glintTranslucent(), new ByteBufferBuilder(RenderType.glintTranslucent().bufferSize()),
|
||||
RenderType.entityGlint(), new ByteBufferBuilder(RenderType.entityGlint().bufferSize()),
|
||||
RenderType.entityGlintDirect(), new ByteBufferBuilder(RenderType.entityGlintDirect().bufferSize())
|
||||
RenderType.entityGlint(), new ByteBufferBuilder(RenderType.entityGlint().bufferSize())
|
||||
//RenderType.entityGlintDirect(), new ByteBufferBuilder(RenderType.entityGlintDirect().bufferSize())
|
||||
));
|
||||
|
||||
public static boolean drawFirstPerson(Player player, MultiBufferSource buffer, PoseStack matrix, int light, float partialTicks)
|
||||
|
|
@ -163,7 +163,7 @@ public class CarriedObjectRender
|
|||
((LivingEntity) entity).hurtTime = 0;
|
||||
|
||||
try {
|
||||
manager.render(entity, 0, 0, 0, 0f, 0, matrix, buffer, light);
|
||||
manager.render(entity, 0, 0, 0, 0f, matrix, buffer, light);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
@ -256,7 +256,7 @@ public class CarriedObjectRender
|
|||
|
||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
manager.render(entity, 0, 0, 0, 0f, 0, matrix, buffer, light);
|
||||
manager.render(entity, 0, 0, 0, 0f, matrix, buffer, light);
|
||||
matrix.popPose();
|
||||
manager.setRenderShadow(true);
|
||||
matrix.popPose();
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ import net.minecraft.core.registries.BuiltInRegistries;
|
|||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntitySpawnReason;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.Pose;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
|
@ -270,7 +271,7 @@ public class CarryRenderHelper
|
|||
ScriptRender render = carry.getActiveScript().get().scriptRender();
|
||||
if(render.renderNameBlock().isPresent())
|
||||
{
|
||||
state = BuiltInRegistries.BLOCK.get(render.renderNameBlock().get()).defaultBlockState();
|
||||
state = BuiltInRegistries.BLOCK.get(render.renderNameBlock().get()).get().value().defaultBlockState();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -318,7 +319,7 @@ public class CarryRenderHelper
|
|||
CarryOnScript script = carry.getActiveScript().get();
|
||||
ScriptRender render = script.scriptRender();
|
||||
if(render.renderNameEntity().isPresent())
|
||||
entity = BuiltInRegistries.ENTITY_TYPE.get(render.renderNameEntity().get()).create(player.level());
|
||||
entity = BuiltInRegistries.ENTITY_TYPE.get(render.renderNameEntity().get()).get().value().create(player.level(), EntitySpawnReason.BUCKET);
|
||||
|
||||
if(render.renderNBT().isPresent())
|
||||
entity.load(render.renderNBT().get());
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
package tschipp.carryon.client.render;
|
||||
|
||||
import tschipp.carryon.common.carry.CarryOnData;
|
||||
|
||||
public interface ICarryOnRenderState {
|
||||
|
||||
CarryOnData getCarryOnData();
|
||||
|
||||
void setCarryOnData(CarryOnData data);
|
||||
|
||||
float getRenderWidth();
|
||||
|
||||
void setRenderWidth(float val);
|
||||
|
||||
}
|
||||
|
|
@ -30,6 +30,7 @@ import net.minecraft.nbt.NbtUtils;
|
|||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.world.entity.AreaEffectCloud;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntitySpawnReason;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
|
|
@ -117,7 +118,7 @@ public class CarryOnData {
|
|||
if(this.type != CarryType.BLOCK)
|
||||
throw new IllegalStateException("Called getBlock on data that contained " + this.type);
|
||||
|
||||
return NbtUtils.readBlockState(BuiltInRegistries.BLOCK.asLookup(), nbt.getCompound("block"));
|
||||
return NbtUtils.readBlockState(BuiltInRegistries.BLOCK, nbt.getCompound("block"));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
|
@ -145,7 +146,7 @@ public class CarryOnData {
|
|||
if(this.type != CarryType.ENTITY)
|
||||
throw new IllegalStateException("Called getEntity on data that contained " + this.type);
|
||||
|
||||
var optionalEntity = EntityType.create(nbt.getCompound("entity"), level);
|
||||
var optionalEntity = EntityType.create(nbt.getCompound("entity"), level, EntitySpawnReason.BUCKET);
|
||||
if(optionalEntity.isPresent())
|
||||
return optionalEntity.get();
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ package tschipp.carryon.common.carry;
|
|||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
|
|
@ -37,7 +38,6 @@ import net.minecraft.world.level.block.Block;
|
|||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
import net.minecraft.world.level.block.state.properties.DirectionProperty;
|
||||
import net.minecraft.world.level.block.state.properties.Property;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
|
@ -119,7 +119,7 @@ public class PlacementHandler
|
|||
placementState = state;
|
||||
|
||||
for (var prop : placementState.getProperties()) {
|
||||
if (prop instanceof DirectionProperty)
|
||||
if (prop.getValueClass() == Direction.class)
|
||||
state = updateProperty(state, placementState, prop);
|
||||
if (prop.getValueClass() == Direction.Axis.class)
|
||||
state = updateProperty(state, placementState, prop);
|
||||
|
|
@ -280,7 +280,7 @@ public class PlacementHandler
|
|||
public static void placeCarriedOnDeath(ServerPlayer oldPlayer, ServerPlayer newPlayer, boolean died)
|
||||
{
|
||||
CarryOnData carry = CarryOnDataManager.getCarryData(oldPlayer);
|
||||
if (oldPlayer.level().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || !died) {
|
||||
if (((ServerLevel) oldPlayer.level()).getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || !died) {
|
||||
if (!carry.isCarrying(CarryType.PLAYER)) {
|
||||
CarryOnDataManager.setCarryData(newPlayer, carry);
|
||||
newPlayer.getInventory().selected = oldPlayer.getInventory().selected;
|
||||
|
|
|
|||
|
|
@ -119,8 +119,8 @@ public class ListHandler {
|
|||
ALLOWED_TILES_TAGS.clear();
|
||||
PROPERTY_EXCEPTION_CLASSES.clear();
|
||||
|
||||
Map<ResourceLocation, TagKey<Block>> blocktags = BuiltInRegistries.BLOCK.getTagNames().collect(Collectors.toMap(t -> t.location(), t -> t));
|
||||
Map<ResourceLocation, TagKey<EntityType<?>>> entitytags = BuiltInRegistries.ENTITY_TYPE.getTagNames().collect(Collectors.toMap(t -> t.location(), t -> t));
|
||||
Map<ResourceLocation, TagKey<Block>> blocktags = BuiltInRegistries.BLOCK.listTagIds().collect(Collectors.toMap(t -> t.location(), t -> t));
|
||||
Map<ResourceLocation, TagKey<EntityType<?>>> entitytags = BuiltInRegistries.ENTITY_TYPE.listTagIds().collect(Collectors.toMap(t -> t.location(), t -> t));
|
||||
|
||||
List<String> forbidden = new ArrayList<>(List.of(Constants.COMMON_CONFIG.blacklist.forbiddenTiles));
|
||||
forbidden.add("#carryon:block_blacklist");
|
||||
|
|
@ -152,7 +152,7 @@ public class ListHandler {
|
|||
continue;
|
||||
String name = propString.substring(0, propString.indexOf("["));
|
||||
String props = propString.substring(propString.indexOf("[") + 1, propString.indexOf("]"));
|
||||
Block blk = BuiltInRegistries.BLOCK.get(ResourceLocation.parse(name));
|
||||
Block blk = BuiltInRegistries.BLOCK.get(ResourceLocation.parse(name)).get().value();
|
||||
for(String propName : props.split(",")) {
|
||||
for (Property<?> prop : blk.defaultBlockState().getProperties()) {
|
||||
if (prop.getName().equals(propName))
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ public class PickupCondition
|
|||
private BlockResult parseState(String state)
|
||||
{
|
||||
try {
|
||||
BlockResult result = BlockStateParser.parseForBlock(BuiltInRegistries.BLOCK.asLookup(), state, false);
|
||||
BlockResult result = BlockStateParser.parseForBlock(BuiltInRegistries.BLOCK, state, false);
|
||||
return result;
|
||||
} catch (CommandSyntaxException e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ public class ScriptManager
|
|||
|
||||
boolean matchblock = true;
|
||||
if(scBlock.typeNameBlock().isPresent())
|
||||
matchblock = block == BuiltInRegistries.BLOCK.get(scBlock.typeNameBlock().get());
|
||||
matchblock = block == BuiltInRegistries.BLOCK.get(scBlock.typeNameBlock().get()).get().value();
|
||||
boolean matchnbt = scBlock.typeBlockTag().matches(nbt);
|
||||
boolean matchhardness = scBlock.typeHardness().matches(hardness);
|
||||
boolean matchresistance = scBlock.typeResistance().matches(resistance);
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import com.google.gson.JsonElement;
|
|||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.DataResult;
|
||||
import com.mojang.serialization.JsonOps;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtOps;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
|
@ -41,41 +42,27 @@ import tschipp.carryon.platform.Services;
|
|||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
public class ScriptReloadListener extends SimpleJsonResourceReloadListener
|
||||
public class ScriptReloadListener extends SimpleJsonResourceReloadListener<CarryOnScript>
|
||||
{
|
||||
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create();
|
||||
|
||||
public ScriptReloadListener()
|
||||
{
|
||||
super(GSON, "carryon/scripts");
|
||||
super(CarryOnScript.CODEC, "carryon/scripts");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void apply(Map<ResourceLocation, JsonElement> objects, ResourceManager manager, ProfilerFiller profiler)
|
||||
protected void apply(Map<ResourceLocation, CarryOnScript> scripts, ResourceManager resourceManager, ProfilerFiller profilerFiller)
|
||||
{
|
||||
ScriptManager.SCRIPTS.clear();
|
||||
|
||||
try {
|
||||
objects.forEach((path, jsonElem) -> {
|
||||
DataResult<CarryOnScript> res = CarryOnScript.CODEC.parse(JsonOps.INSTANCE, jsonElem);
|
||||
if(res.result().isPresent())
|
||||
{
|
||||
CarryOnScript script = res.result().get();
|
||||
if (script.isValid())
|
||||
ScriptManager.SCRIPTS.add(script);
|
||||
}
|
||||
else
|
||||
Constants.LOG.warn("Error while parsing script: " + res.error().get().message());
|
||||
});
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
scripts.forEach((path, script) -> {
|
||||
if (script.isValid())
|
||||
ScriptManager.SCRIPTS.add(script);
|
||||
});
|
||||
|
||||
Collections.sort(ScriptManager.SCRIPTS, (s1, s2) -> Long.compare(s2.priority(), s1.priority()));
|
||||
}
|
||||
|
||||
|
||||
public static void syncScriptsWithClient(ServerPlayer player)
|
||||
{
|
||||
if (player != null)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,35 @@
|
|||
package tschipp.carryon.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import net.minecraft.client.renderer.entity.EntityRenderer;
|
||||
import net.minecraft.client.renderer.entity.state.EntityRenderState;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import tschipp.carryon.client.render.CarryRenderHelper;
|
||||
import tschipp.carryon.client.render.ICarryOnRenderState;
|
||||
import tschipp.carryon.common.carry.CarryOnData;
|
||||
import tschipp.carryon.common.carry.CarryOnDataManager;
|
||||
|
||||
@Mixin(EntityRenderer.class)
|
||||
public class EntityRendererMixin {
|
||||
|
||||
@Inject(at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/client/renderer/entity/EntityRenderer;extractRenderState(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/client/renderer/entity/state/EntityRenderState;F)V",
|
||||
shift = At.Shift.AFTER
|
||||
), method = "createRenderState(Lnet/minecraft/world/entity/Entity;F)Lnet/minecraft/client/renderer/entity/state/EntityRenderState;")
|
||||
private void onCreateRenderState(Entity entity, float $$1, CallbackInfoReturnable<EntityRenderState> cir, @Local(ordinal = 0) EntityRenderState state) {
|
||||
|
||||
if (entity instanceof Player player) {
|
||||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||
|
||||
ICarryOnRenderState carryOnRenderState = (ICarryOnRenderState) state;
|
||||
carryOnRenderState.setCarryOnData(carry);
|
||||
carryOnRenderState.setRenderWidth(CarryRenderHelper.getRenderWidth(player));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -22,8 +22,8 @@ package tschipp.carryon.mixin;
|
|||
|
||||
import net.minecraft.client.model.HumanoidModel;
|
||||
import net.minecraft.client.model.geom.ModelPart;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.client.renderer.entity.state.HumanoidRenderState;
|
||||
import net.minecraft.client.renderer.entity.state.PlayerRenderState;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
|
@ -32,9 +32,8 @@ 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.Constants;
|
||||
import tschipp.carryon.client.render.CarryRenderHelper;
|
||||
import tschipp.carryon.client.render.ICarryOnRenderState;
|
||||
import tschipp.carryon.common.carry.CarryOnData;
|
||||
import tschipp.carryon.common.carry.CarryOnDataManager;
|
||||
import tschipp.carryon.common.scripting.CarryOnScript.ScriptRender;
|
||||
|
||||
@Mixin(HumanoidModel.class)
|
||||
|
|
@ -46,20 +45,20 @@ public class HumanoidModelMixin {
|
|||
@Shadow
|
||||
public ModelPart leftArm;
|
||||
|
||||
@Inject(at = @At("RETURN"), method = "setupAnim(Lnet/minecraft/world/entity/LivingEntity;FFFFF)V")
|
||||
private void onSetupAnimations(LivingEntity living, float f1, float f2, float f3, float f4, float f5, CallbackInfo ci)
|
||||
@Inject(at = @At("RETURN"), method = "setupAnim(Lnet/minecraft/client/renderer/entity/state/HumanoidRenderState;)V")
|
||||
private void onSetupAnimations(HumanoidRenderState state, CallbackInfo ci)
|
||||
{
|
||||
if(living instanceof Player player && Constants.CLIENT_CONFIG.renderArms)
|
||||
if(state instanceof ICarryOnRenderState carryOnRenderState && Constants.CLIENT_CONFIG.renderArms)
|
||||
{
|
||||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||
if(carry.isCarrying() && !player.isVisuallySwimming() && !player.isFallFlying())
|
||||
CarryOnData carry = carryOnRenderState.getCarryOnData();
|
||||
if(carry.isCarrying() && !state.isVisuallySwimming && !state.isFallFlying)
|
||||
{
|
||||
boolean sneaking = !player.getAbilities().flying && player.isShiftKeyDown() || player.isCrouching();
|
||||
boolean sneaking = state.isCrouching;
|
||||
|
||||
float x = 1.0f + (sneaking ? 0.2f : 0.0f) + (carry.isCarrying(CarryOnData.CarryType.BLOCK) ? 0.0f : 0.3f);
|
||||
float z = 0.05f;
|
||||
|
||||
float width = CarryRenderHelper.getRenderWidth(player);
|
||||
float width = carryOnRenderState.getRenderWidth();
|
||||
float offset = Math.min((width - 1) / 1.5f, 0.2f);
|
||||
|
||||
if(carry.getActiveScript().isPresent())
|
||||
|
|
|
|||
|
|
@ -76,8 +76,8 @@ public class InventoryMixin
|
|||
info.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = "swapPaint(D)V", at = @At("HEAD"), cancellable = true)
|
||||
private void onSwapPaint(double direction, CallbackInfo info)
|
||||
@Inject(method = "setSelectedHotbarSlot(I)V", at = @At("HEAD"), cancellable = true)
|
||||
private void onSwapPaint(int $$0, CallbackInfo info)
|
||||
{
|
||||
if(CarryOnDataManager.getCarryData(player).isCarrying())
|
||||
info.cancel();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,41 @@
|
|||
package tschipp.carryon.mixin;
|
||||
|
||||
import net.minecraft.client.renderer.entity.state.PlayerRenderState;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import tschipp.carryon.client.render.ICarryOnRenderState;
|
||||
import tschipp.carryon.common.carry.CarryOnData;
|
||||
|
||||
@Mixin(PlayerRenderState.class)
|
||||
public class PlayerRenderStateMixin implements ICarryOnRenderState {
|
||||
|
||||
@Unique
|
||||
public CarryOnData carryOnData = null;
|
||||
|
||||
@Unique
|
||||
public float renderWidth = 0f;
|
||||
|
||||
@Unique
|
||||
@Override
|
||||
public CarryOnData getCarryOnData() {
|
||||
return carryOnData;
|
||||
}
|
||||
|
||||
@Unique
|
||||
@Override
|
||||
public void setCarryOnData(CarryOnData data) {
|
||||
carryOnData = data;
|
||||
}
|
||||
|
||||
@Unique
|
||||
@Override
|
||||
public float getRenderWidth() {
|
||||
return renderWidth;
|
||||
}
|
||||
|
||||
@Unique
|
||||
@Override
|
||||
public void setRenderWidth(float val) {
|
||||
renderWidth = val;
|
||||
}
|
||||
}
|
||||
|
|
@ -10,7 +10,9 @@
|
|||
],
|
||||
"client": [
|
||||
"HumanoidModelMixin",
|
||||
"MinecraftMixin"
|
||||
"MinecraftMixin",
|
||||
"PlayerRenderStateMixin",
|
||||
"EntityRendererMixin"
|
||||
],
|
||||
"server": [
|
||||
],
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"pack": {
|
||||
"description": "${mod_name}",
|
||||
"pack_format": 8
|
||||
"pack_format": 34
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@ plugins {
|
|||
id 'java'
|
||||
id 'maven-publish'
|
||||
id 'idea'
|
||||
id 'fabric-loom' version '1.6-SNAPSHOT'
|
||||
id 'fabric-loom' version '1.8-SNAPSHOT'
|
||||
}
|
||||
base {
|
||||
archivesName = "${mod_id}-fabric-${minecraft_version}"
|
||||
|
|
|
|||
|
|
@ -20,8 +20,11 @@
|
|||
|
||||
package tschipp.carryon.events;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
||||
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents;
|
||||
import tschipp.carryon.CarryOnCommonClient;
|
||||
import tschipp.carryon.client.render.CarriedObjectRender;
|
||||
|
||||
public class ClientEvents {
|
||||
|
||||
|
|
@ -31,6 +34,10 @@ public class ClientEvents {
|
|||
CarryOnCommonClient.checkForKeybinds();
|
||||
CarryOnCommonClient.onCarryClientTick();
|
||||
});
|
||||
|
||||
WorldRenderEvents.LAST.register(event -> {
|
||||
CarriedObjectRender.drawThirdPerson(event.tickCounter().getGameTimeDeltaPartialTick(true), new PoseStack().last().pose());
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
package tschipp.carryon.mixin;
|
||||
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
|
@ -35,13 +36,13 @@ import tschipp.carryon.common.carry.PlacementHandler;
|
|||
@Mixin(Player.class)
|
||||
public class PlayerMixinFabric
|
||||
{
|
||||
@Inject(at = @At("HEAD"), method = "hurt(Lnet/minecraft/world/damagesource/DamageSource;F)Z")
|
||||
private void onHurt(DamageSource damageSource, float f, CallbackInfoReturnable<Boolean> cir) {
|
||||
@Inject(at = @At("HEAD"), method = "hurtServer(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/damagesource/DamageSource;F)Z")
|
||||
private void onHurt(ServerLevel level, DamageSource damageSource, float amount, CallbackInfoReturnable<Boolean> cir) {
|
||||
if(Constants.COMMON_CONFIG.settings.dropCarriedWhenHit)
|
||||
{
|
||||
Player player = ((Player)(Object)this);
|
||||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||
if(carry.isCarrying() && !player.level().isClientSide)
|
||||
if(carry.isCarrying())
|
||||
PlacementHandler.placeCarried((ServerPlayer)player);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,8 +8,7 @@
|
|||
],
|
||||
"client": [
|
||||
"ItemInHandRendererMixin",
|
||||
"LevelRendererMixin",
|
||||
"ScreenMixin"
|
||||
"ScreenMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ public class CarryOnForge {
|
|||
|
||||
public static SimpleChannel network;
|
||||
|
||||
public CarryOnForge() {
|
||||
public CarryOnForge(FMLJavaModLoadingContext context) {
|
||||
|
||||
// This method is invoked by the Forge mod loader when it is ready
|
||||
// to load your mod. You can access Forge and Common code in this
|
||||
|
|
@ -43,7 +43,7 @@ public class CarryOnForge {
|
|||
// Use Forge to bootstrap the Common mod.
|
||||
CarryOnCommon.registerConfig();
|
||||
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
|
||||
context.getModEventBus().addListener(this::setup);
|
||||
|
||||
ConfigLoaderImpl.initialize();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,6 @@ 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;
|
||||
|
|
@ -58,12 +56,14 @@ public class ClientEvents {
|
|||
event.setCanceled(true);
|
||||
}
|
||||
|
||||
/*
|
||||
@SubscribeEvent
|
||||
public static void onRenderLevel(RenderLevelStageEvent event)
|
||||
public static void onRenderLevel(Render event)
|
||||
{
|
||||
if(event.getStage() == Stage.AFTER_PARTICLES)
|
||||
CarriedObjectRender.drawThirdPerson(Minecraft.getInstance().getTimer().getGameTimeDeltaPartialTick(true), event.getPoseStack());
|
||||
}
|
||||
*/
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onGuiInit(ScreenEvent.Init.Pre event)
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@ import net.minecraft.core.BlockPos;
|
|||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntitySpawnReason;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
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;
|
||||
|
|
@ -99,7 +99,7 @@ public class CommonEvents
|
|||
} else {
|
||||
PlacementHandler.tryPlaceEntity((ServerPlayer) player, pos, event.getFace(), (pPos, toPlace) -> {
|
||||
if (toPlace instanceof Mob mob) {
|
||||
FinalizeSpawn checkSpawn = new FinalizeSpawn(mob, (ServerLevelAccessor) level, pPos.x, pPos.y, pPos.z, level.getCurrentDifficultyAt(new BlockPos((int) pPos.x, (int) pPos.y, (int) pPos.z)), MobSpawnType.EVENT, null, null, null);
|
||||
FinalizeSpawn checkSpawn = new FinalizeSpawn(mob, (ServerLevelAccessor) level, pPos.x, pPos.y, pPos.z, level.getCurrentDifficultyAt(new BlockPos((int) pPos.x, (int) pPos.y, (int) pPos.z)), EntitySpawnReason.EVENT, null, null, null);
|
||||
MinecraftForge.EVENT_BUS.post(checkSpawn);
|
||||
return event.getResult() != Result.DENY;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,26 +20,27 @@
|
|||
|
||||
package tschipp.carryon.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.DeltaTracker;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
import net.minecraft.client.particle.ParticleEngine;
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
import org.joml.Matrix4f;
|
||||
import net.minecraft.client.renderer.culling.Frustum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import tschipp.carryon.client.render.CarriedObjectRender;
|
||||
|
||||
@Mixin(LevelRenderer.class)
|
||||
public class LevelRendererMixin
|
||||
@Mixin(ParticleEngine.class)
|
||||
public class ParticleEngineMixin
|
||||
{
|
||||
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/particle/ParticleEngine;render(Lnet/minecraft/client/renderer/LightTexture;Lnet/minecraft/client/Camera;F)V"), method = "renderLevel(Lnet/minecraft/client/DeltaTracker;ZLnet/minecraft/client/Camera;Lnet/minecraft/client/renderer/GameRenderer;Lnet/minecraft/client/renderer/LightTexture;Lorg/joml/Matrix4f;Lorg/joml/Matrix4f;)V")
|
||||
private void onRenderLevel(DeltaTracker deltaTracker, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f frustumMatrix, Matrix4f projectionMatrix, CallbackInfo ci, @Local PoseStack poseStack)
|
||||
//I am injecting into a lambda, lord help me
|
||||
|
||||
@Inject(method = "Lnet/minecraft/client/particle/ParticleEngine;render(Lnet/minecraft/client/renderer/LightTexture;Lnet/minecraft/client/Camera;FLnet/minecraft/client/renderer/culling/Frustum;)V",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/LightTexture;turnOffLightLayer()V",
|
||||
shift = At.Shift.AFTER))
|
||||
private void onRenderLevel(LightTexture p_107339_, Camera p_107340_, float partialTick, Frustum frustum, CallbackInfo ci)
|
||||
{
|
||||
CarriedObjectRender.drawThirdPerson(deltaTracker.getGameTimeDeltaPartialTick(true), poseStack.last().pose());
|
||||
CarriedObjectRender.drawThirdPerson(partialTick, new PoseStack().last().pose());
|
||||
}
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@
|
|||
"mixins": [
|
||||
],
|
||||
"client": [
|
||||
"ParticleEngineMixin"
|
||||
],
|
||||
"server": [
|
||||
],
|
||||
|
|
|
|||
|
|
@ -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.168'
|
||||
id 'java-library'
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@ import net.minecraft.core.BlockPos;
|
|||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntitySpawnReason;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
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;
|
||||
|
|
@ -93,7 +93,7 @@ public class CommonEvents
|
|||
PlacementHandler.tryPlaceEntity((ServerPlayer) player, pos, event.getFace(), (pPos, toPlace) -> {
|
||||
if (toPlace instanceof Mob mob) {
|
||||
mob.setPos(pPos.x, pPos.y, pPos.z);
|
||||
MobSpawnEvent.PositionCheck checkSpawn = new MobSpawnEvent.PositionCheck(mob, (ServerLevelAccessor) level, MobSpawnType.EVENT, null);
|
||||
MobSpawnEvent.PositionCheck checkSpawn = new MobSpawnEvent.PositionCheck(mob, (ServerLevelAccessor) level, EntitySpawnReason.EVENT, null);
|
||||
NeoForge.EVENT_BUS.post(checkSpawn);
|
||||
return checkSpawn.getResult() != MobSpawnEvent.PositionCheck.Result.FAIL;
|
||||
}
|
||||
|
|
@ -166,7 +166,7 @@ public class CommonEvents
|
|||
@SubscribeEvent
|
||||
public static void onTagsUpdate(TagsUpdatedEvent event)
|
||||
{
|
||||
ConfigLoader.onConfigLoaded(event.getRegistryAccess());
|
||||
ConfigLoader.onConfigLoaded(event.getLookupProvider());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
# Project
|
||||
version=2.2.2
|
||||
version=2.2.3
|
||||
group=tschipp.carryon
|
||||
|
||||
# Common
|
||||
minecraft_version=1.21.1
|
||||
minecraft_version=1.21.3
|
||||
mod_name=Carry On
|
||||
mod_author=Tschipp, PurpliciousCow
|
||||
mod_id=carryon
|
||||
|
|
@ -12,22 +12,22 @@ 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)
|
||||
# Forge
|
||||
forge_version=52.0.4
|
||||
forge_loader_version_range=[52,)
|
||||
forge_version_range=[52,)
|
||||
parchment_mappings=2024.07.28-1.21
|
||||
forge_version=53.0.33
|
||||
forge_loader_version_range=[53,)
|
||||
forge_version_range=[53,)
|
||||
parchment_mappings=2024.12.07-1.21.3
|
||||
//forge_ats_enabled=true
|
||||
|
||||
# Fabric
|
||||
fabric_version=0.102.1+1.21.1
|
||||
fabric_loader_version=0.16.2
|
||||
parchment_mappings_fabric=1.21:2024.07.28
|
||||
fabric_version=0.112.1+1.21.3
|
||||
fabric_loader_version=0.16.9
|
||||
parchment_mappings_fabric=1.21.3:2024.12.07
|
||||
|
||||
# Neoforge
|
||||
neoforge_version=21.1.20
|
||||
neoforge_version=21.3.58
|
||||
neoforge_loader_version_range=[4,)
|
||||
neogradle.subsystems.parchment.minecraftVersion=1.21
|
||||
neogradle.subsystems.parchment.mappingsVersion=2024.07.28
|
||||
neogradle.subsystems.parchment.minecraftVersion=1.21.3
|
||||
neogradle.subsystems.parchment.mappingsVersion=2024.12.07
|
||||
|
||||
|
||||
# Gradle
|
||||
|
|
|
|||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
|
@ -1,6 +1,6 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-all.zip
|
||||
networkTimeout=10000
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user