Skip to content

Commit

Permalink
Fixed spawners turn into pigs when having spawner rates enabled (#1308)
Browse files Browse the repository at this point in the history
  • Loading branch information
OmerBenGera committed Aug 5, 2022
1 parent fdd11c3 commit afc2959
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 0 deletions.
Expand Up @@ -18,6 +18,10 @@ public class MobSpawnerAbstractNotifier extends MobSpawnerAbstract {
public MobSpawnerAbstractNotifier(MobSpawnerAbstract mobSpawnerAbstract, IntFunction<Integer> delayChangeCallback) {
this.mobSpawnerAbstract = mobSpawnerAbstract;
this.delayChangeCallback = delayChangeCallback;

// Copy data from original spawner to this
NBTTagCompound spawnerCompound = mobSpawnerAbstract.b(new NBTTagCompound());
this.a(spawnerCompound);
}

@Nullable
Expand Down
Expand Up @@ -19,6 +19,17 @@ public class MobSpawnerAbstractNotifier extends MobSpawnerAbstract {
public MobSpawnerAbstractNotifier(MobSpawnerAbstract mobSpawnerAbstract, IntFunction<Integer> delayChangeCallback) {
this.mobSpawnerAbstract = mobSpawnerAbstract;
this.delayChangeCallback = delayChangeCallback;

// Copy data from original spawner to this
this.mobs.clear();
this.mobs.addAll(mobSpawnerAbstract.mobs);
this.spawnData = mobSpawnerAbstract.spawnData;
this.minSpawnDelay = mobSpawnerAbstract.minSpawnDelay;
this.maxSpawnDelay = mobSpawnerAbstract.maxSpawnDelay;
this.spawnCount = mobSpawnerAbstract.spawnCount;
this.maxNearbyEntities = mobSpawnerAbstract.maxNearbyEntities;
this.requiredPlayerRange = mobSpawnerAbstract.requiredPlayerRange;
this.spawnRange = mobSpawnerAbstract.spawnRange;
}

@Nullable
Expand Down
Expand Up @@ -20,6 +20,16 @@ public class MobSpawnerAbstractNotifier extends MobSpawnerAbstract {
public MobSpawnerAbstractNotifier(MobSpawnerAbstract mobSpawnerAbstract, IntFunction<Integer> delayChangeCallback) {
this.mobSpawnerAbstract = mobSpawnerAbstract;
this.delayChangeCallback = delayChangeCallback;

// Copy data from original spawner to this
this.e = mobSpawnerAbstract.e;
this.f = mobSpawnerAbstract.f;
this.i = mobSpawnerAbstract.i;
this.j = mobSpawnerAbstract.j;
this.k = mobSpawnerAbstract.k;
this.m = mobSpawnerAbstract.m;
this.n = mobSpawnerAbstract.n;
this.o = mobSpawnerAbstract.o;
}

@Nullable
Expand Down
Expand Up @@ -18,9 +18,27 @@ public class MobSpawnerAbstractNotifier extends MobSpawnerAbstract {
private final MobSpawnerAbstract mobSpawnerAbstract;
private final IntFunction<Integer> delayChangeCallback;

@Remap(classPath = "net.minecraft.world.level.BaseSpawner", name = "spawnPotentials", type = Remap.Type.FIELD, remappedName = "d")
@Remap(classPath = "net.minecraft.world.level.BaseSpawner", name = "nextSpawnData", type = Remap.Type.FIELD, remappedName = "e")
@Remap(classPath = "net.minecraft.world.level.BaseSpawner", name = "minSpawnDelay", type = Remap.Type.FIELD, remappedName = "h")
@Remap(classPath = "net.minecraft.world.level.BaseSpawner", name = "maxSpawnDelay", type = Remap.Type.FIELD, remappedName = "i")
@Remap(classPath = "net.minecraft.world.level.BaseSpawner", name = "spawnCount", type = Remap.Type.FIELD, remappedName = "j")
@Remap(classPath = "net.minecraft.world.level.BaseSpawner", name = "maxNearbyEntities", type = Remap.Type.FIELD, remappedName = "l")
@Remap(classPath = "net.minecraft.world.level.BaseSpawner", name = "requiredPlayerRange", type = Remap.Type.FIELD, remappedName = "m")
@Remap(classPath = "net.minecraft.world.level.BaseSpawner", name = "spawnRange", type = Remap.Type.FIELD, remappedName = "n")
public MobSpawnerAbstractNotifier(MobSpawnerAbstract mobSpawnerAbstract, IntFunction<Integer> delayChangeCallback) {
this.mobSpawnerAbstract = mobSpawnerAbstract;
this.delayChangeCallback = delayChangeCallback;

// Copy data from original spawner to this
this.d = mobSpawnerAbstract.d;
this.e = mobSpawnerAbstract.e;
this.h = mobSpawnerAbstract.h;
this.i = mobSpawnerAbstract.i;
this.j = mobSpawnerAbstract.j;
this.l = mobSpawnerAbstract.l;
this.m = mobSpawnerAbstract.m;
this.n = mobSpawnerAbstract.n;
}

@Remap(classPath = "net.minecraft.world.level.BaseSpawner",
Expand Down
Expand Up @@ -18,9 +18,27 @@ public class MobSpawnerAbstractNotifier extends MobSpawnerAbstract {
private final MobSpawnerAbstract mobSpawnerAbstract;
private final IntFunction<Integer> delayChangeCallback;

@Remap(classPath = "net.minecraft.world.level.BaseSpawner", name = "spawnPotentials", type = Remap.Type.FIELD, remappedName = "d")
@Remap(classPath = "net.minecraft.world.level.BaseSpawner", name = "nextSpawnData", type = Remap.Type.FIELD, remappedName = "e")
@Remap(classPath = "net.minecraft.world.level.BaseSpawner", name = "minSpawnDelay", type = Remap.Type.FIELD, remappedName = "h")
@Remap(classPath = "net.minecraft.world.level.BaseSpawner", name = "maxSpawnDelay", type = Remap.Type.FIELD, remappedName = "i")
@Remap(classPath = "net.minecraft.world.level.BaseSpawner", name = "spawnCount", type = Remap.Type.FIELD, remappedName = "j")
@Remap(classPath = "net.minecraft.world.level.BaseSpawner", name = "maxNearbyEntities", type = Remap.Type.FIELD, remappedName = "l")
@Remap(classPath = "net.minecraft.world.level.BaseSpawner", name = "requiredPlayerRange", type = Remap.Type.FIELD, remappedName = "m")
@Remap(classPath = "net.minecraft.world.level.BaseSpawner", name = "spawnRange", type = Remap.Type.FIELD, remappedName = "n")
public MobSpawnerAbstractNotifier(MobSpawnerAbstract mobSpawnerAbstract, IntFunction<Integer> delayChangeCallback) {
this.mobSpawnerAbstract = mobSpawnerAbstract;
this.delayChangeCallback = delayChangeCallback;

// Copy data from original spawner to this
this.d = mobSpawnerAbstract.d;
this.e = mobSpawnerAbstract.e;
this.h = mobSpawnerAbstract.h;
this.i = mobSpawnerAbstract.i;
this.j = mobSpawnerAbstract.j;
this.l = mobSpawnerAbstract.l;
this.m = mobSpawnerAbstract.m;
this.n = mobSpawnerAbstract.n;
}

@Remap(classPath = "net.minecraft.world.level.BaseSpawner",
Expand Down
Expand Up @@ -18,9 +18,27 @@ public class MobSpawnerAbstractNotifier extends MobSpawnerAbstract {
private final MobSpawnerAbstract mobSpawnerAbstract;
private final IntFunction<Integer> delayChangeCallback;

@Remap(classPath = "net.minecraft.world.level.BaseSpawner", name = "spawnPotentials", type = Remap.Type.FIELD, remappedName = "d")
@Remap(classPath = "net.minecraft.world.level.BaseSpawner", name = "nextSpawnData", type = Remap.Type.FIELD, remappedName = "e")
@Remap(classPath = "net.minecraft.world.level.BaseSpawner", name = "minSpawnDelay", type = Remap.Type.FIELD, remappedName = "h")
@Remap(classPath = "net.minecraft.world.level.BaseSpawner", name = "maxSpawnDelay", type = Remap.Type.FIELD, remappedName = "i")
@Remap(classPath = "net.minecraft.world.level.BaseSpawner", name = "spawnCount", type = Remap.Type.FIELD, remappedName = "j")
@Remap(classPath = "net.minecraft.world.level.BaseSpawner", name = "maxNearbyEntities", type = Remap.Type.FIELD, remappedName = "l")
@Remap(classPath = "net.minecraft.world.level.BaseSpawner", name = "requiredPlayerRange", type = Remap.Type.FIELD, remappedName = "m")
@Remap(classPath = "net.minecraft.world.level.BaseSpawner", name = "spawnRange", type = Remap.Type.FIELD, remappedName = "n")
public MobSpawnerAbstractNotifier(MobSpawnerAbstract mobSpawnerAbstract, IntFunction<Integer> delayChangeCallback) {
this.mobSpawnerAbstract = mobSpawnerAbstract;
this.delayChangeCallback = delayChangeCallback;

// Copy data from original spawner to this
this.d = mobSpawnerAbstract.d;
this.e = mobSpawnerAbstract.e;
this.h = mobSpawnerAbstract.h;
this.i = mobSpawnerAbstract.i;
this.j = mobSpawnerAbstract.j;
this.l = mobSpawnerAbstract.l;
this.m = mobSpawnerAbstract.m;
this.n = mobSpawnerAbstract.n;
}

@Remap(classPath = "net.minecraft.world.level.BaseSpawner",
Expand Down
Expand Up @@ -16,6 +16,11 @@ public class MobSpawnerAbstractNotifier extends MobSpawnerAbstract {
public MobSpawnerAbstractNotifier(MobSpawnerAbstract mobSpawnerAbstract, IntFunction<Integer> delayChangeCallback) {
this.mobSpawnerAbstract = mobSpawnerAbstract;
this.delayChangeCallback = delayChangeCallback;

// Copy data from original spawner to this
NBTTagCompound spawnerCompound = new NBTTagCompound();
mobSpawnerAbstract.b(spawnerCompound);
this.a(spawnerCompound);
}

@Nullable
Expand Down

0 comments on commit afc2959

Please sign in to comment.