use of com.enderio.core.common.util.NNList in project EnderIO by SleepyTrousers.
the class BlockPaintedDoor method getDrops.
@Override
public void getDrops(@Nonnull NonNullList<ItemStack> drops, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, @Nonnull IBlockState state, int fortune) {
NNList<ItemStack> drops2 = new NNList<>();
super.getDrops(drops2, world, pos, state, fortune);
for (ItemStack drop : drops2) {
PaintUtil.setSourceBlock(NullHelper.notnullM(drop, "null stack from getDrops()"), getPaintSource(state, world, pos));
}
drops.addAll(drops2);
}
use of com.enderio.core.common.util.NNList in project EnderIO by SleepyTrousers.
the class BlockPaintedFence method getDrops.
@Override
public void getDrops(@Nonnull NonNullList<ItemStack> drops, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, @Nonnull IBlockState state, int fortune) {
NNList<ItemStack> drops2 = new NNList<>();
super.getDrops(drops2, world, pos, state, fortune);
for (ItemStack drop : drops2) {
PaintUtil.setSourceBlock(NullHelper.notnullM(drop, "null stack from getDrops()"), getPaintSource(state, world, pos));
}
drops.addAll(drops2);
}
use of com.enderio.core.common.util.NNList in project EnderIO by SleepyTrousers.
the class BlockInfinity method updateTick.
@Override
public void updateTick(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull IBlockState state, @Nonnull Random rnd) {
if (!world.isRemote) {
if (world.canBlockSeeSky(pos)) {
// exposed to the sky?
world.setBlockToAir(pos);
world.addWeatherEffect(new EntityLightningBolt(world, pos.getX(), pos.getY(), pos.getZ(), true));
return;
}
IBlockState newState = rnd.nextFloat() < .165f ? state.cycleProperty(AGE) : state;
final Boolean isHarmless = state.getValue(HARMLESS);
if (newState.getValue(AGE) == 7) {
// die of old age
world.setBlockToAir(pos);
if (!isHarmless) {
if (rnd.nextFloat() < .165f) {
spawnResult(world, pos, rnd);
}
if (rnd.nextFloat() < .33f) {
spawnResult(world, pos, rnd);
}
spawnResult(world, pos, rnd);
if (rnd.nextFloat() < .05f) {
spawnAsEntity(world, pos, new ItemStack(this));
}
}
return;
} else {
if (rnd.nextFloat() < .33f) {
NNList<BlockPos> airs = new NNList<>();
for (NNIterator<EnumFacing> itr = NNList.FACING.fastIterator(); itr.hasNext(); ) {
BlockPos neighbor = pos.offset(itr.next());
if (world.isAirBlock(neighbor)) {
airs.add(neighbor);
} else {
IBlockState neighborState = world.getBlockState(neighbor);
if (neighborState.getBlock() == this && neighborState.getValue(HARMLESS)) {
airs.add(neighbor);
}
}
}
if (airs.size() >= 2) {
if (!isHarmless && airs.size() >= 3 && rnd.nextFloat() < .025f) {
// split
BlockPos targetPos1 = airs.remove(rand.nextInt(airs.size()));
BlockPos targetPos2 = airs.remove(rand.nextInt(airs.size()));
world.setBlockState(targetPos1, newState);
world.scheduleBlockUpdate(targetPos1, this, rand.nextInt(40), 0);
world.setBlockState(targetPos2, newState);
world.scheduleBlockUpdate(targetPos2, this, rand.nextInt(40), 0);
world.setBlockToAir(pos);
return;
} else if (!isHarmless && rnd.nextFloat() < .025f) {
// spawn
BlockPos targetPos1 = airs.remove(rand.nextInt(airs.size()));
world.setBlockState(targetPos1, state.withProperty(AGE, 0));
world.scheduleBlockUpdate(targetPos1, this, rand.nextInt(40), 0);
world.setBlockState(pos, newState);
world.scheduleBlockUpdate(pos, this, rand.nextInt(40), 0);
return;
} else if (rnd.nextFloat() < .50f) {
// move
BlockPos targetPos1 = airs.remove(rand.nextInt(airs.size()));
world.setBlockState(targetPos1, newState);
world.scheduleBlockUpdate(targetPos1, this, rand.nextInt(40), 0);
world.setBlockToAir(pos);
return;
} else if (!isHarmless) {
// spawn harmless
BlockPos targetPos1 = airs.remove(rand.nextInt(airs.size()));
world.setBlockState(targetPos1, state.withProperty(AGE, 0).withProperty(HARMLESS, true));
world.scheduleBlockUpdate(targetPos1, this, rand.nextInt(40), 0);
}
} else if (!isHarmless) {
// caged in? no thank you!
world.setBlockToAir(pos);
world.createExplosion(null, pos.getX() + .5, pos.getY() + .5, pos.getZ() + .5, .1f, true);
return;
}
}
if (state != newState) {
world.setBlockState(pos, newState);
}
world.scheduleBlockUpdate(pos, this, rand.nextInt(40), 0);
}
}
}
use of com.enderio.core.common.util.NNList in project EnderIO by SleepyTrousers.
the class Attackera method onUpdate.
@Override
public void onUpdate() {
ItemStack prev = prevWeapon;
ItemStack cur = getHeldItemMainhand();
if (!ItemStack.areItemStacksEqual(cur, prev)) {
if (!prev.isEmpty()) {
getAttributeMap().removeAttributeModifiers(prev.getAttributeModifiers(EntityEquipmentSlot.MAINHAND));
}
if (!cur.isEmpty()) {
getAttributeMap().applyAttributeModifiers(cur.getAttributeModifiers(EntityEquipmentSlot.MAINHAND));
}
prevWeapon = cur.copy();
}
if (chargedLocation != null && chargedLocation.chargeItems(new NNList<>(cur))) {
killerJoe.markDirty();
}
ticksSinceLastSwing++;
}
use of com.enderio.core.common.util.NNList in project EnderIO by SleepyTrousers.
the class ContainerStirlingGenerator method addGhostslots.
public void addGhostslots(NNList<GhostSlot> ghostSlots) {
NNList<ItemStack> fuels = new NNList<>();
ItemHelper.getValidItems().apply(new Callback<ItemStack>() {
@Override
public void apply(@Nonnull ItemStack e) {
if (getTe().isMachineItemValidForSlot(0, e)) {
fuels.add(e);
if (e.getItem() == Items.LAVA_BUCKET || e.getItem() == Items.COAL) {
// put an emphasis on the common fuels, especially the lava bucket---many players don't know about that one
for (int i = 0; i < 30; i++) {
fuels.add(e);
}
}
}
}
});
ghostSlots.add(new GhostBackgroundItemSlot(fuels, getSlotFromInventory(0)));
}
Aggregations