@Override
  public ItemStack onEaten(ItemStack stack, World world, EntityPlayer player) {
    if (!world.isRemote) {
      MovingObjectPosition mop = getMovingObjectPositionFromPlayer(world, player, true);
      if (mop != null && mop.typeOfHit == EnumMovingObjectType.TILE) {
        int blockId = world.getBlockId(mop.blockX, mop.blockY, mop.blockZ);
        if (MFRRegistry.getFluidDrinkHandlers().containsKey(blockId)) {
          MFRRegistry.getFluidDrinkHandlers().get(blockId).onDrink(player);
          world.setBlockToAir(mop.blockX, mop.blockY, mop.blockZ);
        }
      }
    }

    return stack;
  }
  private BlockPosition getNextTreeSegment(BlockPosition pos) {
    Block block;

    if (_treeManager.getIsDone() || !_treeManager.getOrigin().equals(pos)) {
      int lowerBound = 0;
      int upperBound = MFRConfig.fruitTreeSearchMaxVertical.getInt();

      Area a =
          new Area(
              pos.copy(), MFRConfig.fruitTreeSearchMaxHorizontal.getInt(), lowerBound, upperBound);

      _treeManager.reset(worldObj, a, HarvestMode.FruitTree, null);
    }

    Map<Block, IFactoryFruit> fruits = MFRRegistry.getFruits();
    while (!_treeManager.getIsDone()) {
      BlockPosition bp = _treeManager.getNextBlock();
      block = worldObj.getBlock(bp.x, bp.y, bp.z);
      IFactoryFruit fruit = fruits.containsKey(block) ? fruits.get(block) : null;

      if (fruit != null && fruit.canBePicked(worldObj, bp.x, bp.y, bp.z)) return bp;

      _treeManager.moveNext();
    }
    return null;
  }
Exemplo n.º 3
0
 @Override
 public void apply() {
   Map<Block, IFactoryFruit> fruits = MFRRegistry.getFruits();
   for (Block key : removed.keySet()) {
     fruits.remove(key);
   }
 }
Exemplo n.º 4
0
 @Override
 public void undo() {
   Map<Block, IFactoryFruit> fruits = MFRRegistry.getFruits();
   for (Map.Entry<Block, IFactoryFruit> restore : removed.entrySet()) {
     fruits.put(restore.getKey(), restore.getValue());
   }
 }
  private BlockPosition getNextTree() {
    BlockPosition bp = _areaManager.getNextBlock();
    if (!worldObj.blockExists(bp.x, bp.y, bp.z)) {
      return null;
    }

    Block search = worldObj.getBlock(bp.x, bp.y, bp.z);

    if (!MFRRegistry.getFruitLogBlocks().contains(search)) {
      IFactoryFruit f = MFRRegistry.getFruits().get(search);
      return f != null && f.canBePicked(worldObj, bp.x, bp.y, bp.z) ? bp : null;
    }

    BlockPosition temp = getNextTreeSegment(bp);
    if (temp != null) _areaManager.rewindBlock();

    return temp;
  }
Exemplo n.º 6
0
    public RemoveLogAction(IBlockPattern block) {
      this.block = block;

      for (IBlock partial : block.getBlocks()) {
        Block mcBlock = MineTweakerMC.getBlock(partial);
        if (MFRRegistry.getFruitLogBlocks().contains(mcBlock)) {
          if (!removedLogs.contains(mcBlock)) removedLogs.add(mcBlock);
        }
      }
    }
Exemplo n.º 7
0
 @Override
 public void undo() {
   Map<Block, IFactoryFruit> fruits = MFRRegistry.getFruits();
   for (IBlock partial : fruit.block.getBlocks()) {
     Block block = MineTweakerMC.getBlock(partial);
     IFactoryFruit factoryFruit = fruits.get(block);
     if (factoryFruit != null && factoryFruit instanceof TweakerFruitPartial) {
       ((TweakerFruitPartial) factoryFruit).fruits.remove(fruit);
     }
   }
 }
 @Override
 public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
   MovingObjectPosition mop = getMovingObjectPositionFromPlayer(world, player, true);
   if (mop != null && mop.typeOfHit == EnumMovingObjectType.TILE) {
     if (MFRRegistry.getFluidDrinkHandlers()
         .containsKey(world.getBlockId(mop.blockX, mop.blockY, mop.blockZ))) {
       player.setItemInUse(stack, this.getMaxItemUseDuration(stack));
     }
   }
   return stack;
 }
Exemplo n.º 9
0
 private void registerOreDictLaserOre(
     int weight, String name, int focus, String netherName, int netherFocus, String dustName) {
   for (ItemStack ore : OreDictionary.getOres(name))
     if (ore != null) {
       ore = ore.copy();
       ore.stackSize = 1;
       MFRRegistry.registerLaserOre(weight, ore);
       if (focus >= 0) MFRRegistry.addLaserPreferredOre(focus, ore);
       if (netherName != null) {
         registerOreDictLaserOre(weight / 2, netherName, netherFocus, null, null);
       }
       return;
     }
   if (netherName != null & dustName != null)
     for (ItemStack ore : OreDictionary.getOres(dustName))
       if (ore != null) {
         registerOreDictLaserOre(weight / 2, netherName, netherFocus, null, null);
         return;
       }
 }
Exemplo n.º 10
0
    public RemoveFruitAction(IBlockPattern block) {
      this.block = block;

      Map<Block, IFactoryFruit> fruits = MFRRegistry.getFruits();
      removed = new HashMap<Block, IFactoryFruit>();
      for (IBlock partial : block.getBlocks()) {
        Block mcBlock = MineTweakerMC.getBlock(partial);
        if (fruits.containsKey(mcBlock)) {
          removed.put(mcBlock, fruits.get(mcBlock));
        }
      }
    }
Exemplo n.º 11
0
 @Override
 public void apply() {
   Map<Block, IFactoryFruit> fruits = MFRRegistry.getFruits();
   for (IBlock partial : fruit.block.getBlocks()) {
     Block block = ((MCBlockDefinition) partial.getDefinition()).getInternalBlock();
     if (fruits != null && fruits.containsKey(block)) {
       IFactoryFruit existingFruit = fruits.get(block);
       if (existingFruit instanceof TweakerFruitPartial) {
         TweakerFruitPartial existingFruitPartial = (TweakerFruitPartial) existingFruit;
         if (!existingFruitPartial.fruits.contains(fruit)) {
           existingFruitPartial.fruits.add(fruit);
         }
       } else {
         MineTweakerAPI.logError("A non-MineTweaker fruit already exists for this ID");
       }
     } else {
       TweakerFruitPartial factoryFruit = new TweakerFruitPartial(block);
       MFRRegistry.registerFruit(factoryFruit);
     }
   }
 }
  @Override
  public void updateEntity() {
    super.updateEntity();

    if (!worldObj.isRemote) {
      for (int i = 0; i < 9; i++) {
        if (_inventory[i] != null
            && MFRRegistry.getPlantables().containsKey(_inventory[i].itemID)) {
          int targetSlot = findMatchingSlot(_inventory[i]);
          if (targetSlot < 0) {
            continue;
          }

          if (_inventory[targetSlot] == null) {
            _inventory[targetSlot] = _inventory[i];
            _inventory[i] = null;
          } else {
            UtilInventory.mergeStacks(_inventory[targetSlot], _inventory[i]);
            if (_inventory[i].stackSize <= 0) {
              _inventory[i] = null;
            }
          }
        }
      }

      if (Util.isRedstonePowered(this)) {
        return;
      }

      int newBurn = getOutputValue();
      if (_burnTimeMax - _burnTime >= newBurn) {
        _burnTime += newBurn;
        for (int i = 9; i < 18; i++) {
          if (_inventory[i] != null) {
            decrStackSize(i, 1);
          }
        }
      }

      if (_burnTime > 0
          && (_tank.getLiquid() == null
              || _tank.getLiquid().amount <= _tank.getCapacity() - _bioFuelPerTick)) {
        _burnTime -= _burnTimeDecreasePerTick;
        _tank.fill(LiquidDictionary.getLiquid("biofuel", _bioFuelPerTick), true);
      }
    }
  }
  @Override
  protected boolean activateMachine() {
    BlockPosition targetCoords = getNextTree();

    if (targetCoords == null) {
      setIdleTicks(getIdleTicksMax());
      return false;
    }

    Block harvestedBlock = worldObj.getBlock(targetCoords.x, targetCoords.y, targetCoords.z);
    int harvestedBlockMetadata =
        worldObj.getBlockMetadata(targetCoords.x, targetCoords.y, targetCoords.z);

    IFactoryFruit harvestable = MFRRegistry.getFruits().get(harvestedBlock);

    List<ItemStack> drops =
        harvestable.getDrops(worldObj, _rand, targetCoords.x, targetCoords.y, targetCoords.z);

    ReplacementBlock replacement =
        harvestable.getReplacementBlock(worldObj, targetCoords.x, targetCoords.y, targetCoords.z);

    harvestable.prePick(worldObj, targetCoords.x, targetCoords.y, targetCoords.z);

    if (replacement == null) {
      if (!worldObj.setBlockToAir(targetCoords.x, targetCoords.y, targetCoords.z)) return false;
      if (MFRConfig.playSounds.getBoolean(true)) {
        worldObj.playAuxSFXAtEntity(
            null,
            2001,
            targetCoords.x,
            targetCoords.y,
            targetCoords.z,
            Block.getIdFromBlock(harvestedBlock) + (harvestedBlockMetadata << 12));
      }
    } else {
      if (!replacement.replaceBlock(worldObj, targetCoords.x, targetCoords.y, targetCoords.z, null))
        return false;
    }

    doDrop(drops);

    // TODO: sludge?

    harvestable.postPick(worldObj, targetCoords.x, targetCoords.y, targetCoords.z);

    return true;
  }
 @Override
 public Item setUnlocalizedName(String name) {
   super.setUnlocalizedName(name);
   if (_register) MFRRegistry.registerItem(this, getUnlocalizedName());
   return this;
 }
Exemplo n.º 15
0
  @EventHandler
  public void load(FMLInitializationEvent event) {
    MFRRegistry.registerPlantable(
        new PlantableStandard(Block.sapling.blockID, Block.sapling.blockID));
    MFRRegistry.registerPlantable(
        new PlantableStandard(Item.pumpkinSeeds.itemID, Block.pumpkinStem.blockID));
    MFRRegistry.registerPlantable(
        new PlantableStandard(Item.melonSeeds.itemID, Block.melonStem.blockID));
    MFRRegistry.registerPlantable(
        new PlantableStandard(Block.mushroomBrown.blockID, Block.mushroomBrown.blockID));
    MFRRegistry.registerPlantable(
        new PlantableStandard(Block.mushroomRed.blockID, Block.mushroomRed.blockID));
    MFRRegistry.registerPlantable(new PlantableCropPlant(Item.seeds.itemID, Block.crops.blockID));
    MFRRegistry.registerPlantable(new PlantableCropPlant(Item.carrot.itemID, Block.carrot.blockID));
    MFRRegistry.registerPlantable(new PlantableCropPlant(Item.potato.itemID, Block.potato.blockID));
    MFRRegistry.registerPlantable(new PlantableNetherWart());
    MFRRegistry.registerPlantable(
        new PlantableCocoa(Item.dyePowder.itemID, Block.cocoaPlant.blockID, 3));
    MFRRegistry.registerPlantable(
        new PlantableStandard(
            MineFactoryReloadedCore.rubberSaplingBlock.blockID,
            MineFactoryReloadedCore.rubberSaplingBlock.blockID));

    MFRRegistry.registerHarvestable(new HarvestableWood(Block.wood.blockID));
    MFRRegistry.registerHarvestable(new HarvestableTreeLeaves(Block.leaves.blockID));
    MFRRegistry.registerHarvestable(
        new HarvestableStandard(Block.reed.blockID, HarvestType.LeaveBottom));
    MFRRegistry.registerHarvestable(
        new HarvestableStandard(Block.cactus.blockID, HarvestType.LeaveBottom));
    MFRRegistry.registerHarvestable(
        new HarvestableStandard(Block.plantRed.blockID, HarvestType.Normal));
    MFRRegistry.registerHarvestable(
        new HarvestableStandard(Block.plantYellow.blockID, HarvestType.Normal));
    MFRRegistry.registerHarvestable(new HarvestableShrub(Block.tallGrass.blockID));
    MFRRegistry.registerHarvestable(new HarvestableShrub(Block.deadBush.blockID));
    MFRRegistry.registerHarvestable(
        new HarvestableStandard(Block.mushroomCapBrown.blockID, HarvestType.Tree));
    MFRRegistry.registerHarvestable(
        new HarvestableStandard(Block.mushroomCapRed.blockID, HarvestType.Tree));
    MFRRegistry.registerHarvestable(new HarvestableMushroom(Block.mushroomBrown.blockID));
    MFRRegistry.registerHarvestable(new HarvestableMushroom(Block.mushroomRed.blockID));
    MFRRegistry.registerHarvestable(
        new HarvestableStemPlant(Block.pumpkin.blockID, HarvestType.Normal));
    MFRRegistry.registerHarvestable(
        new HarvestableStemPlant(Block.melon.blockID, HarvestType.Normal));
    MFRRegistry.registerHarvestable(new HarvestableCropPlant(Block.crops.blockID, 7));
    MFRRegistry.registerHarvestable(new HarvestableCropPlant(Block.carrot.blockID, 7));
    MFRRegistry.registerHarvestable(new HarvestableCropPlant(Block.potato.blockID, 7));
    MFRRegistry.registerHarvestable(new HarvestableVine());
    MFRRegistry.registerHarvestable(new HarvestableNetherWart());
    MFRRegistry.registerHarvestable(new HarvestableCocoa());
    MFRRegistry.registerHarvestable(
        new HarvestableWood(MineFactoryReloadedCore.rubberWoodBlock.blockID));
    MFRRegistry.registerHarvestable(
        new HarvestableTreeLeaves(MineFactoryReloadedCore.rubberLeavesBlock.blockID));

    MFRRegistry.registerFertilizable(new FertilizableSapling(Block.sapling.blockID));
    MFRRegistry.registerFertilizable(new FertilizableCropPlant(Block.crops.blockID, 7));
    MFRRegistry.registerFertilizable(new FertilizableCropPlant(Block.carrot.blockID, 7));
    MFRRegistry.registerFertilizable(new FertilizableCropPlant(Block.potato.blockID, 7));
    MFRRegistry.registerFertilizable(new FertilizableGiantMushroom(Block.mushroomBrown.blockID));
    MFRRegistry.registerFertilizable(new FertilizableGiantMushroom(Block.mushroomRed.blockID));
    MFRRegistry.registerFertilizable(new FertilizableStemPlants(Block.pumpkinStem.blockID));
    MFRRegistry.registerFertilizable(new FertilizableStemPlants(Block.melonStem.blockID));
    MFRRegistry.registerFertilizable(new FertilizableNetherWart());
    MFRRegistry.registerFertilizable(new FertilizableCocoa(Block.cocoaPlant.blockID));
    MFRRegistry.registerFertilizable(new FertilizableGrass());
    MFRRegistry.registerFertilizable(
        new FertilizableSapling(MineFactoryReloadedCore.rubberSaplingBlock.blockID));

    MFRRegistry.registerFertilizer(
        new FertilizerStandard(MineFactoryReloadedCore.fertilizerItem.itemID, 0));
    if (MFRConfig.enableBonemealFertilizing.getBoolean(false)) {
      MFRRegistry.registerFertilizer(new FertilizerStandard(Item.dyePowder.itemID, 15));
    } else {
      MFRRegistry.registerFertilizer(
          new FertilizerStandard(Item.dyePowder.itemID, 15, FertilizerType.Grass));
    }

    MFRRegistry.registerRanchable(new RanchableCow());
    MFRRegistry.registerRanchable(new RanchableMooshroom());
    MFRRegistry.registerRanchable(new RanchableSheep());
    MFRRegistry.registerRanchable(new RanchableSquid());
    MFRRegistry.registerRanchable(new RanchableChicken());

    if (MFRConfig.conveyorNeverCapturesPlayers.getBoolean(false)) {
      MFRRegistry.registerConveyerBlacklist(EntityPlayer.class);
    }

    if (!MFRConfig.conveyorCaptureNonItems.getBoolean(true)) {
      MFRRegistry.registerConveyerBlacklist(Entity.class);
    }

    MFRRegistry.registerGrinderBlacklist(EntityPlayer.class);
    MFRRegistry.registerGrinderBlacklist(EntityDragon.class);
    MFRRegistry.registerGrinderBlacklist(EntityWither.class);
    MFRRegistry.registerGrinderBlacklist(EntityVillager.class);

    MFRRegistry.registerGrindable(
        new GrindableStandard(
            EntityChicken.class,
            new MobDrop[] {new MobDrop(30, null), new MobDrop(10, new ItemStack(Item.egg))},
            false));
    MFRRegistry.registerGrindable(
        new GrindableStandard(
            EntityOcelot.class,
            new MobDrop[] {
              new MobDrop(10, new ItemStack(Item.fishRaw)),
              new MobDrop(10, new ItemStack(Item.silk))
            }));
    MFRRegistry.registerGrindable(
        new GrindableStandard(EntityWolf.class, new ItemStack(Item.bone)));
    MFRRegistry.registerGrindable(new GrindableZombiePigman());
    MFRRegistry.registerGrindable(new GrindableEnderman());
    MFRRegistry.registerGrindable(
        new GrindableSlime(EntitySlime.class, new ItemStack(Item.slimeBall), 1));
    MFRRegistry.registerGrindable(
        new GrindableSlime(
            EntityPinkSlime.class, new ItemStack(MineFactoryReloadedCore.pinkSlimeballItem), 1));
    MFRRegistry.registerGrindable(
        new GrindableSlime(EntityMagmaCube.class, new ItemStack(Item.magmaCream), 1) {
          @Override
          protected boolean shouldDrop(EntitySlime slime) {
            return slime.getSlimeSize() <= dropSize;
          }
        });

    MFRRegistry.registerSludgeDrop(50, new ItemStack(Block.sand));
    MFRRegistry.registerSludgeDrop(40, new ItemStack(Block.dirt));
    MFRRegistry.registerSludgeDrop(30, new ItemStack(Item.clay, 4));
    MFRRegistry.registerSludgeDrop(10, new ItemStack(Block.gravel));
    MFRRegistry.registerSludgeDrop(5, new ItemStack(Block.slowSand));
    MFRRegistry.registerSludgeDrop(3, new ItemStack(Block.mycelium));
    MFRRegistry.registerSludgeDrop(1, new ItemStack(Block.netherrack));

    MFRRegistry.registerSafariNetHandler(new EntityLivingBaseHandler());
    MFRRegistry.registerSafariNetHandler(new EntityLivingHandler());
    MFRRegistry.registerSafariNetHandler(new EntityAgeableHandler());
    MFRRegistry.registerSafariNetHandler(new SheepHandler());
    MFRRegistry.registerSafariNetHandler(new SlimeHandler());

    MFRRegistry.registerMobEggHandler(new VanillaEggHandler());

    MFRRegistry.registerRubberTreeBiome("Swampland");
    MFRRegistry.registerRubberTreeBiome("Forest");
    MFRRegistry.registerRubberTreeBiome("Taiga");
    MFRRegistry.registerRubberTreeBiome("TaigaHills");
    MFRRegistry.registerRubberTreeBiome("Jungle");
    MFRRegistry.registerRubberTreeBiome("JungleHills");

    MFRRegistry.registerSafariNetBlacklist(EntityPlayer.class);
    MFRRegistry.registerSafariNetBlacklist(EntityDragon.class);
    MFRRegistry.registerSafariNetBlacklist(EntityWither.class);

    MFRRegistry.registerRandomMobProvider(new VanillaMobProvider());

    MFRRegistry.registerLiquidDrinkHandler("water", new DrinkHandlerWater());
    MFRRegistry.registerLiquidDrinkHandler("lava", new DrinkHandlerLava());
    MFRRegistry.registerLiquidDrinkHandler("milk", new DrinkHandlerMilk());
    MFRRegistry.registerLiquidDrinkHandler("biofuel", new DrinkHandlerBiofuel());
    MFRRegistry.registerLiquidDrinkHandler("bioethanol", new DrinkHandlerBiofuel());
    MFRRegistry.registerLiquidDrinkHandler("sewage", new DrinkHandlerSewage());
    MFRRegistry.registerLiquidDrinkHandler("sludge", new DrinkHandlerSludge());
    MFRRegistry.registerLiquidDrinkHandler("mobessence", new DrinkHandlerMobEssence());
    MFRRegistry.registerLiquidDrinkHandler("meat", new DrinkHandlerMeat());
    MFRRegistry.registerLiquidDrinkHandler("pinkslime", new DrinkHandlerPinkSlime());
    MFRRegistry.registerLiquidDrinkHandler("chocolatemilk", new DrinkHandlerChocolateMilk());
    MFRRegistry.registerLiquidDrinkHandler("mushroomsoup", new DrinkHandlerMushroomSoup());

    MFRRegistry.registerRedNetLogicCircuit(new AdderAnalog());
    MFRRegistry.registerRedNetLogicCircuit(new AdderDigitalFull());
    MFRRegistry.registerRedNetLogicCircuit(new AdderDigitalHalf());
    MFRRegistry.registerRedNetLogicCircuit(new And2());
    MFRRegistry.registerRedNetLogicCircuit(new And3());
    MFRRegistry.registerRedNetLogicCircuit(new And4());
    MFRRegistry.registerRedNetLogicCircuit(new Counter());
    MFRRegistry.registerRedNetLogicCircuit(new DecomposeIntToDecimal());
    MFRRegistry.registerRedNetLogicCircuit(new Delay());
    MFRRegistry.registerRedNetLogicCircuit(new DeMux16Analog());
    MFRRegistry.registerRedNetLogicCircuit(new DeMux4());
    MFRRegistry.registerRedNetLogicCircuit(new Equal());
    MFRRegistry.registerRedNetLogicCircuit(new Fanout());
    MFRRegistry.registerRedNetLogicCircuit(new FlipFlopJK());
    MFRRegistry.registerRedNetLogicCircuit(new FlipFlopT());
    MFRRegistry.registerRedNetLogicCircuit(new Greater());
    MFRRegistry.registerRedNetLogicCircuit(new GreaterOrEqual());
    MFRRegistry.registerRedNetLogicCircuit(new Inverter());
    MFRRegistry.registerRedNetLogicCircuit(new LatchDGated());
    MFRRegistry.registerRedNetLogicCircuit(new LatchSR());
    MFRRegistry.registerRedNetLogicCircuit(new LatchSRGated());
    MFRRegistry.registerRedNetLogicCircuit(new Less());
    MFRRegistry.registerRedNetLogicCircuit(new LessOrEqual());
    MFRRegistry.registerRedNetLogicCircuit(new Max2());
    MFRRegistry.registerRedNetLogicCircuit(new Max3());
    MFRRegistry.registerRedNetLogicCircuit(new Max4());
    MFRRegistry.registerRedNetLogicCircuit(new Min2());
    MFRRegistry.registerRedNetLogicCircuit(new Min3());
    MFRRegistry.registerRedNetLogicCircuit(new Min4());
    MFRRegistry.registerRedNetLogicCircuit(new Multipulse());
    MFRRegistry.registerRedNetLogicCircuit(new Mux4());
    MFRRegistry.registerRedNetLogicCircuit(new Nand2());
    MFRRegistry.registerRedNetLogicCircuit(new Nand3());
    MFRRegistry.registerRedNetLogicCircuit(new Nand4());
    MFRRegistry.registerRedNetLogicCircuit(new Negator());
    MFRRegistry.registerRedNetLogicCircuit(new Noop());
    MFRRegistry.registerRedNetLogicCircuit(new Nor2());
    MFRRegistry.registerRedNetLogicCircuit(new Nor3());
    MFRRegistry.registerRedNetLogicCircuit(new Nor4());
    MFRRegistry.registerRedNetLogicCircuit(new NotEqual());
    MFRRegistry.registerRedNetLogicCircuit(new OneShot());
    MFRRegistry.registerRedNetLogicCircuit(new Or2());
    MFRRegistry.registerRedNetLogicCircuit(new Or3());
    MFRRegistry.registerRedNetLogicCircuit(new Or4());
    MFRRegistry.registerRedNetLogicCircuit(new Passthrough());
    MFRRegistry.registerRedNetLogicCircuit(new PassthroughGated());
    MFRRegistry.registerRedNetLogicCircuit(new PassthroughRoundRobin());
    MFRRegistry.registerRedNetLogicCircuit(new PulseLengthener());
    MFRRegistry.registerRedNetLogicCircuit(new RandomizerAnalog());
    MFRRegistry.registerRedNetLogicCircuit(new RandomizerDigital());
    MFRRegistry.registerRedNetLogicCircuit(new SevenSegmentEncoder());
    MFRRegistry.registerRedNetLogicCircuit(new SawtoothFalling());
    MFRRegistry.registerRedNetLogicCircuit(new SawtoothRising());
    MFRRegistry.registerRedNetLogicCircuit(new Scaler());
    MFRRegistry.registerRedNetLogicCircuit(new SchmittTrigger());
    MFRRegistry.registerRedNetLogicCircuit(new Sine());
    MFRRegistry.registerRedNetLogicCircuit(new Square());
    MFRRegistry.registerRedNetLogicCircuit(new Subtractor());
    MFRRegistry.registerRedNetLogicCircuit(new Triangle());
    MFRRegistry.registerRedNetLogicCircuit(new Xnor2());
    MFRRegistry.registerRedNetLogicCircuit(new Xnor3());
    MFRRegistry.registerRedNetLogicCircuit(new Xnor4());
    MFRRegistry.registerRedNetLogicCircuit(new Xor2());
    MFRRegistry.registerRedNetLogicCircuit(new Xor3());
    MFRRegistry.registerRedNetLogicCircuit(new Xor4());

    MFRRegistry.registerFruitLogBlockId(Block.wood.blockID);
    MFRRegistry.registerFruit(new FruitCocoa(Block.cocoaPlant.blockID));

    MFRRegistry.registerAutoSpawnerBlacklist("VillagerGolem");

    MFRRegistry.registerSpawnHandler(new SpawnableHorse());
    MFRRegistry.registerSpawnHandler(new SpawnableEnderman());

    MFRRegistry.registerNeedleAmmoType(
        MineFactoryReloadedCore.needlegunAmmoStandardItem.itemID,
        (INeedleAmmo) MineFactoryReloadedCore.needlegunAmmoStandardItem);
    MFRRegistry.registerNeedleAmmoType(
        MineFactoryReloadedCore.needlegunAmmoLavaItem.itemID,
        (INeedleAmmo) MineFactoryReloadedCore.needlegunAmmoLavaItem);
    MFRRegistry.registerNeedleAmmoType(
        MineFactoryReloadedCore.needlegunAmmoSludgeItem.itemID,
        (INeedleAmmo) MineFactoryReloadedCore.needlegunAmmoSludgeItem);
    MFRRegistry.registerNeedleAmmoType(
        MineFactoryReloadedCore.needlegunAmmoSewageItem.itemID,
        (INeedleAmmo) MineFactoryReloadedCore.needlegunAmmoSewageItem);
    MFRRegistry.registerNeedleAmmoType(
        MineFactoryReloadedCore.needlegunAmmoFireItem.itemID,
        (INeedleAmmo) MineFactoryReloadedCore.needlegunAmmoFireItem);
    MFRRegistry.registerNeedleAmmoType(
        MineFactoryReloadedCore.needlegunAmmoAnvilItem.itemID,
        (INeedleAmmo) MineFactoryReloadedCore.needlegunAmmoAnvilItem);
  }
  @Override
  public void onUpdate() {
    super.onUpdate();

    if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) {
      float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
      this.prevRotationYaw =
          this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
      this.prevRotationPitch =
          this.rotationPitch = (float) (Math.atan2(this.motionY, f) * 180.0D / Math.PI);
    }

    ++this.ticksInAir;
    Vec3 pos = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ);
    Vec3 nextPos =
        this.worldObj
            .getWorldVec3Pool()
            .getVecFromPool(
                this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
    MovingObjectPosition hit = this.worldObj.rayTraceBlocks_do_do(pos, nextPos, false, true);
    pos = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ);
    nextPos =
        this.worldObj
            .getWorldVec3Pool()
            .getVecFromPool(
                this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);

    if (hit != null) {
      nextPos =
          this.worldObj
              .getWorldVec3Pool()
              .getVecFromPool(hit.hitVec.xCoord, hit.hitVec.yCoord, hit.hitVec.zCoord);
    }

    Entity entityHit = null;
    List<?> list =
        this.worldObj.getEntitiesWithinAABBExcludingEntity(
            this,
            this.boundingBox
                .addCoord(this.motionX, this.motionY, this.motionZ)
                .expand(1.0D, 1.0D, 1.0D));
    double closestRange = 0.0D;
    double collisionRange = 0.3D;
    EntityPlayer owner = _owner == null ? null : this.worldObj.getPlayerEntityByName(_owner);

    for (int l = 0; l < list.size(); ++l) {
      Entity e = (Entity) list.get(l);

      if ((e != owner | this.ticksInAir >= 2) && e.canBeCollidedWith()) {
        AxisAlignedBB entitybb =
            e.boundingBox.expand(collisionRange, collisionRange, collisionRange);
        MovingObjectPosition entityHitPos = entitybb.calculateIntercept(pos, nextPos);

        if (entityHitPos != null) {
          double range = pos.distanceTo(entityHitPos.hitVec);

          if (range < closestRange || closestRange == 0.0D) {
            entityHit = e;
            closestRange = range;
          }
        }
      }
    }

    if (entityHit != null) {
      hit = new MovingObjectPosition(entityHit);
    }

    if (hit != null && hit.entityHit != null && hit.entityHit instanceof EntityPlayer) {
      EntityPlayer entityplayer = (EntityPlayer) hit.entityHit;

      if (entityplayer.capabilities.disableDamage
          || (owner != null && !owner.canAttackPlayer(entityplayer))) {
        hit = null;
      }
    }

    float speed = 0.0F;
    speed =
        MathHelper.sqrt_double(
            this.motionX * this.motionX
                + this.motionY * this.motionY
                + this.motionZ * this.motionZ);
    distance += speed;
    if (hit != null && !worldObj.isRemote) {
      if (MFRRegistry.getNeedleAmmoTypes().containsKey(_ammoSource.itemID)) {
        if (hit.entityHit != null) {
          MFRRegistry.getNeedleAmmoTypes()
              .get(_ammoSource.itemID)
              .onHitEntity(owner, hit.entityHit, distance);
        } else {
          MFRRegistry.getNeedleAmmoTypes()
              .get(_ammoSource.itemID)
              .onHitBlock(
                  owner, worldObj, hit.blockX, hit.blockY, hit.blockZ, hit.sideHit, distance);
        }
      }
      setDead();
    }

    this.posX += this.motionX;
    this.posY += this.motionY;
    this.posZ += this.motionZ;
    speed = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
    this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);

    for (this.rotationPitch = (float) (Math.atan2(this.motionY, speed) * 180.0D / Math.PI);
        this.rotationPitch - this.prevRotationPitch < -180.0F;
        this.prevRotationPitch -= 360.0F) {;
    }

    while (this.rotationPitch - this.prevRotationPitch >= 180.0F) {
      this.prevRotationPitch += 360.0F;
    }

    while (this.rotationYaw - this.prevRotationYaw < -180.0F) {
      this.prevRotationYaw -= 360.0F;
    }

    while (this.rotationYaw - this.prevRotationYaw >= 180.0F) {
      this.prevRotationYaw += 360.0F;
    }

    this.rotationPitch =
        this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;
    this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
    float speedDropoff = 0.995F;
    collisionRange = 0.05F;

    if (_falling | speed < 0.05) {
      _falling = true;
      this.motionY -= 0.01;
      speedDropoff = 0.99F;
    }

    if (this.isInWater()) {
      double particleOffset = 0.25D;
      for (int i = 0; i < 4; ++i) {
        this.worldObj.spawnParticle(
            "bubble",
            this.posX - this.motionX * particleOffset,
            this.posY - this.motionY * particleOffset,
            this.posZ - this.motionZ * particleOffset,
            this.motionX,
            this.motionY,
            this.motionZ);
      }

      speedDropoff = 0.8F;
    }

    this.motionX *= speedDropoff;
    this.motionY *= speedDropoff;
    this.motionZ *= speedDropoff;
    this.setPosition(this.posX, this.posY, this.posZ);
    this.doBlockCollisions();
  }
  @Override
  public boolean activateMachine() {
    _grindingWorld.cleanReferences();
    List<?> entities =
        worldObj.getEntitiesWithinAABB(
            EntityLiving.class, _areaManager.getHarvestArea().toAxisAlignedBB());

    entityList:
    for (Object o : entities) {
      EntityLiving e = (EntityLiving) o;
      if (e instanceof EntityAgeable && ((EntityAgeable) e).getGrowingAge() < 0
          || e.isEntityInvulnerable()
          || e.getHealth() <= 0) {
        continue;
      }
      boolean processMob = false;
      processEntity:
      {
        if (MFRRegistry.getGrindables27().containsKey(e.getClass())) {
          IFactoryGrindable2 r = MFRRegistry.getGrindables27().get(e.getClass());
          List<MobDrop> drops = r.grind(e.worldObj, e, getRandom());
          if (drops != null && drops.size() > 0 && WeightedRandom.getTotalWeight(drops) > 0) {
            ItemStack drop = ((MobDrop) WeightedRandom.getRandomItem(_rand, drops)).getStack();
            doDrop(drop);
          }
          if (r instanceof IFactoryGrindable2) {
            if (((IFactoryGrindable2) r).processEntity(e)) {
              processMob = true;
              if (e.getHealth() <= 0) {
                continue entityList;
              }
              break processEntity;
            }
          } else {
            processMob = true;
            break processEntity;
          }
        }
        for (Class<?> t : MFRRegistry.getGrinderBlacklist()) {
          if (t.isInstance(e)) {
            continue entityList;
          }
        }
        if (!_grindingWorld.addEntityForGrinding(e)) {
          continue entityList;
        }
      }
      if (processMob && e.worldObj.getGameRules().getGameRuleBooleanValue("doMobLoot")) {
        try {
          e.worldObj.getGameRules().setOrCreateGameRule("doMobLoot", "false");
          damageEntity(e);
          if (e.getHealth() <= 0) {
            _tank.fill(LiquidDictionary.getLiquid("mobEssence", 100), true);
          }
        } finally {
          e.worldObj.getGameRules().setOrCreateGameRule("doMobLoot", "true");
          setIdleTicks(20);
        }
        return true;
      }
      damageEntity(e);
      if (e.getHealth() <= 0) {
        _tank.fill(LiquidDictionary.getLiquid("mobEssence", 100), true);
        setIdleTicks(20);
      } else {
        setIdleTicks(10);
      }
      return true;
    }
    setIdleTicks(getIdleTicksMax());
    return false;
  }
Exemplo n.º 18
0
  @EventHandler
  public void postLoad(FMLPostInitializationEvent event) {

    MFRRegistry.registerLaserOre(80, new ItemStack(Block.glowStone));
    MFRRegistry.registerLaserOre(175, new ItemStack(Block.oreCoal));
    MFRRegistry.addLaserPreferredOre(black, new ItemStack(Block.oreCoal));
    MFRRegistry.addLaserPreferredOre(yellow, new ItemStack(Block.glowStone));
    registerOreDictLaserOre(175 / 2, "oreNetherCoal", black, null); // coal isn't in the oredict??
    registerOreDictLaserOre(150, "Iron", brown, false);
    registerOreDictLaserOre(100, "Redstone", red, false);
    registerOreDictLaserOre(100, "Nikolite", lightBlue, false);
    registerOreDictLaserOre(90, "Copper", orange, false);
    registerOreDictLaserOre(85, "Tin", silver, false);
    registerOreDictLaserOre(85, "oreCheese", yellow, null);
    registerOreDictLaserOre(85, "Force", yellow, true);
    registerOreDictLaserOre(80, "Lapis", blue, true);
    registerOreDictLaserOre(70, "Gold", yellow, false);
    registerOreDictLaserOre(70, "oreQuartz", white, null);
    registerOreDictLaserOre(60, "Lead", purple, false);
    registerOreDictLaserOre(60, "oreZinc", white, "oreSphalerite", orange, "dustZinc");
    registerOreDictLaserOre(60, "NaturalAluminum", white, false);
    registerOreDictLaserOre(60, "Aluminium", white, false);
    registerOreDictLaserOre(60, "Aluminum", white, false);
    registerOreDictLaserOre(60, "oreSodalite", blue, null);
    registerOreDictLaserOre(55, "Mythril", blue, false);
    registerOreDictLaserOre(55, "Steel", gray, false);
    registerOreDictLaserOre(55, "oreCassiterite", black, null);
    registerOreDictLaserOre(55, "Diamond", lightBlue, true);
    registerOreDictLaserOre(55, "oreDesh", gray, null);
    registerOreDictLaserOre(50, "CertusQuartz", cyan, true);
    registerOreDictLaserOre(50, "Osmium", lightBlue, false);
    registerOreDictLaserOre(50, "oreBauxite", brown, null);
    registerOreDictLaserOre(45, "Rutile", black, false);
    registerOreDictLaserOre(45, "Titanium", black, false);
    registerOreDictLaserOre(45, "Tungsten", black, false);
    registerOreDictLaserOre(45, "oreTungstate", black, "oreNetherTungsten", "dustTungsten");
    registerOreDictLaserOre(45, "orePyrite", orange, null);
    registerOreDictLaserOre(45, "FzDarkIron", purple, false);
    registerOreDictLaserOre(40, "Tennantite", lime, false);
    registerOreDictLaserOre(40, "Nickel", silver, false);
    registerOreDictLaserOre(40, "Sulfur", yellow, false);
    registerOreDictLaserOre(40, "Saltpeter", white, false);
    registerOreDictLaserOre(35, "Emerald", lime, true);
    registerOreDictLaserOre(35, "Ruby", red, true);
    registerOreDictLaserOre(35, "Sapphire", blue, true);
    registerOreDictLaserOre(35, "GreenSapphire", green, true);
    registerOreDictLaserOre(35, "Peridot", green, true);
    registerOreDictLaserOre(35, "Topaz", brown, true);
    registerOreDictLaserOre(35, "Tanzanite", purple, true);
    registerOreDictLaserOre(35, "Malachite", cyan, true);
    registerOreDictLaserOre(35, "Amber", orange, true);
    registerOreDictLaserOre(30, "Adamantium", green, false);
    registerOreDictLaserOre(30, "Silver", gray, false);
    registerOreDictLaserOre(30, "Galena", purple, false);
    registerOreDictLaserOre(30, "Apatite", blue, true);
    registerOreDictLaserOre(30, "Silicon", black, false);
    registerOreDictLaserOre(25, "Amethyst", magenta, true);
    registerOreDictLaserOre(20, "Uranium", lime, false);
    registerOreDictLaserOre(20, "orePitchblende", black, "oreNetherUranium", lime, "dustUranium");
    registerOreDictLaserOre(20, "Yellorite", yellow, false);
    registerOreDictLaserOre(20, "oreFirestone", red, null);
    registerOreDictLaserOre(20, "MonazitOre", green, null);
    registerOreDictLaserOre(15, "Cinnabar", red, true);
    registerOreDictLaserOre(15, "Platinum", lightBlue, false);
    registerOreDictLaserOre(
        15, "oreCooperite", yellow, "oreNetherPlatinum", lightBlue, "dustPlatinum");
    registerOreDictLaserOre(10, "oreArdite", orange, null);
    registerOreDictLaserOre(10, "oreCobalt", blue, null);
    registerOreDictLaserOre(5, "Iridium", white, false);

    // rarity/usefulness unknown
    registerOreDictLaserOre(20, "oreTetrahedrite", orange, null);
    registerOreDictLaserOre(20, "oreCadmium", lightBlue, null);
    registerOreDictLaserOre(20, "oreIndium", silver, null);
    registerOreDictLaserOre(20, "oreAmmonium", white, null);
    registerOreDictLaserOre(20, "oreCalcite", orange, null);
    registerOreDictLaserOre(20, "oreFluorite", silver, null);
  }
Exemplo n.º 19
0
 @Override
 public void undo() {
   for (Block log : removedLogs) {
     MFRRegistry.registerFruitLogBlock(log);
   }
 }
Exemplo n.º 20
0
 @Override
 public void apply() {
   for (Block log : removedLogs) {
     MFRRegistry.getFruitLogBlocks().remove(log);
   }
 }
Exemplo n.º 21
0
 @Override
 public void apply() {
   for (Block log : addedLogs) {
     MFRRegistry.registerFruitLogBlock(log);
   }
 }
Exemplo n.º 22
0
 @Override
 public void undo() {
   for (Block log : addedLogs) {
     MFRRegistry.getFruitLogBlocks().remove(log);
   }
 }