mirror of
https://github.com/GTMEGA/EndlessIDs.git
synced 2026-11-18 21:59:09 +00:00
the rest of the potion ID fixes
This commit is contained in:
10 files changed
+201
-5
No files matched your search
@@ -11,6 +11,8 @@ public class ExtendedConstants {
|
||||
public static final int watchableBits = 7;
|
||||
public static final int bitsPerBiome = 16;
|
||||
|
||||
public static final int maximumPotionIDs = 65536;
|
||||
|
||||
//BlockItemIDs
|
||||
public static final int nibblesPerID = bitsPerID / 4;
|
||||
public static final int bytesPerID = (nibblesPerID + 1) / 2;
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package com.falsepattern.endlessids.mixin.helpers;
|
||||
|
||||
public interface IS1DPacketEntityEffectMixin {
|
||||
int getIDExtended();
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.falsepattern.endlessids.mixin.helpers;
|
||||
|
||||
public class PotionIDHelper {
|
||||
public static final ThreadLocal<Integer> theID = new ThreadLocal<>();
|
||||
}
|
||||
+24
-2
@@ -1,13 +1,20 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.client.vanilla;
|
||||
|
||||
import com.falsepattern.endlessids.mixin.helpers.IS1DPacketEntityEffectMixin;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
||||
import net.minecraft.network.play.server.S1DPacketEntityEffect;
|
||||
import net.minecraft.network.play.server.S22PacketMultiBlockChange;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@@ -15,14 +22,14 @@ import java.io.ByteArrayInputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import static com.falsepattern.endlessids.mixin.helpers.PotionIDHelper.theID;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Mixin(NetHandlerPlayClient.class)
|
||||
public abstract class NetHandlerPlayClientMixin {
|
||||
|
||||
@Shadow
|
||||
private WorldClient clientWorldController;
|
||||
|
||||
|
||||
/**
|
||||
* @author FalsePattern
|
||||
* @reason Direct port from dumped code
|
||||
@@ -47,6 +54,21 @@ public abstract class NetHandlerPlayClientMixin {
|
||||
var9);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//POTIONS
|
||||
@Inject(method = "handleEntityEffect",
|
||||
at = @At("HEAD"),
|
||||
require = 1)
|
||||
private void grabID(S1DPacketEntityEffect packetIn, CallbackInfo ci) {
|
||||
theID.set(((IS1DPacketEntityEffectMixin)packetIn).getIDExtended());
|
||||
}
|
||||
|
||||
@Redirect(method = "handleEntityEffect",
|
||||
at = @At(value = "NEW",
|
||||
target = "Lnet/minecraft/potion/PotionEffect;<init>(III)V"),
|
||||
require = 1)
|
||||
private PotionEffect customNewPotionEffect(int id, int duration, int amplifier) {
|
||||
return new PotionEffect(theID.get(), duration, amplifier);
|
||||
}
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common.vanilla.potion;
|
||||
|
||||
import lombok.val;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
|
||||
@Mixin(value = PotionEffect.class)
|
||||
public abstract class PotionEffectMixin {
|
||||
@Shadow public abstract int getPotionID();
|
||||
|
||||
@Shadow public abstract int getAmplifier();
|
||||
|
||||
@Shadow public abstract int getDuration();
|
||||
|
||||
@Shadow public abstract boolean getIsAmbient();
|
||||
|
||||
@Inject(method = "writeCustomPotionEffectToNBT",
|
||||
at = @At(value = "HEAD"),
|
||||
cancellable = true,
|
||||
require = 1)
|
||||
private void writeCustomPotionEffectToNBTExtended(NBTTagCompound nbt, CallbackInfoReturnable<NBTTagCompound> cir) {
|
||||
val potionID = getPotionID();
|
||||
if (potionID > 127) {
|
||||
nbt.setInteger("IdExtended", potionID);
|
||||
nbt.setByte("Id", (byte)-1);
|
||||
} else {
|
||||
nbt.setByte("Id", (byte)potionID);
|
||||
}
|
||||
nbt.setByte("Amplifier", (byte)this.getAmplifier());
|
||||
nbt.setInteger("Duration", this.getDuration());
|
||||
nbt.setBoolean("Ambient", this.getIsAmbient());
|
||||
cir.setReturnValue(nbt);
|
||||
}
|
||||
|
||||
@Inject(method = "readCustomPotionEffectFromNBT",
|
||||
at = @At(value = "HEAD"),
|
||||
cancellable = true,
|
||||
require = 1)
|
||||
private static void readCustomPotionEffectFromNBT(NBTTagCompound nbt, CallbackInfoReturnable<PotionEffect> cir) {
|
||||
int id;
|
||||
if (nbt.hasKey("IdExtended")) {
|
||||
id = nbt.getInteger("IdExtended");
|
||||
} else {
|
||||
id = nbt.getByte("Id");
|
||||
}
|
||||
|
||||
if (id >= 0 && id < Potion.potionTypes.length && Potion.potionTypes[id] != null) {
|
||||
byte b1 = nbt.getByte("Amplifier");
|
||||
int i = nbt.getInteger("Duration");
|
||||
boolean flag = nbt.getBoolean("Ambient");
|
||||
cir.setReturnValue(new PotionEffect(id, i, b1, flag));
|
||||
} else {
|
||||
cir.setReturnValue(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common.vanilla.potion;
|
||||
|
||||
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Mutable;
|
||||
@@ -26,6 +27,6 @@ public abstract class PotionMixin {
|
||||
at = @At(value = "RETURN"),
|
||||
require = 1)
|
||||
private static void clinit(CallbackInfo ci) {
|
||||
potionTypes = Arrays.copyOf(potionTypes, 32768);
|
||||
potionTypes = Arrays.copyOf(potionTypes, ExtendedConstants.maximumPotionIDs);
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common.vanilla.potion.network;
|
||||
|
||||
import com.falsepattern.endlessids.mixin.helpers.IS1DPacketEntityEffectMixin;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import lombok.Getter;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.server.S1DPacketEntityEffect;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
|
||||
@Mixin(value = S1DPacketEntityEffect.class)
|
||||
public abstract class S1DPacketEntityEffectMixin implements IS1DPacketEntityEffectMixin {
|
||||
@Getter
|
||||
private int idExtended;
|
||||
|
||||
@WrapOperation(method = "<init>(ILnet/minecraft/potion/PotionEffect;)V",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/potion/PotionEffect;getPotionID()I"),
|
||||
require = 1)
|
||||
private int getPotionID(PotionEffect effect, Operation<Integer> original) {
|
||||
idExtended = original.call(effect);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Redirect(method = "readPacketData",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/network/PacketBuffer;readByte()B",
|
||||
ordinal = 0),
|
||||
require = 1)
|
||||
private byte networkReadPacketData(PacketBuffer instance) {
|
||||
idExtended = instance.readInt();
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Redirect(method = "writePacketData",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/network/PacketBuffer;writeByte(I)Lio/netty/buffer/ByteBuf;",
|
||||
ordinal = 0),
|
||||
require = 1)
|
||||
private ByteBuf networkWritePacketData(PacketBuffer instance, int p_writeByte_1_) {
|
||||
instance.writeInt(idExtended);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common.vanilla.potion.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.server.S1EPacketRemoveEntityEffect;
|
||||
|
||||
@Mixin(S1EPacketRemoveEntityEffect.class)
|
||||
public abstract class S1EPacketRemoveEntityEffectMixin {
|
||||
@Shadow private int field_149078_b;
|
||||
|
||||
@Redirect(method = "readPacketData",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/network/PacketBuffer;readUnsignedByte()S"),
|
||||
require = 1)
|
||||
private short dontReadByte(PacketBuffer instance) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Inject(method = "readPacketData",
|
||||
at = @At("RETURN"),
|
||||
require = 1)
|
||||
private void readNewData(PacketBuffer buf, CallbackInfo ci) {
|
||||
field_149078_b = buf.readInt();
|
||||
}
|
||||
|
||||
@Redirect(method = "writePacketData",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/network/PacketBuffer;writeByte(I)Lio/netty/buffer/ByteBuf;"),
|
||||
require = 1)
|
||||
private ByteBuf dontWriteByte(PacketBuffer instance, int p_writeByte_1_) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Inject(method = "writePacketData",
|
||||
at = @At(value = "RETURN"),
|
||||
require = 1)
|
||||
private void writeNewData(PacketBuffer buf, CallbackInfo ci) {
|
||||
buf.writeInt(field_149078_b);
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,10 @@ public enum Mixin implements IMixin {
|
||||
GenLayerVoronoiZoomMixin(Side.COMMON, always(), "vanilla.worldgen.GenLayerVoronoiZoomMixin"),
|
||||
//endregion Minecraft->common->worldgen
|
||||
//region Minecraft->common->potion
|
||||
PotionEffectMixin(Side.COMMON, always(), "vanilla.potion.PotionEffectMixin"),
|
||||
PotionMixin(Side.COMMON, always(), "vanilla.potion.PotionMixin"),
|
||||
S1DPacketEntityEffectMixin(Side.COMMON, always(), "vanilla.potion.network.S1DPacketEntityEffectMixin"),
|
||||
S1EPacketRemoveEntityEffectMixin(Side.COMMON, always(), "vanilla.potion.network.S1EPacketRemoveEntityEffectMixin"),
|
||||
//endregion Minecraft->common->potion
|
||||
//endregion Minecraft->common
|
||||
//region Minecraft->client
|
||||
|
||||
@@ -11,7 +11,6 @@ import static com.falsepattern.lib.mixin.ITargetedMod.PredicateHelpers.startsWit
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public enum TargetedMod implements ITargetedMod {
|
||||
|
||||
ABYSSALCRAFT("AbyssalCraft", false, startsWith("abyssalcraft-")),
|
||||
AROCKETRY("Advanced Rocketry", false, startsWith("advancedrocketry-")),
|
||||
ATG("Alternate Terrain Generation", false, startsWith("atg")),
|
||||
@@ -20,7 +19,7 @@ public enum TargetedMod implements ITargetedMod {
|
||||
BOP("Biomes O' Plenty", false, startsWith("biomesoplenty-")),
|
||||
BIOMETWEAKER("Biome Tweaker", false, startsWith("biometweaker-")),
|
||||
BIOMEWAND("Biome Wand", false, startsWith("1.7.10-biome-wand-").or(startsWith("biome-wand"))),
|
||||
BUILDCRAFT("BuildCraft", false, startsWith("buildcraft-").and(contains("-compat").negate())),
|
||||
BUILDCRAFT("BuildCraft", false, startsWith("buildcraft-").and(contains("compat").negate())),
|
||||
COFHLIB("CoFH Lib", false, startsWith("cofhlib-")),
|
||||
COMPACTMACHINES("Compact Machines", false, startsWith("compactmachines-")),
|
||||
DARKWORLD("Dark World", false, startsWith("darkworld-")),
|
||||
|
||||
Reference in new issue
Block a user