Workaround for 'global' particles at small render distances. Close #15 (mostly)

This commit is contained in:
Vincent Lee committed 2016-05-21 23:38:17 -05:00
1 parent f52dca111f
commit 930703b5c1
6 files changed
+27 -3

No files matched your search

@@ -490,5 +490,10 @@ public class ClientProxy extends CommonProxy {
public void removeBoss(IBotaniaBoss boss) {
BossBarHandler.bosses.remove(boss);
}
@Override
public int getClientRenderDistance() {
return Minecraft.getMinecraft().gameSettings.renderDistanceChunks;
}
}
@@ -35,7 +35,7 @@ public class TileManaBeacon extends TileMod {
Botania.proxy.wispFX(worldObj, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, r / 255F, g / 255F, b / 255F, (float) Math.random() * 5 + 1F, (float) (Math.random() - 0.5F), 10F * (float) Math.sqrt(256F / (256F - pos.getY())), (float) (Math.random() - 0.5F));
for(int i = 0; i < 2; i++)
Botania.proxy.wispFX(worldObj, pos.getX() + 0.5, 256, pos.getZ() + 0.5, r / 255F, g / 255F, b / 255F, (float) Math.random() * 15 + 8F, (float) (Math.random() - 0.5F) * 8F, 0F, (float) (Math.random() - 0.5F) * 8F);
Botania.proxy.wispFX(worldObj, pos.getX() + 0.5, Math.min(256, pos.getY() + Botania.proxy.getClientRenderDistance() * 16), pos.getZ() + 0.5, r / 255F, g / 255F, b / 255F, (float) Math.random() * 15 + 8F, (float) (Math.random() - 0.5F) * 8F, 0F, (float) (Math.random() - 0.5F) * 8F);
Botania.proxy.setWispFXDistanceLimit(true);
}
}
@@ -31,7 +31,7 @@ public class TileStarfield extends TileMod {
int iter = 2;
for(int i = 0; i < iter; i++) {
double x = pos.getX() + 0.5 + (Math.random() - 0.5) * radius;
double y = pos.getY() + 256;
double y = Math.min(256, pos.getY() + Botania.proxy.getClientRenderDistance() * 16);
double z = pos.getZ() + 0.5 + (Math.random() - 0.5) * radius;
float w = 0.6F;
@@ -336,4 +336,8 @@ public class CommonProxy {
// NO-OP
}
public int getClientRenderDistance() {
return 0;
}
}
@@ -17,6 +17,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.datasync.DataParameter;
import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.network.datasync.EntityDataManager;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import vazkii.botania.common.Botania;
@@ -25,7 +26,9 @@ import javax.annotation.Nonnull;
public class EntitySignalFlare extends Entity {
private static final String COLOR_TAG = "color";
private static final String FIRED_Y_TAG = "firedY";
private static final DataParameter<Integer> COLOR = EntityDataManager.createKey(EntitySignalFlare.class, DataSerializers.VARINT);
private static final DataParameter<Integer> FIRED_Y = EntityDataManager.createKey(EntitySignalFlare.class, DataSerializers.VARINT);
public EntitySignalFlare(World par1World) {
super(par1World);
@@ -35,6 +38,7 @@ public class EntitySignalFlare extends Entity {
@Override
protected void entityInit() {
dataManager.register(COLOR, 0);
dataManager.register(FIRED_Y, 0);
}
@Override
@@ -59,7 +63,7 @@ public class EntitySignalFlare extends Entity {
Botania.proxy.wispFX(worldObj, posX, posY, posZ + 0.5, r / 255F, g / 255F, b / 255F, (float) Math.random() * 5 + 1F, (float) (Math.random() - 0.5F), 10F * (float) Math.sqrt(256F / (256F - (float) posY)), (float) (Math.random() - 0.5F));
for(int i = 0; i < 4; i++)
Botania.proxy.wispFX(worldObj, posX + 0.5, 256, posZ + 0.5, r / 255F, g / 255F, b / 255F, (float) Math.random() * 15 + 8F, (float) (Math.random() - 0.5F) * 8F, 0F, (float) (Math.random() - 0.5F) * 8F);
Botania.proxy.wispFX(worldObj, posX + 0.5, Math.min(256, getFiredAt() + Botania.proxy.getClientRenderDistance() * 16), posZ + 0.5, r / 255F, g / 255F, b / 255F, (float) Math.random() * 15 + 8F, (float) (Math.random() - 0.5F) * 8F, 0F, (float) (Math.random() - 0.5F) * 8F);
Botania.proxy.setWispFXDistanceLimit(true);
}
}
@@ -68,11 +72,13 @@ public class EntitySignalFlare extends Entity {
@Override
protected void readEntityFromNBT(@Nonnull NBTTagCompound nbttagcompound) {
setColor(nbttagcompound.getInteger(COLOR_TAG));
setFiredAt(nbttagcompound.getInteger(FIRED_Y_TAG));
}
@Override
protected void writeEntityToNBT(@Nonnull NBTTagCompound nbttagcompound) {
nbttagcompound.setInteger(COLOR_TAG, getColor());
nbttagcompound.setInteger(FIRED_Y_TAG, getFiredAt());
}
public void setColor(int color) {
@@ -83,4 +89,12 @@ public class EntitySignalFlare extends Entity {
return dataManager.get(COLOR);
}
public void setFiredAt(int y) {
dataManager.set(FIRED_Y, y);
}
public int getFiredAt() {
return dataManager.get(FIRED_Y);
}
}
@@ -57,6 +57,7 @@ public class ItemSignalFlare extends ItemMod implements IColorable {
EntitySignalFlare flare = new EntitySignalFlare(par2World);
flare.setPosition(par3EntityPlayer.posX, par3EntityPlayer.posY, par3EntityPlayer.posZ);
flare.setColor(getColor(par1ItemStack));
flare.setFiredAt((int) par3EntityPlayer.posY);
par2World.playSound(null, par3EntityPlayer.posX, par3EntityPlayer.posY, par3EntityPlayer.posZ, SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.PLAYERS, 40F, (1.0F + (par2World.rand.nextFloat() - par2World.rand.nextFloat()) * 0.2F) * 0.7F);
par2World.spawnEntityInWorld(flare);