Advertisement
Guest User

Untitled

a guest
Apr 29th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.54 KB | None | 0 0
  1. package r3qu13m.bf;
  2.  
  3. import java.util.List;
  4.  
  5. import buildcraft.BuildCraftBuilders;
  6. import buildcraft.BuildCraftCore;
  7. import buildcraft.BuildCraftTransport;
  8. import buildcraft.api.core.IBox;
  9. import buildcraft.api.filler.FillerManager;
  10. import buildcraft.api.filler.IFillerPattern;
  11. import buildcraft.builders.FillerRemover;
  12. import buildcraft.core.utils.BlockUtil;
  13. import buildcraft.core.utils.Utils;
  14. import cpw.mods.fml.common.Mod;
  15. import cpw.mods.fml.common.event.FMLInitializationEvent;
  16. import net.minecraft.block.Block;
  17. import net.minecraft.entity.item.EntityItem;
  18. import net.minecraft.item.ItemStack;
  19. import net.minecraft.tileentity.TileEntity;
  20. import net.minecraftforge.common.ForgeDirection;
  21.  
  22. @Mod(modid = "bumpfiller", name = "BumpFiller", version = "0.0.1", dependencies = "after:BuildCraft|Builders")
  23. public class BumpFiller {
  24. @Mod.Instance("bumpfiller")
  25. public static BumpFiller instance;
  26.  
  27. public BumpFiller() {
  28. instance = this;
  29. }
  30.  
  31. @Mod.Init
  32. public void init(FMLInitializationEvent event) {
  33. FillerManager.registry.addRecipe(new FillerRemover() {
  34. @Override
  35. public boolean iteratePattern(TileEntity tile, IBox box, ItemStack stackToPlace) {
  36. int xMin = (int) box.pMin().x;
  37. int yMin = (int) box.pMin().y;
  38. int zMin = (int) box.pMin().z;
  39.  
  40. int xMax = (int) box.pMax().x;
  41. int yMax = (int) box.pMax().y;
  42. int zMax = (int) box.pMax().z;
  43.  
  44. boolean found = false;
  45. int lastX = Integer.MAX_VALUE, lastY = Integer.MAX_VALUE, lastZ = Integer.MAX_VALUE;
  46.  
  47. for (int y = yMax; y >= yMin; y--) {
  48. found = false;
  49. for (int x = xMin; x <= xMax; ++x) {
  50. for (int z = zMin; z <= zMax; ++z) {
  51. if (!BlockUtil.canChangeBlock(tile.worldObj, x, y, z))
  52. return false;
  53. if (!BlockUtil.isSoftBlock(tile.worldObj, x, y, z)) {
  54. found = true;
  55. lastX = x;
  56. lastY = y;
  57. lastZ = z;
  58. }
  59. }
  60. }
  61.  
  62. if (found) {
  63. break;
  64. }
  65. }
  66.  
  67. if (lastX != Integer.MAX_VALUE) {
  68. List<ItemStack> stacks = BlockUtil.getItemStackFromBlock(tile.worldObj, lastX, lastY, lastZ);
  69. for (ItemStack stack : stacks) {
  70. tile.worldObj.setBlockWithNotify(lastX, lastY, lastZ, 0);
  71. // First, try to add to a nearby chest
  72. ItemStack added = Utils.addToRandomInventory(stack, tile.worldObj, tile.xCoord, tile.yCoord,
  73. tile.zCoord, ForgeDirection.UNKNOWN);
  74. stack.stackSize -= added.stackSize;
  75.  
  76. // Second, try to add to adjacent pipes
  77. if (stack.stackSize > 0) {
  78. Utils.addToRandomPipeEntry(tile, ForgeDirection.UNKNOWN, stack);
  79. }
  80.  
  81. // Lastly, throw the object away
  82. if (stack.stackSize > 0) {
  83. float f = tile.worldObj.rand.nextFloat() * 0.8F + 0.1F;
  84. float f1 = tile.worldObj.rand.nextFloat() * 0.8F + 0.1F;
  85. float f2 = tile.worldObj.rand.nextFloat() * 0.8F + 0.1F;
  86.  
  87. EntityItem entityitem = new EntityItem(tile.worldObj, tile.xCoord + f,
  88. tile.yCoord + f1 + 0.5F, tile.zCoord + f2, stack);
  89.  
  90. entityitem.lifespan = BuildCraftCore.itemLifespan;
  91. entityitem.delayBeforeCanPickup = 10;
  92.  
  93. float f3 = 0.05F;
  94. entityitem.motionX = (float) tile.worldObj.rand.nextGaussian() * f3;
  95. entityitem.motionY = (float) tile.worldObj.rand.nextGaussian() * f3 + 1.0F;
  96. entityitem.motionZ = (float) tile.worldObj.rand.nextGaussian() * f3;
  97. tile.worldObj.spawnEntityInWorld(entityitem);
  98. }
  99.  
  100. }
  101. return false;
  102. }
  103.  
  104. return true;
  105. }
  106.  
  107. @Override
  108. public String getName() {
  109. return "ClearPipe";
  110. }
  111. }, new Object[] { "ggg", "gpg", "ggg", 'g', Block.glass, 'p', BuildCraftTransport.pipeItemsGold });
  112. }
  113. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement