net.minecraft.block.BlockDispenser Java Examples
The following examples show how to use
net.minecraft.block.BlockDispenser.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Signals.java From Signals with GNU General Public License v3.0 | 6 votes |
@EventHandler public void PreInit(FMLPreInitializationEvent event){ event.getModMetadata().version = Versions.fullVersionString(); NetworkRegistry.INSTANCE.registerGuiHandler(instance, proxy); proxy.preInit(); ModBlocks.init(); ModItems.init(); CapabilityMinecartDestination.register(); CapabilityDestinationProvider.register(); MinecraftForge.EVENT_BUS.register(proxy); MinecraftForge.EVENT_BUS.register(new com.minemaarten.signals.event.EventHandler()); MinecraftForge.EVENT_BUS.register(new RailReplacerEventHandler()); BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(ModItems.TICKET, new BehaviorDispenseTicket()); ChunkLoadManager.INSTANCE.init(); asmData = event.getAsmData(); if(!SignalsConfig.enableRailNetwork) { Log.warning("RAIL NETWORK IS NOT FUNCTIONAL!"); } }
Example #2
Source File: DispenserBehaviorMobEgg.java From Artifacts with MIT License | 6 votes |
/** * Dispense the specified stack, play the dispense sound and spawn particles. */ public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) { EnumFacing enumfacing = BlockDispenser.func_149937_b/*getFacing*/(par1IBlockSource.getBlockMetadata()); double d0 = par1IBlockSource.getX() + (double)enumfacing.getFrontOffsetX(); double d1 = (double)((float)par1IBlockSource.getYInt() + 0.2F) + enumfacing.getFrontOffsetY(); double d2 = par1IBlockSource.getZ() + (double)enumfacing.getFrontOffsetZ(); Entity entity = ItemMonsterPlacer.spawnCreature(par1IBlockSource.getWorld(), par2ItemStack.getItemDamage(), d0, d1, d2); if (entity instanceof EntityLiving && par2ItemStack.hasDisplayName()) { ((EntityLiving)entity).setCustomNameTag(par2ItemStack.getDisplayName()); } par2ItemStack.splitStack(1); return par2ItemStack; }
Example #3
Source File: ItemTofuShield.java From TofuCraftReload with MIT License | 5 votes |
public ItemTofuShield(int damage) { super(); this.setMaxStackSize(1); this.setMaxDamage(damage); this.addPropertyOverride(new ResourceLocation("blocking"), new IItemPropertyGetter() { @SideOnly(Side.CLIENT) public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) { return entityIn != null && entityIn.isHandActive() && entityIn.getActiveItemStack() == stack ? 1.0F : 0.0F; } }); BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(this, ItemArmor.DISPENSER_BEHAVIOR); }
Example #4
Source File: ItemFukumame.java From TofuCraftReload with MIT License | 5 votes |
public ItemFukumame() { this.maxStackSize = 1; this.setMaxDamage(64); this.setUnlocalizedName(TofuMain.MODID + "." + "fukumame"); BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(this, new DispenserBehaviorFukumame()); this.addPropertyOverride(new ResourceLocation("empty"), new IItemPropertyGetter() { @Override public float apply(ItemStack stack, World worldIn, EntityLivingBase entityIn) { return stack.getItemDamage() > stack.getMaxDamage() ? 1.0f : 0.0f; } }); }
Example #5
Source File: ItemFukumame.java From TofuCraftReload with MIT License | 5 votes |
@Override public ItemStack dispenseStack(IBlockSource source, ItemStack stack) { if (stack.getItemDamage() >= stack.getMaxDamage()) return stack; EnumFacing enumfacing = source.getBlockState().getValue(BlockDispenser.FACING); // getFacing World world = source.getWorld(); double d0 = source.getX() + (double) ((float) enumfacing.getFrontOffsetX() * 1.125F); double d1 = source.getY() + (double) ((float) enumfacing.getFrontOffsetY() * 1.125F); double d2 = source.getZ() + (double) ((float) enumfacing.getFrontOffsetZ() * 1.125F); for (int i = 0; i < 8; i++) { EntityFukumame fukumame = new EntityFukumame(world, d0, d1, d2); fukumame.shoot(enumfacing.getFrontOffsetX(), (enumfacing.getFrontOffsetY()), enumfacing.getFrontOffsetZ(), this.getProjectileVelocity(), this.getProjectileInaccuracy()); applyEffect(fukumame, stack); if (!world.isRemote) { world.spawnEntity(fukumame); } } if (stack.isItemStackDamageable()) { stack.getItem(); stack.attemptDamageItem(1, Item.itemRand, null); } source.getWorld().playEvent(1000, source.getBlockPos(), 0); return stack; }
Example #6
Source File: BehaviorDispenseTicket.java From Signals with GNU General Public License v3.0 | 5 votes |
@Override protected ItemStack dispenseStack(IBlockSource source, ItemStack stack){ EnumFacing facing = source.getBlockState().getValue(BlockDispenser.FACING); AxisAlignedBB aabb = new AxisAlignedBB(source.getBlockPos().offset(facing)); List<EntityMinecart> carts = source.getWorld().getEntitiesWithinAABB(EntityMinecart.class, aabb); carts.forEach(cart -> ItemTicket.applyDestinations(cart, stack)); return stack; }
Example #7
Source File: DispenserBehaviourSpawnEgg.java From Et-Futurum with The Unlicense | 5 votes |
@Override public ItemStack dispenseStack(IBlockSource block, ItemStack stack) { EnumFacing enumfacing = BlockDispenser.func_149937_b(block.getBlockMetadata()); double d0 = block.getX() + enumfacing.getFrontOffsetX(); double d1 = block.getYInt() + 0.2F; double d2 = block.getZ() + enumfacing.getFrontOffsetZ(); Entity entity = ItemEntityEgg.spawnEntity(block.getWorld(), stack.getItemDamage(), d0, d1, d2); if (entity instanceof EntityLivingBase && stack.hasDisplayName()) ((EntityLiving) entity).setCustomNameTag(stack.getDisplayName()); stack.splitStack(1); return stack; }
Example #8
Source File: LingeringPotion.java From Et-Futurum with The Unlicense | 5 votes |
public LingeringPotion() { setTextureName("potion"); setUnlocalizedName(Utils.getUnlocalisedName("lingering_potion")); setCreativeTab(EtFuturum.enableLingeringPotions ? EtFuturum.creativeTab : null); if (EtFuturum.enableLingeringPotions) BlockDispenser.dispenseBehaviorRegistry.putObject(this, new DispenserBehaviourLingeringPotion()); }
Example #9
Source File: TippedArrow.java From Et-Futurum with The Unlicense | 5 votes |
public TippedArrow() { setTextureName("tipped_arrow"); setUnlocalizedName(Utils.getUnlocalisedName("tipped_arrow")); setCreativeTab(EtFuturum.enableTippedArrows ? EtFuturum.creativeTab : null); if (EtFuturum.enableTippedArrows) BlockDispenser.dispenseBehaviorRegistry.putObject(this, new DispenserBehaviourTippedArrow()); }
Example #10
Source File: Dispenser.java From minecraft-roguelike with GNU General Public License v3.0 | 5 votes |
public static boolean generate(IWorldEditor editor, Cardinal dir, Coord pos){ MetaBlock container = new MetaBlock(Blocks.DISPENSER); container.withProperty(BlockDispenser.FACING, Cardinal.facing(dir)); container.set(editor, pos); return true; }
Example #11
Source File: DispenserBehaviorFireworks.java From Artifacts with MIT License | 5 votes |
/** * Dispense the specified stack, play the dispense sound and spawn particles. */ public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) { EnumFacing enumfacing = BlockDispenser.func_149937_b/*getFacing*/(par1IBlockSource.getBlockMetadata()); double d0 = par1IBlockSource.getX() + (double)enumfacing.getFrontOffsetX(); double d1 = (double)((float)par1IBlockSource.getYInt() + 0.2F); double d2 = par1IBlockSource.getZ() + (double)enumfacing.getFrontOffsetZ(); EntityFireworkRocket entityfireworkrocket = new EntityFireworkRocket(par1IBlockSource.getWorld(), d0, d1, d2, par2ItemStack); par1IBlockSource.getWorld().spawnEntityInWorld(entityfireworkrocket); par2ItemStack.splitStack(1); return par2ItemStack; }
Example #12
Source File: ItemEntityEgg.java From Et-Futurum with The Unlicense | 4 votes |
public ItemEntityEgg() { setHasSubtypes(true); setCreativeTab(CreativeTabs.tabMisc); setUnlocalizedName(Utils.getUnlocalisedName("entity_egg")); BlockDispenser.dispenseBehaviorRegistry.putObject(this, new DispenserBehaviourSpawnEgg()); }
Example #13
Source File: DispenserBehaviorSword.java From Artifacts with MIT License | 4 votes |
/** * Dispense the specified stack, play the dispense sound and spawn particles. */ public ItemStack dispenseStack(IBlockSource blockSource, ItemStack itemStack) { EnumFacing enumfacing = BlockDispenser.func_149937_b/*getFacing*/(blockSource.getBlockMetadata()); double d0, d1, d2, d3, d4, d5; d0 = (int)blockSource.getX() - 1; d1 = (int)blockSource.getY() - 1; d2 = (int)blockSource.getZ() - 1; d3 = (int)blockSource.getX() + 1; d4 = (int)blockSource.getY() + 1; d5 = (int)blockSource.getZ() + 1; //System.out.println((int)par1IBlockSource.getX() + "," + (int)par1IBlockSource.getZ()); d0 += 0.5 * d0/Math.abs(d0); d1 += 0.5 * d1/Math.abs(d1); d2 += 0.5 * d2/Math.abs(d2); d3 += 0.5 * d3/Math.abs(d3); d4 += 0.5 * d4/Math.abs(d4); d5 += 0.5 * d5/Math.abs(d5); d0 += enumfacing.getFrontOffsetX(); d3 += enumfacing.getFrontOffsetX(); d2 += enumfacing.getFrontOffsetZ(); d5 += enumfacing.getFrontOffsetZ(); if(enumfacing.getFrontOffsetX() != 0) { d2 += 0.5; d5 -= 0.5; } if(enumfacing.getFrontOffsetZ() != 0) { d0 += 0.5; d3 -= 0.5; } //Play sound. blockSource.getWorld().playAuxSFX(1002, blockSource.getXInt(), blockSource.getYInt(), blockSource.getZInt(), 0); AxisAlignedBB par2AxisAlignedBB = AxisAlignedBB.getBoundingBox(d0, d1, d2, d3, d4, d5); //System.out.println(par2AxisAlignedBB); List<EntityLivingBase> ents = blockSource.getWorld().getEntitiesWithinAABB(EntityLivingBase.class, par2AxisAlignedBB); if(ents.size() > 0) { for(int l=ents.size() - 1; l >= 0; l--) { EntityLivingBase ent = ents.get(l); ent.attackEntityFrom(DamageSourceSword.instance, damage); itemStack.damageItem(1, ent); } } TileEntity te = blockSource.getBlockTileEntity(); if(te != null && te instanceof TileEntityTrap) { TileEntityTrap tet = (TileEntityTrap) te; /*int a = par2ItemStack.getItem().itemID; int b = 0; switch(a) { case 11: b = 1; break; case 12: b = 2; break; case 16: b = 3; break; case 20: b = 4; break; case 27: b = 5; break; }*/ tet.startSwordRender(blockSource.getWorld(), blockSource.getXInt()+enumfacing.getFrontOffsetX(), blockSource.getYInt()+enumfacing.getFrontOffsetY(), blockSource.getZInt()+enumfacing.getFrontOffsetZ(), blockSource.getBlockMetadata(), itemStack); } else { System.out.println("Tile Entity was null!"); } /*EntitySword entsw = new EntitySword(par1IBlockSource.getWorld(), par1IBlockSource.getX(), par1IBlockSource.getY(), par1IBlockSource.getZ()); par1IBlockSource.getWorld().spawnEntityInWorld((Entity)entsw);*/ return itemStack; }