Merge branch 'master' into 1.10

This commit is contained in:
Tschipp 2017-08-14 15:00:26 +02:00
commit 95b56d78a8
3 changed files with 28 additions and 14 deletions

View File

@ -12,6 +12,12 @@ public class Configs {
@Comment("More complex Tile Entities slow down the player more")
public boolean heavyTiles = true;
@Comment("Allow all blocks to be picked up, not just Tile Entites")
public boolean pickupAllBlocks = false;
@Comment("Maximum distance from where Blocks can be picked up")
public double maxDistance = 2.5;
}
public static class ForbiddenTiles
@ -21,6 +27,8 @@ public class Configs {
{
"minecraft:end_portal",
"minecraft:end_gateway",
"minecraft:double_plant",
"minecraft:bed",
"animania:block_trough",
"animania:block_invisiblock",
"colossalchests:*",
@ -52,6 +60,7 @@ public class Configs {
public String[] modelOverrides = new String[]
{
"minecraft:lit_furnace->minecraft:furnace",
"minecraft:bed->minecraft:bed",
"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",

View File

@ -18,13 +18,14 @@ 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.RegistrationHandler;
import tschipp.carryon.common.item.ItemTile;
public class ItemEvents
{
@SubscribeEvent(priority = EventPriority.HIGH)
public void onBlockClick(PlayerInteractEvent.RightClickBlock event)
{
@ -74,7 +75,6 @@ public class ItemEvents
}
}
@SubscribeEvent
public void onBlockRightClick(PlayerInteractEvent.RightClickBlock event)
{
@ -91,17 +91,21 @@ public class ItemEvents
ItemStack stack = new ItemStack(RegistrationHandler.itemTile);
TileEntity te = world.getTileEntity(pos);
if (te != null && (block.getBlockHardness(state, world, pos) != -1 || player.isCreative()))
if ((CarryOnConfig.settings.pickupAllBlocks ? true : te != null) && (block.getBlockHardness(state, world, pos) != -1 || player.isCreative()))
{
double distance = pos.distanceSqToCenter(player.posX, player.posY + 0.5, player.posZ);
if (!ItemTile.isLocked(pos, world))
if (distance < Math.pow(CarryOnConfig.settings.maxDistance, 2))
{
if (ItemTile.storeTileData(te, state.getActualState(world, pos), stack))
if (!ItemTile.isLocked(pos, world))
{
world.removeTileEntity(pos);
world.setBlockToAir(pos);
player.setHeldItem(EnumHand.MAIN_HAND, stack);
event.setUseBlock(Result.DENY);
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);
}
}
}

View File

@ -161,16 +161,17 @@ public class ItemTile extends Item
return false;
}
public static boolean storeTileData(TileEntity tile, IBlockState state, ItemStack stack)
public static boolean storeTileData(@Nullable TileEntity tile, World world, BlockPos pos, IBlockState state, ItemStack stack)
{
if (tile == null)
if (CarryOnConfig.settings.pickupAllBlocks ? false : tile == null)
return false;
if (stack == null)
return false;
NBTTagCompound chest = new NBTTagCompound();
chest = tile.writeToNBT(chest);
if (tile != null)
chest = tile.writeToNBT(chest);
NBTTagCompound tag = stack.hasTagCompound() ? stack.getTagCompound() : new NBTTagCompound();
if (tag.hasKey(TILE_DATA_KEY))
@ -178,7 +179,7 @@ public class ItemTile extends Item
tag.setTag(TILE_DATA_KEY, chest);
ItemStack drop = state.getBlock().getItem(tile.getWorld(), tile.getPos(), state);
ItemStack drop = state.getBlock().getItem(world, pos, state);
tag.setString("block", state.getBlock().getRegistryName().toString());
Item item = Item.getItemFromBlock(state.getBlock());
@ -273,7 +274,7 @@ public class ItemTile extends Item
return tag.hasKey("Lock") ? !tag.getString("Lock").equals("") : false;
}
return true;
return false;
}
private boolean equal(Object[] a, Object[] b)