mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-18 19:29:31 +00:00
Throttle packet output and remove hydroangeas block updates. Closes #734
This commit is contained in:
1 parent
b82b25044c
commit
b455d4bc83
5 files changed
+67
-13
No files matched your search
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* This class was created by <Vazkii>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*
|
||||
* File Created @ [Apr 12, 2015, 3:08:09 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.api.mana;
|
||||
|
||||
/**
|
||||
* A TileEntity that will only send a few packets rather than one per every entity collision.
|
||||
* markDispatchable marks that this TE needs to send a packet. Further handling is to be done
|
||||
* in the TE itself.
|
||||
*/
|
||||
public interface IThrottledPacket {
|
||||
|
||||
public void markDispatchable();
|
||||
|
||||
}
|
||||
+19
-10
@@ -20,11 +20,13 @@ import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import vazkii.botania.api.lexicon.LexiconEntry;
|
||||
import vazkii.botania.api.subtile.RadiusDescriptor;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.core.helper.ItemNBTHelper;
|
||||
import vazkii.botania.common.lexicon.LexiconData;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
public class SubTileHydroangeas extends SubTilePassiveGenerating {
|
||||
|
||||
@@ -46,8 +48,6 @@ public class SubTileHydroangeas extends SubTilePassiveGenerating {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean didSomething = false;
|
||||
|
||||
if(burnTime == 0) {
|
||||
if(mana < getMaxMana() && !supertile.getWorldObj().isRemote) {
|
||||
List<int[]> offsets = Arrays.asList(OFFSETS);
|
||||
@@ -58,15 +58,27 @@ public class SubTileHydroangeas extends SubTilePassiveGenerating {
|
||||
supertile.xCoord + offsetArray[0],
|
||||
supertile.zCoord + offsetArray[1]
|
||||
};
|
||||
if(supertile.getWorldObj().getBlock(positions[0], supertile.yCoord, positions[1]) == getBlockToSearchFor() && (getBlockToSearchBelow() == null || supertile.getWorldObj().getBlock(positions[0], supertile.yCoord - 1, positions[1]) == getBlockToSearchBelow()) && supertile.getWorldObj().getBlockMetadata(positions[0], supertile.yCoord, positions[1]) == 0) {
|
||||
supertile.getWorldObj().setBlockToAir(positions[0], supertile.yCoord, positions[1]);
|
||||
didSomething = true;
|
||||
|
||||
Block search = getBlockToSearchFor();
|
||||
if(supertile.getWorldObj().getBlock(positions[0], supertile.yCoord, positions[1]) == search && (getBlockToSearchBelow() == null || supertile.getWorldObj().getBlock(positions[0], supertile.yCoord - 1, positions[1]) == getBlockToSearchBelow()) && supertile.getWorldObj().getBlockMetadata(positions[0], supertile.yCoord, positions[1]) == 0) {
|
||||
if(search != Blocks.water)
|
||||
supertile.getWorldObj().setBlockToAir(positions[0], supertile.yCoord, positions[1]);
|
||||
else {
|
||||
int waterAround = 0;
|
||||
for(ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS)
|
||||
if(supertile.getWorldObj().getBlock(positions[0] + dir.offsetX, supertile.yCoord, positions[1] + dir.offsetZ) == search)
|
||||
waterAround++;
|
||||
|
||||
if(waterAround < 2)
|
||||
supertile.getWorldObj().setBlockToAir(positions[0], supertile.yCoord, positions[1]);
|
||||
}
|
||||
|
||||
burnTime += getBurnTime();
|
||||
sync();
|
||||
playSound();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
if(supertile.getWorldObj().rand.nextInt(8) == 0)
|
||||
@@ -74,12 +86,9 @@ public class SubTileHydroangeas extends SubTilePassiveGenerating {
|
||||
burnTime--;
|
||||
if(burnTime == 0) {
|
||||
cooldown = getCooldown();
|
||||
didSomething = true;
|
||||
sync();
|
||||
}
|
||||
}
|
||||
|
||||
if(didSomething)
|
||||
sync();
|
||||
}
|
||||
|
||||
public void doBurnParticles() {
|
||||
|
||||
@@ -36,6 +36,7 @@ import vazkii.botania.api.item.IManaDissolvable;
|
||||
import vazkii.botania.api.mana.IKeyLocked;
|
||||
import vazkii.botania.api.mana.IManaItem;
|
||||
import vazkii.botania.api.mana.IManaPool;
|
||||
import vazkii.botania.api.mana.IThrottledPacket;
|
||||
import vazkii.botania.api.mana.ManaNetworkEvent;
|
||||
import vazkii.botania.api.mana.spark.ISparkAttachable;
|
||||
import vazkii.botania.api.mana.spark.ISparkEntity;
|
||||
@@ -50,7 +51,7 @@ import vazkii.botania.common.core.handler.ConfigHandler;
|
||||
import vazkii.botania.common.core.handler.ManaNetworkHandler;
|
||||
import vazkii.botania.common.core.helper.Vector3;
|
||||
|
||||
public class TilePool extends TileMod implements IManaPool, IDyablePool, IKeyLocked, ISparkAttachable {
|
||||
public class TilePool extends TileMod implements IManaPool, IDyablePool, IKeyLocked, ISparkAttachable, IThrottledPacket {
|
||||
|
||||
public static final int MAX_MANA = 1000000;
|
||||
public static final int MAX_MANA_DILLUTED = 10000;
|
||||
@@ -83,6 +84,9 @@ public class TilePool extends TileMod implements IManaPool, IDyablePool, IKeyLoc
|
||||
|
||||
String inputKey = "";
|
||||
String outputKey = "";
|
||||
|
||||
int ticks = 0;
|
||||
boolean sendPacket = false;
|
||||
|
||||
@Override
|
||||
public boolean isFull() {
|
||||
@@ -188,6 +192,9 @@ public class TilePool extends TileMod implements IManaPool, IDyablePool, IKeyLoc
|
||||
if(Math.random() > particleChance)
|
||||
Botania.proxy.wispFX(worldObj, xCoord + 0.3 + Math.random() * 0.5, yCoord + 0.6 + Math.random() * 0.25, zCoord + Math.random(), color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, (float) Math.random() / 3F, (float) -Math.random() / 25F, 2F);
|
||||
}
|
||||
|
||||
if(sendPacket && ticks % 10 == 0)
|
||||
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this);
|
||||
|
||||
alchemy = worldObj.getBlock(xCoord, yCoord - 1, zCoord) == ModBlocks.alchemyCatalyst;
|
||||
conjuration = worldObj.getBlock(xCoord, yCoord - 1, zCoord) == ModBlocks.conjurationCatalyst;
|
||||
@@ -236,6 +243,8 @@ public class TilePool extends TileMod implements IManaPool, IDyablePool, IKeyLoc
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ticks++;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -375,4 +384,9 @@ public class TilePool extends TileMod implements IManaPool, IDyablePool, IKeyLoc
|
||||
public void setColor(int color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDispatchable() {
|
||||
sendPacket = true;
|
||||
}
|
||||
}
|
||||
@@ -43,6 +43,7 @@ import vazkii.botania.api.mana.ILensEffect;
|
||||
import vazkii.botania.api.mana.IManaCollector;
|
||||
import vazkii.botania.api.mana.IManaPool;
|
||||
import vazkii.botania.api.mana.IManaReceiver;
|
||||
import vazkii.botania.api.mana.IThrottledPacket;
|
||||
import vazkii.botania.api.mana.ManaNetworkEvent;
|
||||
import vazkii.botania.api.wand.IWandBindable;
|
||||
import vazkii.botania.client.core.handler.HUDHandler;
|
||||
@@ -56,7 +57,7 @@ import vazkii.botania.common.entity.EntityManaBurst;
|
||||
import vazkii.botania.common.entity.EntityManaBurst.PositionProperties;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
|
||||
public class TileSpreader extends TileSimpleInventory implements IManaCollector, IWandBindable, IKeyLocked {
|
||||
public class TileSpreader extends TileSimpleInventory implements IManaCollector, IWandBindable, IKeyLocked, IThrottledPacket {
|
||||
|
||||
private static final int MAX_MANA = 1000;
|
||||
private static final int ULTRA_MAX_MANA = 6400;
|
||||
@@ -579,4 +580,9 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
checkForReceiver();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDispatchable() {
|
||||
// NO-OP
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,7 @@ import vazkii.botania.api.mana.IManaCollector;
|
||||
import vazkii.botania.api.mana.IManaCollisionGhost;
|
||||
import vazkii.botania.api.mana.IManaReceiver;
|
||||
import vazkii.botania.api.mana.IManaTrigger;
|
||||
import vazkii.botania.api.mana.IThrottledPacket;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.block.tile.mana.TileSpreader;
|
||||
import vazkii.botania.common.core.handler.ConfigHandler;
|
||||
@@ -569,7 +570,9 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst {
|
||||
mana *= ((IManaCollector) tile).getManaYieldMultiplier(this);
|
||||
|
||||
((IManaReceiver) tile).recieveMana(mana);
|
||||
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, tile.xCoord, tile.yCoord, tile.zCoord);
|
||||
if(tile instanceof IThrottledPacket)
|
||||
((IThrottledPacket) tile).markDispatchable();
|
||||
else VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, tile.xCoord, tile.yCoord, tile.zCoord);
|
||||
}
|
||||
|
||||
if(block instanceof IManaTrigger)
|
||||
|
||||
Reference in new issue
Block a user