Compare commits

..
14 Commits
Author SHA1 Message Date
FalsePattern a30a223b87 extend enchantment IDs 2022-12-29 13:16:23 +01:00
FalsePattern 5bd48c168c update readme 2022-12-29 13:03:52 +01:00
FalsePattern 7381139fdf Merge pull request #81 from FalsePattern/1.4-maintenance
Merge fixes from 1.4 maintenance branch
2022-12-29 13:02:16 +01:00
FalsePattern 3c78543a82 Merge pull request #80 from FalsePattern/potion-dev
Potion ID extension
2022-12-29 13:01:51 +01:00
FalsePattern 83227b76f2 Merge pull request #79 from SirFell/potion-dev
Fix AbstractMethodError caused by Lombok naming getter differently
2022-12-29 12:56:15 +01:00
Vitaly 078cc110ff Remove Lombok annotation and make a getter manually. 2022-12-29 11:42:59 +02:00
FalsePattern 5c81a620e2 crash fix 2022-12-28 19:49:13 +01:00
FalsePattern 012fa8188c alias fix 2022-12-28 19:12:47 +01:00
FalsePattern 495c70223c the rest of the potion ID fixes 2022-12-28 14:24:09 +01:00
FalsePattern 7e97287004 0-32767 2022-12-28 12:36:04 +01:00
FalsePattern ccb2c62a89 fix vanilla potions being deleted 2022-12-28 12:35:20 +01:00
FalsePattern c65179a4b3 Merge pull request #76 from SirFell/master
Extend PotionIDs Byte -> Short
2022-12-28 12:31:59 +01:00
Vitaly d825ea3c97 Fix automatic padding to comply with codestyle 2022-12-28 13:07:29 +02:00
Vitaly 9d5d87fe81 Extend PotionIDs Byte -> Short 2022-12-28 13:04:19 +02:00
12 changed files with 270 additions and 9 deletions

No files matched your search

+5 -5
View File
@@ -5,12 +5,12 @@ Comparison of the known limits:
| | Vanilla | NotEnoughIDs | EndlessIDs |
|-----------------|----------------------------------------------------|--------------|----------------------------------|
| Block IDs | 4,096 | 32,000 | 16,777,216 |
| Item IDs | 32,000 | 32,000 | 16,777,216 |
| Biome IDs | 256 | 256 | 65,536 |
| Block IDs | 4,096 | 32,000 | 16,777,216 since 1.3 |
| Item IDs | 32,000 | 32,000 | 16,777,216 since 1.3 |
| Biome IDs | 256 | 256 | 65,536 since 1.4 |
| Entity IDs | 256 | 256 | 256 right now, extension planned |
| Potion IDs | 32 | 32 | 32 right now, extension planned |
| Enchantment IDs | 256 | 256 | 256 right now, extension planned |
| Potion IDs | 32 | 32 | 65,536 since 1.5 |
| Enchantment IDs | 256 | 256 | 32,768 since 1.5 |
| Dimension IDs | Theoretically unlimited, 4,294,967,295 in practice | Same | Same |
This mod also contains patches for the following mods:
@@ -11,6 +11,9 @@ public class ExtendedConstants {
public static final int watchableBits = 7;
public static final int bitsPerBiome = 16;
public static final int maximumPotionIDs = 65536;
public static final int maximumEnchantmentIDs = 32768;
//BlockItemIDs
public static final int nibblesPerID = bitsPerID / 4;
public static final int bytesPerID = (nibblesPerID + 1) / 2;
@@ -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<>();
}
@@ -1,13 +1,23 @@
package com.falsepattern.endlessids.mixin.mixins.client.vanilla;
import com.falsepattern.endlessids.mixin.helpers.IS1DPacketEntityEffectMixin;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import lombok.val;
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.callback.CallbackInfo;
import net.minecraft.block.Block;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.client.network.NetHandlerPlayClient;
import net.minecraft.entity.EntityLivingBase;
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 +25,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 +57,23 @@ 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());
}
@WrapOperation(method = "handleEntityEffect",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/entity/EntityLivingBase;addPotionEffect(Lnet/minecraft/potion/PotionEffect;)V"),
require = 1)
private void addPotionEffect(EntityLivingBase entity, PotionEffect effect, Operation<Void> op) {
val newPotion = new PotionEffect(theID.get(), effect.getDuration(), effect.getAmplifier());
newPotion.setPotionDurationMax(effect.getIsPotionDurationMax());
op.call(entity, newPotion);
}
}
@@ -0,0 +1,18 @@
package com.falsepattern.endlessids.mixin.mixins.common.vanilla.enchantment;
import com.falsepattern.endlessids.constants.ExtendedConstants;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import net.minecraft.enchantment.Enchantment;
@Mixin(Enchantment.class)
public abstract class EnchantmentMixin {
@ModifyConstant(method = "<clinit>",
constant = @Constant(intValue = 256),
require = 1)
private static int extendEnchantmentIDRange(int original) {
return ExtendedConstants.maximumEnchantmentIDs;
}
}
@@ -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);
}
}
}
@@ -0,0 +1,32 @@
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;
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.CallbackInfo;
import net.minecraft.potion.Potion;
import java.util.Arrays;
@Mixin(Potion.class)
public abstract class PotionMixin {
@Shadow(aliases = "field_76425_a")
@Final
@Mutable
public static Potion[] potionTypes;
@Inject(method = "<clinit>",
at = @At(value = "RETURN"),
require = 1)
private static void clinit(CallbackInfo ci) {
potionTypes = Arrays.copyOf(potionTypes, ExtendedConstants.maximumPotionIDs);
}
}
@@ -0,0 +1,53 @@
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 {
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;
}
@Override
public int getIDExtended() {
return this.idExtended;
}
}
@@ -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);
}
}
@@ -46,6 +46,15 @@ public enum Mixin implements IMixin {
GenLayerRiverMixMixin(Side.COMMON, avoid(TargetedMod.DRAGONAPI), "vanilla.worldgen.GenLayerRiverMixMixin"),
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
//region Minecraft->common->enchantment
EnchantmentMixin(Side.COMMON, always(), "vanilla.enchantment.EnchantmentMixin"),
//endregion Minecraft->common->enchantment
//endregion Minecraft->common
//region Minecraft->client
ChunkMixinClient(Side.CLIENT, always(), "vanilla.ChunkMixin"),
@@ -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-")),