Skip to content

Commit

Permalink
Fixed support for 1.19 (Untested)
Browse files Browse the repository at this point in the history
  • Loading branch information
OmerBenGera committed Aug 12, 2022
1 parent 3ca4c4f commit 084c8f3
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 26 deletions.
Expand Up @@ -67,7 +67,7 @@ private static final class EntityHologram extends EntityArmorStand implements Ho
t(true); // Marker
super.collides = false;
super.n(true); // Custom name visible
super.a(EMPTY_BOUND);
super.a(EMPTY_BOUND); // setBoundingBox
}

@Remap(classPath = "net.minecraft.world.entity.Entity",
Expand Down Expand Up @@ -103,24 +103,6 @@ public void inactiveTick() {
}
}

@Remap(classPath = "net.minecraft.world.entity.Entity",
name = "repositionEntityAfterLoad",
type = Remap.Type.METHOD,
remappedName = "bm")
@Override
public boolean bm() {
return false;
}

@Remap(classPath = "net.minecraft.world.entity.Entity",
name = "getBoundingBoxForCulling",
type = Remap.Type.METHOD,
remappedName = "cz")
@Override
public AxisAlignedBB cz() {
return EMPTY_BOUND;
}

@Override
public void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack, boolean silence) {
// Prevent stand being equipped
Expand Down
Expand Up @@ -28,6 +28,7 @@
import com.google.common.base.Suppliers;
import net.minecraft.network.protocol.Packet;
import net.minecraft.server.level.PlayerChunk;
import net.minecraft.world.entity.boss.enderdragon.EntityEnderDragon;
import net.minecraft.world.level.block.BlockBed;
import net.minecraft.world.level.chunk.Chunk;
import net.minecraft.world.level.chunk.ChunkConverter;
Expand Down Expand Up @@ -56,6 +57,13 @@ public final class NMSUtils {
@Remap(classPath = "net.minecraft.world.level.levelgen.Heightmap$Types", name = "WORLD_SURFACE", type = Remap.Type.FIELD, remappedName = "b")
private static final HeightMap.Type WORLD_SURFACE_HEIGHT_MAP = HeightMap.Type.b;

public static final boolean is119Mappings;

static {
ReflectMethod<?> method119 = new ReflectMethod<>(EntityEnderDragon.class, net.minecraft.world.entity.boss.enderdragon.phases.DragonControllerManager.class, "fH");
is119Mappings = method119.isValid();
}

private NMSUtils() {

}
Expand Down
@@ -1,9 +1,11 @@
package com.bgsoftware.superiorskyblock.nms.v1_19_R1.mapping.net.minecraft.world.entity;

import com.bgsoftware.common.reflection.ReflectMethod;
import com.bgsoftware.superiorskyblock.nms.mapping.Remap;
import com.bgsoftware.superiorskyblock.nms.v1_19_R1.NMSUtils;
import com.bgsoftware.superiorskyblock.nms.v1_19_R1.mapping.MappedObject;
import com.bgsoftware.superiorskyblock.nms.v1_19_R1.mapping.net.minecraft.server.level.WorldServer;
import com.bgsoftware.superiorskyblock.nms.v1_19_R1.mapping.net.minecraft.nbt.NBTTagCompound;
import com.bgsoftware.superiorskyblock.nms.v1_19_R1.mapping.net.minecraft.server.level.WorldServer;
import com.bgsoftware.superiorskyblock.nms.v1_19_R1.mapping.net.minecraft.server.network.PlayerConnection;
import com.bgsoftware.superiorskyblock.nms.v1_19_R1.mapping.net.minecraft.world.entity.boss.enderdragon.phases.DragonControllerManager;
import com.mojang.authlib.GameProfile;
Expand All @@ -20,6 +22,32 @@

public final class Entity extends MappedObject<net.minecraft.world.entity.Entity> {

private static final ReflectMethod<UUID> ENTITY_ITEM_GET_THROWER;
private static final ReflectMethod<Float> ENTITY_GET_X_ROT;
private static final ReflectMethod<Float> ENTITY_GET_Y_ROT;
private static final ReflectMethod<GameProfile> ENTITY_HUMAN_GET_PROFILE;
private static final ReflectMethod<net.minecraft.world.entity.boss.enderdragon.phases.DragonControllerManager> ENTITY_DRAGON_CONTROLLER_MANAGER;
private static final ReflectMethod<UUID> ENTITY_GET_UNIQUE_ID;

static {
if (NMSUtils.is119Mappings) {
ENTITY_ITEM_GET_THROWER = new ReflectMethod<>(EntityItem.class, "i");
ENTITY_GET_X_ROT = new ReflectMethod<>(net.minecraft.world.entity.Entity.class, "dt");
ENTITY_GET_Y_ROT = new ReflectMethod<>(net.minecraft.world.entity.Entity.class, "dr");
ENTITY_HUMAN_GET_PROFILE = new ReflectMethod<>(EntityHuman.class, "fz");
ENTITY_DRAGON_CONTROLLER_MANAGER = new ReflectMethod<>(EntityEnderDragon.class, "fH");
ENTITY_GET_UNIQUE_ID = new ReflectMethod<>(net.minecraft.world.entity.Entity.class, "cp");
} else {
ENTITY_ITEM_GET_THROWER = null;
ENTITY_GET_X_ROT = null;
ENTITY_GET_Y_ROT = null;
ENTITY_HUMAN_GET_PROFILE = null;
ENTITY_DRAGON_CONTROLLER_MANAGER = null;
ENTITY_GET_UNIQUE_ID = null;
}

}

public Entity(net.minecraft.world.entity.Entity handle) {
super(handle);
}
Expand All @@ -42,23 +70,23 @@ public void setRemoved(net.minecraft.world.entity.Entity.RemovalReason removalRe
type = Remap.Type.METHOD,
remappedName = "ds")
public float getXRot() {
return handle.ds();
return ENTITY_GET_X_ROT == null ? handle.ds() : ENTITY_GET_X_ROT.invoke(handle);
}

@Remap(classPath = "net.minecraft.world.entity.Entity",
name = "getYRot",
type = Remap.Type.METHOD,
remappedName = "dq")
public float getYRot() {
return handle.dq();
return ENTITY_GET_Y_ROT == null ? handle.dq() : ENTITY_GET_Y_ROT.invoke(handle);
}

@Remap(classPath = "net.minecraft.world.entity.Entity",
name = "getUUID",
type = Remap.Type.METHOD,
remappedName = "co")
public UUID getUniqueID() {
return handle.co();
return ENTITY_GET_UNIQUE_ID == null ? handle.co() : ENTITY_GET_UNIQUE_ID.invoke(handle);
}

@Remap(classPath = "net.minecraft.world.entity.Entity",
Expand All @@ -82,15 +110,15 @@ public boolean isBreedItem(ItemStack itemStack) {
type = Remap.Type.METHOD,
remappedName = "fy")
public GameProfile getProfile() {
return ((EntityHuman) handle).fy();
return ENTITY_HUMAN_GET_PROFILE == null ? ((EntityHuman) handle).fy() : ENTITY_HUMAN_GET_PROFILE.invoke(handle);
}

@Remap(classPath = "net.minecraft.world.entity.item.ItemEntity",
name = "getOwner",
type = Remap.Type.METHOD,
remappedName = "j")
public UUID getThrower() {
return ((EntityItem) handle).j();
return ENTITY_ITEM_GET_THROWER == null ? ((EntityItem) handle).j() : ENTITY_ITEM_GET_THROWER.invoke(handle);
}

@Remap(classPath = "net.minecraft.world.entity.Entity",
Expand All @@ -106,7 +134,8 @@ public void save(NBTTagCompound nbtTagCompound) {
type = Remap.Type.METHOD,
remappedName = "fG")
public DragonControllerManager getDragonControllerManager() {
return new DragonControllerManager(((EntityEnderDragon) handle).fG());
return new DragonControllerManager(ENTITY_DRAGON_CONTROLLER_MANAGER == null ?
((EntityEnderDragon) handle).fG() : ENTITY_DRAGON_CONTROLLER_MANAGER.invoke(handle));
}

@Remap(classPath = "net.minecraft.server.network.ServerGamePacketListenerImpl",
Expand Down

0 comments on commit 084c8f3

Please sign in to comment.