commit
24ca37414d
|
|
@ -27,6 +27,10 @@ public class CarryOnConfig {
|
||||||
@Config.Comment("Blacklist for Blocks and Entities")
|
@Config.Comment("Blacklist for Blocks and Entities")
|
||||||
public static Configs.Blacklist blacklist = new Configs.Blacklist();
|
public static Configs.Blacklist blacklist = new Configs.Blacklist();
|
||||||
|
|
||||||
|
@Config.LangKey(CarryOn.MODID)
|
||||||
|
@Config.Comment("Whitelist for Entities")
|
||||||
|
public static Configs.WhiteList whitelist = new Configs.WhiteList();
|
||||||
|
|
||||||
@Config.LangKey(CarryOn.MODID)
|
@Config.LangKey(CarryOn.MODID)
|
||||||
@Config.Comment("Model Overrides based on NBT or on Meta. Advanced Users Only!")
|
@Config.Comment("Model Overrides based on NBT or on Meta. Advanced Users Only!")
|
||||||
public static Configs.ModelOverrides modelOverrides = new Configs.ModelOverrides();
|
public static Configs.ModelOverrides modelOverrides = new Configs.ModelOverrides();
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,23 @@ public class Configs {
|
||||||
|
|
||||||
@Comment("Arms should render on sides when carrying")
|
@Comment("Arms should render on sides when carrying")
|
||||||
public boolean renderArms = true;
|
public boolean renderArms = true;
|
||||||
|
|
||||||
|
@Comment("Allow babies to be carried when parents are not")
|
||||||
|
public boolean allowBabies=false;
|
||||||
|
|
||||||
|
@Comment("Use Whitelist instead of Blacklist")
|
||||||
|
public boolean useWhiteList=false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class WhiteList
|
||||||
|
{
|
||||||
|
@Config.RequiresMcRestart()
|
||||||
|
@Comment("Entities that CAN be picked up")
|
||||||
|
public String[] allowedEntities=new String[]
|
||||||
|
{
|
||||||
|
"minecraft:chicken",
|
||||||
|
"minecraft:rabbit"
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Blacklist
|
public static class Blacklist
|
||||||
|
|
@ -101,6 +118,7 @@ public class Configs {
|
||||||
"animania:textures/entity/pigs/hamster_tarou.png",
|
"animania:textures/entity/pigs/hamster_tarou.png",
|
||||||
"mynko:*"
|
"mynko:*"
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ModelOverrides
|
public static class ModelOverrides
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ public class ForbiddenTileHandler
|
||||||
{
|
{
|
||||||
public static List<String> FORBIDDEN_TILES;
|
public static List<String> FORBIDDEN_TILES;
|
||||||
public static List<String> FORBIDDEN_ENTITIES;
|
public static List<String> FORBIDDEN_ENTITIES;
|
||||||
|
public static List<String> ALLOWED_ENTITIES;
|
||||||
|
|
||||||
public static boolean isForbidden(Block block)
|
public static boolean isForbidden(Block block)
|
||||||
{
|
{
|
||||||
|
|
@ -30,6 +31,16 @@ public class ForbiddenTileHandler
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isAllowed(Entity entity){
|
||||||
|
if (EntityList.getKey(entity) != null)
|
||||||
|
{
|
||||||
|
String name = EntityList.getKey(entity).toString();
|
||||||
|
boolean contains = ALLOWED_ENTITIES.contains(name);
|
||||||
|
return contains;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public static void initForbiddenTiles()
|
public static void initForbiddenTiles()
|
||||||
{
|
{
|
||||||
String[] forbidden = CarryOnConfig.blacklist.forbiddenTiles;
|
String[] forbidden = CarryOnConfig.blacklist.forbiddenTiles;
|
||||||
|
|
@ -69,6 +80,22 @@ public class ForbiddenTileHandler
|
||||||
}
|
}
|
||||||
FORBIDDEN_ENTITIES.add(forbiddenEntity[i]);
|
FORBIDDEN_ENTITIES.add(forbiddenEntity[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String [] allowedEntities=CarryOnConfig.whitelist.allowedEntities;
|
||||||
|
ALLOWED_ENTITIES=new ArrayList<String>();
|
||||||
|
for(int i=0;i<allowedEntities.length;i++){
|
||||||
|
if(allowedEntities[i].contains("*"))
|
||||||
|
{
|
||||||
|
String modid=allowedEntities[i].replace("*", "");
|
||||||
|
for(int k=0;k<ForgeRegistries.ENTITIES.getKeys().size();k++)
|
||||||
|
{
|
||||||
|
if(ForgeRegistries.ENTITIES.getKeys().toArray()[k].toString().contains(modid)){
|
||||||
|
ALLOWED_ENTITIES.add(ForgeRegistries.ENTITIES.getKeys().toArray()[k].toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ALLOWED_ENTITIES.add(allowedEntities[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,8 @@ import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.EntityAgeable;
|
||||||
|
import net.minecraft.entity.EntityLiving;
|
||||||
import net.minecraft.entity.EnumCreatureType;
|
import net.minecraft.entity.EnumCreatureType;
|
||||||
import net.minecraft.entity.passive.EntityTameable;
|
import net.minecraft.entity.passive.EntityTameable;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
|
@ -68,36 +70,79 @@ public class PickupHandler
|
||||||
public static boolean canPlayerPickUpEntity(EntityPlayer player, Entity toPickUp)
|
public static boolean canPlayerPickUpEntity(EntityPlayer player, Entity toPickUp)
|
||||||
{
|
{
|
||||||
BlockPos pos = toPickUp.getPosition();
|
BlockPos pos = toPickUp.getPosition();
|
||||||
if (!(toPickUp instanceof EntityPlayer) && !ForbiddenTileHandler.isForbidden(toPickUp))
|
|
||||||
{
|
|
||||||
if ((CarryOnConfig.settings.pickupHostileMobs ? true : !toPickUp.isCreatureType(EnumCreatureType.MONSTER, false) || player.isCreative()))
|
|
||||||
{
|
|
||||||
if ((toPickUp.height <= CarryOnConfig.settings.maxEntityHeight && toPickUp.width <= CarryOnConfig.settings.maxEntityWidth || player.isCreative()))
|
|
||||||
{
|
|
||||||
double distance = pos.distanceSqToCenter(player.posX, player.posY + 0.5, player.posZ);
|
|
||||||
if (distance < Math.pow(CarryOnConfig.settings.maxDistance, 2))
|
|
||||||
{
|
|
||||||
if (toPickUp instanceof EntityTameable)
|
|
||||||
{
|
|
||||||
EntityTameable tame = (EntityTameable) toPickUp;
|
|
||||||
if (tame.getOwnerId() != null && tame.getOwnerId() != player.getUUID(player.getGameProfile()))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CustomPickupOverrideHandler.hasSpecialPickupConditions(toPickUp))
|
|
||||||
{
|
|
||||||
IStageData stageData = PlayerDataHandler.getStageData(player);
|
//check for allow babies to be picked up
|
||||||
String condition = CustomPickupOverrideHandler.getPickupCondition(toPickUp);
|
if(toPickUp instanceof EntityAgeable && CarryOnConfig.settings.allowBabies){
|
||||||
if (stageData.hasUnlockedStage(condition))
|
EntityAgeable entity_living=(EntityAgeable) toPickUp;
|
||||||
return true;
|
if(entity_living.getGrowingAge()<0){
|
||||||
}
|
|
||||||
else
|
double distance = pos.distanceSqToCenter(player.posX, player.posY + 0.5, player.posZ);
|
||||||
|
if (distance < Math.pow(CarryOnConfig.settings.maxDistance, 2))
|
||||||
|
{
|
||||||
|
if (toPickUp instanceof EntityTameable)
|
||||||
|
{
|
||||||
|
EntityTameable tame = (EntityTameable) toPickUp;
|
||||||
|
if (tame.getOwnerId() != null && tame.getOwnerId() != player.getUUID(player.getGameProfile()))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CustomPickupOverrideHandler.hasSpecialPickupConditions(toPickUp))
|
||||||
|
{
|
||||||
|
IStageData stageData = PlayerDataHandler.getStageData(player);
|
||||||
|
String condition = CustomPickupOverrideHandler.getPickupCondition(toPickUp);
|
||||||
|
if (stageData.hasUnlockedStage(condition))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(toPickUp instanceof EntityPlayer)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(CarryOnConfig.settings.useWhiteList){
|
||||||
|
if(!ForbiddenTileHandler.isAllowed(toPickUp)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if (ForbiddenTileHandler.isForbidden(toPickUp))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((CarryOnConfig.settings.pickupHostileMobs ? true : !toPickUp.isCreatureType(EnumCreatureType.MONSTER, false) || player.isCreative()))
|
||||||
|
{
|
||||||
|
if ((toPickUp.height <= CarryOnConfig.settings.maxEntityHeight && toPickUp.width <= CarryOnConfig.settings.maxEntityWidth || player.isCreative()))
|
||||||
|
{
|
||||||
|
double distance = pos.distanceSqToCenter(player.posX, player.posY + 0.5, player.posZ);
|
||||||
|
if (distance < Math.pow(CarryOnConfig.settings.maxDistance, 2))
|
||||||
|
{
|
||||||
|
if (toPickUp instanceof EntityTameable)
|
||||||
|
{
|
||||||
|
EntityTameable tame = (EntityTameable) toPickUp;
|
||||||
|
if (tame.getOwnerId() != null && tame.getOwnerId() != player.getUUID(player.getGameProfile()))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CustomPickupOverrideHandler.hasSpecialPickupConditions(toPickUp))
|
||||||
|
{
|
||||||
|
IStageData stageData = PlayerDataHandler.getStageData(player);
|
||||||
|
String condition = CustomPickupOverrideHandler.getPickupCondition(toPickUp);
|
||||||
|
if (stageData.hasUnlockedStage(condition))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user