mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-18 03:15:07 +00:00
Fix #2309 and also fix the particles not accounting for position shift
This commit is contained in:
1 parent
1d810fba7a
commit
9f0068538e
1 file changed
+37
-25
+37
-25
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
package vazkii.botania.common.block.subtile.generating;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -18,9 +19,11 @@ import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import vazkii.botania.api.lexicon.LexiconEntry;
|
||||
import vazkii.botania.api.subtile.RadiusDescriptor;
|
||||
import vazkii.botania.api.subtile.SubTileGenerating;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.core.handler.ModSounds;
|
||||
import vazkii.botania.common.lexicon.LexiconData;
|
||||
@@ -28,26 +31,34 @@ import vazkii.botania.common.lexicon.LexiconData;
|
||||
import java.util.List;
|
||||
|
||||
public class SubTileEndoflame extends SubTileGenerating {
|
||||
|
||||
private static final String TAG_BURN_TIME = "burnTime";
|
||||
private static final int FUEL_CAP = 32000;
|
||||
private static final int RANGE = 3;
|
||||
private static final int START_BURN_EVENT = 0;
|
||||
|
||||
int burnTime = 0;
|
||||
private int burnTime = 0;
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
|
||||
if(burnTime > 0)
|
||||
burnTime--;
|
||||
|
||||
if(getWorld().isRemote) {
|
||||
if(burnTime > 0 && supertile.getWorld().rand.nextInt(10) == 0) {
|
||||
Vec3d offset = getWorld().getBlockState(getPos()).getOffset(getWorld(), getPos()).addVector(0.4, 0.7, 0.4);
|
||||
supertile.getWorld().spawnParticle(EnumParticleTypes.FLAME, supertile.getPos().getX() + offset.x + Math.random() * 0.2, supertile.getPos().getY() + offset.y, supertile.getPos().getZ() + offset.z + Math.random() * 0.2, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if(linkedCollector != null) {
|
||||
if(burnTime == 0) {
|
||||
if(mana < getMaxMana()) {
|
||||
boolean didSomething = false;
|
||||
|
||||
int slowdown = getSlowdownFactor();
|
||||
|
||||
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)));
|
||||
for(EntityItem item : items) {
|
||||
for(EntityItem item : supertile.getWorld().getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(supertile.getPos().add(-RANGE, -RANGE, -RANGE), supertile.getPos().add(RANGE + 1, RANGE + 1, RANGE + 1)))) {
|
||||
if(item.age >= 59 + slowdown && !item.isDead) {
|
||||
ItemStack stack = item.getItem();
|
||||
if(stack.isEmpty() || stack.getItem().hasContainerItem(stack))
|
||||
@@ -57,34 +68,35 @@ public class SubTileEndoflame extends SubTileGenerating {
|
||||
if(burnTime > 0 && stack.getCount() > 0) {
|
||||
this.burnTime = Math.min(FUEL_CAP, burnTime) / 2;
|
||||
|
||||
if(!supertile.getWorld().isRemote) {
|
||||
stack.shrink(1);
|
||||
supertile.getWorld().playSound(null, supertile.getPos(), ModSounds.endoflame, SoundCategory.BLOCKS, 0.2F, 1F);
|
||||
stack.shrink(1);
|
||||
supertile.getWorld().playSound(null, supertile.getPos(), ModSounds.endoflame, SoundCategory.BLOCKS, 0.2F, 1F);
|
||||
getWorld().addBlockEvent(getPos(), getWorld().getBlockState(getPos()).getBlock(), START_BURN_EVENT, item.getEntityId());
|
||||
sync();
|
||||
|
||||
didSomething = true;
|
||||
} else {
|
||||
item.world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, item.posX, item.posY + 0.1, item.posZ, 0.0D, 0.0D, 0.0D);
|
||||
item.world.spawnParticle(EnumParticleTypes.FLAME, item.posX, item.posY, item.posZ, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(didSomething)
|
||||
sync();
|
||||
}
|
||||
} else {
|
||||
if(supertile.getWorld().rand.nextInt(10) == 0)
|
||||
supertile.getWorld().spawnParticle(EnumParticleTypes.FLAME, supertile.getPos().getX() + 0.4 + Math.random() * 0.2, supertile.getPos().getY() + 0.65, supertile.getPos().getZ() + 0.4 + Math.random() * 0.2, 0.0D, 0.0D, 0.0D);
|
||||
|
||||
burnTime--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean receiveClientEvent(int event, int param) {
|
||||
if(event == START_BURN_EVENT) {
|
||||
Entity e = getWorld().getEntityByID(param);
|
||||
if(e != null) {
|
||||
Botania.LOGGER.info("Meep? {}", getWorld().isRemote);
|
||||
e.world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, e.posX, e.posY + 0.1, e.posZ, 0.0D, 0.0D, 0.0D);
|
||||
e.world.spawnParticle(EnumParticleTypes.FLAME, e.posX, e.posY, e.posZ, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return super.receiveClientEvent(event, param);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxMana() {
|
||||
return 300;
|
||||
|
||||
Reference in new issue
Block a user