mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-22 13:09:42 +00:00
Serverside many subtiles
This commit is contained in:
19 files changed
+91
-76
No files matched your search
+7
-1
@@ -36,6 +36,12 @@ public class SubTileAgricarnation extends SubTileFunctional {
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
|
||||
if(supertile.getWorld().isRemote)
|
||||
return;
|
||||
|
||||
if(ticksExisted % 200 == 0)
|
||||
sync();
|
||||
|
||||
if(ticksExisted % 6 == 0 && redstoneSignal == 0) {
|
||||
int range = getRange();
|
||||
int x = supertile.getPos().getX() + supertile.getWorld().rand.nextInt(range * 2 + 1) - range;
|
||||
@@ -66,7 +72,7 @@ public class SubTileAgricarnation extends SubTileFunctional {
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean isPlant(BlockPos pos) {
|
||||
private boolean isPlant(BlockPos pos) {
|
||||
IBlockState state = supertile.getWorld().getBlockState(pos);
|
||||
Block block = state.getBlock();
|
||||
if(block == Blocks.grass || block == Blocks.leaves || block == Blocks.leaves2 || block instanceof BlockBush && !(block instanceof BlockCrops) && !(block instanceof BlockSapling))
|
||||
|
||||
@@ -43,9 +43,12 @@ public class SubTileBellethorn extends SubTileFunctional {
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
|
||||
if(redstoneSignal > 0)
|
||||
if(supertile.getWorld().isRemote || redstoneSignal > 0)
|
||||
return;
|
||||
|
||||
if(ticksExisted % 200 == 0)
|
||||
sync();
|
||||
|
||||
final int manaToUse = getManaCost();
|
||||
|
||||
if(ticksExisted % 5 == 0) {
|
||||
|
||||
@@ -38,6 +38,12 @@ public class SubTileBubbell extends SubTileFunctional {
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
|
||||
if(supertile.getWorld().isRemote)
|
||||
return;
|
||||
|
||||
if(ticksExisted % 200 == 0)
|
||||
sync();
|
||||
|
||||
if(mana > COST_PER_TICK) {
|
||||
mana -= COST_PER_TICK;
|
||||
|
||||
@@ -46,15 +52,17 @@ public class SubTileBubbell extends SubTileFunctional {
|
||||
|
||||
for(int i = -range; i < range + 1; i++)
|
||||
for(int j = -range; j < range + 1; j++)
|
||||
for(int k = -range; k < range + 1; k++)
|
||||
for(int k = -range; k < range + 1; k++) {
|
||||
BlockPos pos = supertile.getPos().add(i, j, k);
|
||||
if(MathHelper.pointDistanceSpace(i, j, k, 0, 0, 0) < range) {
|
||||
IBlockState state = supertile.getWorld().getBlockState(supertile.getPos().add(i, j, k));
|
||||
IBlockState state = supertile.getWorld().getBlockState(pos);
|
||||
if(state.getMaterial() == Material.water) {
|
||||
supertile.getWorld().setBlockState(supertile.getPos().add(i, j, k), ModBlocks.fakeAir.getDefaultState(), 2);
|
||||
TileFakeAir air = (TileFakeAir) supertile.getWorld().getTileEntity(supertile.getPos().add(i, j, k));
|
||||
supertile.getWorld().setBlockState(pos, ModBlocks.fakeAir.getDefaultState(), 2);
|
||||
TileFakeAir air = (TileFakeAir) supertile.getWorld().getTileEntity(pos);
|
||||
air.setFlower(supertile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,8 +30,8 @@ public class SubTileDaffomill extends SubTileFunctional {
|
||||
private static final String TAG_ORIENTATION = "orientation";
|
||||
private static final String TAG_WIND_TICKS = "windTicks";
|
||||
|
||||
int windTicks = 0;
|
||||
EnumFacing orientation = EnumFacing.NORTH;
|
||||
private int windTicks = 0;
|
||||
private EnumFacing orientation = EnumFacing.NORTH;
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
@@ -71,7 +71,7 @@ public class SubTileDaffomill extends SubTileFunctional {
|
||||
}
|
||||
}
|
||||
|
||||
AxisAlignedBB aabbForOrientation() {
|
||||
private AxisAlignedBB aabbForOrientation() {
|
||||
int x = supertile.getPos().getX();
|
||||
int y = supertile.getPos().getY();
|
||||
int z = supertile.getPos().getZ();
|
||||
|
||||
@@ -28,13 +28,16 @@ public class SubTileExoflame extends SubTileFunctional {
|
||||
|
||||
private static final int RANGE = 5;
|
||||
private static final int RANGE_Y = 2;
|
||||
private static final int COST = 300;
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
|
||||
if(supertile.getWorld().isRemote)
|
||||
return;
|
||||
|
||||
boolean did = false;
|
||||
int cost = 300;
|
||||
|
||||
fireFurnaces : {
|
||||
for(int i = -RANGE; i < RANGE + 1; i++)
|
||||
@@ -53,7 +56,7 @@ public class SubTileExoflame extends SubTileFunctional {
|
||||
if(furnace.getField(0) == 0)
|
||||
BlockFurnace.setState(true, supertile.getWorld(), pos);
|
||||
furnace.setField(0, 200);
|
||||
mana = Math.max(0, mana - cost);
|
||||
mana = Math.max(0, mana - COST);
|
||||
}
|
||||
if(ticksExisted % 2 == 0)
|
||||
furnace.setField(2, Math.min(199, furnace.getField(2) + 1)); // Field 2 -> cook time
|
||||
@@ -69,7 +72,7 @@ public class SubTileExoflame extends SubTileFunctional {
|
||||
if(heatable.canSmelt() && mana > 2) {
|
||||
if(heatable.getBurnTime() == 0) {
|
||||
heatable.boostBurnTime();
|
||||
mana = Math.max(0, mana - cost);
|
||||
mana = Math.max(0, mana - COST);
|
||||
}
|
||||
|
||||
if(ticksExisted % 2 == 0)
|
||||
|
||||
+8
-5
@@ -24,21 +24,24 @@ import java.util.List;
|
||||
public class SubTileFallenKanade extends SubTileFunctional {
|
||||
|
||||
private static final int RANGE = 2;
|
||||
private static final int COST = 120;
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
|
||||
final int cost = 120;
|
||||
|
||||
if(!supertile.getWorld().isRemote && supertile.getWorld().provider.getDimension() != 1) {
|
||||
boolean did = false;
|
||||
List<EntityPlayer> players = supertile.getWorld().getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(supertile.getPos().add(-RANGE, -RANGE, -RANGE), supertile.getPos().add(RANGE + 1, RANGE + 1, RANGE + 1)));
|
||||
for(EntityPlayer player : players) {
|
||||
if(player.getActivePotionEffect(MobEffects.regeneration) == null && mana >= cost ) {
|
||||
player.addPotionEffect(new PotionEffect(MobEffects.regeneration, 60, 2));
|
||||
mana -= cost;
|
||||
if(player.getActivePotionEffect(MobEffects.regeneration) == null && mana >= COST) {
|
||||
player.addPotionEffect(new PotionEffect(MobEffects.regeneration, 60, 2, true, true));
|
||||
mana -= COST;
|
||||
did = true;
|
||||
}
|
||||
}
|
||||
if(did)
|
||||
sync();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+5
-2
@@ -37,11 +37,14 @@ public class SubTileHeiseiDream extends SubTileFunctional {
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
|
||||
if(supertile.getWorld().isRemote)
|
||||
return;
|
||||
|
||||
final int cost = 100;
|
||||
|
||||
List mobs = supertile.getWorld().getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(supertile.getPos().add(-RANGE, -RANGE, -RANGE), supertile.getPos().add(RANGE + 1, RANGE + 1, RANGE + 1)), Predicates.instanceOf(IMob.class));
|
||||
List<IMob> mobs = (List<IMob>) (List) supertile.getWorld().getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(supertile.getPos().add(-RANGE, -RANGE, -RANGE), supertile.getPos().add(RANGE + 1, RANGE + 1, RANGE + 1)), Predicates.instanceOf(IMob.class));
|
||||
if(mobs.size() > 1 && mana >= cost)
|
||||
for(IMob mob : ((List<IMob>) mobs)) {
|
||||
for(IMob mob : mobs) {
|
||||
if(mob instanceof EntityLiving) {
|
||||
EntityLiving entity = (EntityLiving) mob;
|
||||
if(brainwashEntity(entity, mobs)) {
|
||||
|
||||
+11
-15
@@ -54,13 +54,13 @@ public class SubTileHopperhock extends SubTileFunctional {
|
||||
|
||||
private static Set<EntityItem> particled = Collections.newSetFromMap(new WeakHashMap<>());
|
||||
|
||||
int filterType = 0;
|
||||
private int filterType = 0;
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
|
||||
if(redstoneSignal > 0)
|
||||
if(supertile.getWorld().isRemote || redstoneSignal > 0)
|
||||
return;
|
||||
|
||||
boolean pulledAny = false;
|
||||
@@ -97,7 +97,7 @@ public class SubTileHopperhock extends SubTileFunctional {
|
||||
boolean canAccept = canAcceptItem(stack, filter, filterType);
|
||||
|
||||
ItemStack simulate = ItemHandlerHelper.insertItem(inv.handler, stack.copy(), true);
|
||||
int availablePut = supertile.getWorld().isRemote ? 1 : stack.stackSize - (simulate == null ? 0 : simulate.stackSize);
|
||||
int availablePut = stack.stackSize - (simulate == null ? 0 : simulate.stackSize); // todo this is broken for vanilla single chests. investigate?
|
||||
|
||||
canAccept &= availablePut > 0;
|
||||
|
||||
@@ -118,19 +118,15 @@ public class SubTileHopperhock extends SubTileFunctional {
|
||||
}
|
||||
|
||||
if(invToPutItemIn != null && !item.isDead) {
|
||||
boolean remote = supertile.getWorld().isRemote;
|
||||
if(remote) {
|
||||
if(!particled.contains(item)) {
|
||||
SubTileSpectranthemum.spawnExplosionParticles(item, 3);
|
||||
particled.add(item);
|
||||
}
|
||||
} else {
|
||||
ItemHandlerHelper.insertItem(invToPutItemIn, stack.splitStack(amountToPutIn), false);
|
||||
item.setEntityItemStack(stack); // Just in case someone subclasses EntityItem and changes something important.
|
||||
if(item.getEntityItem().stackSize == 0)
|
||||
item.setDead();
|
||||
pulledAny = true;
|
||||
if(!particled.contains(item)) {
|
||||
SubTileSpectranthemum.spawnExplosionParticles(item, 3); // todo packet
|
||||
particled.add(item);
|
||||
}
|
||||
ItemHandlerHelper.insertItem(invToPutItemIn, stack.splitStack(amountToPutIn), false);
|
||||
item.setEntityItemStack(stack); // Just in case someone subclasses EntityItem and changes something important.
|
||||
if(item.getEntityItem().stackSize == 0)
|
||||
item.setDead();
|
||||
pulledAny = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ public class SubTileHyacidus extends SubTileFunctional {
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
|
||||
if(redstoneSignal > 0)
|
||||
if(supertile.getWorld().isRemote || redstoneSignal > 0)
|
||||
return;
|
||||
|
||||
final int cost = 20;
|
||||
|
||||
+2
-2
@@ -32,10 +32,10 @@ public class SubTileJadedAmaranthus extends SubTileFunctional {
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
|
||||
if(redstoneSignal > 0)
|
||||
if(supertile.getWorld().isRemote || redstoneSignal > 0)
|
||||
return;
|
||||
|
||||
if(!supertile.getWorld().isRemote && ticksExisted % 30 == 0 && mana >= COST) {
|
||||
if(ticksExisted % 30 == 0 && mana >= COST) {
|
||||
BlockPos pos = new BlockPos(
|
||||
supertile.getPos().getX() - RANGE + supertile.getWorld().rand.nextInt(RANGE * 2 + 1),
|
||||
supertile.getPos().getY() + RANGE,
|
||||
|
||||
+3
-3
@@ -52,10 +52,10 @@ public class SubTileMarimorphosis extends SubTileFunctional {
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
if(redstoneSignal > 0)
|
||||
if(supertile.getWorld().isRemote && redstoneSignal > 0)
|
||||
return;
|
||||
|
||||
if(!supertile.getWorld().isRemote && mana >= COST && ticksExisted % 2 == 0) {
|
||||
if(mana >= COST && ticksExisted % 2 == 0) {
|
||||
BlockPos coords = getCoordsToPut();
|
||||
if(coords != null) {
|
||||
ItemStack stack = getStoneToPut(coords);
|
||||
@@ -89,7 +89,7 @@ public class SubTileMarimorphosis extends SubTileFunctional {
|
||||
return new ItemStack(ModFluffBlocks.biomeStoneA, 1, values.get(supertile.getWorld().rand.nextInt(values.size())));
|
||||
}
|
||||
|
||||
public BlockPos getCoordsToPut() {
|
||||
private BlockPos getCoordsToPut() {
|
||||
List<BlockPos> possibleCoords = new ArrayList<>();
|
||||
|
||||
int range = getRange();
|
||||
|
||||
@@ -30,7 +30,7 @@ public class SubTileMedumone extends SubTileFunctional {
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
|
||||
if(mana > 0) {
|
||||
if(!supertile.getWorld().isRemote && mana > 0) {
|
||||
List<EntityLivingBase> entities = supertile.getWorld().getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(supertile.getPos().add(-RANGE, -RANGE, -RANGE), supertile.getPos().add(RANGE + 1, RANGE + 1, RANGE + 1)));
|
||||
|
||||
for(EntityLivingBase entity : entities)
|
||||
|
||||
@@ -46,11 +46,11 @@ public class SubTileOrechid extends SubTileFunctional {
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
|
||||
if(redstoneSignal > 0 || !canOperate())
|
||||
if(supertile.getWorld().isRemote && redstoneSignal > 0 || !canOperate())
|
||||
return;
|
||||
|
||||
int cost = getCost();
|
||||
if(!supertile.getWorld().isRemote && mana >= cost && ticksExisted % getDelay() == 0) {
|
||||
if(mana >= cost && ticksExisted % getDelay() == 0) {
|
||||
BlockPos coords = getCoordsToPut();
|
||||
if(coords != null) {
|
||||
ItemStack stack = getOreToPut();
|
||||
@@ -99,7 +99,7 @@ public class SubTileOrechid extends SubTileFunctional {
|
||||
return getOreToPut();
|
||||
}
|
||||
|
||||
public BlockPos getCoordsToPut() {
|
||||
private BlockPos getCoordsToPut() {
|
||||
List<BlockPos> possibleCoords = new ArrayList<>();
|
||||
|
||||
Block source = getSourceBlock();
|
||||
|
||||
+6
-8
@@ -62,7 +62,7 @@ public class SubTileRannuncarpus extends SubTileFunctional {
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
|
||||
if(redstoneSignal > 0)
|
||||
if(supertile.getWorld().isRemote || redstoneSignal > 0)
|
||||
return;
|
||||
|
||||
if(ticksExisted % 10 == 0) {
|
||||
@@ -108,7 +108,7 @@ public class SubTileRannuncarpus extends SubTileFunctional {
|
||||
}
|
||||
|
||||
|
||||
if(!validPositions.isEmpty() && !supertile.getWorld().isRemote) {
|
||||
if(!validPositions.isEmpty()) {
|
||||
BlockPos coords = validPositions.get(supertile.getWorld().rand.nextInt(validPositions.size()));
|
||||
|
||||
IBlockState stateToPlace = null;
|
||||
@@ -140,11 +140,9 @@ public class SubTileRannuncarpus extends SubTileFunctional {
|
||||
if(stackItem instanceof IFlowerPlaceable)
|
||||
((IFlowerPlaceable) stackItem).onBlockPlacedByFlower(stack, this, coords);
|
||||
|
||||
if(!supertile.getWorld().isRemote) {
|
||||
stack.stackSize--;
|
||||
if(stack.stackSize <= 0)
|
||||
item.setDead();
|
||||
}
|
||||
stack.stackSize--;
|
||||
if(stack.stackSize <= 0)
|
||||
item.setDead();
|
||||
|
||||
if(mana > 1)
|
||||
mana--;
|
||||
@@ -176,7 +174,7 @@ public class SubTileRannuncarpus extends SubTileFunctional {
|
||||
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
if(recieverStack != null && recieverStack.getItem() != null) {
|
||||
if(recieverStack.getItem() != null) {
|
||||
String stackName = recieverStack.getDisplayName();
|
||||
int width = 16 + mc.fontRendererObj.getStringWidth(stackName) / 2;
|
||||
int x = res.getScaledWidth() / 2 - width;
|
||||
|
||||
+7
-11
@@ -26,7 +26,7 @@ public class SubTileSolegnolia extends SubTileFunctional {
|
||||
private static final double RANGE = 5;
|
||||
private static final double RANGE_MINI = 1;
|
||||
|
||||
public static final Set<SubTileSolegnolia> existingFlowers = Collections.newSetFromMap(new WeakHashMap<>());
|
||||
private static final Set<SubTileSolegnolia> existingFlowers = Collections.newSetFromMap(new WeakHashMap<>());
|
||||
private static boolean registered = false;
|
||||
|
||||
@Override
|
||||
@@ -46,16 +46,12 @@ public class SubTileSolegnolia extends SubTileFunctional {
|
||||
}
|
||||
|
||||
public static boolean hasSolegnoliaAround(Entity e) {
|
||||
for(SubTileSolegnolia flower : existingFlowers) {
|
||||
if(flower.redstoneSignal > 0 || flower.supertile.getWorld() != e.worldObj || flower.supertile.getWorld().getTileEntity(flower.supertile.getPos()) != flower.supertile)
|
||||
continue;
|
||||
|
||||
double range = flower.getRange();
|
||||
if(MathHelper.pointDistanceSpace(e.posX, e.posY, e.posZ, flower.supertile.getPos().getX() + 0.5, flower.supertile.getPos().getY() + 0.5, flower.supertile.getPos().getZ() + 0.5) <= range)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return existingFlowers.stream()
|
||||
.filter(f -> f.redstoneSignal == 0)
|
||||
.filter(f -> f.supertile.getWorld() != e.worldObj)
|
||||
.filter(f -> f.supertile.getWorld().getTileEntity(f.supertile.getPos()) == f.supertile)
|
||||
.filter(f -> f.supertile.getDistanceSq(e.posX, e.posY, e.posZ) <= f.getRange())
|
||||
.findAny().isPresent();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+6
-8
@@ -44,18 +44,18 @@ public class SubTileSpectranthemum extends SubTileFunctional {
|
||||
|
||||
private static final String TAG_TELEPORTED = "Botania_TPd";
|
||||
|
||||
BlockPos bindPos = new BlockPos(0, -1, 0);
|
||||
private BlockPos bindPos = new BlockPos(0, -1, 0);
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
|
||||
if(redstoneSignal == 0 && supertile.getWorld().isBlockLoaded(bindPos)) {
|
||||
if(!supertile.getWorld().isRemote && redstoneSignal == 0 && supertile.getWorld().isBlockLoaded(bindPos)) {
|
||||
BlockPos pos = supertile.getPos();
|
||||
|
||||
boolean did = false;
|
||||
|
||||
List<EntityItem> items = supertile.getWorld().getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(supertile.getPos().add(-RANGE, -RANGE, -RANGE), supertile.getPos().add(RANGE + 1, RANGE + 1, RANGE + 1)));
|
||||
List<EntityItem> items = supertile.getWorld().getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(pos.add(-RANGE, -RANGE, -RANGE), pos.add(RANGE + 1, RANGE + 1, RANGE + 1)));
|
||||
int slowdown = getSlowdownFactor();
|
||||
|
||||
for(EntityItem item : items) {
|
||||
@@ -81,11 +81,9 @@ public class SubTileSpectranthemum extends SubTileFunctional {
|
||||
item.setPosition(bindPos.getX() + 0.5, bindPos.getY() + 1.5, bindPos.getZ() + 0.5);
|
||||
item.getEntityData().setBoolean(TAG_TELEPORTED, true);
|
||||
item.motionX = item.motionY = item.motionZ = 0;
|
||||
spawnExplosionParticles(item, 10);
|
||||
if(!supertile.getWorld().isRemote) {
|
||||
mana -= cost;
|
||||
did = true;
|
||||
}
|
||||
spawnExplosionParticles(item, 10); // todo packet
|
||||
mana -= cost;
|
||||
did = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,10 @@ public class SubTileTigerseye extends SubTileFunctional {
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
|
||||
if(supertile.getWorld().isRemote)
|
||||
return;
|
||||
|
||||
final int cost = 70;
|
||||
|
||||
boolean shouldAfffect = mana >= cost;
|
||||
|
||||
@@ -36,7 +36,7 @@ public class SubTileVinculotus extends SubTileFunctional {
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
|
||||
if(!existingFlowers.contains(this)) {
|
||||
if(!supertile.getWorld().isRemote && !existingFlowers.contains(this)) {
|
||||
existingFlowers.add(this);
|
||||
if(!registered) {
|
||||
MinecraftForge.EVENT_BUS.register(new EndermanIntercepter());
|
||||
@@ -74,9 +74,6 @@ public class SubTileVinculotus extends SubTileFunctional {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onEndermanTeleport(EnderTeleportEvent event) {
|
||||
if(event.getEntityLiving().worldObj.isRemote)
|
||||
return;
|
||||
|
||||
int cost = 50;
|
||||
|
||||
if(event.getEntityLiving() instanceof EntityEnderman) {
|
||||
|
||||
@@ -21,7 +21,7 @@ public class TileFakeAir extends TileMod {
|
||||
private static final String TAG_FLOWER_Y = "flowerY";
|
||||
private static final String TAG_FLOWER_Z = "flowerZ";
|
||||
|
||||
BlockPos flowerPos;
|
||||
private BlockPos flowerPos;
|
||||
|
||||
public void setFlower(TileEntity tile) {
|
||||
flowerPos = tile.getPos();
|
||||
|
||||
Reference in new issue
Block a user