mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-18 19:29:31 +00:00
claim bypass fix --lens
This commit is contained in:
1 parent
1cf98f845c
commit
9da2885b18
19 files changed
+161
-81
No files matched your search
@@ -7,6 +7,7 @@ dependencies {
|
||||
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.43:api') {transitive=false}
|
||||
compileOnly('com.github.GTNewHorizons:ForgeMultipart:1.6.4:dev') {transitive=false}
|
||||
devOnlyNonPublishable('com.github.GTNewHorizons:NotEnoughItems:2.7.51-GTNH:dev')
|
||||
runtimeOnlyNonPublishable('com.github.GTNewHorizons:ServerUtilities:2.1.54:dev')
|
||||
compileOnly('com.github.GTNewHorizons:Railcraft:9.16.30:api') {transitive=false}
|
||||
compileOnly('com.github.GTNewHorizons:StorageDrawers:2.1.2-GTNH:api') {transitive=false}
|
||||
compileOnly('curse.maven:cofh-lib-220333:2388748')
|
||||
|
||||
@@ -31,6 +31,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
import vazkii.botania.api.lexicon.ILexiconable;
|
||||
import vazkii.botania.api.lexicon.LexiconEntry;
|
||||
import vazkii.botania.api.mana.ILens;
|
||||
@@ -51,6 +52,7 @@ public class BlockSpreader extends BlockModContainer<TileSpreader> implements IW
|
||||
|
||||
Random random;
|
||||
|
||||
|
||||
public BlockSpreader() {
|
||||
super(Material.wood);
|
||||
setHardness(2.0F);
|
||||
|
||||
@@ -10,9 +10,12 @@
|
||||
*/
|
||||
package vazkii.botania.common.block.tile.mana;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
@@ -31,6 +34,9 @@ import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
import net.minecraftforge.common.util.FakePlayerFactory;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
@@ -119,6 +125,10 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector
|
||||
|
||||
UUID identity;
|
||||
|
||||
FakePlayer fakeplayer;
|
||||
GameProfile profile = new GameProfile(UUID.fromString("0d0f407d-1760-4f68-84af-3067c3ed0837"), "[Botania]");
|
||||
private static final WeakHashMap<World, WeakReference<EntityPlayer>> FakePlayers = new WeakHashMap<>();
|
||||
|
||||
int mana;
|
||||
int knownMana = -1;
|
||||
public float rotationX, rotationY;
|
||||
@@ -173,7 +183,6 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector
|
||||
ManaNetworkEvent.addCollector(this);
|
||||
inNetwork = true;
|
||||
}
|
||||
|
||||
boolean redstone = false;
|
||||
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
@@ -211,6 +220,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector
|
||||
List<IManaBurst> bursts = worldObj.getEntitiesWithinAABB(IManaBurst.class, aabb);
|
||||
IManaBurst found = null;
|
||||
UUID identity = getIdentifier();
|
||||
|
||||
for(IManaBurst burst : bursts)
|
||||
if(burst != null && identity.equals(burst.getShooterUIID())) {
|
||||
found = burst;
|
||||
@@ -465,7 +475,8 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector
|
||||
|
||||
public EntityManaBurst getBurst(boolean fake) {
|
||||
EntityManaBurst burst = new EntityManaBurst(this, fake);
|
||||
|
||||
setFakeplayer();
|
||||
burst.setPlayer(fakeplayer);
|
||||
boolean dreamwood = isDreamwood();
|
||||
boolean ultra = isULTRA_SPREADER();
|
||||
int maxMana = ultra ? 640 : dreamwood ? 240 : 160;
|
||||
@@ -757,6 +768,16 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector
|
||||
identity = UUID.randomUUID();
|
||||
return identity;
|
||||
}
|
||||
public void setFakeplayer(){
|
||||
if(!worldObj.isRemote) {
|
||||
final WeakReference<EntityPlayer> playerref = FakePlayers.get(worldObj);
|
||||
if(playerref == null) {
|
||||
final FakePlayer player = FakePlayerFactory.get((WorldServer) worldObj, profile);
|
||||
FakePlayers.put(worldObj, new WeakReference<>(player));
|
||||
this.fakeplayer = player;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public UUID getIdentifierUnsafe() {
|
||||
return identity;
|
||||
|
||||
@@ -674,6 +674,9 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst {
|
||||
public EntityPlayer getPlayer(){
|
||||
return player;
|
||||
}
|
||||
public void setPlayer(EntityPlayer player){
|
||||
this.player = player;
|
||||
}
|
||||
@Override
|
||||
protected float getGravityVelocity() {
|
||||
return getGravity();
|
||||
|
||||
@@ -302,7 +302,7 @@ public class ItemCraftingHalo extends ItemMod implements ICraftAchievement {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onItemCrafted(ItemCraftedEvent event) {
|
||||
if(!(event.craftMatrix instanceof InventoryCraftingHalo))
|
||||
if(event.player.worldObj.isRemote && !(event.craftMatrix instanceof InventoryCraftingHalo))
|
||||
return;
|
||||
|
||||
for(int i = 0; i < event.player.inventory.getSizeInventory(); i++) {
|
||||
|
||||
@@ -10,10 +10,17 @@
|
||||
*/
|
||||
package vazkii.botania.common.item.lens;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityThrowable;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.BlockSnapshot;
|
||||
import net.minecraftforge.event.entity.player.EntityInteractEvent;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
import vazkii.botania.api.internal.IManaBurst;
|
||||
import vazkii.botania.api.mana.BurstProperties;
|
||||
import vazkii.botania.api.mana.IManaSpreader;
|
||||
@@ -23,7 +30,29 @@ public class Lens {
|
||||
public void apply(ItemStack stack, BurstProperties props) {
|
||||
// NO-OP
|
||||
}
|
||||
protected boolean canPlaceBlock(World world, int x, int y, int z, int xAt, int yAt, int zAt, EntityPlayer player){
|
||||
Block block = world.getBlock(x,y,z);
|
||||
Block blockAt= world.getBlock(xAt,zAt,yAt);
|
||||
int meta = world.getBlockMetadata(x,y,z);
|
||||
BlockSnapshot snapshot = new BlockSnapshot(world,x,y,z,block,meta);
|
||||
BlockEvent.PlaceEvent event = new BlockEvent.PlaceEvent(snapshot,blockAt,player);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
|
||||
return !event.isCanceled();
|
||||
}
|
||||
protected boolean canBreakBlock(World world,int x, int y, int z,EntityPlayer player){
|
||||
Block block = world.getBlock(x,y,z);
|
||||
int meta = world.getBlockMetadata(x,y,z);
|
||||
BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(x, y, z, world, block, meta, player);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
boolean canMineBlock = world.canMineBlock(player,x,y,z);
|
||||
|
||||
return !event.isCanceled() && canMineBlock;
|
||||
}
|
||||
protected boolean canInteract(EntityPlayer player, Entity entity){
|
||||
EntityInteractEvent event = new EntityInteractEvent(player,entity);
|
||||
return !event.isCanceled();
|
||||
}
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) {
|
||||
return dead;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
package vazkii.botania.common.item.lens;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityThrowable;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
@@ -21,7 +22,7 @@ import vazkii.botania.common.core.helper.Vector3;
|
||||
public class LensBounce extends Lens {
|
||||
|
||||
@Override
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) {
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack, EntityPlayer player) {
|
||||
if(!isManaBlock && pos.entityHit == null) {
|
||||
ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates();
|
||||
if(coords.posX != pos.blockX || coords.posY != pos.blockY || coords.posZ != pos.blockZ) {
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
*/
|
||||
package vazkii.botania.common.item.lens;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityThrowable;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
@@ -20,7 +21,7 @@ import vazkii.botania.api.internal.IManaBurst;
|
||||
public class LensExplosive extends Lens {
|
||||
|
||||
@Override
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) {
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack, EntityPlayer player) {
|
||||
if(!burst.isFake()) {
|
||||
ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates();
|
||||
if(!entity.worldObj.isRemote && pos.entityHit == null && !isManaBlock && (pos.blockX != coords.posX || pos.blockY != coords.posY || pos.blockZ != coords.posZ))
|
||||
|
||||
@@ -11,12 +11,17 @@
|
||||
package vazkii.botania.common.item.lens;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityThrowable;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.BlockSnapshot;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
import vazkii.botania.api.internal.IManaBurst;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.block.tile.TileIncensePlate;
|
||||
@@ -24,7 +29,10 @@ import vazkii.botania.common.block.tile.TileIncensePlate;
|
||||
public class LensFire extends Lens {
|
||||
|
||||
@Override
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) {
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack, EntityPlayer player) {
|
||||
World world = entity.worldObj;
|
||||
if(world.isRemote)
|
||||
return false;
|
||||
ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates();
|
||||
if((coords.posX != pos.blockX || coords.posY != pos.blockY || coords.posZ != pos.blockZ) && !burst.isFake() && !isManaBlock) {
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(pos.sideHit);
|
||||
@@ -32,20 +40,20 @@ public class LensFire extends Lens {
|
||||
int x = pos.blockX + dir.offsetX;
|
||||
int y = pos.blockY + dir.offsetY;
|
||||
int z = pos.blockZ + dir.offsetZ;
|
||||
if (canPlaceBlock(world, pos.blockX, pos.blockY, pos.blockZ, x, y, z, player)) {
|
||||
Block blockAt = world.getBlock(pos.blockX, pos.blockY, pos.blockZ);
|
||||
Block blockAt_ = world.getBlock(x, y, z);
|
||||
|
||||
Block blockAt = entity.worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ);
|
||||
Block blockAt_ = entity.worldObj.getBlock(x, y, z);
|
||||
|
||||
if(blockAt == Blocks.portal)
|
||||
entity.worldObj.setBlock(pos.blockX, pos.blockY, pos.blockZ, Blocks.air);
|
||||
else if(blockAt == ModBlocks.incensePlate) {
|
||||
TileIncensePlate plate = (TileIncensePlate) entity.worldObj.getTileEntity(pos.blockX, pos.blockY, pos.blockZ);
|
||||
plate.ignite();
|
||||
} else if(blockAt_.isAir(entity.worldObj, x, y, z))
|
||||
entity.worldObj.setBlock(x, y, z, Blocks.fire);
|
||||
if (blockAt == Blocks.portal)
|
||||
world.setBlock(pos.blockX, pos.blockY, pos.blockZ, Blocks.air);
|
||||
else if (blockAt == ModBlocks.incensePlate) {
|
||||
TileIncensePlate plate = (TileIncensePlate) world.getTileEntity(pos.blockX, pos.blockY, pos.blockZ);
|
||||
plate.ignite();
|
||||
} else if (blockAt_.isAir(world, x, y, z))
|
||||
world.setBlock(x, y, z, Blocks.fire);
|
||||
}
|
||||
}
|
||||
|
||||
return dead;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,6 +11,7 @@
|
||||
package vazkii.botania.common.item.lens;
|
||||
|
||||
import net.minecraft.entity.item.EntityFireworkRocket;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityThrowable;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -24,7 +25,7 @@ import vazkii.botania.common.core.helper.ItemNBTHelper;
|
||||
public class LensFirework extends Lens {
|
||||
|
||||
@Override
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) {
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack, EntityPlayer player) {
|
||||
if(!burst.isFake()) {
|
||||
ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates();
|
||||
if(!entity.worldObj.isRemote && pos.entityHit == null && !isManaBlock && (pos.blockX != coords.posX || pos.blockY != coords.posY || pos.blockZ != coords.posZ)) {
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
package vazkii.botania.common.item.lens;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityThrowable;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -25,7 +26,9 @@ import vazkii.botania.common.block.tile.TileManaFlame;
|
||||
public class LensLight extends Lens {
|
||||
|
||||
@Override
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) {
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack, EntityPlayer player) {
|
||||
if(entity.worldObj.isRemote)
|
||||
return false;
|
||||
ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates();
|
||||
if((coords.posX != pos.blockX || coords.posY != pos.blockY || coords.posZ != pos.blockZ) && !burst.isFake() && !isManaBlock) {
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(pos.sideHit);
|
||||
@@ -36,15 +39,16 @@ public class LensLight extends Lens {
|
||||
|
||||
Block blockAt = entity.worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ);
|
||||
Block blockAt_ = entity.worldObj.getBlock(x, y, z);
|
||||
if (canPlaceBlock(entity.worldObj,pos.blockX, pos.blockY, pos.blockZ,x,y,z,player)){
|
||||
if (blockAt == ModBlocks.manaFlame)
|
||||
entity.worldObj.setBlock(pos.blockX, pos.blockY, pos.blockZ, Blocks.air);
|
||||
else if (blockAt_.isAir(entity.worldObj, x, y, z) || blockAt_.isReplaceable(entity.worldObj, x, y, z)) {
|
||||
entity.worldObj.setBlock(x, y, z, ModBlocks.manaFlame);
|
||||
TileEntity tile = entity.worldObj.getTileEntity(x, y, z);
|
||||
|
||||
if(blockAt == ModBlocks.manaFlame)
|
||||
entity.worldObj.setBlock(pos.blockX, pos.blockY, pos.blockZ, Blocks.air);
|
||||
else if(blockAt_.isAir(entity.worldObj, x, y, z) || blockAt_.isReplaceable(entity.worldObj, x, y, z)) {
|
||||
entity.worldObj.setBlock(x, y, z, ModBlocks.manaFlame);
|
||||
TileEntity tile = entity.worldObj.getTileEntity(x, y, z);
|
||||
|
||||
if(tile instanceof TileManaFlame)
|
||||
((TileManaFlame) tile).setColor(burst.getColor());
|
||||
if (tile instanceof TileManaFlame)
|
||||
((TileManaFlame) tile).setColor(burst.getColor());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -87,6 +87,9 @@ public class LensMine extends Lens {
|
||||
|
||||
return dead;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack, EntityPlayer player) {
|
||||
World world = entity.worldObj;
|
||||
@@ -104,44 +107,38 @@ public class LensMine extends Lens {
|
||||
int harvestLevel = ConfigHandler.harvestLevelBore;
|
||||
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
|
||||
if(world.isRemote)
|
||||
return false;
|
||||
float hardness = block.getBlockHardness(world, x, y, z);
|
||||
int neededHarvestLevel = block.getHarvestLevel(meta);
|
||||
int mana = burst.getMana();
|
||||
|
||||
ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates();
|
||||
if((coords.posX != x || coords.posY != y || coords.posZ != z) && !(tile instanceof IManaBlock) && neededHarvestLevel <= harvestLevel && hardness != -1 && hardness < 50F && (burst.isFake() || mana >= 24)) {
|
||||
if(!world.isRemote) {
|
||||
BlockEvent.BreakEvent breakEvent = ForgeHooks.onBlockBreakEvent(world, ((EntityPlayerMP) player).theItemInWorldManager.getGameType(), (EntityPlayerMP) player, x, y, z);
|
||||
if (breakEvent.isCanceled())
|
||||
return false;
|
||||
}
|
||||
List<ItemStack> items = new ArrayList<>();
|
||||
if(canBreakBlock(world, x, y, z, player) && (coords.posX != x || coords.posY != y || coords.posZ != z) && !(tile instanceof IManaBlock) && neededHarvestLevel <= harvestLevel && hardness != -1 && hardness < 50F && (burst.isFake() || mana >= 24)) {
|
||||
List<ItemStack> items = new ArrayList<>();
|
||||
items.addAll(block.getDrops(world, x, y, z, meta, 0));
|
||||
if (!burst.hasAlreadyCollidedAt(x, y, z)) {
|
||||
if (!burst.isFake() && !entity.worldObj.isRemote) {
|
||||
world.setBlockToAir(x, y, z);
|
||||
if (ConfigHandler.blockBreakParticles)
|
||||
entity.worldObj.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12));
|
||||
|
||||
items.addAll(block.getDrops(world, x, y, z, meta, 0));
|
||||
boolean offBounds = coords.posY < 0;
|
||||
boolean doWarp = warp && !offBounds;
|
||||
int dropX = doWarp ? coords.posX : x;
|
||||
int dropY = doWarp ? coords.posY : y;
|
||||
int dropZ = doWarp ? coords.posZ : z;
|
||||
|
||||
if(!burst.hasAlreadyCollidedAt(x, y, z)) {
|
||||
if(!burst.isFake() && !entity.worldObj.isRemote) {
|
||||
world.setBlockToAir(x, y, z);
|
||||
if(ConfigHandler.blockBreakParticles)
|
||||
entity.worldObj.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12));
|
||||
for (ItemStack stack_ : items)
|
||||
world.spawnEntityInWorld(new EntityItem(world, dropX + 0.5, dropY + 0.5, dropZ + 0.5, stack_));
|
||||
|
||||
boolean offBounds = coords.posY < 0;
|
||||
boolean doWarp = warp && !offBounds;
|
||||
int dropX = doWarp ? coords.posX : x;
|
||||
int dropY = doWarp ? coords.posY : y;
|
||||
int dropZ = doWarp ? coords.posZ : z;
|
||||
|
||||
for(ItemStack stack_ : items)
|
||||
world.spawnEntityInWorld(new EntityItem(world, dropX + 0.5, dropY + 0.5, dropZ + 0.5, stack_));
|
||||
|
||||
burst.setMana(mana - 24);
|
||||
burst.setMana(mana - 24);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dead = false;
|
||||
dead = false;
|
||||
}
|
||||
|
||||
|
||||
return dead;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.passive.EntitySheep;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityThrowable;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
@@ -28,16 +29,20 @@ import vazkii.botania.common.Botania;
|
||||
public class LensPaint extends Lens {
|
||||
|
||||
@Override
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) {
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack, EntityPlayer player) {
|
||||
int storedColor = ItemLens.getStoredColor(stack);
|
||||
if(!burst.isFake() && storedColor > -1 && storedColor < 17) {
|
||||
if(pos.entityHit != null && pos.entityHit instanceof EntitySheep) {
|
||||
int r = 20;
|
||||
int sheepColor = ((EntitySheep) pos.entityHit).getFleeceColor();
|
||||
List<EntitySheep> sheepList = entity.worldObj.getEntitiesWithinAABB(EntitySheep.class, AxisAlignedBB.getBoundingBox(pos.entityHit.posX - r, pos.entityHit.posY - r, pos.entityHit.posZ - r, pos.entityHit.posX + r, pos.entityHit.posY + r, pos.entityHit.posZ + r));
|
||||
for(EntitySheep sheep : sheepList) {
|
||||
if(sheep.getFleeceColor() == sheepColor)
|
||||
sheep.setFleeceColor(storedColor == 16 ? sheep.worldObj.rand.nextInt(16) : storedColor);
|
||||
if(!entity.worldObj.isRemote) {
|
||||
for (EntitySheep sheep : sheepList) {
|
||||
if (canInteract(player, pos.entityHit)) {
|
||||
if (sheep.getFleeceColor() == sheepColor)
|
||||
sheep.setFleeceColor(storedColor == 16 ? sheep.worldObj.rand.nextInt(16) : storedColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
dead = true;
|
||||
} else {
|
||||
@@ -71,15 +76,15 @@ public class LensPaint extends Lens {
|
||||
int metaThere = entity.worldObj.getBlockMetadata(coords.posX, coords.posY, coords.posZ);
|
||||
|
||||
if(metaThere != placeColor) {
|
||||
if(!entity.worldObj.isRemote)
|
||||
if(!entity.worldObj.isRemote && canBreakBlock(entity.worldObj, coords.posX, coords.posY, coords.posZ,player)) {
|
||||
entity.worldObj.setBlockMetadataWithNotify(coords.posX, coords.posY, coords.posZ, placeColor, 2);
|
||||
float[] color = EntitySheep.fleeceColorTable[placeColor];
|
||||
float r = color[0];
|
||||
float g = color[1];
|
||||
float b = color[2];
|
||||
for(int i = 0; i < 4; i++)
|
||||
Botania.proxy.sparkleFX(entity.worldObj, coords.posX + (float) Math.random(), coords.posY + (float) Math.random(), coords.posZ + (float) Math.random(), r, g, b, 0.6F + (float) Math.random() * 0.3F, 5);
|
||||
|
||||
float[] color = EntitySheep.fleeceColorTable[placeColor];
|
||||
float r = color[0];
|
||||
float g = color[1];
|
||||
float b = color[2];
|
||||
for (int i = 0; i < 4; i++)
|
||||
Botania.proxy.sparkleFX(entity.worldObj, coords.posX + (float) Math.random(), coords.posY + (float) Math.random(), coords.posZ + (float) Math.random(), r, g, b, 0.6F + (float) Math.random() * 0.3F, 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
package vazkii.botania.common.item.lens;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityThrowable;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
@@ -18,7 +19,7 @@ import vazkii.botania.api.internal.IManaBurst;
|
||||
public class LensPhantom extends Lens {
|
||||
|
||||
@Override
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) {
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack, EntityPlayer player) {
|
||||
if(!isManaBlock) {
|
||||
dead = false;
|
||||
burst.setMinManaLoss(Math.max(0, burst.getMinManaLoss() - 4));
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
package vazkii.botania.common.item.lens;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityThrowable;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -23,7 +24,7 @@ import vazkii.botania.api.internal.IManaBurst;
|
||||
public class LensPiston extends Lens {
|
||||
|
||||
@Override
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) {
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack, EntityPlayer player) {
|
||||
ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates();
|
||||
if((coords.posX != pos.blockX || coords.posY != pos.blockY || coords.posZ != pos.blockZ) && !burst.isFake() && !isManaBlock && !entity.worldObj.isRemote) {
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(pos.sideHit).getOpposite();
|
||||
@@ -36,7 +37,7 @@ public class LensPiston extends Lens {
|
||||
int meta = entity.worldObj.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ);
|
||||
TileEntity tile = entity.worldObj.getTileEntity(pos.blockX, pos.blockY, pos.blockZ);
|
||||
|
||||
if(block.getMobilityFlag() == 0 && block != Blocks.obsidian && block.getBlockHardness(entity.worldObj, pos.blockX, pos.blockY, pos.blockZ) >= 0 && tile == null) {
|
||||
if(canBreakBlock(entity.worldObj,pos.blockX, pos.blockY, pos.blockZ,player) && block.getMobilityFlag() == 0 && block != Blocks.obsidian && block.getBlockHardness(entity.worldObj, pos.blockX, pos.blockY, pos.blockZ) >= 0 && tile == null) {
|
||||
entity.worldObj.setBlockToAir(pos.blockX, pos.blockY, pos.blockZ);
|
||||
entity.worldObj.setBlock(x, y, z, block, meta, 1 | 2);
|
||||
entity.worldObj.playAuxSFX(2001, pos.blockX, pos.blockY, pos.blockZ, Block.getIdFromBlock(block) + (meta << 12));
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
package vazkii.botania.common.item.lens;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityThrowable;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -24,7 +25,7 @@ import vazkii.botania.common.core.helper.Vector3;
|
||||
public class LensRedirect extends Lens {
|
||||
|
||||
@Override
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) {
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack, EntityPlayer player) {
|
||||
ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates();
|
||||
if(!entity.worldObj.isRemote && pos.entityHit == null && coords.posY != -1 && (pos.blockX != coords.posX || pos.blockY != coords.posY || pos.blockZ != coords.posZ)) {
|
||||
TileEntity tile = entity.worldObj.getTileEntity(pos.blockX, pos.blockY, pos.blockZ);
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
package vazkii.botania.common.item.lens;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityThrowable;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
@@ -19,7 +20,7 @@ import vazkii.botania.api.internal.IManaBurst;
|
||||
public class LensStorm extends Lens {
|
||||
|
||||
@Override
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) {
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack, EntityPlayer player) {
|
||||
if(!burst.isFake()) {
|
||||
ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates();
|
||||
if(!entity.worldObj.isRemote && pos.entityHit == null && !isManaBlock && (pos.blockX != coords.posX || pos.blockY != coords.posY || pos.blockZ != coords.posZ))
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
package vazkii.botania.common.item.lens;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityThrowable;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
@@ -21,7 +22,7 @@ import vazkii.botania.common.block.ModBlocks;
|
||||
public class LensWarp extends Lens {
|
||||
|
||||
@Override
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) {
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack, EntityPlayer player) {
|
||||
if(burst.isFake())
|
||||
return dead;
|
||||
|
||||
|
||||
@@ -12,31 +12,33 @@ package vazkii.botania.common.item.lens;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.item.EntityFallingBlock;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityThrowable;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.api.internal.IManaBurst;
|
||||
import vazkii.botania.common.core.handler.ConfigHandler;
|
||||
|
||||
public class LensWeight extends Lens {
|
||||
|
||||
@Override
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) {
|
||||
if(!burst.isFake()) {
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack, EntityPlayer player) {
|
||||
if(!burst.isFake() && !entity.worldObj.isRemote) {
|
||||
World world = entity.worldObj;
|
||||
int x = pos.blockX;
|
||||
int y = pos.blockY;
|
||||
int z = pos.blockZ;
|
||||
int harvestLevel = ConfigHandler.harvestLevelWeight;
|
||||
|
||||
Block block = entity.worldObj.getBlock(x, y, z);
|
||||
Block blockBelow = entity.worldObj.getBlock(x, y - 1, z);
|
||||
int meta = entity.worldObj.getBlockMetadata(x, y, z);
|
||||
Block block = world.getBlock(x, y, z);
|
||||
Block blockBelow = world.getBlock(x, y - 1, z);
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
int neededHarvestLevel = block.getHarvestLevel(meta);
|
||||
|
||||
if(blockBelow.isAir(entity.worldObj, x, y - 1, z) && block.getBlockHardness(entity.worldObj, x, y, z) != -1 && neededHarvestLevel <= harvestLevel && entity.worldObj.getTileEntity(x, y, z) == null && block.canSilkHarvest(entity.worldObj, null, x, y, z, meta)) {
|
||||
EntityFallingBlock falling = new EntityFallingBlock(entity.worldObj, x + 0.5, y + 0.5, z + 0.5, block, meta);
|
||||
if(!entity.worldObj.isRemote)
|
||||
entity.worldObj.spawnEntityInWorld(falling);
|
||||
if(canBreakBlock(world,x,y,z,player) && blockBelow.isAir(world, x, y - 1, z) && block.getBlockHardness(world, x, y, z) != -1 && neededHarvestLevel <= harvestLevel && world.getTileEntity(x, y, z) == null && block.canSilkHarvest(world, null, x, y, z, meta)) {
|
||||
EntityFallingBlock falling = new EntityFallingBlock(world, x + 0.5, y + 0.5, z + 0.5, block, meta);
|
||||
world.spawnEntityInWorld(falling);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user