use of me.desht.pneumaticcraft.common.entity.living.EntityDrone in project pnc-repressurized by TeamPneumatic.
the class PacketSyncDroneEntityProgWidgets method handleClientSide.
@Override
public void handleClientSide(PacketSyncDroneEntityProgWidgets message, EntityPlayer player) {
Entity entity = player.world.getEntityByID(message.entityId);
if (entity instanceof EntityDrone) {
EntityDrone drone = (EntityDrone) entity;
List<IProgWidget> widgets = drone.getProgWidgets();
widgets.clear();
widgets.addAll(message.progWidgets);
}
}
use of me.desht.pneumaticcraft.common.entity.living.EntityDrone in project pnc-repressurized by TeamPneumatic.
the class DroneSpecialVariableHandler method onSpecialVariableRetrieving.
@SubscribeEvent
public void onSpecialVariableRetrieving(SpecialVariableRetrievalEvent.CoordinateVariable.Drone event) {
if (event.specialVarName.equalsIgnoreCase("owner")) {
EntityDrone drone = (EntityDrone) event.drone;
EntityPlayer player = drone.getOwner();
if (player != null)
event.coordinate = getPosForEntity(player);
} else if (event.specialVarName.equalsIgnoreCase("drone")) {
event.coordinate = getPosForEntity(event.drone);
} else if (event.specialVarName.toLowerCase().startsWith("player=")) {
EntityPlayer player = FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().getPlayerByUsername(event.specialVarName.substring("player=".length()));
if (player != null)
event.coordinate = getPosForEntity(player);
}
}
use of me.desht.pneumaticcraft.common.entity.living.EntityDrone in project pnc-repressurized by TeamPneumatic.
the class ContainerAmadron method retrieveOrderItems.
public static EntityDrone retrieveOrderItems(AmadronOffer offer, int times, World itemWorld, BlockPos itemPos, World liquidWorld, BlockPos liquidPos) {
if (offer.getInput() instanceof ItemStack) {
if (itemWorld == null || itemPos == null)
return null;
ItemStack queryingItems = (ItemStack) offer.getInput();
int amount = queryingItems.getCount() * times;
NonNullList<ItemStack> stacks = NonNullList.create();
while (amount > 0) {
ItemStack stack = queryingItems.copy();
stack.setCount(Math.min(amount, stack.getMaxStackSize()));
stacks.add(stack);
amount -= stack.getCount();
}
return (EntityDrone) DroneRegistry.getInstance().retrieveItemsAmazonStyle(itemWorld, itemPos, stacks.toArray(new ItemStack[stacks.size()]));
} else {
if (liquidWorld == null || liquidPos == null)
return null;
FluidStack queryingFluid = ((FluidStack) offer.getInput()).copy();
queryingFluid.amount *= times;
return (EntityDrone) DroneRegistry.getInstance().retrieveFluidAmazonStyle(liquidWorld, liquidPos, queryingFluid);
}
}
use of me.desht.pneumaticcraft.common.entity.living.EntityDrone in project pnc-repressurized by TeamPneumatic.
the class TileEntityDroneInterface method handleUpdateTag.
@Override
public void handleUpdateTag(NBTTagCompound tag) {
Entity entity = getWorld().getEntityByID(tag.getInteger("drone"));
drone = entity instanceof EntityDrone ? (EntityDrone) entity : null;
}
use of me.desht.pneumaticcraft.common.entity.living.EntityDrone in project pnc-repressurized by TeamPneumatic.
the class DroneAIPlace method doBlockInteraction.
// TODO 1.8 test
@Override
protected boolean doBlockInteraction(BlockPos pos, double distToBlock) {
if (drone.getPathNavigator().hasNoPath()) {
EnumFacing side = ProgWidgetPlace.getDirForSides(((ISidedWidget) widget).getSides());
for (int i = 0; i < drone.getInv().getSlots(); i++) {
ItemStack droneStack = drone.getInv().getStackInSlot(i);
if (droneStack.getItem() instanceof ItemBlock && ((ItemBlock) droneStack.getItem()).getBlock().canPlaceBlockOnSide(drone.world(), pos, ProgWidgetPlace.getDirForSides(((ISidedWidget) widget).getSides()))) {
if (widget.isItemValidForFilters(droneStack)) {
ItemBlock itemBlock = (ItemBlock) droneStack.getItem();
Block block = itemBlock.getBlock();
if (drone.world().mayPlace(block, pos, false, side, drone instanceof EntityDrone ? (EntityDrone) drone : null)) {
int newMeta = itemBlock.getMetadata(droneStack.getMetadata());
setFakePlayerAccordingToDir();
IBlockState iblockstate1 = block.getStateForPlacement(drone.world(), pos, side, side.getFrontOffsetX(), side.getFrontOffsetY(), side.getFrontOffsetZ(), newMeta, drone.getFakePlayer(), EnumHand.MAIN_HAND);
if (itemBlock.placeBlockAt(droneStack, drone.getFakePlayer(), drone.world(), pos, side, side.getFrontOffsetX(), side.getFrontOffsetY(), side.getFrontOffsetZ(), iblockstate1)) {
drone.addAir(null, -PneumaticValues.DRONE_USAGE_PLACE);
SoundType soundType = block.getSoundType(iblockstate1, drone.world(), pos, drone.getFakePlayer());
drone.world().playSound(pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F, soundType.getPlaceSound(), SoundCategory.BLOCKS, (soundType.getVolume() + 1.0F) / 2.0F, soundType.getPitch() * 0.8F, false);
droneStack.shrink(1);
if (droneStack.getCount() <= 0) {
drone.getInv().setStackInSlot(i, ItemStack.EMPTY);
}
}
return false;
}
}
}
}
return false;
} else {
return true;
}
}
Aggregations