Skip to content

Commit

Permalink
Don't check the entire registry for enderman blocks, only ones in lis…
Browse files Browse the repository at this point in the history
…t for mob.
  • Loading branch information
wendall911 committed Jun 2, 2018
1 parent 823e231 commit 1d19dd9
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/main/java/tinkersurvival/proxy/CommonProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@

import net.minecraft.block.Block;
import net.minecraft.entity.monster.EntityEnderman;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.registry.RegistryNamespacedDefaultedByKey;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.translation.I18n;
import net.minecraft.world.World;

Expand Down Expand Up @@ -74,6 +73,23 @@ public void postInit(FMLPostInitializationEvent event) {
if (Config.Features.NO_GRIEFING) {
final Set<String> griefBlockIds = Sets.newHashSet(Config.Features.GRIEFING_WHITELIST);
Set<Block> griefBlocks = new HashSet<Block>();
Block[] blocks = new Block[] {
Blocks.GRASS,
Blocks.DIRT,
Blocks.SAND,
Blocks.GRAVEL,
Blocks.YELLOW_FLOWER,
Blocks.RED_FLOWER,
Blocks.BROWN_MUSHROOM,
Blocks.RED_MUSHROOM,
Blocks.TNT,
Blocks.CACTUS,
Blocks.CLAY,
Blocks.PUMPKIN,
Blocks.MELON_BLOCK,
Blocks.MYCELIUM,
Blocks.NETHERRACK
};

for (String id: griefBlockIds) {
Block block = Block.getBlockFromName(id);
Expand All @@ -82,8 +98,7 @@ public void postInit(FMLPostInitializationEvent event) {
}
}

RegistryNamespacedDefaultedByKey<ResourceLocation, Block> griefBlock = Block.REGISTRY;
for (Block block : griefBlock) {
for (Block block : blocks) {
if (!griefBlocks.contains(block)) {
EntityEnderman.setCarriable(block, false);
}
Expand Down

0 comments on commit 1d19dd9

Please sign in to comment.