fixed some EntityList weirdness

This commit is contained in:
LAX1DUDE 2022-03-30 17:08:08 -07:00
parent 050bf47771
commit d69742f10c
11 changed files with 125 additions and 67 deletions

View File

@ -991,10 +991,14 @@ public abstract class Entity {
/**
* Sets the reference to the World object.
* @return TODO
*/
public void setWorld(World par1World) {
public Entity setWorld(World par1World) {
this.worldObj = par1World;
this.dimension = par1World.provider.dimensionId;
if(par1World != null) {
this.dimension = par1World.provider.dimensionId;
}
return this;
}
/**

View File

@ -3,16 +3,19 @@ package net.minecraft.src;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.function.Function;
public class EntityList {
/** Provides a mapping between entity classes and a string */
private static Map stringToClassMapping = new HashMap();
private static Map stringToConstructorMapping = new HashMap();
/** Provides a mapping between a string and an entity classes */
private static Map classToStringMapping = new HashMap();
/** provides a mapping between an entityID and an Entity Class */
private static Map IDtoClassMapping = new HashMap();
private static Map IDtoConstructorMapping = new HashMap();
/** provides a mapping between an Entity Class and an entity ID */
private static Map classToIDMapping = new HashMap();
@ -27,10 +30,12 @@ public class EntityList {
* adds a mapping between Entity classes and both a string representation and an
* ID
*/
private static void addMapping(Class par0Class, String par1Str, int par2) {
private static void addMapping(Class par0Class, Function<World,Entity> construst, String par1Str, int par2) {
stringToClassMapping.put(par1Str, par0Class);
stringToConstructorMapping.put(par1Str, construst);
classToStringMapping.put(par0Class, par1Str);
IDtoClassMapping.put(Integer.valueOf(par2), par0Class);
IDtoConstructorMapping.put(Integer.valueOf(par2), construst);
classToIDMapping.put(par0Class, Integer.valueOf(par2));
stringToIDMapping.put(par1Str, Integer.valueOf(par2));
}
@ -38,8 +43,8 @@ public class EntityList {
/**
* Adds a entity mapping with egg info.
*/
private static void addMapping(Class par0Class, String par1Str, int par2, int par3, int par4) {
addMapping(par0Class, par1Str, par2);
private static void addMapping(Class par0Class, Function<World,Entity> construst, String par1Str, int par2, int par3, int par4) {
addMapping(par0Class, construst, par1Str, par2);
entityEggs.put(Integer.valueOf(par2), new EntityEggInfo(par2, par3, par4));
}
@ -47,6 +52,7 @@ public class EntityList {
* Create a new instance of an entity in the world by using the entity name.
*/
public static Entity createEntityByName(String par0Str, World par1World) {
/*
Entity var2 = null;
Class var3 = (Class) stringToClassMapping.get(par0Str);
@ -61,8 +67,20 @@ public class EntityList {
}
}
}
if(var2 == null) {
System.err.println("The entity '" + par0Str + "' isn't registered");
}
return var2;
*/
Function<World,Entity> ff = (Function<World,Entity>)stringToConstructorMapping.get(par0Str);
if(ff == null) {
System.err.println("The entity '" + par0Str + "' isn't registered");
return null;
}else {
return ff.apply(par1World);
}
}
/**
@ -89,10 +107,9 @@ public class EntityList {
}
try {
Class var3 = (Class) stringToClassMapping.get(par0NBTTagCompound.getString("id"));
if (var3 != null) {
var2 = (Entity) var3.getConstructor(new Class[] { World.class }).newInstance(new Object[] { par1World });
Function<World,Entity> ff = (Function<World,Entity>)stringToConstructorMapping.get(par0NBTTagCompound.getString("id"));
if (ff != null) {
var2 = ff.apply(par1World);
}
} catch (Exception var4) {
var4.printStackTrace();
@ -163,58 +180,58 @@ public class EntityList {
}
static {
addMapping(EntityItem.class, "Item", 1);
addMapping(EntityXPOrb.class, "XPOrb", 2);
addMapping(EntityPainting.class, "Painting", 9);
addMapping(EntityArrow.class, "Arrow", 10);
addMapping(EntitySnowball.class, "Snowball", 11);
addMapping(EntityLargeFireball.class, "Fireball", 12);
addMapping(EntitySmallFireball.class, "SmallFireball", 13);
addMapping(EntityEnderPearl.class, "ThrownEnderpearl", 14);
addMapping(EntityEnderEye.class, "EyeOfEnderSignal", 15);
addMapping(EntityPotion.class, "ThrownPotion", 16);
addMapping(EntityExpBottle.class, "ThrownExpBottle", 17);
addMapping(EntityItemFrame.class, "ItemFrame", 18);
addMapping(EntityWitherSkull.class, "WitherSkull", 19);
addMapping(EntityTNTPrimed.class, "PrimedTnt", 20);
addMapping(EntityFallingSand.class, "FallingSand", 21);
addMapping(EntityFireworkRocket.class, "FireworksRocketEntity", 22);
addMapping(EntityBoat.class, "Boat", 41);
addMapping(EntityMinecartEmpty.class, "MinecartRideable", 42);
addMapping(EntityMinecartChest.class, "MinecartChest", 43);
addMapping(EntityMinecartFurnace.class, "MinecartFurnace", 44);
addMapping(EntityMinecartTNT.class, "MinecartTNT", 45);
addMapping(EntityMinecartHopper.class, "MinecartHopper", 46);
addMapping(EntityMinecartMobSpawner.class, "MinecartSpawner", 47);
addMapping(EntityLiving.class, "Mob", 48);
addMapping(EntityMob.class, "Monster", 49);
addMapping(EntityCreeper.class, "Creeper", 50, 894731, 0);
addMapping(EntitySkeleton.class, "Skeleton", 51, 12698049, 4802889);
addMapping(EntitySpider.class, "Spider", 52, 3419431, 11013646);
addMapping(EntityZombie.class, "Zombie", 54, 44975, 7969893);
addMapping(EntitySlime.class, "Slime", 55, 5349438, 8306542);
addMapping(EntityGhast.class, "Ghast", 56, 16382457, 12369084);
addMapping(EntityPigZombie.class, "PigZombie", 57, 15373203, 5009705);
addMapping(EntityEnderman.class, "Enderman", 58, 1447446, 0);
addMapping(EntityCaveSpider.class, "CaveSpider", 59, 803406, 11013646);
addMapping(EntitySilverfish.class, "Silverfish", 60, 7237230, 3158064);
addMapping(EntityBlaze.class, "Blaze", 61, 16167425, 16775294);
addMapping(EntityMagmaCube.class, "LavaSlime", 62, 3407872, 16579584);
addMapping(EntityDragon.class, "EnderDragon", 63);
addMapping(EntityWither.class, "WitherBoss", 64);
addMapping(EntityBat.class, "Bat", 65, 4996656, 986895);
addMapping(EntityWitch.class, "Witch", 66, 3407872, 5349438);
addMapping(EntityPig.class, "Pig", 90, 15771042, 14377823);
addMapping(EntitySheep.class, "Sheep", 91, 15198183, 16758197);
addMapping(EntityCow.class, "Cow", 92, 4470310, 10592673);
addMapping(EntityChicken.class, "Chicken", 93, 10592673, 16711680);
addMapping(EntitySquid.class, "Squid", 94, 2243405, 7375001);
addMapping(EntityWolf.class, "Wolf", 95, 14144467, 13545366);
addMapping(EntityMooshroom.class, "MushroomCow", 96, 10489616, 12040119);
addMapping(EntitySnowman.class, "SnowMan", 97);
addMapping(EntityOcelot.class, "Ozelot", 98, 15720061, 5653556);
addMapping(EntityIronGolem.class, "VillagerGolem", 99);
addMapping(EntityVillager.class, "Villager", 120, 5651507, 12422002);
addMapping(EntityEnderCrystal.class, "EnderCrystal", 200);
addMapping(EntityItem.class, (w) -> new EntityItem().setWorld(w), "Item", 1);
addMapping(EntityXPOrb.class, (w) -> new EntityXPOrb().setWorld(w), "XPOrb", 2);
addMapping(EntityPainting.class, (w) -> new EntityPainting(w), "Painting", 9);
addMapping(EntityArrow.class, (w) -> new EntityArrow().setWorld(w), "Arrow", 10);
addMapping(EntitySnowball.class, (w) -> new EntitySnowball().setWorld(w), "Snowball", 11);
addMapping(EntityLargeFireball.class, (w) -> new EntityLargeFireball().setWorld(w), "Fireball", 12);
addMapping(EntitySmallFireball.class, (w) -> new EntitySmallFireball().setWorld(w), "SmallFireball", 13);
addMapping(EntityEnderPearl.class, (w) -> new EntityEnderPearl().setWorld(w), "ThrownEnderpearl", 14);
addMapping(EntityEnderEye.class, (w) -> new EntityEnderEye().setWorld(w), "EyeOfEnderSignal", 15);
addMapping(EntityPotion.class, (w) -> new EntityPotion().setWorld(w), "ThrownPotion", 16);
addMapping(EntityExpBottle.class, (w) -> new EntityExpBottle().setWorld(w), "ThrownExpBottle", 17);
addMapping(EntityItemFrame.class, (w) -> new EntityItemFrame().setWorld(w), "ItemFrame", 18);
addMapping(EntityWitherSkull.class, (w) -> new EntityWitherSkull().setWorld(w), "WitherSkull", 19);
addMapping(EntityTNTPrimed.class, (w) -> new EntityTNTPrimed().setWorld(w), "PrimedTnt", 20);
addMapping(EntityFallingSand.class, (w) -> new EntityFallingSand().setWorld(w), "FallingSand", 21);
addMapping(EntityFireworkRocket.class, (w) -> new EntityFireworkRocket().setWorld(w), "FireworksRocketEntity", 22);
addMapping(EntityBoat.class, (w) -> new EntityBoat().setWorld(w), "Boat", 41);
addMapping(EntityMinecartEmpty.class, (w) -> new EntityMinecartEmpty(w), "MinecartRideable", 42);
addMapping(EntityMinecartChest.class, (w) -> new EntityMinecartChest(w), "MinecartChest", 43);
addMapping(EntityMinecartFurnace.class, (w) -> new EntityMinecartFurnace(w), "MinecartFurnace", 44);
addMapping(EntityMinecartTNT.class, (w) -> new EntityMinecartTNT(w), "MinecartTNT", 45);
addMapping(EntityMinecartHopper.class, (w) -> new EntityMinecartHopper(w), "MinecartHopper", 46);
addMapping(EntityMinecartMobSpawner.class, (w) -> new EntityMinecartMobSpawner(w), "MinecartSpawner", 47);
//addMapping(EntityLiving.class, "Mob", 48);
//addMapping(EntityMob.class, "Monster", 49);
addMapping(EntityCreeper.class, (w) -> new EntityCreeper().setWorld(w), "Creeper", 50, 894731, 0);
addMapping(EntitySkeleton.class, (w) -> new EntitySkeleton().setWorld(w), "Skeleton", 51, 12698049, 4802889);
addMapping(EntitySpider.class, (w) -> new EntitySpider().setWorld(w), "Spider", 52, 3419431, 11013646);
addMapping(EntityZombie.class, (w) -> new EntityZombie().setWorld(w), "Zombie", 54, 44975, 7969893);
addMapping(EntitySlime.class, (w) -> new EntitySlime().setWorld(w), "Slime", 55, 5349438, 8306542);
addMapping(EntityGhast.class, (w) -> new EntityGhast().setWorld(w), "Ghast", 56, 16382457, 12369084);
addMapping(EntityPigZombie.class, (w) -> new EntityPigZombie().setWorld(w), "PigZombie", 57, 15373203, 5009705);
addMapping(EntityEnderman.class, (w) -> new EntityEnderman().setWorld(w), "Enderman", 58, 1447446, 0);
addMapping(EntityCaveSpider.class, (w) -> new EntityCaveSpider().setWorld(w), "CaveSpider", 59, 803406, 11013646);
addMapping(EntitySilverfish.class, (w) -> new EntitySilverfish().setWorld(w), "Silverfish", 60, 7237230, 3158064);
addMapping(EntityBlaze.class, (w) -> new EntityBlaze().setWorld(w), "Blaze", 61, 16167425, 16775294);
addMapping(EntityMagmaCube.class, (w) -> new EntityMagmaCube().setWorld(w), "LavaSlime", 62, 3407872, 16579584);
addMapping(EntityDragon.class, (w) -> new EntityDragon().setWorld(w), "EnderDragon", 63);
addMapping(EntityWither.class, (w) -> new EntityWither().setWorld(w), "WitherBoss", 64);
addMapping(EntityBat.class, (w) -> new EntityBat().setWorld(w), "Bat", 65, 4996656, 986895);
addMapping(EntityWitch.class, (w) -> new EntityWitch().setWorld(w), "Witch", 66, 3407872, 5349438);
addMapping(EntityPig.class, (w) -> new EntityPig().setWorld(w), "Pig", 90, 15771042, 14377823);
addMapping(EntitySheep.class, (w) -> new EntitySheep().setWorld(w), "Sheep", 91, 15198183, 16758197);
addMapping(EntityCow.class, (w) -> new EntityCow().setWorld(w), "Cow", 92, 4470310, 10592673);
addMapping(EntityChicken.class, (w) -> new EntityChicken().setWorld(w), "Chicken", 93, 10592673, 16711680);
addMapping(EntitySquid.class, (w) -> new EntitySquid().setWorld(w), "Squid", 94, 2243405, 7375001);
addMapping(EntityWolf.class, (w) -> new EntityWolf().setWorld(w), "Wolf", 95, 14144467, 13545366);
addMapping(EntityMooshroom.class, (w) -> new EntityMooshroom().setWorld(w), "MushroomCow", 96, 10489616, 12040119);
addMapping(EntitySnowman.class, (w) -> new EntitySnowman().setWorld(w), "SnowMan", 97);
addMapping(EntityOcelot.class, (w) -> new EntityOcelot().setWorld(w), "Ozelot", 98, 15720061, 5653556);
addMapping(EntityIronGolem.class, (w) -> new EntityIronGolem().setWorld(w), "VillagerGolem", 99);
addMapping(EntityVillager.class, (w) -> new EntityVillager().setWorld(w), "Villager", 120, 5651507, 12422002);
addMapping(EntityEnderCrystal.class, (w) -> new EntityEnderCrystal().setWorld(w), "EnderCrystal", 200);
}
}

View File

@ -61,9 +61,12 @@ public abstract class EntityMinecart extends Entity {
}
}
public void setWorld(World w) {
public Entity setWorld(World w) {
super.setWorld(w);
this.field_82344_g = w.func_82735_a(this);
if(w != null) {
this.field_82344_g = w.func_82735_a(this);
}
return this;
}
/**

View File

@ -2,6 +2,11 @@ package net.minecraft.src;
public class EntityMinecartChest extends EntityMinecartContainer {
public EntityMinecartChest(World par1) {
super();
setWorld(par1);
}
public EntityMinecartChest(World par1, double par2, double par4, double par6) {
super(par1, par2, par4, par6);
}

View File

@ -1,6 +1,11 @@
package net.minecraft.src;
public class EntityMinecartEmpty extends EntityMinecart {
public EntityMinecartEmpty(World par1) {
super();
setWorld(par1);
}
public EntityMinecartEmpty(World par1, double par2, double par4, double par6) {
super(par1, par2, par4, par6);

View File

@ -5,6 +5,10 @@ public class EntityMinecartFurnace extends EntityMinecart {
public double pushX;
public double pushZ;
public EntityMinecartFurnace(World par1World) {
super();
setWorld(par1World);
}
public EntityMinecartFurnace(World par1World, double par2, double par4, double par6) {
super(par1World, par2, par4, par6);
}

View File

@ -6,7 +6,11 @@ public class EntityMinecartHopper extends EntityMinecartContainer implements Hop
/** Whether this hopper minecart is being blocked by an activator rail. */
private boolean isBlocked = true;
private int transferTicker = -1;
public EntityMinecartHopper(World par1World) {
super();
setWorld(par1World);
}
public EntityMinecartHopper(World par1World, double par2, double par4, double par6) {
super(par1World, par2, par4, par6);
}

View File

@ -2,7 +2,10 @@ package net.minecraft.src;
public class EntityMinecartMobSpawner extends EntityMinecart {
/** Mob spawner logic for this spawner minecart. */
public EntityMinecartMobSpawner(World par1World) {
super();
setWorld(par1World);
}
public EntityMinecartMobSpawner(World par1World, double par2, double par4, double par6) {
super(par1World, par2, par4, par6);
}

View File

@ -5,6 +5,10 @@ package net.minecraft.src;
public class EntityMinecartTNT extends EntityMinecart {
private int minecartTNTFuse = -1;
public EntityMinecartTNT(World par1) {
super();
setWorld(par1);
}
public EntityMinecartTNT(World par1, double par2, double par4, double par6) {
super(par1, par2, par4, par6);
}

View File

@ -4,6 +4,11 @@ import java.util.ArrayList;
public class EntityPainting extends EntityHanging {
public EnumArt art;
public EntityPainting(World par1World) {
super();
this.setWorld(par1World);
}
public EntityPainting(World par1World, int par2, int par3, int par4, int par5) {
super(par1World, par2, par3, par4, par5);

View File

@ -52,9 +52,13 @@ public class GuiConnecting extends GuiScreen {
this.mc.displayGuiScreen(new GuiDisconnected(this.field_98098_c, "connect.failed", "disconnect.genericReason", "invalid uri websocket protocol", ""));
return;
}
int i = uria.indexOf(':');
int i = uria.lastIndexOf(':');
int port = -1;
if(i > 0 && uria.startsWith("[") && uria.charAt(i - 1) != ']') {
i = -1;
}
if(i == -1) port = uri.startsWith("wss") ? 443 : 80;
if(uria.endsWith("/")) uria = uria.substring(0, uria.length() - 1);