mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 16:27:47 +00:00
This commit is contained in:
1 parent
464cccaa3e
commit
74c3aab720
4 files changed
+41
-18
No files matched your search
+1
-2
@@ -76,7 +76,6 @@ public class EntitySpawnHandler extends SimpleChannelInboundHandler<FMLMessage.E
|
||||
" at ( " + spawnMsg.rawX + "," + spawnMsg.rawY + ", " + spawnMsg.rawZ + ") Please contact mod author or server admin.");
|
||||
}
|
||||
WorldClient wc = FMLClientHandler.instance().getWorldClient();
|
||||
Class<? extends Entity> cls = er.getEntityClass();
|
||||
try
|
||||
{
|
||||
Entity entity;
|
||||
@@ -85,7 +84,7 @@ public class EntitySpawnHandler extends SimpleChannelInboundHandler<FMLMessage.E
|
||||
entity = er.doCustomSpawning(spawnMsg);
|
||||
} else
|
||||
{
|
||||
entity = cls.getConstructor(World.class).newInstance(wc);
|
||||
entity = er.newInstance(wc);
|
||||
|
||||
int offset = spawnMsg.entityId - entity.getEntityId();
|
||||
entity.setEntityId(spawnMsg.entityId);
|
||||
|
||||
@@ -276,15 +276,6 @@ public final class EntityEntryBuilder<E extends Entity>
|
||||
return entry;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
private EntityRegistry.EntityRegistration createRegistration()
|
||||
{
|
||||
return EntityRegistry.instance().new EntityRegistration(
|
||||
this.mod, this.id, this.entity, this.name, this.network,
|
||||
this.trackingRange, this.trackingUpdateFrequency, this.trackingVelocityUpdates
|
||||
);
|
||||
}
|
||||
|
||||
private void registerStatistics()
|
||||
{
|
||||
if (!this.statisticsRegistered && (this.killEntityStatistic != null && this.entityKilledByStatistic != null))
|
||||
@@ -340,7 +331,7 @@ public final class EntityEntryBuilder<E extends Entity>
|
||||
if (this.added) return;
|
||||
this.added = true;
|
||||
EntityEntryBuilder.this.registerStatistics();
|
||||
EntityRegistry.instance().insert(EntityEntryBuilder.this.entity, EntityEntryBuilder.this.createRegistration());
|
||||
EntityRegistry.instance().insert(EntityEntryBuilder.this.entity, createRegistration());
|
||||
if (EntityEntryBuilder.this.spawns != null)
|
||||
{
|
||||
for (final Spawn spawn : EntityEntryBuilder.this.spawns)
|
||||
@@ -350,6 +341,17 @@ public final class EntityEntryBuilder<E extends Entity>
|
||||
EntityEntryBuilder.this.spawns = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
private EntityRegistry.EntityRegistration createRegistration()
|
||||
{
|
||||
EntityEntryBuilder<E> builder = EntityEntryBuilder.this;
|
||||
return EntityRegistry.instance().new EntityRegistration(
|
||||
builder.mod, builder.id, builder.entity, builder.name, builder.network,
|
||||
builder.trackingRange, builder.trackingUpdateFrequency, builder.trackingVelocityUpdates, this.factory
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final class Spawn
|
||||
|
||||
@@ -29,6 +29,7 @@ import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.EntityTracker;
|
||||
import net.minecraft.entity.EnumCreatureType;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.Biome.SpawnListEntry;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
@@ -48,7 +49,9 @@ public class EntityRegistry
|
||||
{
|
||||
public class EntityRegistration
|
||||
{
|
||||
@Deprecated
|
||||
private Class<? extends Entity> entityClass;
|
||||
private Function<World, ? extends Entity> factory;
|
||||
private ModContainer container;
|
||||
private ResourceLocation regName;
|
||||
private String entityName;
|
||||
@@ -58,7 +61,14 @@ public class EntityRegistry
|
||||
private boolean sendsVelocityUpdates;
|
||||
private Function<EntitySpawnMessage, Entity> customSpawnCallback;
|
||||
private boolean usesVanillaSpawning;
|
||||
|
||||
@Deprecated //1.13
|
||||
public EntityRegistration(ModContainer mc, ResourceLocation registryName, Class<? extends Entity> entityClass, String entityName, int id, int trackingRange, int updateFrequency, boolean sendsVelocityUpdates)
|
||||
{
|
||||
this(mc, registryName, entityClass, entityName, id, trackingRange, updateFrequency, sendsVelocityUpdates, null);
|
||||
}
|
||||
|
||||
public EntityRegistration(ModContainer mc, ResourceLocation registryName, Class<? extends Entity> entityClass, String entityName, int id, int trackingRange, int updateFrequency, boolean sendsVelocityUpdates, Function<World, ? extends Entity> factory)
|
||||
{
|
||||
this.container = mc;
|
||||
this.regName = registryName;
|
||||
@@ -68,15 +78,27 @@ public class EntityRegistry
|
||||
this.trackingRange = trackingRange;
|
||||
this.updateFrequency = updateFrequency;
|
||||
this.sendsVelocityUpdates = sendsVelocityUpdates;
|
||||
this.factory = factory != null ? factory :
|
||||
new EntityEntryBuilder.ConstructorFactory<Entity>(entityClass) {
|
||||
@Override
|
||||
protected String describeEntity() {
|
||||
return String.valueOf(EntityRegistration.this.getRegistryName());
|
||||
}
|
||||
};
|
||||
}
|
||||
public ResourceLocation getRegistryName()
|
||||
{
|
||||
return regName;
|
||||
}
|
||||
@Deprecated //Used only for creating a new instance in EntitySpawnHandler, use newInstance(world) instead.
|
||||
public Class<? extends Entity> getEntityClass()
|
||||
{
|
||||
return entityClass;
|
||||
}
|
||||
public Entity newInstance(World world)
|
||||
{
|
||||
return this.factory.apply(world);
|
||||
}
|
||||
public ModContainer getContainer()
|
||||
{
|
||||
return container;
|
||||
|
||||
Reference in new issue
Block a user