use of blusunrize.immersiveengineering.common.util.network.MessageTileSync in project ImmersiveEngineering by BluSunrize.
the class TileEntityBelljar method sendSyncPacket.
protected void sendSyncPacket(int type) {
NBTTagCompound nbt = new NBTTagCompound();
if (type == 0) {
nbt.setFloat("growth", growth);
nbt.setInteger("energy", energyStorage.getEnergyStored());
nbt.setBoolean("renderActive", renderActive);
} else if (type == 1) {
nbt.setInteger("fertilizerAmount", fertilizerAmount);
nbt.setFloat("fertilizerMod", fertilizerMod);
} else if (type == 2)
nbt.setTag("tank", tank.writeToNBT(new NBTTagCompound()));
ImmersiveEngineering.packetHandler.sendToAllAround(new MessageTileSync(this, nbt), new TargetPoint(worldObj.provider.getDimension(), getPos().getX(), getPos().getY(), getPos().getZ(), 128));
}
use of blusunrize.immersiveengineering.common.util.network.MessageTileSync in project ImmersiveEngineering by BluSunrize.
the class TileEntityExcavator method update.
@Override
public void update() {
super.update();
if (isDummy())
return;
if (!worldObj.isRemote) {
BlockPos wheelPos = this.getBlockPosForPos(31);
TileEntity center = worldObj.getTileEntity(wheelPos);
if (center instanceof TileEntityBucketWheel) {
float rot = 0;
int target = -1;
TileEntityBucketWheel wheel = ((TileEntityBucketWheel) center);
EnumFacing fRot = this.facing.rotateYCCW();
if (wheel.facing == fRot) {
if (active != wheel.active)
worldObj.addBlockEvent(wheel.getPos(), wheel.getBlockType(), 0, active ? 1 : 0);
rot = wheel.rotation;
if (rot % 45 > 40)
target = Math.round(rot / 360f * 8) % 8;
}
if (wheel.facing != fRot || wheel.mirrored != this.mirrored) {
for (int h = -3; h <= 3; h++) for (int w = -3; w <= 3; w++) {
TileEntity te = worldObj.getTileEntity(wheelPos.add(0, h, 0).offset(facing, w));
if (te instanceof TileEntityBucketWheel) {
((TileEntityBucketWheel) te).facing = fRot;
((TileEntityBucketWheel) te).mirrored = this.mirrored;
te.markDirty();
((TileEntityBucketWheel) te).markContainingBlockForUpdate(null);
worldObj.addBlockEvent(te.getPos(), te.getBlockType(), 255, 0);
}
}
}
if (!isRSDisabled()) {
ExcavatorHandler.MineralMix mineral = ExcavatorHandler.getRandomMineral(worldObj, wheelPos.getX() >> 4, wheelPos.getZ() >> 4);
int consumed = IEConfig.Machines.excavator_consumption;
int extracted = energyStorage.extractEnergy(consumed, true);
if (extracted >= consumed) {
energyStorage.extractEnergy(consumed, false);
active = true;
if (target >= 0 && target < 8) {
int targetDown = (target + 4) % 8;
NBTTagCompound packet = new NBTTagCompound();
if (wheel.digStacks[targetDown] == null) {
ItemStack blocking = this.digBlocksInTheWay(wheel);
BlockPos lowGroundPos = wheelPos.add(0, -5, 0);
if (blocking != null) {
wheel.digStacks[targetDown] = blocking;
wheel.markDirty();
this.markContainingBlockForUpdate(null);
} else if (mineral != null && !worldObj.isAirBlock(lowGroundPos.offset(facing, -2)) && !worldObj.isAirBlock(lowGroundPos.offset(facing, 2)) && !worldObj.isAirBlock(lowGroundPos.offset(facing, -1)) && !worldObj.isAirBlock(lowGroundPos.offset(facing, 1)) && !worldObj.isAirBlock(lowGroundPos)) {
ItemStack ore = mineral.getRandomOre(worldObj.rand);
float configChance = worldObj.rand.nextFloat();
float failChance = worldObj.rand.nextFloat();
if (ore != null && configChance > IEConfig.Machines.excavator_fail_chance && failChance > mineral.failChance) {
wheel.digStacks[targetDown] = ore;
wheel.markDirty();
this.markContainingBlockForUpdate(null);
}
ExcavatorHandler.depleteMinerals(worldObj, wheelPos.getX() >> 4, wheelPos.getZ() >> 4);
}
if (wheel.digStacks[targetDown] != null) {
packet.setInteger("fill", targetDown);
packet.setTag("fillStack", wheel.digStacks[targetDown].writeToNBT(new NBTTagCompound()));
}
}
if (wheel.digStacks[target] != null) {
this.doProcessOutput(wheel.digStacks[target].copy());
Block b = Block.getBlockFromItem(wheel.digStacks[target].getItem());
if (b != null && b != Blocks.AIR)
wheel.particleStack = wheel.digStacks[target].copy();
wheel.digStacks[target] = null;
wheel.markDirty();
this.markContainingBlockForUpdate(null);
packet.setInteger("empty", target);
}
if (!packet.hasNoTags())
ImmersiveEngineering.packetHandler.sendToAll(new MessageTileSync(wheel, packet));
}
} else if (active)
active = false;
} else if (active) {
active = false;
// update = true;
}
// if(update)
// {
// this.markDirty();
// worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
// }
}
}
}
use of blusunrize.immersiveengineering.common.util.network.MessageTileSync in project ImmersiveEngineering by BluSunrize.
the class TileEntityBucketWheel method update.
@Override
public void update() {
if (!formed || pos != 24)
return;
if (active) {
rotation += IEConfig.Machines.excavator_speed;
rotation %= 360;
}
if (worldObj.isRemote) {
if (particleStack != null) {
ImmersiveEngineering.proxy.spawnBucketWheelFX(this, particleStack);
particleStack = null;
}
} else if (active && worldObj.getTotalWorldTime() % 20 == 0) {
NBTTagCompound nbt = new NBTTagCompound();
nbt.setFloat("rotation", rotation);
MessageTileSync sync = new MessageTileSync(this, nbt);
ImmersiveEngineering.packetHandler.sendToAllAround(sync, new TargetPoint(worldObj.provider.getDimension(), getPos().getX(), getPos().getY(), getPos().getZ(), 100));
}
}
use of blusunrize.immersiveengineering.common.util.network.MessageTileSync in project ImmersiveEngineering by BluSunrize.
the class GuiAssembler method actionPerformed.
@Override
protected void actionPerformed(GuiButton button) {
NBTTagCompound tag = new NBTTagCompound();
tag.setInteger("buttonID", button.id);
ImmersiveEngineering.packetHandler.sendToServer(new MessageTileSync(tile, tag));
if (button.id == 3) {
tile.recursiveIngredients = !tile.recursiveIngredients;
this.initGui();
}
}
use of blusunrize.immersiveengineering.common.util.network.MessageTileSync in project ImmersiveEngineering by BluSunrize.
the class GuiSorter method actionPerformed.
@Override
protected void actionPerformed(GuiButton button) {
if (button instanceof ButtonSorter && FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) {
int side = button.id / 3;
int bit = button.id % 3;
int mask = (1 << bit);
this.tile.sideFilter[side] = this.tile.sideFilter[side] ^ mask;
NBTTagCompound tag = new NBTTagCompound();
tag.setIntArray("sideConfig", this.tile.sideFilter);
ImmersiveEngineering.packetHandler.sendToServer(new MessageTileSync(tile, tag));
this.initGui();
}
}
Aggregations