use of micdoodle8.mods.galacticraft.core.entities.EntityMeteorChunk 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 micdoodle8.mods.galacticraft.core.entities.EntityMeteorChunk in project Galacticraft by micdoodle8.
the class ItemMeteorChunk method onItemRightClick.
@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) {
if (!player.capabilities.isCreativeMode) {
--itemStack.stackSize;
}
world.playSoundAtEntity(player, "random.bow", 1.0F, 0.0001F / (Item.itemRand.nextFloat() * 0.1F));
if (!world.isRemote) {
EntityMeteorChunk meteor = new EntityMeteorChunk(world, player, 1.0F);
if (itemStack.getItemDamage() > 0) {
meteor.setFire(20);
meteor.isHot = true;
}
meteor.canBePickedUp = player.capabilities.isCreativeMode ? 2 : 1;
world.spawnEntityInWorld(meteor);
}
player.swingItem();
return itemStack;
}
Aggregations