Skip to content

Commit

Permalink
add rule - UnstableOnGroundTagFix
Browse files Browse the repository at this point in the history
  • Loading branch information
HeyBlack233 committed Jun 5, 2024
1 parent 6cc1e39 commit e44ab16
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 34 deletions.
6 changes: 3 additions & 3 deletions src/main/java/heyblack/flexiblepcb/FlexiblePCBSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ public Integer validate(ServerCommandSource source, ParsedRule<Integer> currentR
public static boolean commandChunkSaveState = false;

@Rule(
desc = "Fixes MC-254307",
category = {FEATURE, BUGFIX, "flexiblepcb"}
desc = "Fixes MC-254307, and the same issue with beds",
category = {BUGFIX, "flexiblepcb"}
)
public static boolean fixUnstableOnGroundTag = false;
public static boolean UnstableOnGroundTagFix = false;
}
18 changes: 9 additions & 9 deletions src/main/java/heyblack/flexiblepcb/hook/Hooks.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package heyblack.flexiblepcb.hook;

import heyblack.flexiblepcb.FlexiblePCBSettings;
import net.minecraft.block.BedBlock;
import net.minecraft.block.Block;
import net.minecraft.block.SlimeBlock;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.BlockView;
Expand All @@ -10,16 +12,14 @@ public class Hooks {

@SuppressWarnings("unused")
public static void checkVelocity(Block block, BlockView world, Entity entity, Vec3d vec3d) {
block.onEntityLand(world, entity);
if (FlexiblePCBSettings.fixUnstableOnGroundTag) {
// 条件大概是adjustMovementForCollisions后的y轴动量小于0且绝对值小于0.08
System.out.println("block = " + block);
System.out.println("world = " + world);
System.out.println("entity = " + entity);
System.out.println("vec3d = " + vec3d);
if (vec3d.y < -0.08f) {

if (FlexiblePCBSettings.UnstableOnGroundTagFix) {
if ((entity.getVelocity().y <= 0.0 && entity.getVelocity().y >= -0.08)
&& (block instanceof SlimeBlock || block instanceof BedBlock)
){
entity.setVelocity(entity.getVelocity().multiply(1.0, 0.0, 1.0));
return;
}
}
block.onEntityLand(world, entity);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ public void preApply(String targetClassName, ClassNode targetClass, String mixin

@Override
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
System.out.println("targetClassName = " + targetClassName);
// System.out.println("targetClassName = " + targetClassName);
if (targetClassName.equals(Names.Entity_class)) {
for (MethodNode method : targetClass.methods) {
if (method.name.equals(Names.Entity_move) && method.desc.equals(Names.Entity_move_desc)) {
System.out.println("method = " + method);
// System.out.println("method = " + method);
ListIterator<AbstractInsnNode> iter = method.instructions.iterator();
while (iter.hasNext()) {
AbstractInsnNode insnNode = iter.next();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,9 @@
package heyblack.flexiblepcb.mixin.rule.fixUnstableOnGroundTag;

import heyblack.flexiblepcb.FlexiblePCBSettings;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.world.BlockView;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

@Mixin(Entity.class)
public class EntityMixin
{
// @Redirect(
// method = "move",
// at = @At(
// value = "INVOKE",
// target = "Lnet/minecraft/block/Block;onEntityLand(Lnet/minecraft/world/BlockView;Lnet/minecraft/entity/Entity;)V"
// )
// )
// public void checkVelocity(Block instance, BlockView world, Entity entity) {
// if (FlexiblePCBSettings.fixUnstableOnGroundTag) {
// // 条件大概是adjustMovementForCollisions后的y轴动量小于0且绝对值小于0.08
// if () {
//
// }
// }
// }
}

0 comments on commit e44ab16

Please sign in to comment.