Skip to content

Commit

Permalink
Added a blacklist for the animal grower, this time its the correct ma…
Browse files Browse the repository at this point in the history
…chine
  • Loading branch information
Buuz135 committed Jan 1, 2019
1 parent 10ea2e1 commit 9ca43d6
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
# This is required to provide enough memory for the Minecraft decompilation process.
org.gradle.jvmargs=-Xmx3G
mod_version=1.12.3
mod_version=1.12.4
minecraft_version=1.12.2
teslacorelib_version=1.0.15.+
teslacorelib_mc_version=1.12.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,17 @@
*/
package com.buuz135.industrial.tile.agriculture;

import com.buuz135.industrial.proxy.BlockRegistry;
import com.buuz135.industrial.tile.CustomColoredItemHandler;
import com.buuz135.industrial.tile.WorkingAreaElectricMachine;
import net.minecraft.entity.EntityAgeable;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.item.EnumDyeColor;
import net.minecraftforge.items.ItemStackHandler;

import java.util.concurrent.atomic.AtomicBoolean;

public class AnimalGrowthIncreaserTile extends WorkingAreaElectricMachine {

private ItemStackHandler items;
Expand All @@ -51,16 +55,18 @@ protected void onContentsChanged(int slot) {

@Override
public float work() {
world.getEntitiesWithinAABB(EntityAnimal.class, getWorkingArea()).stream().filter(EntityAgeable::isChild).forEach(entityAnimal -> {
AtomicBoolean hasWorked = new AtomicBoolean(false);
world.getEntitiesWithinAABB(EntityAnimal.class, getWorkingArea()).stream().filter(EntityAgeable::isChild).filter(entityAnimal -> !BlockRegistry.animalGrowthIncreaserBlock.entityBlacklist.contains(EntityList.getKey(entityAnimal).toString())).forEach(entityAnimal -> {
for (int i = 0; i < items.getSlots(); ++i) {
if (entityAnimal.isBreedingItem(items.getStackInSlot(i))) {
entityAnimal.ageUp(30, true);
items.getStackInSlot(i).shrink(1);
hasWorked.set(true);
break;
}
}
});
return 1;
return hasWorked.get() ? 1 : 0;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,27 @@
package com.buuz135.industrial.tile.block;

import com.buuz135.industrial.book.BookCategory;
import com.buuz135.industrial.config.CustomConfiguration;
import com.buuz135.industrial.proxy.ItemRegistry;
import com.buuz135.industrial.tile.agriculture.AnimalGrowthIncreaserTile;
import com.buuz135.industrial.utils.RecipeUtils;
import net.minecraft.block.material.Material;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.config.Configuration;
import net.ndrei.teslacorelib.items.MachineCaseItem;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class AnimalGrowthIncreaserBlock extends CustomAreaOrientedBlock<AnimalGrowthIncreaserTile> {

public List<String> entityBlacklist;

public AnimalGrowthIncreaserBlock() {
super("animal_growth_increaser", AnimalGrowthIncreaserTile.class, Material.ROCK, 20 * 20, 20, RangeType.FRONT, 5, 1, true);
entityBlacklist = new ArrayList<>();
}

public void createRecipe() {
Expand All @@ -50,4 +59,10 @@ public BookCategory getCategory() {
return BookCategory.ANIMAL_HUSBANDRY;
}

@Override
public void getMachineConfig() {
super.getMachineConfig();
entityBlacklist = Arrays.asList(CustomConfiguration.config.getStringList("entityBlacklist", "machines" + Configuration.CATEGORY_SPLITTER + this.getRegistryName().getPath().toString(),
new String[]{}, "A list of entities blacklist from being fed with the machine. Format: 'modid:entityid'"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import net.minecraftforge.common.config.Configuration;
import net.ndrei.teslacorelib.items.MachineCaseItem;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

Expand All @@ -41,6 +42,7 @@ public class AnimalStockIncreaserBlock extends CustomAreaOrientedBlock<AnimalSto

public AnimalStockIncreaserBlock() {
super("animal_stock_increaser", AnimalStockIncreaserTile.class, Material.ROCK, 400, 20, RangeType.FRONT, 5, 1, true);
entityBlacklist = new ArrayList<>();
}

public void createRecipe() {
Expand All @@ -62,6 +64,6 @@ public BookCategory getCategory() {
public void getMachineConfig() {
super.getMachineConfig();
entityBlacklist = Arrays.asList(CustomConfiguration.config.getStringList("entityBlacklist", "machines" + Configuration.CATEGORY_SPLITTER + this.getRegistryName().getPath().toString(),
new String[]{}, "A list of entities blacklist from being fed with the machine"));
new String[]{}, "A list of entities blacklist from being fed with the machine. Format: 'modid:entityid'"));
}
}

0 comments on commit 9ca43d6

Please sign in to comment.