use of arekkuusu.solar.api.entanglement.IEntangledStack in project Solar by ArekkuusuJerii.
the class BlockQelaion method getItem.
@Override
public ItemStack getItem(World world, BlockPos pos, IBlockState state) {
Optional<TileQelaion> optional = getTile(TileQelaion.class, world, pos);
if (optional.isPresent()) {
TileQelaion qelaion = optional.get();
ItemStack stack = new ItemStack(Item.getItemFromBlock(this));
qelaion.getKey().ifPresent(uuid -> {
((IEntangledStack) stack.getItem()).setKey(stack, uuid);
});
if (qelaion.getNodes() != null) {
NBTHelper.setUniqueID(stack, "nodes", qelaion.getNodes());
}
return stack;
}
return super.getItem(world, pos, state);
}
use of arekkuusu.solar.api.entanglement.IEntangledStack in project Solar by ArekkuusuJerii.
the class BlockQimranut method onBlockPlacedBy.
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
if (!world.isRemote) {
getTile(TileQimranut.class, world, pos).ifPresent(qimranut -> {
IEntangledStack entangled = (IEntangledStack) stack.getItem();
Optional<UUID> optional = entangled.getKey(stack);
if (!optional.isPresent() || RelativityHandler.getRelatives(optional.get()).size() >= 2) {
entangled.setKey(stack, UUID.randomUUID());
}
entangled.getKey(stack).ifPresent(qimranut::setKey);
});
}
}
use of arekkuusu.solar.api.entanglement.IEntangledStack in project Solar by ArekkuusuJerii.
the class BlockQimranut method getItem.
@Override
public ItemStack getItem(World world, BlockPos pos, IBlockState state) {
Optional<TileQimranut> optional = getTile(TileQimranut.class, world, pos);
if (optional.isPresent()) {
TileQimranut qimranut = optional.get();
ItemStack stack = new ItemStack(Item.getItemFromBlock(this));
qimranut.getKey().ifPresent(uuid -> {
((IEntangledStack) stack.getItem()).setKey(stack, uuid);
});
return stack;
}
return super.getItem(world, pos, state);
}
use of arekkuusu.solar.api.entanglement.IEntangledStack in project Solar by ArekkuusuJerii.
the class BlockQuantumMirror method getItem.
@Override
public ItemStack getItem(World world, BlockPos pos, IBlockState state) {
Optional<TileQuantumMirror> optional = getTile(TileQuantumMirror.class, world, pos);
if (optional.isPresent()) {
TileQuantumMirror mirror = optional.get();
ItemStack stack = new ItemStack(Item.getItemFromBlock(this));
mirror.getKey().ifPresent(uuid -> {
((IEntangledStack) stack.getItem()).setKey(stack, uuid);
});
return stack;
}
return super.getItem(world, pos, state);
}
use of arekkuusu.solar.api.entanglement.IEntangledStack in project Solar by ArekkuusuJerii.
the class BlockAlternator method onBlockPlacedBy.
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
if (!world.isRemote) {
getTile(TileAlternator.class, world, pos).ifPresent(alternator -> {
IEntangledStack entangled = (IEntangledStack) stack.getItem();
if (!entangled.getKey(stack).isPresent()) {
entangled.setKey(stack, UUID.randomUUID());
}
entangled.getKey(stack).ifPresent(alternator::setKey);
});
}
}
Aggregations