Merge branch 'master' into 1.10

This commit is contained in:
Tschipp 2017-09-17 22:44:37 +02:00
commit 9a38b115b7
11 changed files with 165 additions and 15 deletions

View File

@ -29,7 +29,7 @@ public class CarryOn {
public static CarryOn instance;
public static final String MODID = "carryon";
public static final String VERSION = "1.4.1";
public static final String VERSION = "1.5";
public static final String NAME = "Carry On";
public static final String UPDATE_JSON = "https://gist.githubusercontent.com/Tschipp/dccadee7c90d7a34e6e76a35d9d6fa2e/raw/";
public static final Logger LOGGER = LogManager.getFormatterLogger("CarryOn");

View File

@ -200,7 +200,8 @@ public class RenderEntityEvents
{
Entity entity = ItemEntity.getEntity(stack, world);
float rotation = -player.renderYawOffset;
float rotation = -(player.prevRenderYawOffset + (player.renderYawOffset - player.prevRenderYawOffset) * partialticks);
int perspective = Minecraft.getMinecraft().gameSettings.thirdPersonView;
if (entity != null)

View File

@ -251,11 +251,7 @@ public class RenderEvents
ItemStack tileItem = ItemTile.getItemStack(stack);
EntityItem entityItem = new EntityItem(Minecraft.getMinecraft().theWorld, 0, 0, 0);
entityItem.hoverStart = 0;
entityItem.setEntityItemStack(tileItem);
float rotation = -player.renderYawOffset;
float rotation = -(player.prevRenderYawOffset + (player.renderYawOffset - player.prevRenderYawOffset) * partialticks);
int perspective = Minecraft.getMinecraft().gameSettings.thirdPersonView;
double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double) partialticks;

View File

@ -27,6 +27,10 @@ public class CarryOnConfig {
@Config.Comment("Blacklist for Blocks and Entities")
public static Configs.Blacklist blacklist = new Configs.Blacklist();
@Config.LangKey(CarryOn.MODID)
@Config.Comment("Whitelist for Blocks and Entities (useWhitelist must be true!)")
public static Configs.WhiteList whitelist = new Configs.WhiteList();
@Config.LangKey(CarryOn.MODID)
@Config.Comment("Model Overrides based on NBT or on Meta. Advanced Users Only!")
public static Configs.ModelOverrides modelOverrides = new Configs.ModelOverrides();

View File

@ -45,6 +45,28 @@ public class Configs {
@Comment("Arms should render on sides when carrying")
public boolean renderArms = true;
@Comment("Allow babies to be carried even when adult mob is blacklisted (or not whitelisted)")
public boolean allowBabies = false;
@Comment("Use Whitelist instead of Blacklist for Blocks")
public boolean useWhitelistBlocks=false;
@Comment("Use Whitelist instead of Blacklist for Entities")
public boolean useWhitelistEntities=false;
}
public static class WhiteList
{
@Comment("Entities that CAN be picked up")
public String[] allowedEntities=new String[]
{
};
@Comment("Blocks that CAN be picked up")
public String[] allowedBlocks=new String[]
{
};
}
public static class Blacklist
@ -97,6 +119,9 @@ public class Configs {
"Ghast",
"Shulker",
"animania:textures/entity/pigs/hamster_tarou.png",
"animania:hamster",
"animania:ferret*",
"animania:hedgehog*",
"mynko:*"
};
}
@ -153,7 +178,20 @@ public class Configs {
"storagedrawers:basicdrawers;4{Mat:\"birch\"}->storagedrawers:basicdrawers;4{material:\"birch\"}",
"storagedrawers:basicdrawers;4{Mat:\"jungle\"}->storagedrawers:basicdrawers;4{material:\"jungle\"}",
"storagedrawers:basicdrawers;4{Mat:\"acacia\"}->storagedrawers:basicdrawers;4{material:\"acacia\"}",
"storagedrawers:basicdrawers;4{Mat:\"dark_oak\"}->storagedrawers:basicdrawers;4{material:\"dark_oak\"}"
"storagedrawers:basicdrawers;4{Mat:\"dark_oak\"}->storagedrawers:basicdrawers;4{material:\"dark_oak\"}",
"animania:nest->(block)animania:nest",
"animania:cheese_mold;0->(block)cheese_mold;0",
"animania:cheese_mold;1->(block)cheese_mold;1",
"animania:cheese_mold;2->(block)cheese_mold;2",
"animania:cheese_mold;3->(block)cheese_mold;3",
"animania:cheese_mold;4->(block)cheese_mold;4",
"animania:cheese_mold;5->(block)cheese_mold;5",
"animania:cheese_mold;6->(block)cheese_mold;6",
"animania:cheese_mold;7->(block)cheese_mold;7",
"animania:cheese_mold;8->(block)cheese_mold;8",
"animania:cheese_mold;9->(block)cheese_mold;9",
"animania:cheese_mold;10->(block)cheese_mold;10",
};
}

View File

@ -25,7 +25,7 @@ import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import tschipp.carryon.CarryOn;
import tschipp.carryon.client.keybinds.CarryOnKeybinds;
import tschipp.carryon.common.handler.ForbiddenTileHandler;
import tschipp.carryon.common.handler.ListHandler;
import tschipp.carryon.common.handler.PickupHandler;
import tschipp.carryon.common.handler.RegistrationHandler;
import tschipp.carryon.common.item.ItemTile;
@ -102,7 +102,7 @@ public class ItemEvents
Block block = world.getBlockState(pos).getBlock();
IBlockState state = world.getBlockState(pos);
if (main == null && off == null && CarryOnKeybinds.isKeyPressed(player) && !ForbiddenTileHandler.isForbidden(block))
if (main == null && off == null && CarryOnKeybinds.isKeyPressed(player))
{
ItemStack stack = new ItemStack(RegistrationHandler.itemTile);

View File

@ -9,10 +9,12 @@ import net.minecraft.entity.EntityList;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
import tschipp.carryon.common.config.CarryOnConfig;
public class ForbiddenTileHandler
public class ListHandler
{
public static List<String> FORBIDDEN_TILES;
public static List<String> FORBIDDEN_ENTITIES;
public static List<String> ALLOWED_ENTITIES;
public static List<String> ALLOWED_TILES;
public static boolean isForbidden(Block block)
{
@ -30,6 +32,21 @@ public class ForbiddenTileHandler
return true;
}
public static boolean isAllowed(Entity entity){
if (EntityList.getEntityString(entity) != null)
{
String name = EntityList.getEntityString(entity).toString();
boolean contains = ALLOWED_ENTITIES.contains(name);
return contains;
}
return true;
}
public static boolean isAllowed(Block block)
{
return ALLOWED_TILES.contains(block.getRegistryName().toString());
}
public static void initForbiddenTiles()
{
String[] forbidden = CarryOnConfig.blacklist.forbiddenTiles;
@ -69,6 +86,42 @@ public class ForbiddenTileHandler
}
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 < EntityList.getEntityNameList().size(); k++)
{
if (EntityList.getEntityNameList().get(k).contains(modid))
ALLOWED_ENTITIES.add(EntityList.getEntityNameList().get(k));
}
}
ALLOWED_ENTITIES.add(allowedEntities[i]);
}
String[] allowedBlocks = CarryOnConfig.whitelist.allowedBlocks;
ALLOWED_TILES = new ArrayList<String>();
for (int i = 0; i < allowedBlocks.length; i++)
{
if (allowedBlocks[i].contains("*"))
{
String modid = allowedBlocks[i].replace("*", "");
for (int k = 0; k < Block.REGISTRY.getKeys().size(); k++)
{
if (Block.REGISTRY.getKeys().toArray()[k].toString().contains(modid))
{
ALLOWED_TILES.add(Block.REGISTRY.getKeys().toArray()[k].toString());
}
}
}
ALLOWED_TILES.add(allowedBlocks[i]);
}
}
}

View File

@ -8,8 +8,8 @@ import com.feed_the_beast.ftbu.api_impl.ClaimedChunkStorage;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityAgeable;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.entity.passive.EntityTameable;
import net.minecraft.entity.player.EntityPlayer;
@ -32,6 +32,21 @@ public class PickupHandler
player.closeScreen();
if (CarryOnConfig.settings.useWhitelistBlocks)
{
if (!ListHandler.isAllowed(world.getBlockState(pos).getBlock()))
{
return false;
}
}
else
{
if (ListHandler.isForbidden(world.getBlockState(pos).getBlock()))
{
return false;
}
}
if ((block.getBlockHardness(state, world, pos) != -1 || player.isCreative()))
{
double distance = pos.distanceSqToCenter(player.posX, player.posY + 0.5, player.posZ);
@ -55,7 +70,48 @@ public class PickupHandler
public static boolean canPlayerPickUpEntity(EntityPlayer player, Entity toPickUp)
{
BlockPos pos = toPickUp.getPosition();
if (!(toPickUp instanceof EntityPlayer) && !ForbiddenTileHandler.isForbidden(toPickUp))
if (toPickUp instanceof EntityPlayer)
return false;
// check for allow babies to be picked up
if (toPickUp instanceof EntityAgeable && CarryOnConfig.settings.allowBabies)
{
EntityAgeable living = (EntityAgeable) toPickUp;
if (living.getGrowingAge() < 0 || living.isChild())
{
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;
}
return true;
}
}
}
if (CarryOnConfig.settings.useWhitelistEntities)
{
if (!ListHandler.isAllowed(toPickUp))
{
return false;
}
}
else
{
if (ListHandler.isForbidden(toPickUp))
{
return false;
}
}
if ((CarryOnConfig.settings.pickupHostileMobs ? true : !toPickUp.isCreatureType(EnumCreatureType.MONSTER, false) || player.isCreative()))
{
if ((CarryOnConfig.settings.pickupHostileMobs ? true : !toPickUp.isCreatureType(EnumCreatureType.MONSTER, false) || player.isCreative()))
{
@ -77,6 +133,7 @@ public class PickupHandler
}
}
return false;
}

View File

@ -44,7 +44,7 @@ public class RegistrationHandler
public static void regOverrideList()
{
ModelOverridesHandler.initOverrides();
ForbiddenTileHandler.initForbiddenTiles();
ListHandler.initForbiddenTiles();
}

View File

@ -2,6 +2,7 @@ carryon.category.settings=Settings
carryon.category.blacklist=Blacklist
carryon.category.modeloverrides=Model Overrides (Advanced)
carryon.category.custompickupconditions=Custom Pickup Conditions (Advanced)
carryon.category.whitelist=Whitelist
carryon.general.modeloverrides.modeloverrides=Model Overrides
carryon.general.blacklist.forbiddenentities=Entities that the Player cannot pick up

View File

@ -2,7 +2,7 @@
{
"modid" : "carryon",
"name" : "Carry On",
"version" : "1.4.1", "mcversion" : "1.10.2",
"version" : "1.5", "mcversion" : "1.10.2",
"url" : "",
"credits" : "Tschipp, Purplicious_Cow, cy4n",
"authorList" : ["Tschipp, Purplicious_Cow, cy4n"],