M src/main/java/vazkii/botania/client/render/entity/RenderCorporeaSpark.java => src/main/java/vazkii/botania/client/render/entity/RenderCorporeaSpark.java +0 -5
@@ 31,11 31,6 @@ public class RenderCorporeaSpark extends RenderSparkBase<EntityCorporeaSpark> {
}
@Override
- protected DataParameter<Integer> getInvisibilityParam() {
- return EntityCorporeaSpark.INVISIBILITY;
- }
-
- @Override
public TextureAtlasSprite getBaseIcon(EntityCorporeaSpark entity) {
return entity.isMaster() ? MiscellaneousIcons.INSTANCE.corporeaWorldIconMaster : MiscellaneousIcons.INSTANCE.corporeaWorldIcon;
}
M src/main/java/vazkii/botania/client/render/entity/RenderSpark.java => src/main/java/vazkii/botania/client/render/entity/RenderSpark.java +0 -5
@@ 23,11 23,6 @@ public class RenderSpark extends RenderSparkBase<EntitySpark> {
}
@Override
- protected DataParameter<Integer> getInvisibilityParam() {
- return EntitySpark.INVISIBILITY;
- }
-
- @Override
public TextureAtlasSprite getSpinningIcon(EntitySpark entity) {
int upgrade = entity.getUpgrade().ordinal() - 1;
return upgrade >= 0 && upgrade < MiscellaneousIcons.INSTANCE.sparkUpgradeIcons.length ? MiscellaneousIcons.INSTANCE.sparkUpgradeIcons[upgrade] : null;
M src/main/java/vazkii/botania/client/render/entity/RenderSparkBase.java => src/main/java/vazkii/botania/client/render/entity/RenderSparkBase.java +1 -3
@@ 49,7 49,7 @@ public abstract class RenderSparkBase<T extends Entity> extends Render<T> {
double time = ClientTickHandler.ticksInGame + par9;
time += new Random(tEntity.getEntityId()).nextInt();
- float a = 0.1F + (1 - tEntity.getDataManager().get(getInvisibilityParam())) * 0.8F;
+ float a = 0.1F + (tEntity.isInvisible() ? 0 : 1) * 0.8F;
GlStateManager.color(1F, 1F, 1F, (0.7F + 0.3F * (float) (Math.sin(time / 5.0) + 0.5) * 2) * a);
@@ 80,8 80,6 @@ public abstract class RenderSparkBase<T extends Entity> extends Render<T> {
GlStateManager.popMatrix();
}
- protected abstract DataParameter<Integer> getInvisibilityParam();
-
protected TextureAtlasSprite getBaseIcon(T entity) {
return MiscellaneousIcons.INSTANCE.sparkWorldIcon;
}
M src/main/java/vazkii/botania/common/entity/EntityCorporeaSpark.java => src/main/java/vazkii/botania/common/entity/EntityCorporeaSpark.java +34 -47
@@ 48,7 48,6 @@ public class EntityCorporeaSpark extends Entity implements ICorporeaSpark {
private static final DataParameter<Boolean> MASTER = EntityDataManager.createKey(EntityCorporeaSpark.class, DataSerializers.BOOLEAN);
private static final DataParameter<Integer> NETWORK = EntityDataManager.createKey(EntityCorporeaSpark.class, DataSerializers.VARINT);
- public static final DataParameter<Integer> INVISIBILITY = EntityDataManager.createKey(EntityCorporeaSpark.class, DataSerializers.VARINT);
private static final DataParameter<Integer> ITEM_DISPLAY_TICKS = EntityDataManager.createKey(EntityCorporeaSpark.class, DataSerializers.VARINT);
private static final DataParameter<ItemStack> DISPLAY_STACK = EntityDataManager.createKey(EntityCorporeaSpark.class, DataSerializers.OPTIONAL_ITEM_STACK);
@@ 65,7 64,6 @@ public class EntityCorporeaSpark extends Entity implements ICorporeaSpark {
@Override
protected void entityInit() {
setSize(0.1F, 0.5F);
- dataManager.register(INVISIBILITY, 0);
dataManager.register(MASTER, false);
dataManager.register(NETWORK, 0);
dataManager.register(ITEM_DISPLAY_TICKS, 0);
@@ 131,9 129,8 @@ public class EntityCorporeaSpark extends Entity implements ICorporeaSpark {
@Override
public void registerConnections(ICorporeaSpark master, ICorporeaSpark referrer, List<ICorporeaSpark> connections) {
- List<ICorporeaSpark> sparks = getNearbySparks();
relatives.clear();
- for(ICorporeaSpark spark : sparks) {
+ for(ICorporeaSpark spark : getNearbySparks()) {
if(spark == null || connections.contains(spark) || spark.getNetwork() != getNetwork() || spark.isMaster() || ((Entity) spark).isDead)
continue;
@@ 147,8 144,7 @@ public class EntityCorporeaSpark extends Entity implements ICorporeaSpark {
}
private List<ICorporeaSpark> getNearbySparks() {
- List ret = world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(posX - SCAN_RANGE, posY - SCAN_RANGE, posZ - SCAN_RANGE, posX + SCAN_RANGE, posY + SCAN_RANGE, posZ + SCAN_RANGE), Predicates.instanceOf(ICorporeaSpark.class));
- return ret;
+ return (List) world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(posX - SCAN_RANGE, posY - SCAN_RANGE, posZ - SCAN_RANGE, posX + SCAN_RANGE, posY + SCAN_RANGE, posZ + SCAN_RANGE), Predicates.instanceOf(ICorporeaSpark.class));
}
private void restartNetwork() {
@@ 164,19 160,16 @@ public class EntityCorporeaSpark extends Entity implements ICorporeaSpark {
}
private void findNetwork() {
- List<ICorporeaSpark> sparks = getNearbySparks();
- if(sparks.size() > 0) {
- for(ICorporeaSpark spark : sparks)
- if(spark.getNetwork() == getNetwork() && !((Entity) spark).isDead) {
- ICorporeaSpark master = spark.getMaster();
- if(master != null) {
- this.master = master;
- restartNetwork();
-
- break;
- }
+ for(ICorporeaSpark spark : getNearbySparks())
+ if(spark.getNetwork() == getNetwork() && !((Entity) spark).isDead) {
+ ICorporeaSpark master = spark.getMaster();
+ if(master != null) {
+ this.master = master;
+ restartNetwork();
+
+ break;
}
- }
+ }
}
private static void displayRelatives(EntityPlayer player, List<ICorporeaSpark> checked, ICorporeaSpark spark) {
@@ 270,46 263,40 @@ public class EntityCorporeaSpark extends Entity implements ICorporeaSpark {
public boolean processInitialInteract(EntityPlayer player, EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
if(!stack.isEmpty()) {
+ if(player.world.isRemote) {
+ boolean valid = stack.getItem() == ModItems.twigWand || stack.getItem() == ModItems.dye || stack.getItem() == ModItems.phantomInk;
+ if(valid)
+ player.swingArm(hand);
+ return valid;
+ }
+
if(stack.getItem() == ModItems.twigWand) {
if(player.isSneaking()) {
- if(!player.world.isRemote) {
- dropAndKill();
- if(isMaster())
- restartNetwork();
- } else player.swingArm(hand);
- return true;
+ dropAndKill();
+ if(isMaster())
+ restartNetwork();
} else {
- if(!player.world.isRemote) {
- displayRelatives(player, new ArrayList<>(), master);
- }
- return true;
+ displayRelatives(player, new ArrayList<>(), master);
}
+ return true;
} else if(stack.getItem() == ModItems.dye) {
int color = stack.getItemDamage();
if(color != getNetwork().getMetadata()) {
- if(!world.isRemote) {
- setNetwork(EnumDyeColor.byMetadata(color));
+ setNetwork(EnumDyeColor.byMetadata(color));
- if(master != null)
- restartNetwork();
- else findNetwork();
+ if(master != null)
+ restartNetwork();
+ else findNetwork();
- stack.shrink(1);
- } else player.swingArm(hand);
+ stack.shrink(1);
+ return true;
}
+ } else if(stack.getItem() == ModItems.phantomInk) {
+ setInvisible(true);
+ return true;
}
}
- return doPhantomInk(stack);
- }
-
- public boolean doPhantomInk(ItemStack stack) {
- if(!stack.isEmpty() && stack.getItem() == ModItems.phantomInk && !world.isRemote) {
- int invis = dataManager.get(INVISIBILITY);
- dataManager.set(INVISIBILITY, ~invis & 1);
- return true;
- }
-
return false;
}
@@ 317,14 304,14 @@ public class EntityCorporeaSpark extends Entity implements ICorporeaSpark {
protected void readEntityFromNBT(@Nonnull NBTTagCompound cmp) {
setMaster(cmp.getBoolean(TAG_MASTER));
setNetwork(EnumDyeColor.byMetadata(cmp.getInteger(TAG_NETWORK)));
- dataManager.set(INVISIBILITY, cmp.getInteger(TAG_INVIS));
+ setInvisible(cmp.getInteger(TAG_INVIS) == 1);
}
@Override
protected void writeEntityToNBT(@Nonnull NBTTagCompound cmp) {
cmp.setBoolean(TAG_MASTER, isMaster());
cmp.setInteger(TAG_NETWORK, getNetwork().getMetadata());
- cmp.setInteger(TAG_INVIS, dataManager.get(INVISIBILITY));
+ cmp.setInteger(TAG_INVIS, isInvisible() ? 1 : 0);
}
}
M src/main/java/vazkii/botania/common/entity/EntitySpark.java => src/main/java/vazkii/botania/common/entity/EntitySpark.java +11 -13
@@ 56,7 56,6 @@ public class EntitySpark extends Entity implements ISparkEntity {
private static final int TRANSFER_RATE = 1000;
private static final String TAG_UPGRADE = "upgrade";
private static final String TAG_INVIS = "invis";
- public static final DataParameter<Integer> INVISIBILITY = EntityDataManager.createKey(EntitySpark.class, DataSerializers.VARINT);
private static final DataParameter<Integer> UPGRADE = EntityDataManager.createKey(EntitySpark.class, DataSerializers.VARINT);
private final Set<ISparkEntity> transfers = Collections.newSetFromMap(new WeakHashMap<>());
@@ 71,7 70,6 @@ public class EntitySpark extends Entity implements ISparkEntity {
@Override
protected void entityInit() {
setSize(0.1F, 0.5F);
- dataManager.register(INVISIBILITY, 0);
dataManager.register(UPGRADE, 0);
}
@@ 245,9 243,13 @@ public class EntitySpark extends Entity implements ISparkEntity {
public boolean processInitialInteract(EntityPlayer player, EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
if(!stack.isEmpty()) {
- if(world.isRemote)
- return stack.getItem() == ModItems.twigWand || stack.getItem() == ModItems.sparkUpgrade
- || stack.getItem() == ModItems.phantomInk;
+ if(world.isRemote) {
+ boolean valid = stack.getItem() == ModItems.twigWand || stack.getItem() == ModItems.sparkUpgrade
+ || stack.getItem() == ModItems.phantomInk;
+ if(valid)
+ player.swingArm(hand);
+ return valid;
+ }
SparkUpgradeType upgrade = getUpgrade();
if(stack.getItem() == ModItems.twigWand) {
@@ 259,11 261,9 @@ public class EntitySpark extends Entity implements ISparkEntity {
transfers.clear();
removeTransferants = 2;
} else dropAndKill();
- player.swingArm(hand);
return true;
} else {
- List<ISparkEntity> allSparks = SparkHelper.getSparksAround(world, posX, posY, posZ);
- for(ISparkEntity spark : allSparks)
+ for(ISparkEntity spark : SparkHelper.getSparksAround(world, posX, posY, posZ))
particleBeam(player, this, (Entity) spark);
return true;
}
@@ 271,11 271,9 @@ public class EntitySpark extends Entity implements ISparkEntity {
int newUpgrade = stack.getItemDamage() + 1;
setUpgrade(SparkUpgradeType.values()[newUpgrade]);
stack.shrink(1);
- player.swingArm(hand);
return true;
} else if (stack.getItem() == ModItems.phantomInk) {
- int invis = dataManager.get(INVISIBILITY);
- dataManager.set(INVISIBILITY, ~invis & 1);
+ setInvisible(true);
return true;
}
}
@@ 286,13 284,13 @@ public class EntitySpark extends Entity implements ISparkEntity {
@Override
protected void readEntityFromNBT(@Nonnull NBTTagCompound cmp) {
setUpgrade(SparkUpgradeType.values()[cmp.getInteger(TAG_UPGRADE)]);
- dataManager.set(INVISIBILITY, cmp.getInteger(TAG_INVIS));
+ setInvisible(cmp.getInteger(TAG_INVIS) == 1);
}
@Override
protected void writeEntityToNBT(@Nonnull NBTTagCompound cmp) {
cmp.setInteger(TAG_UPGRADE, getUpgrade().ordinal());
- cmp.setInteger(TAG_INVIS, dataManager.get(INVISIBILITY));
+ cmp.setInteger(TAG_INVIS, isInvisible() ? 1 : 0);
}
@Override