Skip to content

Commit

Permalink
update to 1.1.1-alpha.2
Browse files Browse the repository at this point in the history
尝试修复矿车预览鬼畜的bug
重构代码拆分了一些mixin
增加了支持在灵魂出窍的情况下移动投影的功能
  • Loading branch information
plusls committed Jan 8, 2021
1 parent f83979a commit 6712fd7
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 16 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G
loader_version=0.10.8

# Mod Properties
mod_version = 1.1.1-alpha.1
mod_version = 1.1.1-alpha.2
maven_group = io.github.plusls
archives_base_name = MasaGadget

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.plusls.MasaGadget.mixin.litematica.feature.nudgeSelectionSupportFreeCamera;

import com.plusls.MasaGadget.MasaGadgetMixinPlugin;
import fi.dy.masa.litematica.event.InputHandler;
import fi.dy.masa.tweakeroo.config.FeatureToggle;
import net.minecraft.client.MinecraftClient;
import net.minecraft.entity.player.PlayerEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyVariable;

@Mixin(value = InputHandler.class, remap = false)
public class MixinInputHandler {
@ModifyVariable(method = "nudgeSelection", at = @At(value = "HEAD"), ordinal = 0)
static private PlayerEntity modifyPlayer(PlayerEntity oldPlayerEntity) {
if (MasaGadgetMixinPlugin.isTweakerooLoaded && FeatureToggle.TWEAK_FREE_CAMERA.getBooleanValue()) {
return (PlayerEntity) MinecraftClient.getInstance().getCameraEntity();
} else {
return oldPlayerEntity;
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.plusls.MasaGadget.mixin.tweakeroo.feature.inventoryPreviewSupportFreeCamera;

import fi.dy.masa.tweakeroo.config.FeatureToggle;
import fi.dy.masa.tweakeroo.renderer.RenderUtils;
import net.minecraft.client.MinecraftClient;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

import java.util.UUID;

@Mixin(value = RenderUtils.class, remap = false)
public abstract class MixinRenderUtils {
@Redirect(method = "renderInventoryOverlay",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/World;getPlayerByUuid(Ljava/util/UUID;)Lnet/minecraft/entity/player/PlayerEntity;",
ordinal = 0, remap = true))
private static PlayerEntity redirectGetPlayerByUuid(World world, UUID uuid) {
// support free camera
if (FeatureToggle.TWEAK_FREE_CAMERA.getBooleanValue()) {
return (PlayerEntity) MinecraftClient.getInstance().getCameraEntity();
} else {
return world.getPlayerByUuid(uuid);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,4 @@ private static Entity redirectGetEntity(EntityHitResult entityHitResult) {
}
return entity;
}


@Redirect(method = "renderInventoryOverlay",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/World;getPlayerByUuid(Ljava/util/UUID;)Lnet/minecraft/entity/player/PlayerEntity;",
ordinal = 0, remap = true))
private static PlayerEntity redirectGetPlayerByUuid(World world, UUID uuid) {
// support free camera
if (FeatureToggle.TWEAK_FREE_CAMERA.getBooleanValue()) {
return (PlayerEntity) MinecraftClient.getInstance().getCameraEntity();
} else {
return world.getPlayerByUuid(uuid);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import net.minecraft.network.PacketByteBuf;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;

public class PcaSyncProtocol {
Expand Down Expand Up @@ -92,6 +93,7 @@ public void onCustomPayload(ICustomPayloadEvent<Identifier> event) {


private static void onDisconnect(ClientPlayNetworkHandler clientPlayNetworkHandler, MinecraftClient minecraftClient) {
MasaGadgetMod.LOGGER.info("pcaSyncProtocol disable.");
enable = false;
}

Expand Down Expand Up @@ -122,9 +124,34 @@ private static void updateEntityHandler(MinecraftClient client, ClientPlayNetwor
int entityId = buf.readInt();
CompoundTag tag = buf.readCompoundTag();
Entity entity = world.getEntityById(entityId);

if (entity != null) {
MasaGadgetMod.LOGGER.debug("update entity!");
Vec3d localPos = entity.getPos();
double prevX = entity.prevX;
double prevY = entity.prevY;
double prevZ = entity.prevZ;
float pitch = entity.pitch;
float horizontalSpeed = entity.horizontalSpeed;
float yaw = entity.yaw;
float prevPitch = entity.prevPitch;
float prevHorizontalSpeed = entity.prevHorizontalSpeed;
float prevYaw = entity.prevYaw;
Vec3d velocity = entity.getVelocity();

entity.fromTag(tag);

entity.prevX = prevX;
entity.prevY = prevY;
entity.prevZ = prevZ;
entity.setPos(localPos.x, localPos.y, localPos.z);
entity.prevPitch = prevPitch;
entity.prevHorizontalSpeed = prevHorizontalSpeed;
entity.prevYaw = prevYaw;
entity.pitch = pitch;
entity.horizontalSpeed = horizontalSpeed;
entity.yaw = yaw;
entity.setVelocity(velocity);
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/masa_gadget_mod.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
"defaultRequire": 1
},
"mixins": [
"litematica.feature.nudgeSelectionSupportFreeCamera.MixinInputHandler",
"litematica.fix.carpetAccurateProtocol.MixinWorldUtils",
"malilib.feature.optimizeConfigWidgetSearch.MixinWidgetListConfigOptions",
"malilib.fix.configWidgetWidth.MixinWidgetListConfigOptions"
"malilib.fix.configWidgetWidth.MixinWidgetListConfigOptions",
"tweakeroo.feature.inventoryPreviewSupportFreeCamera.MixinRenderUtils"
]
}

0 comments on commit 6712fd7

Please sign in to comment.