Custom Pickup Overrides, FTBUtils Integration
This commit is contained in:
parent
b787aec975
commit
ec60f185e8
23
build.gradle
23
build.gradle
|
|
@ -2,11 +2,16 @@ buildscript {
|
|||
repositories {
|
||||
jcenter()
|
||||
maven { url = "http://files.minecraftforge.net/maven" }
|
||||
|
||||
}
|
||||
dependencies {
|
||||
classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
apply plugin: 'net.minecraftforge.gradle.forge'
|
||||
|
||||
version = "1.0"
|
||||
|
|
@ -26,8 +31,26 @@ minecraft {
|
|||
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
|
||||
}
|
||||
|
||||
repositories {
|
||||
|
||||
maven { url 'http://maven.epoxide.org' }
|
||||
|
||||
ivy {
|
||||
name "LatMod"
|
||||
artifactPattern "http://mods.latmod.com/[module]/[revision]/[module]-[revision](-[classifier]).[ext]"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
dependencies {
|
||||
|
||||
deobfCompile "net.darkhax.gamestages:GameStages-1.11.2:1.0.11"
|
||||
|
||||
deobfCompile "LatMod:FTBUtilities:1.1x-3.6.5"
|
||||
deobfCompile "LatMod:FTBLib:1.1x-3.6.5"
|
||||
|
||||
|
||||
}
|
||||
|
||||
processResources {
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ public class CarryOn {
|
|||
public static CarryOn instance;
|
||||
|
||||
public static final String MODID = "carryon";
|
||||
public static final String VERSION = "1.1.1";
|
||||
public static final String VERSION = "1.2";
|
||||
public static final String NAME = "Carry On";
|
||||
public static final String UPDATE_JSON = "https://gist.githubusercontent.com/Tschipp/dccadee7c90d7a34e6e76a35d9d6fa2e/raw/bf7fb60d5e59f73eee65b271d5c01585e26a0352/update.json";
|
||||
public static final Logger LOGGER = LogManager.getFormatterLogger("CarryOn");
|
||||
|
|
|
|||
|
|
@ -224,6 +224,7 @@ public class RenderEntityEvents
|
|||
|
||||
GlStateManager.scale(1, 1, 1);
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -273,6 +273,7 @@ public class RenderEvents
|
|||
@SubscribeEvent
|
||||
public void onPlayerRenderPre(RenderPlayerEvent.Pre event)
|
||||
{
|
||||
|
||||
if (!Loader.isModLoaded("mobends")) {
|
||||
|
||||
EntityPlayer player = event.getEntityPlayer();
|
||||
|
|
@ -366,6 +367,7 @@ public class RenderEvents
|
|||
model.bipedRightArm.isHidden = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,18 +24,16 @@ public class CarryOnConfig {
|
|||
public static Configs.Settings settings = new Configs.Settings();
|
||||
|
||||
@Config.LangKey(CarryOn.MODID)
|
||||
@Config.Comment("Tile Entities that the Player is not allowed to pick up")
|
||||
public static Configs.ForbiddenTiles forbiddenTiles = new Configs.ForbiddenTiles();
|
||||
|
||||
@Config.LangKey(CarryOn.MODID)
|
||||
@Config.Comment("Entities that the Player is not allowed to pick up")
|
||||
public static Configs.ForbiddenEntities forbiddenEntities = new Configs.ForbiddenEntities();
|
||||
@Config.Comment("Blacklist for Blocks and Entities")
|
||||
public static Configs.Blacklist blacklist = new Configs.Blacklist();
|
||||
|
||||
@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();
|
||||
|
||||
|
||||
@Config.LangKey(CarryOn.MODID)
|
||||
@Config.Comment("Custom Pickup Conditions for certain blocks. ONLY WORKS WHEN GAMESTAGES IS INSTALLED! Advanced Users Only!")
|
||||
public static Configs.CustomPickupConditions customPickupConditions = new Configs.CustomPickupConditions();
|
||||
|
||||
@Mod.EventBusSubscriber
|
||||
public static class EventHandler {
|
||||
|
|
|
|||
|
|
@ -38,22 +38,7 @@ public class Configs {
|
|||
public boolean heavyEntities = true;
|
||||
}
|
||||
|
||||
public static class ForbiddenEntities
|
||||
{
|
||||
|
||||
@Config.RequiresMcRestart()
|
||||
@Comment("Entities that cannot be picked up")
|
||||
public String[] forbiddenEntities = new String[]
|
||||
{
|
||||
"minecraft:ender_crystal",
|
||||
"minecraft:ender_dragon",
|
||||
"minecraft:ghast",
|
||||
"minecraft:shulker"
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public static class ForbiddenTiles
|
||||
public static class Blacklist
|
||||
{
|
||||
@Config.RequiresMcRestart()
|
||||
@Comment("Tile Entities that cannot be picked up")
|
||||
|
|
@ -93,6 +78,17 @@ public class Configs {
|
|||
"embers:inferno_forge",
|
||||
"storagedrawers:framingtable",
|
||||
};
|
||||
|
||||
@Config.RequiresMcRestart()
|
||||
@Comment("Entities that cannot be picked up")
|
||||
public String[] forbiddenEntities = new String[]
|
||||
{
|
||||
"minecraft:ender_crystal",
|
||||
"minecraft:ender_dragon",
|
||||
"minecraft:ghast",
|
||||
"minecraft:shulker",
|
||||
"animania:textures/entity/pigs/hamster_tarou.png"
|
||||
};
|
||||
}
|
||||
|
||||
public static class ModelOverrides
|
||||
|
|
@ -112,6 +108,7 @@ public class Configs {
|
|||
"minecraft:tallgrass;1->(item)minecraft:tallgrass;1",
|
||||
"minecraft:tallgrass;2->(item)minecraft:tallgrass;2",
|
||||
"minecraft:flower_pot->(block)minecraft:flower_pot",
|
||||
"minecraft:leaves2->(item)minecraft:leaves2",
|
||||
"quark:custom_chest{type:\"spruce\"}->quark:custom_chest;0",
|
||||
"quark:custom_chest{type:\"birch\"}->quark:custom_chest;1",
|
||||
"quark:custom_chest{type:\"jungle\"}->quark:custom_chest;2",
|
||||
|
|
@ -149,5 +146,24 @@ public class Configs {
|
|||
"storagedrawers:basicdrawers;4{Mat:\"dark_oak\"}->storagedrawers:basicdrawers;4{material:\"dark_oak\"}"
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static class CustomPickupConditions
|
||||
{
|
||||
@Config.RequiresMcRestart()
|
||||
@Comment("Custom Pickup Conditions for Blocks")
|
||||
public String[] customPickupConditionsBlocks = new String[]
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
@Config.RequiresMcRestart()
|
||||
@Comment("Custom Pickup Conditions for Entities")
|
||||
public String[] customPickupConditionsEntities = new String[]
|
||||
{
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
package tschipp.carryon.common.event;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EnumCreatureType;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.passive.EntityTameable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumHand;
|
||||
|
|
@ -15,8 +14,7 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
|||
import net.minecraftforge.fml.common.eventhandler.Event.Result;
|
||||
import net.minecraftforge.fml.common.eventhandler.EventPriority;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import tschipp.carryon.common.config.CarryOnConfig;
|
||||
import tschipp.carryon.common.handler.ForbiddenTileHandler;
|
||||
import tschipp.carryon.common.handler.PickupHandler;
|
||||
import tschipp.carryon.common.handler.RegistrationHandler;
|
||||
import tschipp.carryon.common.item.ItemEntity;
|
||||
|
||||
|
|
@ -58,42 +56,36 @@ public class ItemEntityEvents
|
|||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@SubscribeEvent(priority = EventPriority.NORMAL)
|
||||
public void onEntityRightClick(PlayerInteractEvent.EntityInteract event)
|
||||
{
|
||||
EntityPlayer player = event.getEntityPlayer();
|
||||
ItemStack main = player.getHeldItemMainhand();
|
||||
ItemStack off = player.getHeldItemOffhand();
|
||||
World world = event.getWorld();
|
||||
Entity entity = event.getTarget();
|
||||
BlockPos pos = entity.getPosition();
|
||||
|
||||
if (main.isEmpty() && off.isEmpty() && player.isSneaking())
|
||||
if (player instanceof EntityPlayerMP)
|
||||
{
|
||||
ItemStack stack = new ItemStack(RegistrationHandler.itemEntity);
|
||||
ItemStack main = player.getHeldItemMainhand();
|
||||
ItemStack off = player.getHeldItemOffhand();
|
||||
World world = event.getWorld();
|
||||
Entity entity = event.getTarget();
|
||||
BlockPos pos = entity.getPosition();
|
||||
|
||||
if (!(entity instanceof EntityPlayer) && !ForbiddenTileHandler.isForbidden(entity) && (CarryOnConfig.settings.pickupHostileMobs ? true : !entity.isCreatureType(EnumCreatureType.MONSTER, false) || player.isCreative()) && (entity.height <= CarryOnConfig.settings.maxEntityHeight && entity.width <= CarryOnConfig.settings.maxEntityWidth || player.isCreative()))
|
||||
if (main.isEmpty() && off.isEmpty() && player.isSneaking())
|
||||
{
|
||||
double distance = pos.distanceSqToCenter(player.posX, player.posY + 0.5, player.posZ);
|
||||
ItemStack stack = new ItemStack(RegistrationHandler.itemEntity);
|
||||
|
||||
if (distance < Math.pow(CarryOnConfig.settings.maxDistance, 2))
|
||||
if (PickupHandler.canPlayerPickUpEntity(player, entity))
|
||||
{
|
||||
if (entity instanceof EntityTameable)
|
||||
{
|
||||
EntityTameable tame = (EntityTameable) entity;
|
||||
if (tame.getOwnerId() != null && tame.getOwnerId() != player.getUUID(player.getGameProfile()))
|
||||
return;
|
||||
}
|
||||
if (ItemEntity.storeEntityData(entity, world, stack))
|
||||
{
|
||||
entity.setDead();
|
||||
player.setHeldItem(EnumHand.MAIN_HAND, stack);
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import net.minecraft.block.state.IBlockState;
|
|||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
|
@ -20,6 +21,7 @@ import net.minecraftforge.fml.common.eventhandler.EventPriority;
|
|||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import tschipp.carryon.common.config.CarryOnConfig;
|
||||
import tschipp.carryon.common.handler.ForbiddenTileHandler;
|
||||
import tschipp.carryon.common.handler.PickupHandler;
|
||||
import tschipp.carryon.common.handler.RegistrationHandler;
|
||||
import tschipp.carryon.common.item.ItemTile;
|
||||
|
||||
|
|
@ -79,38 +81,36 @@ public class ItemEvents
|
|||
public void onBlockRightClick(PlayerInteractEvent.RightClickBlock event)
|
||||
{
|
||||
EntityPlayer player = event.getEntityPlayer();
|
||||
ItemStack main = player.getHeldItemMainhand();
|
||||
ItemStack off = player.getHeldItemOffhand();
|
||||
World world = event.getWorld();
|
||||
BlockPos pos = event.getPos();
|
||||
Block block = world.getBlockState(pos).getBlock();
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
|
||||
if (main.isEmpty() && off.isEmpty() && player.isSneaking() && !ForbiddenTileHandler.isForbidden(block))
|
||||
if (player instanceof EntityPlayerMP)
|
||||
{
|
||||
ItemStack stack = new ItemStack(RegistrationHandler.itemTile);
|
||||
|
||||
TileEntity te = world.getTileEntity(pos);
|
||||
if ((CarryOnConfig.settings.pickupAllBlocks ? true : te != null) && (block.getBlockHardness(state, world, pos) != -1 || player.isCreative()))
|
||||
ItemStack main = player.getHeldItemMainhand();
|
||||
ItemStack off = player.getHeldItemOffhand();
|
||||
World world = event.getWorld();
|
||||
BlockPos pos = event.getPos();
|
||||
Block block = world.getBlockState(pos).getBlock();
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
|
||||
if (main.isEmpty() && off.isEmpty() && player.isSneaking() && !ForbiddenTileHandler.isForbidden(block))
|
||||
{
|
||||
double distance = pos.distanceSqToCenter(player.posX, player.posY + 0.5, player.posZ);
|
||||
ItemStack stack = new ItemStack(RegistrationHandler.itemTile);
|
||||
|
||||
if (distance < Math.pow(CarryOnConfig.settings.maxDistance, 2))
|
||||
TileEntity te = world.getTileEntity(pos);
|
||||
if (PickupHandler.canPlayerPickUpBlock(player, te, world, pos))
|
||||
{
|
||||
if (!ItemTile.isLocked(pos, world))
|
||||
if (ItemTile.storeTileData(te, world, pos, state.getActualState(world, pos), stack))
|
||||
{
|
||||
if (ItemTile.storeTileData(te, world, pos, state.getActualState(world, pos), stack))
|
||||
{
|
||||
world.removeTileEntity(pos);
|
||||
world.setBlockToAir(pos);
|
||||
player.setHeldItem(EnumHand.MAIN_HAND, stack);
|
||||
event.setUseBlock(Result.DENY);
|
||||
}
|
||||
world.removeTileEntity(pos);
|
||||
world.setBlockToAir(pos);
|
||||
player.setHeldItem(EnumHand.MAIN_HAND, stack);
|
||||
event.setUseBlock(Result.DENY);
|
||||
event.setCanceled(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,125 @@
|
|||
package tschipp.carryon.common.handler;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import tschipp.carryon.common.config.CarryOnConfig;
|
||||
import tschipp.carryon.common.helper.InvalidConfigException;
|
||||
|
||||
public class CustomPickupOverrideHandler
|
||||
{
|
||||
|
||||
public static HashMap<String, String> PICKUP_CONDITIONS = new HashMap<String, String>();
|
||||
public static HashMap<String, String> PICKUP_CONDITIONS_ENTITIES = new HashMap<String, String>();
|
||||
|
||||
public static void initPickupOverrides()
|
||||
{
|
||||
if (Loader.isModLoaded("gamestages"))
|
||||
{
|
||||
|
||||
String[] conditions = CarryOnConfig.customPickupConditions.customPickupConditionsBlocks;
|
||||
|
||||
for (int i = 0; i < conditions.length; i++)
|
||||
{
|
||||
String line = conditions[i];
|
||||
|
||||
if (!line.contains("(") || !line.contains(")"))
|
||||
new InvalidConfigException("Invalid Condition at line " + i + ": " + line).printException();
|
||||
|
||||
String condition = line.substring(line.indexOf("("));
|
||||
String blockname = line.replace(condition, "");
|
||||
condition = condition.replace("(", "");
|
||||
condition = condition.replace(")", "");
|
||||
|
||||
if (blockname.contains("*"))
|
||||
{
|
||||
String modid = blockname.replace("*", "");
|
||||
for (int k = 0; k < Block.REGISTRY.getKeys().size(); k++)
|
||||
{
|
||||
if (Block.REGISTRY.getKeys().toArray()[k].toString().contains(modid))
|
||||
{
|
||||
PICKUP_CONDITIONS.put(Block.REGISTRY.getKeys().toArray()[k].toString() + ";any", condition);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!blockname.contains(";"))
|
||||
blockname = blockname + ";any";
|
||||
|
||||
PICKUP_CONDITIONS.put(blockname, condition);
|
||||
}
|
||||
}
|
||||
|
||||
String[] entityConditions = CarryOnConfig.customPickupConditions.customPickupConditionsEntities;
|
||||
|
||||
for (int i = 0; i < entityConditions.length; i++)
|
||||
{
|
||||
String line = entityConditions[i];
|
||||
|
||||
if (!line.contains("(") || !line.contains(")"))
|
||||
new InvalidConfigException("Invalid Condition at line " + i + ": " + line).printException();
|
||||
|
||||
String condition = line.substring(line.indexOf("("));
|
||||
String entityname = line.replace(condition, "");
|
||||
condition = condition.replace("(", "");
|
||||
condition = condition.replace(")", "");
|
||||
|
||||
PICKUP_CONDITIONS_ENTITIES.put(entityname, condition);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean hasSpecialPickupConditions(IBlockState state)
|
||||
{
|
||||
if (!Loader.isModLoaded("gamestages"))
|
||||
return false;
|
||||
|
||||
String block = state.getBlock().getRegistryName().toString();
|
||||
String meta = "" + state.getBlock().getMetaFromState(state);
|
||||
|
||||
boolean absolute = PICKUP_CONDITIONS.containsKey(block + ";" + meta);
|
||||
boolean any = PICKUP_CONDITIONS.containsKey(block + ";any");
|
||||
|
||||
return absolute || any;
|
||||
}
|
||||
|
||||
public static String getPickupCondition(IBlockState state)
|
||||
{
|
||||
String block = state.getBlock().getRegistryName().toString();
|
||||
String meta = "" + state.getBlock().getMetaFromState(state);
|
||||
|
||||
String absolute = PICKUP_CONDITIONS.get(block + ";" + meta);
|
||||
String any = PICKUP_CONDITIONS.get(block + ";any");
|
||||
|
||||
if (absolute != null)
|
||||
return absolute;
|
||||
else
|
||||
return any;
|
||||
}
|
||||
|
||||
public static boolean hasSpecialPickupConditions(Entity entity)
|
||||
{
|
||||
if (!Loader.isModLoaded("gamestages"))
|
||||
return false;
|
||||
|
||||
String entityname = EntityList.getKey(entity).toString();
|
||||
boolean condition = PICKUP_CONDITIONS_ENTITIES.containsKey(entityname);
|
||||
|
||||
return condition;
|
||||
}
|
||||
|
||||
public static String getPickupCondition(Entity entity)
|
||||
{
|
||||
String entityname = EntityList.getKey(entity).toString();
|
||||
String condition = PICKUP_CONDITIONS_ENTITIES.get(entityname);
|
||||
|
||||
return condition;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -11,8 +11,8 @@ import tschipp.carryon.common.config.CarryOnConfig;
|
|||
|
||||
public class ForbiddenTileHandler
|
||||
{
|
||||
public static final List<String> FORBIDDEN_TILES;
|
||||
public static final List<String> FORBIDDEN_ENTITIES;
|
||||
public static List<String> FORBIDDEN_TILES;
|
||||
public static List<String> FORBIDDEN_ENTITIES;
|
||||
|
||||
public static boolean isForbidden(Block block)
|
||||
{
|
||||
|
|
@ -30,9 +30,9 @@ public class ForbiddenTileHandler
|
|||
return true;
|
||||
}
|
||||
|
||||
static
|
||||
public static void initForbiddenTiles()
|
||||
{
|
||||
String[] forbidden = CarryOnConfig.forbiddenTiles.forbiddenTiles;
|
||||
String[] forbidden = CarryOnConfig.blacklist.forbiddenTiles;
|
||||
FORBIDDEN_TILES = new ArrayList<String>();
|
||||
|
||||
for (int i = 0; i < forbidden.length; i++)
|
||||
|
|
@ -51,7 +51,7 @@ public class ForbiddenTileHandler
|
|||
FORBIDDEN_TILES.add(forbidden[i]);
|
||||
}
|
||||
|
||||
String[] forbiddenEntity = CarryOnConfig.forbiddenEntities.forbiddenEntities;
|
||||
String[] forbiddenEntity = CarryOnConfig.blacklist.forbiddenEntities;
|
||||
FORBIDDEN_ENTITIES = new ArrayList<String>();
|
||||
|
||||
for (int i = 0; i < forbiddenEntity.length; i++)
|
||||
|
|
|
|||
112
src/main/java/tschipp/carryon/common/handler/PickupHandler.java
Normal file
112
src/main/java/tschipp/carryon/common/handler/PickupHandler.java
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
package tschipp.carryon.common.handler;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.feed_the_beast.ftbl.lib.math.BlockPosContainer;
|
||||
import com.feed_the_beast.ftbu.FTBUPermissions;
|
||||
import com.feed_the_beast.ftbu.api.chunks.BlockInteractionType;
|
||||
import com.feed_the_beast.ftbu.api_impl.ClaimedChunkStorage;
|
||||
|
||||
import net.darkhax.gamestages.capabilities.PlayerDataHandler;
|
||||
import net.darkhax.gamestages.capabilities.PlayerDataHandler.IStageData;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EnumCreatureType;
|
||||
import net.minecraft.entity.passive.EntityTameable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import tschipp.carryon.common.config.CarryOnConfig;
|
||||
import tschipp.carryon.common.item.ItemTile;
|
||||
|
||||
public class PickupHandler
|
||||
{
|
||||
|
||||
public static boolean canPlayerPickUpBlock(EntityPlayer player, @Nullable TileEntity tile, World world, BlockPos pos)
|
||||
{
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
Block block = state.getBlock();
|
||||
|
||||
player.closeScreen();
|
||||
|
||||
if ((block.getBlockHardness(state, world, pos) != -1 || player.isCreative()))
|
||||
{
|
||||
double distance = pos.distanceSqToCenter(player.posX, player.posY + 0.5, player.posZ);
|
||||
|
||||
if (distance < Math.pow(CarryOnConfig.settings.maxDistance, 2))
|
||||
{
|
||||
if (!ItemTile.isLocked(pos, world))
|
||||
{
|
||||
if (CustomPickupOverrideHandler.hasSpecialPickupConditions(state))
|
||||
{
|
||||
IStageData stageData = PlayerDataHandler.getStageData(player);
|
||||
String condition = CustomPickupOverrideHandler.getPickupCondition(state);
|
||||
if (stageData.hasUnlockedStage(condition))
|
||||
return true && handleFTBUtils((EntityPlayerMP) player, world, pos, state);
|
||||
|
||||
}
|
||||
else if (CarryOnConfig.settings.pickupAllBlocks ? true : tile != null)
|
||||
{
|
||||
return true && handleFTBUtils((EntityPlayerMP) player, world, pos, state);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean canPlayerPickUpEntity(EntityPlayer player, Entity toPickUp)
|
||||
{
|
||||
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);
|
||||
String condition = CustomPickupOverrideHandler.getPickupCondition(toPickUp);
|
||||
if (stageData.hasUnlockedStage(condition))
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean handleFTBUtils(EntityPlayerMP player, World world, BlockPos pos, IBlockState state)
|
||||
{
|
||||
if (Loader.isModLoaded("ftbu"))
|
||||
{
|
||||
BlockPosContainer container = new BlockPosContainer(world, pos, state);
|
||||
return ClaimedChunkStorage.INSTANCE.canPlayerInteract((EntityPlayerMP) player, EnumHand.MAIN_HAND, container, BlockInteractionType.CNB_BREAK);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -44,6 +44,8 @@ public class RegistrationHandler
|
|||
public static void regOverrideList()
|
||||
{
|
||||
ModelOverridesHandler.initOverrides();
|
||||
CustomPickupOverrideHandler.initPickupOverrides();
|
||||
ForbiddenTileHandler.initForbiddenTiles();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ public class ItemEntity extends Item
|
|||
if(e == null)
|
||||
return 1;
|
||||
|
||||
int i = (int) (e.height * e.width);
|
||||
int i = (int) (e.height * e.width) / 300;
|
||||
if (i > 4)
|
||||
i = 4;
|
||||
|
||||
|
|
|
|||
|
|
@ -177,9 +177,6 @@ public class ItemTile extends Item
|
|||
|
||||
public static boolean storeTileData(@Nullable TileEntity tile, World world, BlockPos pos, IBlockState state, ItemStack stack)
|
||||
{
|
||||
if (CarryOnConfig.settings.pickupAllBlocks ? false : tile == null)
|
||||
return false;
|
||||
|
||||
if (stack.isEmpty())
|
||||
return false;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
carryon.category.settings=Settings
|
||||
carryon.category.forbiddentiles=Forbidden Tile Entities
|
||||
carryon.category.blacklist=Blacklist
|
||||
carryon.category.modeloverrides=Model Overrides (Advanced)
|
||||
carryon.category.forbiddenentities=Forbidden Entities
|
||||
carryon.category.custompickupconditions=Custom Pickup Conditions (Advanced)
|
||||
|
||||
carryon.general.modeloverrides.modeloverrides=Model Overrides
|
||||
carryon.general.forbiddenentities.forbiddenentities=Entities that the Player cannot pick up
|
||||
carryon.general.forbiddentiles.forbiddentiles=Blocks that the Player cannot pick up
|
||||
carryon.general.blacklist.forbiddenentities=Entities that the Player cannot pick up
|
||||
carryon.general.blacklist.forbiddentiles=Blocks that the Player cannot pick up
|
||||
carryon.category.custompickupconditions.custompickupconditionsblocks=Custom Block Pickup Conditions
|
||||
carryon.category.custompickupconditions.custompickupconditionsentities=Custom Entity Pickup Conditions
|
||||
|
|
|
|||
|
|
@ -2,13 +2,13 @@
|
|||
{
|
||||
"modid" : "carryon",
|
||||
"name" : "Carry On",
|
||||
"version" : "1.1.1", "mcversion" : "1.11.2",
|
||||
"version" : "1.2", "mcversion" : "1.11.2",
|
||||
"url" : "",
|
||||
"credits" : "Tschipp, Purplicious_Cow, cy4n",
|
||||
"authorList" : ["Tschipp, Purplicious_Cow, cy4n"],
|
||||
"description": "Carry On is a simple mod that improves game interaction by allowing players to pick up, carry, and place single block Tile Entities using only their empty hands.",
|
||||
"logoFile" : "assets/carryon/logo.png",
|
||||
"updateUrl" : "",
|
||||
"updateUrl" : "https://gist.githubusercontent.com/Tschipp/dccadee7c90d7a34e6e76a35d9d6fa2e/raw/5115328bf7c35d5c5cea64bdb58becd2ca17fcac/update.json",
|
||||
"parent" : "",
|
||||
"dependencies": [],
|
||||
"screenshots": []
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user