ModLoader mob spawns use packet 24- build a bypass system so that

they can still use it
This commit is contained in:
Christian 2012-08-29 12:58:16 -04:00
parent 3415dbfd0d
commit 81a8e94c79
4 changed files with 16 additions and 2 deletions

View File

@ -15,6 +15,7 @@ public class ModLoaderEntitySpawnCallback implements Function<EntitySpawnPacket,
private BaseModProxy mod;
private EntityRegistration registration;
private boolean isAnimal;
public ModLoaderEntitySpawnCallback(BaseModProxy mod, EntityRegistration er)
{

View File

@ -26,7 +26,9 @@ import com.google.common.collect.Maps;
import net.minecraft.src.BaseMod;
import net.minecraft.src.Container;
import net.minecraft.src.Entity;
import net.minecraft.src.EntityDragon;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.IAnimals;
import net.minecraft.src.ICommand;
import net.minecraft.src.TradeEntry;
import cpw.mods.fml.common.FMLCommonHandler;
@ -169,7 +171,7 @@ public class ModLoaderHelper
boolean 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];

View File

@ -329,6 +329,10 @@ public class FMLNetworkHandler
{
return null;
}
if (er.usesVanillaSpawning())
{
return null;
}
Packet250CustomPayload pkt = new Packet250CustomPayload();
pkt.field_73630_a = "FML";
pkt.field_73629_c = FMLPacket.makePacket(Type.ENTITYSPAWN, er, entity, instance().findNetworkModHandler(er.getContainer()));

View File

@ -41,6 +41,7 @@ public class EntityRegistry
private int updateFrequency;
private boolean sendsVelocityUpdates;
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)
{
this.container = mc;
@ -79,6 +80,11 @@ public class EntityRegistry
{
return sendsVelocityUpdates;
}
public boolean usesVanillaSpawning()
{
return usesVanillaSpawning;
}
public boolean hasCustomSpawning()
{
return customSpawnCallback != null;
@ -87,9 +93,10 @@ public class EntityRegistry
{
return customSpawnCallback.apply(packet);
}
public void setCustomSpawning(Function<EntitySpawnPacket, Entity> callable)
public void setCustomSpawning(Function<EntitySpawnPacket, Entity> callable, boolean usesVanillaSpawning)
{
this.customSpawnCallback = callable;
this.usesVanillaSpawning = usesVanillaSpawning;
}
}