Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
added enderman griefing config
- Loading branch information
Showing
4 changed files
with
101 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
src/main/java/net/doubledoordev/d3core/util/EndermanGriefing.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package net.doubledoordev.d3core.util; | ||
|
||
import cpw.mods.fml.common.registry.GameData; | ||
import net.doubledoordev.d3core.D3Core; | ||
import net.minecraft.block.Block; | ||
import net.minecraft.entity.monster.EntityEnderman; | ||
import net.minecraft.init.Blocks; | ||
|
||
import java.util.HashMap; | ||
|
||
/** | ||
* @author Dries007 | ||
*/ | ||
public class EndermanGriefing | ||
{ | ||
public static boolean disable; | ||
public static String[] blacklist; | ||
public static String[] addList; | ||
|
||
private static HashMap<String, Boolean> reverseMap = new HashMap<>(); | ||
|
||
public static void init() | ||
{ | ||
if (disable) | ||
{ | ||
for (Object key : GameData.getBlockRegistry().getKeys()) | ||
{ | ||
Block block = (Block) GameData.getBlockRegistry().getObject(key); | ||
reverseMap.put(GameData.getBlockRegistry().getNameForObject(block), EntityEnderman.getCarriable(block)); | ||
EntityEnderman.setCarriable(block, false); | ||
} | ||
} | ||
else | ||
{ | ||
for (String item : addList) | ||
{ | ||
if (!GameData.getBlockRegistry().containsKey(item)) | ||
{ | ||
D3Core.getLogger().warn("Block %s does not exist...", item); | ||
continue; | ||
} | ||
reverseMap.put(item, EntityEnderman.getCarriable(GameData.getBlockRegistry().getObject(item))); | ||
EntityEnderman.setCarriable(GameData.getBlockRegistry().getObject(item), true); | ||
} | ||
for (String item : blacklist) | ||
{ | ||
if (!GameData.getBlockRegistry().containsKey(item)) | ||
{ | ||
D3Core.getLogger().warn("Block %s does not exist...", item); | ||
continue; | ||
} | ||
reverseMap.put(item, EntityEnderman.getCarriable(GameData.getBlockRegistry().getObject(item))); | ||
EntityEnderman.setCarriable(GameData.getBlockRegistry().getObject(item), false); | ||
} | ||
} | ||
} | ||
|
||
public static void undo() | ||
{ | ||
for (String entry : reverseMap.keySet()) | ||
{ | ||
EntityEnderman.setCarriable(GameData.getBlockRegistry().getObject(entry), reverseMap.get(entry)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters