mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 07:17:58 +01:00
Fix compatibility with Synatra Connector / Froge
This commit is contained in:
parent
18f2865264
commit
ae0179be8f
10 changed files with 101 additions and 26 deletions
|
@ -24,7 +24,7 @@ org.gradle.daemon=false
|
|||
modmenu_version=7.0.0-beta.2
|
||||
minelp_version=4.10.4+1.20.1
|
||||
kirin_version=1.15.4+1.20
|
||||
reach_attributes_version=2.3.3
|
||||
reach_attributes_version=2.3.4
|
||||
trinkets_version=3.7.1
|
||||
terraformer_api_version=7.0.0-beta.1
|
||||
|
||||
|
|
Binary file not shown.
BIN
lib/reach-entity-attributes-2.3.4.jar
Normal file
BIN
lib/reach-entity-attributes-2.3.4.jar
Normal file
Binary file not shown.
|
@ -38,6 +38,9 @@ public class UnicopiaMixinPlugin implements IMixinConfigPlugin {
|
|||
if (mixinClassName.indexOf("minelp") != -1) {
|
||||
return FabricLoader.getInstance().isModLoaded("minelp");
|
||||
}
|
||||
if (mixinClassName.indexOf("forgified") != -1) {
|
||||
return FabricLoader.getInstance().isModLoaded("connectormod");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ import net.minecraft.util.math.BlockPos;
|
|||
import net.minecraft.util.math.Box;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
import net.minecraft.world.EntityView;
|
||||
|
||||
public class EntityCollisions {
|
||||
|
||||
|
@ -40,7 +40,7 @@ public class EntityCollisions {
|
|||
}
|
||||
}
|
||||
|
||||
public static List<VoxelShape> getColissonShapes(@Nullable Entity entity, WorldAccess world, Box box) {
|
||||
public static List<VoxelShape> getColissonShapes(@Nullable Entity entity, EntityView world, Box box) {
|
||||
ShapeContext ctx = entity == null ? ShapeContext.absent() : ShapeContext.of(entity);
|
||||
return collectCollisionBoxes(box, collector -> {
|
||||
world.getOtherEntities(entity, box.expand(50), e -> {
|
||||
|
|
|
@ -31,7 +31,12 @@ abstract class MixinBoatEntity extends Entity implements LavaAffine {
|
|||
"fall",
|
||||
"canAddPassenger"
|
||||
},
|
||||
at = @At(value = "FIELD", target = "net/minecraft/registry/tag/FluidTags.WATER:Lnet/minecraft/registry/tag/TagKey;", opcode = Opcodes.GETSTATIC)
|
||||
at = @At(
|
||||
value = "FIELD",
|
||||
target = "net/minecraft/registry/tag/FluidTags.WATER:Lnet/minecraft/registry/tag/TagKey;",
|
||||
opcode = Opcodes.GETSTATIC
|
||||
),
|
||||
require = 0 // Forge
|
||||
)
|
||||
private TagKey<Fluid> redirectFluidTag() {
|
||||
return isLavaAffine() ? FluidTags.LAVA : FluidTags.WATER;
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
package com.minelittlepony.unicopia.mixin;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
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 com.minelittlepony.unicopia.entity.collision.EntityCollisions;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.math.Box;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.world.EntityView;
|
||||
|
||||
@Mixin(EntityView.class)
|
||||
interface MixinEntityView {
|
||||
@Inject(method = "getEntityCollisions(Lnet/minecraft/entity/Entity;Lnet/minecraft/util/math/Box;)Ljava/util/List;", at = @At("RETURN"), cancellable = true)
|
||||
private void onGetEntityCollisions(@Nullable Entity entity, Box box, CallbackInfoReturnable<List<VoxelShape>> info) {
|
||||
if (box.getAverageSideLength() < 1.0E-7D) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<VoxelShape> shapes = EntityCollisions.getColissonShapes(entity, (EntityView)this, box);
|
||||
if (!shapes.isEmpty()) {
|
||||
info.setReturnValue(Stream.concat(shapes.stream(), info.getReturnValue().stream()).toList());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,26 +1,17 @@
|
|||
package com.minelittlepony.unicopia.mixin;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
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.ModifyVariable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import com.minelittlepony.unicopia.entity.collision.EntityCollisions;
|
||||
import com.minelittlepony.unicopia.entity.duck.RotatedView;
|
||||
import com.minelittlepony.unicopia.server.world.BlockDestructionManager;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Box;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
|
||||
|
@ -47,18 +38,6 @@ abstract class MixinWorld implements WorldAccess, BlockDestructionManager.Source
|
|||
return destructions.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VoxelShape> getEntityCollisions(@Nullable Entity entity, Box box) {
|
||||
if (box.getAverageSideLength() >= 1.0E-7D) {
|
||||
List<VoxelShape> shapes = EntityCollisions.getColissonShapes(entity, this, box);
|
||||
if (!shapes.isEmpty()) {
|
||||
return Stream.concat(shapes.stream(), WorldAccess.super.getEntityCollisions(entity, box).stream()).toList();
|
||||
}
|
||||
}
|
||||
|
||||
return WorldAccess.super.getEntityCollisions(entity, box);
|
||||
}
|
||||
|
||||
@ModifyVariable(method = "setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;II)Z", at = @At("HEAD"))
|
||||
private BlockPos modifyBlockPos(BlockPos pos) {
|
||||
pos = applyRotation(pos);
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
package com.minelittlepony.unicopia.mixin.forgified;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Pseudo;
|
||||
import org.spongepowered.asm.mixin.injection.*;
|
||||
import com.minelittlepony.unicopia.entity.duck.LavaAffine;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.fluid.FluidState;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.registry.tag.FluidTags;
|
||||
|
||||
@Pseudo
|
||||
@Mixin(targets = "net.minecraftforge.common.extensions.IForgeBoat")
|
||||
interface MixinIForgeBoat {
|
||||
@ModifyVariable(
|
||||
method = "canBoatInFluid(Lnet/minecraft/fluid/FluidState;)Z",
|
||||
at = @At("HEAD"),
|
||||
ordinal = 0,
|
||||
argsOnly = true,
|
||||
require = 0
|
||||
)
|
||||
private FluidState modifyFluidState(FluidState incoming) {
|
||||
if (this instanceof LavaAffine a && a.isLavaAffine()) {
|
||||
if (incoming.isIn(FluidTags.WATER)) {
|
||||
return Fluids.LAVA.getDefaultState();
|
||||
}
|
||||
if (incoming.isIn(FluidTags.LAVA)) {
|
||||
return Fluids.WATER.getDefaultState();
|
||||
}
|
||||
}
|
||||
|
||||
return incoming;
|
||||
}
|
||||
@SuppressWarnings("deprecation")
|
||||
@ModifyVariable(
|
||||
method = "canBoatInFluid(Lnet/minecraft/fluid/Fluid;)Z",
|
||||
at = @At("HEAD"),
|
||||
ordinal = 0,
|
||||
argsOnly = true,
|
||||
require = 0
|
||||
)
|
||||
private Fluid modifyFluid(Fluid incoming) {
|
||||
if (this instanceof LavaAffine a && a.isLavaAffine()) {
|
||||
if (incoming.isIn(FluidTags.WATER)) {
|
||||
return Fluids.LAVA;
|
||||
}
|
||||
if (incoming.isIn(FluidTags.LAVA)) {
|
||||
return Fluids.WATER;
|
||||
}
|
||||
}
|
||||
|
||||
return incoming;
|
||||
}
|
||||
}
|
|
@ -20,6 +20,7 @@
|
|||
"MixinEnchantmentHelper",
|
||||
"MixinFallLocation",
|
||||
"MixinEntity",
|
||||
"MixinEntityView",
|
||||
"MixinEntityShapeContext",
|
||||
"MixinFallingBlock",
|
||||
"MixinFallingBlockEntity",
|
||||
|
@ -57,7 +58,8 @@
|
|||
"trinkets.MixinTrinketInventory",
|
||||
"trinkets.MixinScreenHandler",
|
||||
"seasons.MixinFertilizableUtil",
|
||||
"ad_astra.MixinOxygenUtils"
|
||||
"ad_astra.MixinOxygenUtils",
|
||||
"forgified.MixinIForgeBoat"
|
||||
],
|
||||
"client": [
|
||||
"client.MixinAnimalModel",
|
||||
|
|
Loading…
Reference in a new issue