use of arekkuusu.solar.api.entanglement.IEntangledStack in project Solar by ArekkuusuJerii.
the class BlockBlinker method onBlockPlacedBy.
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
if (!world.isRemote) {
getTile(TileBlinker.class, world, pos).ifPresent(blinker -> {
IEntangledStack entangled = (IEntangledStack) stack.getItem();
if (!entangled.getKey(stack).isPresent()) {
entangled.setKey(stack, UUID.randomUUID());
}
entangled.getKey(stack).ifPresent(blinker::setKey);
});
}
}
use of arekkuusu.solar.api.entanglement.IEntangledStack in project Solar by ArekkuusuJerii.
the class BlockNeutronBattery method getItem.
@Override
public ItemStack getItem(World world, BlockPos pos, IBlockState state) {
Optional<TileNeutronBattery> optional = getTile(TileNeutronBattery.class, world, pos);
if (optional.isPresent()) {
TileNeutronBattery neutron = optional.get();
ItemStack stack = new ItemStack(Item.getItemFromBlock(this));
neutron.getKey().ifPresent(uuid -> {
((IEntangledStack) stack.getItem()).setKey(stack, uuid);
});
NBTHelper.setEnum(stack, state.getValue(CAPACITY), "neutron_nbt");
return stack;
}
return super.getItem(world, pos, state);
}
use of arekkuusu.solar.api.entanglement.IEntangledStack in project Solar by ArekkuusuJerii.
the class BlockNeutronBattery method onBlockPlacedBy.
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
if (!world.isRemote) {
getTile(TileNeutronBattery.class, world, pos).ifPresent(neutron -> {
IEntangledStack entangled = (IEntangledStack) stack.getItem();
if (!entangled.getKey(stack).isPresent()) {
entangled.setKey(stack, UUID.randomUUID());
}
entangled.getKey(stack).ifPresent(neutron::setKey);
if (placer instanceof EntityPlayer && ((EntityPlayer) placer).capabilities.isCreativeMode) {
ILumen lumen = neutron.getCapability(ModCapability.LUMEN_CAPABILITY, EnumFacing.UP);
if (lumen != null) {
// CHEATER!!
lumen.set(neutron.getCapacityLazy().max);
}
}
});
}
}
use of arekkuusu.solar.api.entanglement.IEntangledStack in project Solar by ArekkuusuJerii.
the class BlockQelaion method onBlockActivated.
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if (world.isRemote)
return true;
ItemStack stack = player.getHeldItem(hand);
if (stack.getItem() == ModItems.QELAION) {
Optional<TileQelaion> optional = getTile(TileQelaion.class, world, pos);
if (optional.isPresent()) {
TileQelaion qelaion = optional.get();
Optional<UUID> nodes = ((IEntangledStack) stack.getItem()).getKey(stack);
Optional<UUID> parent = qelaion.getKey();
if (nodes.isPresent() && parent.isPresent()) {
qelaion.setNodes(nodes.get());
return true;
}
return false;
}
} else if (stack.isEmpty()) {
getTile(TileQelaion.class, world, pos).ifPresent(qelaion -> {
if (!player.isSneaking()) {
qelaion.put(facing);
} else
qelaion.setNodes(null);
});
}
return false;
}
use of arekkuusu.solar.api.entanglement.IEntangledStack in project Solar by ArekkuusuJerii.
the class BlockQelaion method onBlockPlacedBy.
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
if (!world.isRemote) {
getTile(TileQelaion.class, world, pos).ifPresent(qelaion -> {
IEntangledStack entangled = (IEntangledStack) stack.getItem();
if (!entangled.getKey(stack).isPresent()) {
entangled.setKey(stack, UUID.randomUUID());
}
entangled.getKey(stack).ifPresent(qelaion::setKey);
if (NBTHelper.hasUniqueID(stack, "nodes")) {
qelaion.setNodes(NBTHelper.getUniqueID(stack, "nodes"));
}
});
}
}
Aggregations