Manastar now uses serverside mana information

This commit is contained in:
Vincent Lee committed 2018-01-11 23:23:22 -06:00
1 parent 161928b14c
commit 4ff5b6f7ca
1 file changed
+30 -13
@@ -19,27 +19,44 @@ import vazkii.botania.common.Botania;
import vazkii.botania.common.lexicon.LexiconData;
public class SubTileManastar extends SubTileEntity {
private static final int SET_STATE_EVENT = 0;
private static final int NONE = 0, DECREASING = 1, INCREASING = 2;
int manaLastTick = -1;
private int lastMana = 0;
private int state = NONE;
@Override
public void onUpdate() {
super.onUpdate();
int mana = 0;
for(EnumFacing dir : EnumFacing.HORIZONTALS) {
TileEntity tile = supertile.getWorld().getTileEntity(supertile.getPos().offset(dir));
if(tile instanceof IManaPool)
mana += ((IManaPool) tile).getCurrentMana();
}
if(getWorld().isRemote) {
if(state != NONE && Math.random() > 0.6)
Botania.proxy.wispFX(supertile.getPos().getX() + 0.55 + Math.random() * 0.2 - 0.1, supertile.getPos().getY() + 0.75 + Math.random() * 0.2 - 0.1, supertile.getPos().getZ() + 0.5, state == INCREASING ? 0.05F : 1F, 0.05F, state == INCREASING ? 1F : 0.05F, (float) Math.random() / 7, (float) -Math.random() / 50);
} else {
int mana = 0;
for(EnumFacing dir : EnumFacing.HORIZONTALS) {
TileEntity tile = supertile.getWorld().getTileEntity(supertile.getPos().offset(dir));
if(tile instanceof IManaPool)
mana += ((IManaPool) tile).getCurrentMana();
}
if(manaLastTick != -1 && mana != manaLastTick && Math.random() > 0.6) {
boolean more = mana > manaLastTick;
Botania.proxy.wispFX(supertile.getPos().getX() + 0.55 + Math.random() * 0.2 - 0.1, supertile.getPos().getY() + 0.75 + Math.random() * 0.2 - 0.1, supertile.getPos().getZ() + 0.5, more ? 0.05F : 1F, 0.05F, more ? 1F : 0.05F, (float) Math.random() / 7, (float) -Math.random() / 50);
}
int newState = mana > lastMana ? INCREASING : mana < lastMana ? DECREASING : NONE;
if(newState != state)
getWorld().addBlockEvent(getPos(), supertile.getBlockType(), SET_STATE_EVENT, newState);
if(ticksExisted % 60 == 0)
manaLastTick = mana;
if(ticksExisted % 60 == 0)
lastMana = mana;
}
}
@Override
public boolean receiveClientEvent(int id, int param) {
if(id == SET_STATE_EVENT) {
state = param;
return true;
} else {
return super.receiveClientEvent(id, param);
}
}
@Override