ModLoader mob spawns use packet 24- build a bypass system so that
they can still use it
This commit is contained in:
parent
3415dbfd0d
commit
81a8e94c79
4 changed files with 16 additions and 2 deletions
|
@ -15,6 +15,7 @@ public class ModLoaderEntitySpawnCallback implements Function<EntitySpawnPacket,
|
||||||
|
|
||||||
private BaseModProxy mod;
|
private BaseModProxy mod;
|
||||||
private EntityRegistration registration;
|
private EntityRegistration registration;
|
||||||
|
private boolean isAnimal;
|
||||||
|
|
||||||
public ModLoaderEntitySpawnCallback(BaseModProxy mod, EntityRegistration er)
|
public ModLoaderEntitySpawnCallback(BaseModProxy mod, EntityRegistration er)
|
||||||
{
|
{
|
||||||
|
|
|
@ -26,7 +26,9 @@ import com.google.common.collect.Maps;
|
||||||
import net.minecraft.src.BaseMod;
|
import net.minecraft.src.BaseMod;
|
||||||
import net.minecraft.src.Container;
|
import net.minecraft.src.Container;
|
||||||
import net.minecraft.src.Entity;
|
import net.minecraft.src.Entity;
|
||||||
|
import net.minecraft.src.EntityDragon;
|
||||||
import net.minecraft.src.EntityPlayer;
|
import net.minecraft.src.EntityPlayer;
|
||||||
|
import net.minecraft.src.IAnimals;
|
||||||
import net.minecraft.src.ICommand;
|
import net.minecraft.src.ICommand;
|
||||||
import net.minecraft.src.TradeEntry;
|
import net.minecraft.src.TradeEntry;
|
||||||
import cpw.mods.fml.common.FMLCommonHandler;
|
import cpw.mods.fml.common.FMLCommonHandler;
|
||||||
|
@ -169,7 +171,7 @@ public class ModLoaderHelper
|
||||||
boolean sendVelocityInfo)
|
boolean sendVelocityInfo)
|
||||||
{
|
{
|
||||||
EntityRegistration er = EntityRegistry.registerModLoaderEntity(mod, entityClass, entityTypeId, updateRange, updateInterval, sendVelocityInfo);
|
EntityRegistration er = EntityRegistry.registerModLoaderEntity(mod, entityClass, entityTypeId, updateRange, updateInterval, sendVelocityInfo);
|
||||||
er.setCustomSpawning(new ModLoaderEntitySpawnCallback(mod, er));
|
er.setCustomSpawning(new ModLoaderEntitySpawnCallback(mod, er), !(EntityDragon.class.isAssignableFrom(entityClass) || IAnimals.class.isAssignableFrom(entityClass)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ModLoaderVillageTradeHandler[] tradeHelpers = new ModLoaderVillageTradeHandler[6];
|
private static ModLoaderVillageTradeHandler[] tradeHelpers = new ModLoaderVillageTradeHandler[6];
|
||||||
|
|
|
@ -329,6 +329,10 @@ public class FMLNetworkHandler
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
if (er.usesVanillaSpawning())
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
Packet250CustomPayload pkt = new Packet250CustomPayload();
|
Packet250CustomPayload pkt = new Packet250CustomPayload();
|
||||||
pkt.field_73630_a = "FML";
|
pkt.field_73630_a = "FML";
|
||||||
pkt.field_73629_c = FMLPacket.makePacket(Type.ENTITYSPAWN, er, entity, instance().findNetworkModHandler(er.getContainer()));
|
pkt.field_73629_c = FMLPacket.makePacket(Type.ENTITYSPAWN, er, entity, instance().findNetworkModHandler(er.getContainer()));
|
||||||
|
|
|
@ -41,6 +41,7 @@ public class EntityRegistry
|
||||||
private int updateFrequency;
|
private int updateFrequency;
|
||||||
private boolean sendsVelocityUpdates;
|
private boolean sendsVelocityUpdates;
|
||||||
private Function<EntitySpawnPacket, Entity> customSpawnCallback;
|
private Function<EntitySpawnPacket, Entity> customSpawnCallback;
|
||||||
|
private boolean usesVanillaSpawning;
|
||||||
public EntityRegistration(ModContainer mc, Class<? extends Entity> entityClass, String entityName, int id, int trackingRange, int updateFrequency, boolean sendsVelocityUpdates)
|
public EntityRegistration(ModContainer mc, Class<? extends Entity> entityClass, String entityName, int id, int trackingRange, int updateFrequency, boolean sendsVelocityUpdates)
|
||||||
{
|
{
|
||||||
this.container = mc;
|
this.container = mc;
|
||||||
|
@ -79,6 +80,11 @@ public class EntityRegistry
|
||||||
{
|
{
|
||||||
return sendsVelocityUpdates;
|
return sendsVelocityUpdates;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean usesVanillaSpawning()
|
||||||
|
{
|
||||||
|
return usesVanillaSpawning;
|
||||||
|
}
|
||||||
public boolean hasCustomSpawning()
|
public boolean hasCustomSpawning()
|
||||||
{
|
{
|
||||||
return customSpawnCallback != null;
|
return customSpawnCallback != null;
|
||||||
|
@ -87,9 +93,10 @@ public class EntityRegistry
|
||||||
{
|
{
|
||||||
return customSpawnCallback.apply(packet);
|
return customSpawnCallback.apply(packet);
|
||||||
}
|
}
|
||||||
public void setCustomSpawning(Function<EntitySpawnPacket, Entity> callable)
|
public void setCustomSpawning(Function<EntitySpawnPacket, Entity> callable, boolean usesVanillaSpawning)
|
||||||
{
|
{
|
||||||
this.customSpawnCallback = callable;
|
this.customSpawnCallback = callable;
|
||||||
|
this.usesVanillaSpawning = usesVanillaSpawning;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue