use of net.minecraft.dispenser.IPosition in project TechReborn by TechReborn.
the class BehaviorDispenseScrapbox method dispenseStack.
@Override
protected ItemStack dispenseStack(IBlockSource source, ItemStack stack) {
if (dispenseScrapboxes) {
List<IBaseRecipeType> scrapboxRecipeList = RecipeHandler.getRecipeClassFromName(Reference.SCRAPBOX_RECIPE);
int random = new Random().nextInt(scrapboxRecipeList.size());
ItemStack out = scrapboxRecipeList.get(random).getOutput(0);
stack.splitStack(1);
TileEntityDispenser tile = source.getBlockTileEntity();
EnumFacing enumfacing = tile.getWorld().getBlockState(new BlockPos(source.getX(), source.getY(), source.getZ())).getValue(BlockDispenser.FACING);
IPosition iposition = BlockDispenser.getDispensePosition(source);
doDispense(source.getWorld(), out, 6, enumfacing, iposition);
}
return stack;
}
use of net.minecraft.dispenser.IPosition in project Bewitchment by Um-Mitternacht.
the class ModEntities method init.
public static void init() {
int id = 0;
EntityRegistry.registerModEntity(getResource("brew_throwable"), EntityBrew.class, "brew_throwable", id++, Bewitchment.instance, 64, 1, true);
EntityRegistry.registerModEntity(getResource("spell_carrier"), EntitySpellCarrier.class, "spell_carrier", id++, Bewitchment.instance, 64, 1, true);
BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(ModItems.brew_phial_splash, new IBehaviorDispenseItem() {
@Override
public ItemStack dispense(IBlockSource source, final ItemStack stack) {
return (new BehaviorProjectileDispense() {
@Override
protected IProjectile getProjectileEntity(World worldIn, IPosition position, ItemStack stackIn) {
return new EntityBrew(worldIn, position.getX(), position.getY(), position.getZ(), stack.copy(), EntityBrew.BrewDispersion.SPLASH);
}
@Override
protected float getProjectileInaccuracy() {
return super.getProjectileInaccuracy() * 0.5F;
}
@Override
protected float getProjectileVelocity() {
return super.getProjectileVelocity() * 1.25F;
}
}).dispense(source, stack);
}
});
EntityRegistry.registerModEntity(getResource("broom"), EntityFlyingBroom.class, "broom", id++, Bewitchment.instance, 64, 1, true);
EntityRegistry.registerModEntity(getResource("swarm"), EntityBatSwarm.class, "swarm", id++, Bewitchment.instance, 64, 1, true);
EntityRegistry.registerModEntity(getResource("brew_linger"), EntityBrewLinger.class, "brew_linger", id, Bewitchment.instance, 64, 1, false);
BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(ModItems.brew_phial_linger, new IBehaviorDispenseItem() {
@Override
public ItemStack dispense(IBlockSource source, final ItemStack stack) {
return (new BehaviorProjectileDispense() {
@Override
protected IProjectile getProjectileEntity(World worldIn, IPosition position, ItemStack stackIn) {
return new EntityBrew(worldIn, position.getX(), position.getY(), position.getZ(), stack.copy(), EntityBrew.BrewDispersion.LINGER);
}
@Override
protected float getProjectileInaccuracy() {
return super.getProjectileInaccuracy() * 0.5F;
}
@Override
protected float getProjectileVelocity() {
return super.getProjectileVelocity() * 1.25F;
}
}).dispense(source, stack);
}
});
}
use of net.minecraft.dispenser.IPosition in project ClaySoldiersMod by SanAndreasP.
the class BehaviorDisruptorDispenseItem method dispenseStack.
/**
* Dispense the specified stack, play the dispense sound and spawn particles.
*/
ItemStack dispenseStack(IBlockSource blockSource, ItemStack stack) {
IPosition position = BlockDispenser.func_149939_a(blockSource);
ItemDisruptor.disrupt(stack, blockSource.getWorld(), position.getX(), position.getY(), position.getZ(), null);
return stack;
}
use of net.minecraft.dispenser.IPosition in project Galacticraft by micdoodle8.
the class GCFluids method registerDispenserBehaviours.
public static void registerDispenserBehaviours() {
IBehaviorDispenseItem ibehaviordispenseitem = new BehaviorDefaultDispenseItem() {
private final BehaviorDefaultDispenseItem dispenseBehavior = new BehaviorDefaultDispenseItem();
@Override
public ItemStack dispenseStack(IBlockSource source, ItemStack stack) {
ItemBucketGC itembucket = (ItemBucketGC) stack.getItem();
BlockPos blockpos = source.getBlockPos().offset(BlockDispenser.getFacing(source.getBlockMetadata()));
if (itembucket.tryPlaceContainedLiquid(source.getWorld(), blockpos)) {
stack.setItem(Items.bucket);
stack.stackSize = 1;
return stack;
} else {
return this.dispenseBehavior.dispense(source, stack);
}
}
};
if (GCItems.bucketFuel != null) {
BlockDispenser.dispenseBehaviorRegistry.putObject(GCItems.bucketFuel, ibehaviordispenseitem);
}
if (GCItems.bucketOil != null) {
BlockDispenser.dispenseBehaviorRegistry.putObject(GCItems.bucketOil, ibehaviordispenseitem);
}
if (GalacticraftCore.isPlanetsLoaded) {
if (MarsItems.bucketSludge != null) {
BlockDispenser.dispenseBehaviorRegistry.putObject(MarsItems.bucketSludge, ibehaviordispenseitem);
}
if (VenusItems.bucketSulphuricAcid != null) {
BlockDispenser.dispenseBehaviorRegistry.putObject(VenusItems.bucketSulphuricAcid, ibehaviordispenseitem);
}
}
// The following code is for other objects, not liquids, but it's convenient to keep it all together
BlockDispenser.dispenseBehaviorRegistry.putObject(GCItems.meteorChunk, new BehaviorProjectileDispense() {
@Override
protected IProjectile getProjectileEntity(World worldIn, IPosition position) {
return new EntityMeteorChunk(worldIn);
}
@Override
public ItemStack dispenseStack(IBlockSource source, ItemStack stack) {
World world = source.getWorld();
IPosition position = BlockDispenser.getDispensePosition(source);
EnumFacing enumfacing = BlockDispenser.getFacing(source.getBlockMetadata());
EntityMeteorChunk meteor = new EntityMeteorChunk(world);
meteor.setPosition(position.getX(), position.getY(), position.getZ());
meteor.setThrowableHeading((double) enumfacing.getFrontOffsetX(), (double) ((float) enumfacing.getFrontOffsetY() + 0.1F), (double) enumfacing.getFrontOffsetZ(), 1.0F, this.func_82498_a());
if (stack.getItemDamage() > 0) {
meteor.setFire(20);
meteor.isHot = true;
}
meteor.canBePickedUp = 1;
world.spawnEntityInWorld((Entity) meteor);
stack.splitStack(1);
return stack;
}
});
BlockDispenser.dispenseBehaviorRegistry.putObject(GCItems.rocketTier1, new BehaviorDefaultDispenseItem() {
@Override
public ItemStack dispenseStack(IBlockSource source, ItemStack stack) {
World world = source.getWorld();
BlockPos pos = source.getBlockPos().offset(BlockDispenser.getFacing(source.getBlockMetadata()), 2);
IBlockState iblockstate = world.getBlockState(pos);
boolean rocketPlaced = false;
if (iblockstate.getBlock() == GCBlocks.landingPadFull && GCBlocks.landingPadFull.getMetaFromState(iblockstate) == 0) {
float centerX = pos.getX() + 0.5F;
float centerY = pos.getY() + 0.4F;
float centerZ = pos.getZ() + 0.5F;
rocketPlaced = ItemTier1Rocket.placeRocketOnPad(stack, world, world.getTileEntity(pos), centerX, centerY, centerZ);
}
if (rocketPlaced) {
stack.splitStack(1);
}
return stack;
}
});
if (GalacticraftCore.isPlanetsLoaded) {
BlockDispenser.dispenseBehaviorRegistry.putObject(MarsItems.rocketMars, new BehaviorDefaultDispenseItem() {
@Override
public ItemStack dispenseStack(IBlockSource source, ItemStack stack) {
World world = source.getWorld();
BlockPos pos = source.getBlockPos().offset(BlockDispenser.getFacing(source.getBlockMetadata()), 2);
IBlockState iblockstate = world.getBlockState(pos);
boolean rocketPlaced = false;
if (iblockstate.getBlock() == GCBlocks.landingPadFull && GCBlocks.landingPadFull.getMetaFromState(iblockstate) == 0) {
float centerX = pos.getX() + 0.5F;
float centerY = pos.getY() + 0.4F;
float centerZ = pos.getZ() + 0.5F;
rocketPlaced = ItemTier2Rocket.placeRocketOnPad(stack, world, world.getTileEntity(pos), centerX, centerY, centerZ);
}
if (rocketPlaced) {
stack.splitStack(1);
}
return stack;
}
});
BlockDispenser.dispenseBehaviorRegistry.putObject(AsteroidsItems.tier3Rocket, new BehaviorDefaultDispenseItem() {
@Override
public ItemStack dispenseStack(IBlockSource source, ItemStack stack) {
World world = source.getWorld();
BlockPos pos = source.getBlockPos().offset(BlockDispenser.getFacing(source.getBlockMetadata()), 2);
IBlockState iblockstate = world.getBlockState(pos);
boolean rocketPlaced = false;
if (iblockstate.getBlock() == GCBlocks.landingPadFull && GCBlocks.landingPadFull.getMetaFromState(iblockstate) == 0) {
float centerX = pos.getX() + 0.5F;
float centerY = pos.getY() + 0.4F;
float centerZ = pos.getZ() + 0.5F;
rocketPlaced = ItemTier3Rocket.placeRocketOnPad(stack, world, world.getTileEntity(pos), centerX, centerY, centerZ);
}
if (rocketPlaced) {
stack.splitStack(1);
}
return stack;
}
});
}
}
use of net.minecraft.dispenser.IPosition in project Gaspunk by Ladysnake.
the class CommonProxy method init.
public void init() {
PacketHandler.initPackets();
if (GasPunkConfig.alternativeAshRecipe)
GameRegistry.addSmelting(Items.NETHER_WART, new ItemStack(ModItems.ASH), 0.8f);
else
GameRegistry.addSmelting(Items.ROTTEN_FLESH, new ItemStack(ModItems.ASH), 0.35f);
if (Loader.isModLoaded("baubles"))
MinecraftForge.EVENT_BUS.register(new BaublesCompatHandler());
new Thread(SpecialRewardChecker::retrieveSpecialRewards).start();
BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(ModItems.GRENADE, new BehaviorProjectileDispense() {
@Nonnull
@Override
protected IProjectile getProjectileEntity(@Nonnull World worldIn, @Nonnull IPosition position, @Nonnull ItemStack stackIn) {
return new EntityGrenade(worldIn, stackIn.copy(), position.getX(), position.getY(), position.getZ());
}
});
}
Aggregations