use of net.minecraft.util.math.BlockPos in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class CustomNetHandlerPlayServer method processUpdateSign.
@Override
public void processUpdateSign(CPacketUpdateSign packetIn) {
BlockPos packetPos = packetIn.getPosition();
PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(playerEntity.worldObj, packetPos);
if (playerEntity.interactionManager.getBlockReachDistance() != dummyBlockReachDist) {
lastGoodBlockReachDist = playerEntity.interactionManager.getBlockReachDistance();
}
if (wrapper != null) {
playerEntity.interactionManager.setBlockReachDistance(dummyBlockReachDist);
ticksSinceLastTry = 0;
}
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerWorld());
if (wrapper != null && wrapper.wrapping.coordTransform != null) {
float playerYaw = playerEntity.rotationYaw;
float playerPitch = playerEntity.rotationPitch;
RotationMatrices.applyTransform(wrapper.wrapping.coordTransform.wToLTransform, wrapper.wrapping.coordTransform.wToLRotation, playerEntity);
super.processUpdateSign(packetIn);
RotationMatrices.applyTransform(wrapper.wrapping.coordTransform.lToWTransform, wrapper.wrapping.coordTransform.lToWRotation, playerEntity);
playerEntity.rotationYaw = playerYaw;
playerEntity.rotationPitch = playerPitch;
} else {
super.processUpdateSign(packetIn);
}
}
use of net.minecraft.util.math.BlockPos in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class CustomNetHandlerPlayServer method processRightClickBlock.
@Override
public void processRightClickBlock(CPacketPlayerTryUseItemOnBlock packetIn) {
BlockPos packetPos = packetIn.getPos();
PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(playerEntity.worldObj, packetPos);
if (playerEntity.interactionManager.getBlockReachDistance() != dummyBlockReachDist) {
lastGoodBlockReachDist = playerEntity.interactionManager.getBlockReachDistance();
}
if (wrapper != null) {
playerEntity.interactionManager.setBlockReachDistance(dummyBlockReachDist);
ticksSinceLastTry = 0;
}
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerWorld());
if (wrapper != null && wrapper.wrapping.coordTransform != null) {
float playerYaw = playerEntity.rotationYaw;
float playerPitch = playerEntity.rotationPitch;
RotationMatrices.applyTransform(wrapper.wrapping.coordTransform.wToLTransform, wrapper.wrapping.coordTransform.wToLRotation, playerEntity);
if (playerEntity.getHeldItem(packetIn.getHand()) != null && playerEntity.getHeldItem(packetIn.getHand()).getItem() instanceof ItemBucket) {
playerEntity.interactionManager.setBlockReachDistance(lastGoodBlockReachDist);
}
try {
super.processRightClickBlock(packetIn);
} catch (Exception e) {
}
RotationMatrices.applyTransform(wrapper.wrapping.coordTransform.lToWTransform, wrapper.wrapping.coordTransform.lToWRotation, playerEntity);
playerEntity.rotationYaw = playerYaw;
playerEntity.rotationPitch = playerPitch;
} else {
super.processRightClickBlock(packetIn);
}
}
use of net.minecraft.util.math.BlockPos in project Realistic-Terrain-Generation by Team-RTG.
the class PEUtils method transferPEToCollectors.
/**
* Attempts to transfer PE from a Manipulator to nearby Collectors
* @param world Current World
* @param pos Current BlockPos
* @param manipulator PE Manipulator
* @param boost Any range boost applied to the manipulator
*/
public static void transferPEToCollectors(World world, BlockPos pos, IEnergyManipulator manipulator, int boost) {
int xp = pos.getX();
int yp = pos.getY();
int zp = pos.getZ();
List<TileEntity> collectors = Lists.newArrayList();
for (int x = -1 * (3 + boost); x <= 3 + boost; x++) for (int y = 0; y <= getRangeAmplifiers(world, pos); y++) for (int z = -1 * (3 + boost); z <= 3 + boost; z++) if (x < -2 || x > 2 || z < -2 || z > 2)
if (isCollector(world.getTileEntity(new BlockPos(xp + x, yp - y, zp + z))))
collectors.add(world.getTileEntity(new BlockPos(xp + x, yp - y, zp + z)));
for (TileEntity tile : collectors) if (checkForAdjacentCollectors(world, tile.getPos()))
if (world.rand.nextInt(120 - (int) (20 * manipulator.getAmplifier(AmplifierType.DURATION))) == 0)
if (((IEnergyContainer) tile).getContainedEnergy() < ((IEnergyContainer) tile).getMaxEnergy()) {
if (!world.isRemote)
((IEnergyContainer) tile).addEnergy(manipulator.getEnergyQuanta());
for (double i = 0; i <= 0.7; i += 0.03) {
int xPos = xp < tile.getPos().getX() ? 1 : xp > tile.getPos().getX() ? -1 : 0;
int yPos = yp < tile.getPos().getY() ? 1 : yp > tile.getPos().getY() ? -1 : 0;
int zPos = zp < tile.getPos().getZ() ? 1 : zp > tile.getPos().getZ() ? -1 : 0;
double x = i * Math.cos(i) / 2 * xPos;
double y = i * Math.sin(i) / 2 * yPos;
double z = i * Math.sin(i) / 2 * zPos;
world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, xp + 0.5, yp + 0.5, zp + 0.5, x, y, z);
}
}
}
use of net.minecraft.util.math.BlockPos in project Realistic-Terrain-Generation by Team-RTG.
the class PEUtils method getRangeAmplifiers.
/**
* Checks for any range amplifying blocks below a specific BlockPos
* @param world Current World
* @param pos Current BlockPos
* @return A number between 0 and 2, representing the amount of range amplifiers below this BlockPos
*/
public static int getRangeAmplifiers(World world, BlockPos pos) {
Block block1 = world.getBlockState(new BlockPos(pos.getX(), pos.getY() - 1, pos.getZ())).getBlock();
Block block2 = world.getBlockState(new BlockPos(pos.getX(), pos.getY() - 2, pos.getZ())).getBlock();
int num = 0;
if (block1 != null && block1 instanceof IEnergyAmplifier && ((IEnergyAmplifier) block1).getAmplifierType() == AmplifierType.RANGE)
num = 1;
if (block1 != null && block1 instanceof IEnergyAmplifier && ((IEnergyAmplifier) block1).getAmplifierType() == AmplifierType.RANGE && block2 != null && block2 instanceof IEnergyAmplifier && ((IEnergyAmplifier) block2).getAmplifierType() == AmplifierType.RANGE)
num = 2;
return num;
}
use of net.minecraft.util.math.BlockPos in project Witchworks by Um-Mitternacht.
the class BlockSaltBarrier method updateSurroundingSalt.
private IBlockState updateSurroundingSalt(World worldIn, IBlockState state) {
final List<BlockPos> list = Lists.newArrayList(this.blocksNeedingUpdate);
this.blocksNeedingUpdate.clear();
for (BlockPos blockpos : list) {
worldIn.notifyNeighborsOfStateChange(blockpos, this, true);
}
return state;
}
Aggregations