| 1 | package net.minecraft.init;
|
| 2 |
|
| 3 | import com.mojang.authlib.GameProfile;
|
| 4 | import java.io.PrintStream;
|
| 5 | import java.util.Random;
|
| 6 | import java.util.UUID;
|
| 7 | import net.minecraft.block.Block;
|
| 8 | import net.minecraft.block.BlockDispenser;
|
| 9 | import net.minecraft.block.BlockFire;
|
| 10 | import net.minecraft.block.BlockLiquid;
|
| 11 | import net.minecraft.block.BlockPumpkin;
|
| 12 | import net.minecraft.block.BlockSkull;
|
| 13 | import net.minecraft.block.BlockTNT;
|
| 14 | import net.minecraft.block.material.Material;
|
| 15 | import net.minecraft.block.state.IBlockState;
|
| 16 | import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
|
| 17 | import net.minecraft.dispenser.BehaviorProjectileDispense;
|
| 18 | import net.minecraft.dispenser.IBehaviorDispenseItem;
|
| 19 | import net.minecraft.dispenser.IBlockSource;
|
| 20 | import net.minecraft.dispenser.IPosition;
|
| 21 | import net.minecraft.entity.Entity;
|
| 22 | import net.minecraft.entity.EntityLiving;
|
| 23 | import net.minecraft.entity.EntityLivingBase;
|
| 24 | import net.minecraft.entity.IProjectile;
|
| 25 | import net.minecraft.entity.item.EntityBoat;
|
| 26 | import net.minecraft.entity.item.EntityExpBottle;
|
| 27 | import net.minecraft.entity.item.EntityFireworkRocket;
|
| 28 | import net.minecraft.entity.item.EntityTNTPrimed;
|
| 29 | import net.minecraft.entity.projectile.EntityArrow;
|
| 30 | import net.minecraft.entity.projectile.EntityEgg;
|
| 31 | import net.minecraft.entity.projectile.EntityPotion;
|
| 32 | import net.minecraft.entity.projectile.EntitySmallFireball;
|
| 33 | import net.minecraft.entity.projectile.EntitySnowball;
|
| 34 | import net.minecraft.item.EnumDyeColor;
|
| 35 | import net.minecraft.item.Item;
|
| 36 | import net.minecraft.item.ItemBucket;
|
| 37 | import net.minecraft.item.ItemDye;
|
| 38 | import net.minecraft.item.ItemMonsterPlacer;
|
| 39 | import net.minecraft.item.ItemPotion;
|
| 40 | import net.minecraft.item.ItemStack;
|
| 41 | import net.minecraft.nbt.NBTTagCompound;
|
| 42 | import net.minecraft.nbt.NBTUtil;
|
| 43 | import net.minecraft.stats.StatList;
|
| 44 | import net.minecraft.tileentity.TileEntity;
|
| 45 | import net.minecraft.tileentity.TileEntityDispenser;
|
| 46 | import net.minecraft.tileentity.TileEntitySkull;
|
| 47 | import net.minecraft.util.BlockPos;
|
| 48 | import net.minecraft.util.EnumFacing;
|
| 49 | import net.minecraft.util.LoggingPrintStream;
|
| 50 | import net.minecraft.util.StringUtils;
|
| 51 | import net.minecraft.world.World;
|
| 52 | import org.apache.logging.log4j.LogManager;
|
| 53 | import org.apache.logging.log4j.Logger;
|
| 54 |
|
| 55 | public class Bootstrap
|
| 56 | {
|
| 57 | private static final PrintStream SYSOUT = System.out;
|
| 58 |
|
| 59 | /** Whether the blocks, items, etc have already been registered */
|
| 60 | private static boolean alreadyRegistered = false;
|
| 61 | private static final Logger LOGGER = LogManager.getLogger();
|
| 62 |
|
| 63 | /**
|
| 64 | * Is Bootstrap registration already done?
|
| 65 | */
|
| 66 | public static boolean isRegistered()
|
| 67 | {
|
| 68 | return alreadyRegistered;
|
| 69 | }
|
| 70 |
|
| 71 | static void registerDispenserBehaviors()
|
| 72 | {
|
| 73 | BlockDispenser.dispenseBehaviorRegistry.putObject(Items.arrow, new BehaviorProjectileDispense()
|
| 74 | {
|
| 75 | protected IProjectile getProjectileEntity(World worldIn, IPosition position)
|
| 76 | {
|
| 77 | EntityArrow entityarrow = new EntityArrow(worldIn, position.getX(), position.getY(), position.getZ());
|
| 78 | entityarrow.canBePickedUp = 1;
|
| 79 | return entityarrow;
|
| 80 | }
|
| 81 | });
|
| 82 | BlockDispenser.dispenseBehaviorRegistry.putObject(Items.egg, new BehaviorProjectileDispense()
|
| 83 | {
|
| 84 | protected IProjectile getProjectileEntity(World worldIn, IPosition position)
|
| 85 | {
|
| 86 | return new EntityEgg(worldIn, position.getX(), position.getY(), position.getZ());
|
| 87 | }
|
| 88 | });
|
| 89 | BlockDispenser.dispenseBehaviorRegistry.putObject(Items.snowball, new BehaviorProjectileDispense()
|
| 90 | {
|
| 91 | protected IProjectile getProjectileEntity(World worldIn, IPosition position)
|
| 92 | {
|
| 93 | return new EntitySnowball(worldIn, position.getX(), position.getY(), position.getZ());
|
| 94 | }
|
| 95 | });
|
| 96 | BlockDispenser.dispenseBehaviorRegistry.putObject(Items.experience_bottle, new BehaviorProjectileDispense()
|
| 97 | {
|
| 98 | protected IProjectile getProjectileEntity(World worldIn, IPosition position)
|
| 99 | {
|
| 100 | return new EntityExpBottle(worldIn, position.getX(), position.getY(), position.getZ());
|
| 101 | }
|
| 102 | protected float func_82498_a()
|
| 103 | {
|
| 104 | return super.func_82498_a() * 0.5F;
|
| 105 | }
|
| 106 | protected float func_82500_b()
|
| 107 | {
|
| 108 | return super.func_82500_b() * 1.25F;
|
| 109 | }
|
| 110 | });
|
| 111 | BlockDispenser.dispenseBehaviorRegistry.putObject(Items.potionitem, new IBehaviorDispenseItem()
|
| 112 | {
|
| 113 | private final BehaviorDefaultDispenseItem field_150843_b = new BehaviorDefaultDispenseItem();
|
| 114 | public ItemStack dispense(IBlockSource source, final ItemStack stack)
|
| 115 | {
|
| 116 | return ItemPotion.isSplash(stack.getMetadata()) ? (new BehaviorProjectileDispense()
|
| 117 | {
|
| 118 | protected IProjectile getProjectileEntity(World worldIn, IPosition position)
|
| 119 | {
|
| 120 | return new EntityPotion(worldIn, position.getX(), position.getY(), position.getZ(), stack.copy());
|
| 121 | }
|
| 122 | protected float func_82498_a()
|
| 123 | {
|
| 124 | return super.func_82498_a() * 0.5F;
|
| 125 | }
|
| 126 | protected float func_82500_b()
|
| 127 | {
|
| 128 | return super.func_82500_b() * 1.25F;
|
| 129 | }
|
| 130 | }).dispense(source, stack): this.field_150843_b.dispense(source, stack);
|
| 131 | }
|
| 132 | });
|
| 133 | BlockDispenser.dispenseBehaviorRegistry.putObject(Items.spawn_egg, new BehaviorDefaultDispenseItem()
|
| 134 | {
|
| 135 | public ItemStack dispenseStack(IBlockSource source, ItemStack stack)
|
| 136 | {
|
| 137 | EnumFacing enumfacing = BlockDispenser.getFacing(source.getBlockMetadata());
|
| 138 | double d0 = source.getX() + (double)enumfacing.getFrontOffsetX();
|
| 139 | double d1 = (double)((float)source.getBlockPos().getY() + 0.2F);
|
| 140 | double d2 = source.getZ() + (double)enumfacing.getFrontOffsetZ();
|
| 141 | Entity entity = ItemMonsterPlacer.spawnCreature(source.getWorld(), stack.getMetadata(), d0, d1, d2);
|
| 142 |
|
| 143 | if (entity instanceof EntityLivingBase && stack.hasDisplayName())
|
| 144 | {
|
| 145 | ((EntityLiving)entity).setCustomNameTag(stack.getDisplayName());
|
| 146 | }
|
| 147 |
|
| 148 | stack.splitStack(1);
|
| 149 | return stack;
|
| 150 | }
|
| 151 | });
|
| 152 | BlockDispenser.dispenseBehaviorRegistry.putObject(Items.fireworks, new BehaviorDefaultDispenseItem()
|
| 153 | {
|
| 154 | public ItemStack dispenseStack(IBlockSource source, ItemStack stack)
|
| 155 | {
|
| 156 | EnumFacing enumfacing = BlockDispenser.getFacing(source.getBlockMetadata());
|
| 157 | double d0 = source.getX() + (double)enumfacing.getFrontOffsetX();
|
| 158 | double d1 = (double)((float)source.getBlockPos().getY() + 0.2F);
|
| 159 | double d2 = source.getZ() + (double)enumfacing.getFrontOffsetZ();
|
| 160 | EntityFireworkRocket entityfireworkrocket = new EntityFireworkRocket(source.getWorld(), d0, d1, d2, stack);
|
| 161 | source.getWorld().spawnEntityInWorld(entityfireworkrocket);
|
| 162 | stack.splitStack(1);
|
| 163 | return stack;
|
| 164 | }
|
| 165 | protected void playDispenseSound(IBlockSource source)
|
| 166 | {
|
| 167 | source.getWorld().playAuxSFX(1002, source.getBlockPos(), 0);
|
| 168 | }
|
| 169 | });
|
| 170 | BlockDispenser.dispenseBehaviorRegistry.putObject(Items.fire_charge, new BehaviorDefaultDispenseItem()
|
| 171 | {
|
| 172 | public ItemStack dispenseStack(IBlockSource source, ItemStack stack)
|
| 173 | {
|
| 174 | EnumFacing enumfacing = BlockDispenser.getFacing(source.getBlockMetadata());
|
| 175 | IPosition iposition = BlockDispenser.getDispensePosition(source);
|
| 176 | double d0 = iposition.getX() + (double)((float)enumfacing.getFrontOffsetX() * 0.3F);
|
| 177 | double d1 = iposition.getY() + (double)((float)enumfacing.getFrontOffsetY() * 0.3F);
|
| 178 | double d2 = iposition.getZ() + (double)((float)enumfacing.getFrontOffsetZ() * 0.3F);
|
| 179 | World world = source.getWorld();
|
| 180 | Random random = world.rand;
|
| 181 | double d3 = random.nextGaussian() * 0.05D + (double)enumfacing.getFrontOffsetX();
|
| 182 | double d4 = random.nextGaussian() * 0.05D + (double)enumfacing.getFrontOffsetY();
|
| 183 | double d5 = random.nextGaussian() * 0.05D + (double)enumfacing.getFrontOffsetZ();
|
| 184 | world.spawnEntityInWorld(new EntitySmallFireball(world, d0, d1, d2, d3, d4, d5));
|
| 185 | stack.splitStack(1);
|
| 186 | return stack;
|
| 187 | }
|
| 188 | protected void playDispenseSound(IBlockSource source)
|
| 189 | {
|
| 190 | source.getWorld().playAuxSFX(1009, source.getBlockPos(), 0);
|
| 191 | }
|
| 192 | });
|
| 193 | BlockDispenser.dispenseBehaviorRegistry.putObject(Items.boat, new BehaviorDefaultDispenseItem()
|
| 194 | {
|
| 195 | private final BehaviorDefaultDispenseItem field_150842_b = new BehaviorDefaultDispenseItem();
|
| 196 | public ItemStack dispenseStack(IBlockSource source, ItemStack stack)
|
| 197 | {
|
| 198 | EnumFacing enumfacing = BlockDispenser.getFacing(source.getBlockMetadata());
|
| 199 | World world = source.getWorld();
|
| 200 | double d0 = source.getX() + (double)((float)enumfacing.getFrontOffsetX() * 1.125F);
|
| 201 | double d1 = source.getY() + (double)((float)enumfacing.getFrontOffsetY() * 1.125F);
|
| 202 | double d2 = source.getZ() + (double)((float)enumfacing.getFrontOffsetZ() * 1.125F);
|
| 203 | BlockPos blockpos = source.getBlockPos().offset(enumfacing);
|
| 204 | Material material = world.getBlockState(blockpos).getBlock().getMaterial();
|
| 205 | double d3;
|
| 206 |
|
| 207 | if (Material.water.equals(material))
|
| 208 | {
|
| 209 | d3 = 1.0D;
|
| 210 | }
|
| 211 | else
|
| 212 | {
|
| 213 | if (!Material.air.equals(material) || !Material.water.equals(world.getBlockState(blockpos.down()).getBlock().getMaterial()))
|
| 214 | {
|
| 215 | return this.field_150842_b.dispense(source, stack);
|
| 216 | }
|
| 217 |
|
| 218 | d3 = 0.0D;
|
| 219 | }
|
| 220 |
|
| 221 | EntityBoat entityboat = new EntityBoat(world, d0, d1 + d3, d2);
|
| 222 | world.spawnEntityInWorld(entityboat);
|
| 223 | stack.splitStack(1);
|
| 224 | return stack;
|
| 225 | }
|
| 226 | protected void playDispenseSound(IBlockSource source)
|
| 227 | {
|
| 228 | source.getWorld().playAuxSFX(1000, source.getBlockPos(), 0);
|
| 229 | }
|
| 230 | });
|
| 231 | IBehaviorDispenseItem ibehaviordispenseitem = new BehaviorDefaultDispenseItem()
|
| 232 | {
|
| 233 | private final BehaviorDefaultDispenseItem field_150841_b = new BehaviorDefaultDispenseItem();
|
| 234 | public ItemStack dispenseStack(IBlockSource source, ItemStack stack)
|
| 235 | {
|
| 236 | ItemBucket itembucket = (ItemBucket)stack.getItem();
|
| 237 | BlockPos blockpos = source.getBlockPos().offset(BlockDispenser.getFacing(source.getBlockMetadata()));
|
| 238 |
|
| 239 | if (itembucket.tryPlaceContainedLiquid(source.getWorld(), blockpos))
|
| 240 | {
|
| 241 | stack.setItem(Items.bucket);
|
| 242 | stack.stackSize = 1;
|
| 243 | return stack;
|
| 244 | }
|
| 245 | else
|
| 246 | {
|
| 247 | return this.field_150841_b.dispense(source, stack);
|
| 248 | }
|
| 249 | }
|
| 250 | };
|
| 251 | BlockDispenser.dispenseBehaviorRegistry.putObject(Items.lava_bucket, ibehaviordispenseitem);
|
| 252 | BlockDispenser.dispenseBehaviorRegistry.putObject(Items.water_bucket, ibehaviordispenseitem);
|
| 253 | BlockDispenser.dispenseBehaviorRegistry.putObject(Items.bucket, new BehaviorDefaultDispenseItem()
|
| 254 | {
|
| 255 | private final BehaviorDefaultDispenseItem field_150840_b = new BehaviorDefaultDispenseItem();
|
| 256 | public ItemStack dispenseStack(IBlockSource source, ItemStack stack)
|
| 257 | {
|
| 258 | World world = source.getWorld();
|
| 259 | BlockPos blockpos = source.getBlockPos().offset(BlockDispenser.getFacing(source.getBlockMetadata()));
|
| 260 | IBlockState iblockstate = world.getBlockState(blockpos);
|
| 261 | Block block = iblockstate.getBlock();
|
| 262 | Material material = block.getMaterial();
|
| 263 | Item item;
|
| 264 |
|
| 265 | if (Material.water.equals(material) && block instanceof BlockLiquid && ((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue() == 0)
|
| 266 | {
|
| 267 | item = Items.water_bucket;
|
| 268 | }
|
| 269 | else
|
| 270 | {
|
| 271 | if (!Material.lava.equals(material) || !(block instanceof BlockLiquid) || ((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue() != 0)
|
| 272 | {
|
| 273 | return super.dispenseStack(source, stack);
|
| 274 | }
|
| 275 |
|
| 276 | item = Items.lava_bucket;
|
| 277 | }
|
| 278 |
|
| 279 | world.setBlockToAir(blockpos);
|
| 280 |
|
| 281 | if (--stack.stackSize == 0)
|
| 282 | {
|
| 283 | stack.setItem(item);
|
| 284 | stack.stackSize = 1;
|
| 285 | }
|
| 286 | else if (((TileEntityDispenser)source.getBlockTileEntity()).addItemStack(new ItemStack(item)) < 0)
|
| 287 | {
|
| 288 | this.field_150840_b.dispense(source, new ItemStack(item));
|
| 289 | }
|
| 290 |
|
| 291 | return stack;
|
| 292 | }
|
| 293 | });
|
| 294 | BlockDispenser.dispenseBehaviorRegistry.putObject(Items.flint_and_steel, new BehaviorDefaultDispenseItem()
|
| 295 | {
|
| 296 | private boolean field_150839_b = true;
|
| 297 | protected ItemStack dispenseStack(IBlockSource source, ItemStack stack)
|
| 298 | {
|
| 299 | World world = source.getWorld();
|
| 300 | BlockPos blockpos = source.getBlockPos().offset(BlockDispenser.getFacing(source.getBlockMetadata()));
|
| 301 |
|
| 302 | if (world.isAirBlock(blockpos))
|
| 303 | {
|
| 304 | world.setBlockState(blockpos, Blocks.fire.getDefaultState());
|
| 305 |
|
| 306 | if (stack.attemptDamageItem(1, world.rand))
|
| 307 | {
|
| 308 | stack.stackSize = 0;
|
| 309 | }
|
| 310 | }
|
| 311 | else if (world.getBlockState(blockpos).getBlock() == Blocks.tnt)
|
| 312 | {
|
| 313 | Blocks.tnt.onBlockDestroyedByPlayer(world, blockpos, Blocks.tnt.getDefaultState().withProperty(BlockTNT.EXPLODE, Boolean.valueOf(true)));
|
| 314 | world.setBlockToAir(blockpos);
|
| 315 | }
|
| 316 | else
|
| 317 | {
|
| 318 | this.field_150839_b = false;
|
| 319 | }
|
| 320 |
|
| 321 | return stack;
|
| 322 | }
|
| 323 | protected void playDispenseSound(IBlockSource source)
|
| 324 | {
|
| 325 | if (this.field_150839_b)
|
| 326 | {
|
| 327 | source.getWorld().playAuxSFX(1000, source.getBlockPos(), 0);
|
| 328 | }
|
| 329 | else
|
| 330 | {
|
| 331 | source.getWorld().playAuxSFX(1001, source.getBlockPos(), 0);
|
| 332 | }
|
| 333 | }
|
| 334 | });
|
| 335 | BlockDispenser.dispenseBehaviorRegistry.putObject(Items.dye, new BehaviorDefaultDispenseItem()
|
| 336 | {
|
| 337 | private boolean field_150838_b = true;
|
| 338 | protected ItemStack dispenseStack(IBlockSource source, ItemStack stack)
|
| 339 | {
|
| 340 | if (EnumDyeColor.WHITE == EnumDyeColor.byDyeDamage(stack.getMetadata()))
|
| 341 | {
|
| 342 | World world = source.getWorld();
|
| 343 | BlockPos blockpos = source.getBlockPos().offset(BlockDispenser.getFacing(source.getBlockMetadata()));
|
| 344 |
|
| 345 | if (ItemDye.applyBonemeal(stack, world, blockpos))
|
| 346 | {
|
| 347 | if (!world.isRemote)
|
| 348 | {
|
| 349 | world.playAuxSFX(2005, blockpos, 0);
|
| 350 | }
|
| 351 | }
|
| 352 | else
|
| 353 | {
|
| 354 | this.field_150838_b = false;
|
| 355 | }
|
| 356 |
|
| 357 | return stack;
|
| 358 | }
|
| 359 | else
|
| 360 | {
|
| 361 | return super.dispenseStack(source, stack);
|
| 362 | }
|
| 363 | }
|
| 364 | protected void playDispenseSound(IBlockSource source)
|
| 365 | {
|
| 366 | if (this.field_150838_b)
|
| 367 | {
|
| 368 | source.getWorld().playAuxSFX(1000, source.getBlockPos(), 0);
|
| 369 | }
|
| 370 | else
|
| 371 | {
|
| 372 | source.getWorld().playAuxSFX(1001, source.getBlockPos(), 0);
|
| 373 | }
|
| 374 | }
|
| 375 | });
|
| 376 | BlockDispenser.dispenseBehaviorRegistry.putObject(Item.getItemFromBlock(Blocks.tnt), new BehaviorDefaultDispenseItem()
|
| 377 | {
|
| 378 | protected ItemStack dispenseStack(IBlockSource source, ItemStack stack)
|
| 379 | {
|
| 380 | World world = source.getWorld();
|
| 381 | BlockPos blockpos = source.getBlockPos().offset(BlockDispenser.getFacing(source.getBlockMetadata()));
|
| 382 | EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, (double)blockpos.getX() + 0.5D, (double)blockpos.getY(), (double)blockpos.getZ() + 0.5D, (EntityLivingBase)null);
|
| 383 | world.spawnEntityInWorld(entitytntprimed);
|
| 384 | world.playSoundAtEntity(entitytntprimed, "game.tnt.primed", 1.0F, 1.0F);
|
| 385 | --stack.stackSize;
|
| 386 | return stack;
|
| 387 | }
|
| 388 | });
|
| 389 | BlockDispenser.dispenseBehaviorRegistry.putObject(Items.skull, new BehaviorDefaultDispenseItem()
|
| 390 | {
|
| 391 | private boolean field_179240_b = true;
|
| 392 | protected ItemStack dispenseStack(IBlockSource source, ItemStack stack)
|
| 393 | {
|
| 394 | World world = source.getWorld();
|
| 395 | EnumFacing enumfacing = BlockDispenser.getFacing(source.getBlockMetadata());
|
| 396 | BlockPos blockpos = source.getBlockPos().offset(enumfacing);
|
| 397 | BlockSkull blockskull = Blocks.skull;
|
| 398 |
|
| 399 | if (world.isAirBlock(blockpos) && blockskull.canDispenserPlace(world, blockpos, stack))
|
| 400 | {
|
| 401 | if (!world.isRemote)
|
| 402 | {
|
| 403 | world.setBlockState(blockpos, blockskull.getDefaultState().withProperty(BlockSkull.FACING, EnumFacing.UP), 3);
|
| 404 | TileEntity tileentity = world.getTileEntity(blockpos);
|
| 405 |
|
| 406 | if (tileentity instanceof TileEntitySkull)
|
| 407 | {
|
| 408 | if (stack.getMetadata() == 3)
|
| 409 | {
|
| 410 | GameProfile gameprofile = null;
|
| 411 |
|
| 412 | if (stack.hasTagCompound())
|
| 413 | {
|
| 414 | NBTTagCompound nbttagcompound = stack.getTagCompound();
|
| 415 |
|
| 416 | if (nbttagcompound.hasKey("SkullOwner", 10))
|
| 417 | {
|
| 418 | gameprofile = NBTUtil.readGameProfileFromNBT(nbttagcompound.getCompoundTag("SkullOwner"));
|
| 419 | }
|
| 420 | else if (nbttagcompound.hasKey("SkullOwner", 8))
|
| 421 | {
|
| 422 | String s = nbttagcompound.getString("SkullOwner");
|
| 423 |
|
| 424 | if (!StringUtils.isNullOrEmpty(s))
|
| 425 | {
|
| 426 | gameprofile = new GameProfile((UUID)null, s);
|
| 427 | }
|
| 428 | }
|
| 429 | }
|
| 430 |
|
| 431 | ((TileEntitySkull)tileentity).setPlayerProfile(gameprofile);
|
| 432 | }
|
| 433 | else
|
| 434 | {
|
| 435 | ((TileEntitySkull)tileentity).setType(stack.getMetadata());
|
| 436 | }
|
| 437 |
|
| 438 | ((TileEntitySkull)tileentity).setSkullRotation(enumfacing.getOpposite().getHorizontalIndex() * 4);
|
| 439 | Blocks.skull.checkWitherSpawn(world, blockpos, (TileEntitySkull)tileentity);
|
| 440 | }
|
| 441 |
|
| 442 | --stack.stackSize;
|
| 443 | }
|
| 444 | }
|
| 445 | else
|
| 446 | {
|
| 447 | this.field_179240_b = false;
|
| 448 | }
|
| 449 |
|
| 450 | return stack;
|
| 451 | }
|
| 452 | protected void playDispenseSound(IBlockSource source)
|
| 453 | {
|
| 454 | if (this.field_179240_b)
|
| 455 | {
|
| 456 | source.getWorld().playAuxSFX(1000, source.getBlockPos(), 0);
|
| 457 | }
|
| 458 | else
|
| 459 | {
|
| 460 | source.getWorld().playAuxSFX(1001, source.getBlockPos(), 0);
|
| 461 | }
|
| 462 | }
|
| 463 | });
|
| 464 | BlockDispenser.dispenseBehaviorRegistry.putObject(Item.getItemFromBlock(Blocks.pumpkin), new BehaviorDefaultDispenseItem()
|
| 465 | {
|
| 466 | private boolean field_179241_b = true;
|
| 467 | protected ItemStack dispenseStack(IBlockSource source, ItemStack stack)
|
| 468 | {
|
| 469 | World world = source.getWorld();
|
| 470 | BlockPos blockpos = source.getBlockPos().offset(BlockDispenser.getFacing(source.getBlockMetadata()));
|
| 471 | BlockPumpkin blockpumpkin = (BlockPumpkin)Blocks.pumpkin;
|
| 472 |
|
| 473 | if (world.isAirBlock(blockpos) && blockpumpkin.canDispenserPlace(world, blockpos))
|
| 474 | {
|
| 475 | if (!world.isRemote)
|
| 476 | {
|
| 477 | world.setBlockState(blockpos, blockpumpkin.getDefaultState(), 3);
|
| 478 | }
|
| 479 |
|
| 480 | --stack.stackSize;
|
| 481 | }
|
| 482 | else
|
| 483 | {
|
| 484 | this.field_179241_b = false;
|
| 485 | }
|
| 486 |
|
| 487 | return stack;
|
| 488 | }
|
| 489 | protected void playDispenseSound(IBlockSource source)
|
| 490 | {
|
| 491 | if (this.field_179241_b)
|
| 492 | {
|
| 493 | source.getWorld().playAuxSFX(1000, source.getBlockPos(), 0);
|
| 494 | }
|
| 495 | else
|
| 496 | {
|
| 497 | source.getWorld().playAuxSFX(1001, source.getBlockPos(), 0);
|
| 498 | }
|
| 499 | }
|
| 500 | });
|
| 501 | }
|
| 502 |
|
| 503 | /**
|
| 504 | * Registers blocks, items, stats, etc.
|
| 505 | */
|
| 506 | public static void register()
|
| 507 | {
|
| 508 | if (!alreadyRegistered)
|
| 509 | {
|
| 510 | alreadyRegistered = true;
|
| 511 |
|
| 512 | if (LOGGER.isDebugEnabled())
|
| 513 | {
|
| 514 | redirectOutputToLog();
|
| 515 | }
|
| 516 |
|
| 517 | Block.registerBlocks();
|
| 518 | BlockFire.init();
|
| 519 | Item.registerItems();
|
| 520 | StatList.init();
|
| 521 | registerDispenserBehaviors();
|
| 522 | }
|
| 523 | }
|
| 524 |
|
| 525 | /**
|
| 526 | * redirect standard streams to logger
|
| 527 | */
|
| 528 | private static void redirectOutputToLog()
|
| 529 | {
|
| 530 | System.setErr(new LoggingPrintStream("STDERR", System.err));
|
| 531 | System.setOut(new LoggingPrintStream("STDOUT", SYSOUT));
|
| 532 | }
|
| 533 |
|
| 534 | public static void printToSYSOUT(String p_179870_0_)
|
| 535 | {
|
| 536 | SYSOUT.println(p_179870_0_);
|
| 537 | }
|
| 538 | }
|
| 539 |
|