2012-08-06 02:15:13 +00:00
|
|
|
package net.minecraftforge.common;
|
|
|
|
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
import static net.minecraft.init.Blocks.diamond_block;
|
|
|
|
import static net.minecraft.init.Blocks.diamond_ore;
|
|
|
|
import static net.minecraft.init.Blocks.emerald_block;
|
|
|
|
import static net.minecraft.init.Blocks.emerald_ore;
|
|
|
|
import static net.minecraft.init.Blocks.gold_block;
|
|
|
|
import static net.minecraft.init.Blocks.gold_ore;
|
|
|
|
import static net.minecraft.init.Blocks.lit_redstone_ore;
|
|
|
|
import static net.minecraft.init.Blocks.redstone_ore;
|
2014-12-23 23:04:41 +00:00
|
|
|
|
|
|
|
import java.net.URI;
|
2015-02-17 06:46:55 +00:00
|
|
|
import java.net.URISyntaxException;
|
2013-06-30 12:50:11 +00:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
import java.util.Random;
|
2013-12-13 07:32:36 +00:00
|
|
|
import java.util.Set;
|
2014-12-23 23:04:41 +00:00
|
|
|
import java.util.regex.Matcher;
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
2012-12-13 07:27:57 +00:00
|
|
|
import net.minecraft.block.Block;
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
import net.minecraft.block.BlockLiquid;
|
|
|
|
import net.minecraft.block.material.Material;
|
|
|
|
import net.minecraft.block.state.IBlockState;
|
|
|
|
import net.minecraft.client.gui.GuiScreen;
|
|
|
|
import net.minecraft.entity.Entity;
|
2013-06-30 12:50:11 +00:00
|
|
|
import net.minecraft.entity.EntityLivingBase;
|
2012-12-13 07:27:57 +00:00
|
|
|
import net.minecraft.entity.item.EntityItem;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2013-10-09 00:00:02 +00:00
|
|
|
import net.minecraft.entity.player.EntityPlayerMP;
|
2014-12-23 23:04:41 +00:00
|
|
|
import net.minecraft.event.ClickEvent;
|
2013-12-13 07:32:36 +00:00
|
|
|
import net.minecraft.init.Blocks;
|
|
|
|
import net.minecraft.init.Items;
|
2013-10-09 00:00:02 +00:00
|
|
|
import net.minecraft.inventory.Container;
|
2014-04-03 01:33:13 +00:00
|
|
|
import net.minecraft.inventory.ContainerRepair;
|
|
|
|
import net.minecraft.inventory.IInventory;
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
import net.minecraft.inventory.InventoryCrafting;
|
2014-08-27 02:47:22 +00:00
|
|
|
import net.minecraft.item.Item;
|
2012-12-13 07:27:57 +00:00
|
|
|
import net.minecraft.item.ItemArmor;
|
|
|
|
import net.minecraft.item.ItemAxe;
|
2014-08-27 02:47:22 +00:00
|
|
|
import net.minecraft.item.ItemBucket;
|
2012-12-13 07:27:57 +00:00
|
|
|
import net.minecraft.item.ItemPickaxe;
|
|
|
|
import net.minecraft.item.ItemSpade;
|
|
|
|
import net.minecraft.item.ItemStack;
|
2013-10-09 00:00:02 +00:00
|
|
|
import net.minecraft.item.ItemSword;
|
2014-08-27 02:47:22 +00:00
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
import net.minecraft.nbt.NBTTagList;
|
|
|
|
import net.minecraft.nbt.NBTTagString;
|
2013-12-21 08:10:35 +00:00
|
|
|
import net.minecraft.network.NetHandlerPlayServer;
|
2013-12-13 07:32:36 +00:00
|
|
|
import net.minecraft.network.Packet;
|
2013-12-21 08:10:35 +00:00
|
|
|
import net.minecraft.network.play.server.S23PacketBlockChange;
|
2014-08-27 02:47:22 +00:00
|
|
|
import net.minecraft.stats.StatList;
|
2013-10-09 00:00:02 +00:00
|
|
|
import net.minecraft.tileentity.TileEntity;
|
2014-06-02 23:57:04 +00:00
|
|
|
import net.minecraft.tileentity.TileEntityNote;
|
2013-08-11 02:39:06 +00:00
|
|
|
import net.minecraft.util.AxisAlignedBB;
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
import net.minecraft.util.BlockPos;
|
2014-12-23 23:04:41 +00:00
|
|
|
import net.minecraft.util.ChatComponentText;
|
2013-12-21 08:10:35 +00:00
|
|
|
import net.minecraft.util.ChatComponentTranslation;
|
2012-12-13 07:27:57 +00:00
|
|
|
import net.minecraft.util.DamageSource;
|
2015-11-04 21:57:47 +00:00
|
|
|
import net.minecraft.util.EnumChatFormatting;
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
import net.minecraft.util.EnumFacing;
|
2014-12-23 23:04:41 +00:00
|
|
|
import net.minecraft.util.IChatComponent;
|
2013-08-11 02:39:06 +00:00
|
|
|
import net.minecraft.util.MathHelper;
|
2012-12-13 07:27:57 +00:00
|
|
|
import net.minecraft.util.MovingObjectPosition;
|
2013-12-21 08:10:35 +00:00
|
|
|
import net.minecraft.util.MovingObjectPosition.MovingObjectType;
|
2012-12-13 07:27:57 +00:00
|
|
|
import net.minecraft.util.WeightedRandom;
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
import net.minecraft.world.IBlockAccess;
|
2012-12-13 07:27:57 +00:00
|
|
|
import net.minecraft.world.World;
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
import net.minecraft.world.WorldSettings;
|
2013-12-21 08:10:35 +00:00
|
|
|
import net.minecraft.world.WorldSettings.GameType;
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
import net.minecraft.world.gen.feature.WorldGeneratorBonusChest;
|
|
|
|
import net.minecraftforge.common.util.BlockSnapshot;
|
2014-04-03 01:33:13 +00:00
|
|
|
import net.minecraftforge.event.AnvilUpdateEvent;
|
2014-08-27 02:47:22 +00:00
|
|
|
import net.minecraftforge.event.ForgeEventFactory;
|
2013-06-30 12:50:11 +00:00
|
|
|
import net.minecraftforge.event.ServerChatEvent;
|
2012-09-11 22:27:34 +00:00
|
|
|
import net.minecraftforge.event.entity.item.ItemTossEvent;
|
2013-06-30 12:50:11 +00:00
|
|
|
import net.minecraftforge.event.entity.living.LivingAttackEvent;
|
|
|
|
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
|
|
|
import net.minecraftforge.event.entity.living.LivingDropsEvent;
|
|
|
|
import net.minecraftforge.event.entity.living.LivingEvent.LivingJumpEvent;
|
|
|
|
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
|
|
|
|
import net.minecraftforge.event.entity.living.LivingFallEvent;
|
|
|
|
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
|
|
|
import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent;
|
2014-08-04 20:54:35 +00:00
|
|
|
import net.minecraftforge.event.entity.player.AnvilRepairEvent;
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
import net.minecraftforge.event.entity.player.AttackEntityEvent;
|
|
|
|
import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent;
|
|
|
|
import net.minecraftforge.event.entity.player.PlayerOpenContainerEvent;
|
2013-10-09 00:00:02 +00:00
|
|
|
import net.minecraftforge.event.world.BlockEvent;
|
2014-06-02 23:57:04 +00:00
|
|
|
import net.minecraftforge.event.world.NoteBlockEvent;
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
import net.minecraftforge.fluids.IFluidBlock;
|
|
|
|
import net.minecraftforge.fml.common.eventhandler.Event;
|
|
|
|
import net.minecraftforge.fml.relauncher.ReflectionHelper;
|
2012-08-06 02:15:13 +00:00
|
|
|
|
|
|
|
public class ForgeHooks
|
|
|
|
{
|
2013-12-13 07:32:36 +00:00
|
|
|
static class SeedEntry extends WeightedRandom.Item
|
2012-08-06 02:15:13 +00:00
|
|
|
{
|
|
|
|
public final ItemStack seed;
|
|
|
|
public SeedEntry(ItemStack seed, int weight)
|
|
|
|
{
|
|
|
|
super(weight);
|
|
|
|
this.seed = seed;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
static final List<SeedEntry> seedList = new ArrayList<SeedEntry>();
|
2012-09-09 14:02:21 +00:00
|
|
|
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
public static ItemStack getGrassSeed(Random rand)
|
2012-08-06 02:41:18 +00:00
|
|
|
{
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
SeedEntry entry = (SeedEntry)WeightedRandom.getRandomItem(rand, seedList);
|
2012-08-06 02:41:18 +00:00
|
|
|
if (entry == null || entry.seed == null)
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return entry.seed.copy();
|
|
|
|
}
|
2012-09-09 14:02:21 +00:00
|
|
|
|
2012-08-06 10:35:57 +00:00
|
|
|
private static boolean toolInit = false;
|
2013-12-24 04:34:39 +00:00
|
|
|
//static HashSet<List> toolEffectiveness = new HashSet<List>();
|
2012-09-09 14:02:21 +00:00
|
|
|
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
public static boolean canHarvestBlock(Block block, EntityPlayer player, IBlockAccess world, BlockPos pos)
|
2012-08-06 10:35:57 +00:00
|
|
|
{
|
2014-02-05 08:05:37 +00:00
|
|
|
if (block.getMaterial().isToolNotRequired())
|
2012-08-06 10:35:57 +00:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2012-08-11 21:45:48 +00:00
|
|
|
|
2012-08-06 10:35:57 +00:00
|
|
|
ItemStack stack = player.inventory.getCurrentItem();
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
IBlockState state = world.getBlockState(pos);
|
|
|
|
state = state.getBlock().getActualState(state, world, pos);
|
|
|
|
String tool = block.getHarvestTool(state);
|
2013-12-21 08:10:35 +00:00
|
|
|
if (stack == null || tool == null)
|
2012-08-06 10:35:57 +00:00
|
|
|
{
|
2014-02-05 08:05:37 +00:00
|
|
|
return player.canHarvestBlock(block);
|
2012-08-06 10:35:57 +00:00
|
|
|
}
|
|
|
|
|
2013-12-21 08:10:35 +00:00
|
|
|
int toolLevel = stack.getItem().getHarvestLevel(stack, tool);
|
|
|
|
if (toolLevel < 0)
|
2012-08-06 10:35:57 +00:00
|
|
|
{
|
2014-02-05 08:05:37 +00:00
|
|
|
return player.canHarvestBlock(block);
|
2012-08-06 10:35:57 +00:00
|
|
|
}
|
2012-08-11 21:45:48 +00:00
|
|
|
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
return toolLevel >= block.getHarvestLevel(state);
|
2012-08-06 10:35:57 +00:00
|
|
|
}
|
2013-04-10 20:37:25 +00:00
|
|
|
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
public static boolean canToolHarvestBlock(IBlockAccess world, BlockPos pos, ItemStack stack)
|
2012-12-26 06:02:30 +00:00
|
|
|
{
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
IBlockState state = world.getBlockState(pos);
|
|
|
|
state = state.getBlock().getActualState(state, world, pos);
|
|
|
|
String tool = state.getBlock().getHarvestTool(state);
|
2013-12-21 08:10:35 +00:00
|
|
|
if (stack == null || tool == null) return false;
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
return stack.getItem().getHarvestLevel(stack, tool) >= state.getBlock().getHarvestLevel(state);
|
2012-12-26 06:02:30 +00:00
|
|
|
}
|
2012-08-06 10:35:57 +00:00
|
|
|
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
public static float blockStrength(IBlockState state, EntityPlayer player, World world, BlockPos pos)
|
2012-08-06 10:35:57 +00:00
|
|
|
{
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
float hardness = state.getBlock().getBlockHardness(world, pos);
|
2012-08-06 10:35:57 +00:00
|
|
|
if (hardness < 0.0F)
|
|
|
|
{
|
|
|
|
return 0.0F;
|
|
|
|
}
|
|
|
|
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
if (!canHarvestBlock(state.getBlock(), player, world, pos))
|
2012-08-06 10:35:57 +00:00
|
|
|
{
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
return player.getBreakSpeed(state, pos) / hardness / 100F;
|
2012-08-06 10:35:57 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
return player.getBreakSpeed(state, pos) / hardness / 30F;
|
2012-08-06 10:35:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
public static boolean isToolEffective(IBlockAccess world, BlockPos pos, ItemStack stack)
|
2012-08-06 10:35:57 +00:00
|
|
|
{
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
IBlockState state = world.getBlockState(pos);
|
|
|
|
state = state.getBlock().getActualState(state, world, pos);
|
2013-12-21 08:10:35 +00:00
|
|
|
for (String type : stack.getItem().getToolClasses(stack))
|
|
|
|
{
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
if (state.getBlock().isToolEffective(type, state))
|
2013-12-21 08:10:35 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2012-08-06 10:35:57 +00:00
|
|
|
}
|
2012-09-09 14:02:21 +00:00
|
|
|
|
2012-08-06 10:35:57 +00:00
|
|
|
static void initTools()
|
|
|
|
{
|
|
|
|
if (toolInit)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
toolInit = true;
|
|
|
|
|
2013-12-13 07:32:36 +00:00
|
|
|
Set<Block> blocks = ReflectionHelper.getPrivateValue(ItemPickaxe.class, null, 0);
|
|
|
|
for (Block block : blocks)
|
2012-08-06 10:35:57 +00:00
|
|
|
{
|
2013-12-21 08:10:35 +00:00
|
|
|
block.setHarvestLevel("pickaxe", 0);
|
2012-08-06 10:35:57 +00:00
|
|
|
}
|
|
|
|
|
2013-12-13 07:32:36 +00:00
|
|
|
blocks = ReflectionHelper.getPrivateValue(ItemSpade.class, null, 0);
|
|
|
|
for (Block block : blocks)
|
2012-08-06 10:35:57 +00:00
|
|
|
{
|
2013-12-21 08:10:35 +00:00
|
|
|
block.setHarvestLevel("shovel", 0);
|
2012-08-06 10:35:57 +00:00
|
|
|
}
|
|
|
|
|
2013-12-13 07:32:36 +00:00
|
|
|
blocks = ReflectionHelper.getPrivateValue(ItemAxe.class, null, 0);
|
|
|
|
for (Block block : blocks)
|
2012-08-06 10:35:57 +00:00
|
|
|
{
|
2013-12-21 08:10:35 +00:00
|
|
|
block.setHarvestLevel("axe", 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
Blocks.obsidian.setHarvestLevel("pickaxe", 3);
|
|
|
|
for (Block block : new Block[]{emerald_ore, emerald_block, diamond_ore, diamond_block, gold_ore, gold_block, redstone_ore, lit_redstone_ore})
|
|
|
|
{
|
|
|
|
block.setHarvestLevel("pickaxe", 2);
|
|
|
|
}
|
|
|
|
Blocks.iron_ore.setHarvestLevel("pickaxe", 1);
|
|
|
|
Blocks.iron_block.setHarvestLevel("pickaxe", 1);
|
|
|
|
Blocks.lapis_ore.setHarvestLevel("pickaxe", 1);
|
|
|
|
Blocks.lapis_block.setHarvestLevel("pickaxe", 1);
|
2014-12-07 11:41:53 +00:00
|
|
|
Blocks.quartz_ore.setHarvestLevel("pickaxe", 0);
|
2012-08-06 10:35:57 +00:00
|
|
|
}
|
|
|
|
|
2012-08-06 22:07:53 +00:00
|
|
|
public static int getTotalArmorValue(EntityPlayer player)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
for (int x = 0; x < player.inventory.armorInventory.length; x++)
|
|
|
|
{
|
|
|
|
ItemStack stack = player.inventory.armorInventory[x];
|
|
|
|
if (stack != null && stack.getItem() instanceof ISpecialArmor)
|
|
|
|
{
|
|
|
|
ret += ((ISpecialArmor)stack.getItem()).getArmorDisplay(player, stack, x);
|
|
|
|
}
|
|
|
|
else if (stack != null && stack.getItem() instanceof ItemArmor)
|
|
|
|
{
|
|
|
|
ret += ((ItemArmor)stack.getItem()).damageReduceAmount;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
2012-09-09 14:02:21 +00:00
|
|
|
|
2012-08-06 22:07:53 +00:00
|
|
|
static
|
|
|
|
{
|
2013-12-13 07:32:36 +00:00
|
|
|
seedList.add(new SeedEntry(new ItemStack(Items.wheat_seeds), 10));
|
2012-08-06 22:07:53 +00:00
|
|
|
initTools();
|
|
|
|
}
|
2012-08-07 08:24:06 +00:00
|
|
|
|
2012-08-10 09:09:11 +00:00
|
|
|
/**
|
|
|
|
* Called when a player uses 'pick block', calls new Entity and Block hooks.
|
|
|
|
*/
|
|
|
|
public static boolean onPickBlock(MovingObjectPosition target, EntityPlayer player, World world)
|
|
|
|
{
|
LoadingScreenRenderer,Minecraft,GuiContainerCreative,PlayerControllerMP,LanguageManager,Locale,SimpleReloadableResourceManager,EntityList,EntityLivingBase,EntityWither,EntityMinecart,EntityPlayerMP
NethanlderPlayClient patch is now in vanilla. The FMLCommonHandler future exception catcher is not needed anymore, it's in Util. The caching of player profiles is now in vanilla (SkinManager).
2015-11-11 15:33:37 +00:00
|
|
|
/*
|
|
|
|
int i = 0;
|
|
|
|
boolean flag1 = false;
|
|
|
|
TileEntity tileentity = null;
|
|
|
|
Item item;
|
|
|
|
|
|
|
|
if (this.objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
|
|
|
|
{
|
|
|
|
BlockPos blockpos = this.objectMouseOver.getBlockPos();
|
|
|
|
Block block = this.theWorld.getBlockState(blockpos).getBlock();
|
|
|
|
|
|
|
|
if (block.getMaterial() == Material.air)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
item = block.getItem(this.theWorld, blockpos);
|
|
|
|
|
|
|
|
if (item == null)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flag && GuiScreen.isCtrlKeyDown())
|
|
|
|
{
|
|
|
|
tileentity = this.theWorld.getTileEntity(blockpos);
|
|
|
|
}
|
|
|
|
|
|
|
|
Block block1 = item instanceof ItemBlock && !block.isFlowerPot() ? Block.getBlockFromItem(item) : block;
|
|
|
|
i = block1.getDamageValue(this.theWorld, blockpos);
|
|
|
|
flag1 = item.getHasSubtypes();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (this.objectMouseOver.typeOfHit != MovingObjectPosition.MovingObjectType.ENTITY || this.objectMouseOver.entityHit == null || !flag)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.objectMouseOver.entityHit instanceof EntityPainting)
|
|
|
|
{
|
|
|
|
item = Items.painting;
|
|
|
|
}
|
|
|
|
else if (this.objectMouseOver.entityHit instanceof EntityLeashKnot)
|
|
|
|
{
|
|
|
|
item = Items.lead;
|
|
|
|
}
|
|
|
|
else if (this.objectMouseOver.entityHit instanceof EntityItemFrame)
|
|
|
|
{
|
|
|
|
EntityItemFrame entityitemframe = (EntityItemFrame)this.objectMouseOver.entityHit;
|
|
|
|
ItemStack itemstack = entityitemframe.getDisplayedItem();
|
|
|
|
|
|
|
|
if (itemstack == null)
|
|
|
|
{
|
|
|
|
item = Items.item_frame;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
item = itemstack.getItem();
|
|
|
|
i = itemstack.getMetadata();
|
|
|
|
flag1 = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (this.objectMouseOver.entityHit instanceof EntityMinecart)
|
|
|
|
{
|
|
|
|
EntityMinecart entityminecart = (EntityMinecart)this.objectMouseOver.entityHit;
|
|
|
|
|
|
|
|
switch (entityminecart.getMinecartType())
|
|
|
|
{
|
|
|
|
case FURNACE:
|
|
|
|
item = Items.furnace_minecart;
|
|
|
|
break;
|
|
|
|
case CHEST:
|
|
|
|
item = Items.chest_minecart;
|
|
|
|
break;
|
|
|
|
case TNT:
|
|
|
|
item = Items.tnt_minecart;
|
|
|
|
break;
|
|
|
|
case HOPPER:
|
|
|
|
item = Items.hopper_minecart;
|
|
|
|
break;
|
|
|
|
case COMMAND_BLOCK:
|
|
|
|
item = Items.command_block_minecart;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
item = Items.minecart;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (this.objectMouseOver.entityHit instanceof EntityBoat)
|
|
|
|
{
|
|
|
|
item = Items.boat;
|
|
|
|
}
|
|
|
|
else if (this.objectMouseOver.entityHit instanceof EntityArmorStand)
|
|
|
|
{
|
|
|
|
item = Items.armor_stand;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
item = Items.spawn_egg;
|
|
|
|
i = EntityList.getEntityID(this.objectMouseOver.entityHit);
|
|
|
|
flag1 = true;
|
|
|
|
|
|
|
|
if (!EntityList.entityEggs.containsKey(Integer.valueOf(i)))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
InventoryPlayer inventoryplayer = this.thePlayer.inventory;
|
|
|
|
|
|
|
|
if (tileentity == null)
|
|
|
|
{
|
|
|
|
inventoryplayer.setCurrentItem(item, i, flag1, flag);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ItemStack itemstack1 = this.func_181036_a(item, i, tileentity);
|
|
|
|
inventoryplayer.setInventorySlotContents(inventoryplayer.currentItem, itemstack1);
|
|
|
|
}
|
|
|
|
*/
|
2012-08-10 09:09:11 +00:00
|
|
|
ItemStack result = null;
|
|
|
|
boolean isCreative = player.capabilities.isCreativeMode;
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
TileEntity te = null;
|
2012-08-10 09:09:11 +00:00
|
|
|
|
2013-12-21 08:10:35 +00:00
|
|
|
if (target.typeOfHit == MovingObjectType.BLOCK)
|
2012-08-10 09:09:11 +00:00
|
|
|
{
|
2014-12-02 03:11:17 +00:00
|
|
|
IBlockState state = world.getBlockState(target.getBlockPos());
|
2012-08-10 09:09:11 +00:00
|
|
|
|
2014-12-02 03:11:17 +00:00
|
|
|
if (state.getBlock().isAir(world, target.getBlockPos()))
|
2012-08-10 09:09:11 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
if (isCreative && GuiScreen.isCtrlKeyDown())
|
2014-12-02 03:11:17 +00:00
|
|
|
te = world.getTileEntity(target.getBlockPos());
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
|
2015-04-09 06:09:58 +00:00
|
|
|
result = state.getBlock().getPickBlock(target, world, target.getBlockPos(), player);
|
2012-08-10 09:09:11 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-12-21 08:10:35 +00:00
|
|
|
if (target.typeOfHit != MovingObjectType.ENTITY || target.entityHit == null || !isCreative)
|
2012-08-10 09:09:11 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
result = target.entityHit.getPickedResult(target);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (result == null)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
if (te != null)
|
|
|
|
{
|
|
|
|
NBTTagCompound nbt = new NBTTagCompound();
|
|
|
|
te.writeToNBT(nbt);
|
|
|
|
result.setTagInfo("BlockEntityTag", nbt);
|
|
|
|
|
|
|
|
NBTTagCompound display = new NBTTagCompound();
|
|
|
|
result.setTagInfo("display", display);
|
|
|
|
|
|
|
|
NBTTagList lore = new NBTTagList();
|
|
|
|
display.setTag("Lore", lore);
|
|
|
|
lore.appendTag(new NBTTagString("(+NBT)"));
|
|
|
|
}
|
|
|
|
|
2012-08-10 09:09:11 +00:00
|
|
|
for (int x = 0; x < 9; x++)
|
|
|
|
{
|
|
|
|
ItemStack stack = player.inventory.getStackInSlot(x);
|
2012-10-31 17:16:46 +00:00
|
|
|
if (stack != null && stack.isItemEqual(result) && ItemStack.areItemStackTagsEqual(stack, result))
|
2012-08-10 09:09:11 +00:00
|
|
|
{
|
|
|
|
player.inventory.currentItem = x;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!isCreative)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
int slot = player.inventory.getFirstEmptyStack();
|
|
|
|
if (slot < 0 || slot >= 9)
|
|
|
|
{
|
2012-08-22 20:46:01 +00:00
|
|
|
slot = player.inventory.currentItem;
|
2012-08-10 09:09:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
player.inventory.setInventorySlotContents(slot, result);
|
2012-08-14 06:05:39 +00:00
|
|
|
player.inventory.currentItem = slot;
|
2012-08-10 09:09:11 +00:00
|
|
|
return true;
|
|
|
|
}
|
2012-08-23 01:02:14 +00:00
|
|
|
|
|
|
|
//Optifine Helper Functions u.u, these are here specifically for Optifine
|
|
|
|
//Note: When using Optfine, these methods are invoked using reflection, which
|
|
|
|
//incurs a major performance penalty.
|
2013-06-30 12:50:11 +00:00
|
|
|
public static void onLivingSetAttackTarget(EntityLivingBase entity, EntityLivingBase target)
|
2012-08-23 01:02:14 +00:00
|
|
|
{
|
|
|
|
MinecraftForge.EVENT_BUS.post(new LivingSetAttackTargetEvent(entity, target));
|
|
|
|
}
|
|
|
|
|
2013-06-30 12:50:11 +00:00
|
|
|
public static boolean onLivingUpdate(EntityLivingBase entity)
|
2012-08-23 01:02:14 +00:00
|
|
|
{
|
|
|
|
return MinecraftForge.EVENT_BUS.post(new LivingUpdateEvent(entity));
|
|
|
|
}
|
|
|
|
|
2013-06-30 12:50:11 +00:00
|
|
|
public static boolean onLivingAttack(EntityLivingBase entity, DamageSource src, float amount)
|
2012-08-23 01:02:14 +00:00
|
|
|
{
|
2014-11-28 15:43:10 +00:00
|
|
|
return !MinecraftForge.EVENT_BUS.post(new LivingAttackEvent(entity, src, amount));
|
2012-08-23 01:02:14 +00:00
|
|
|
}
|
|
|
|
|
2013-06-30 12:50:11 +00:00
|
|
|
public static float onLivingHurt(EntityLivingBase entity, DamageSource src, float amount)
|
2012-08-23 01:02:14 +00:00
|
|
|
{
|
|
|
|
LivingHurtEvent event = new LivingHurtEvent(entity, src, amount);
|
|
|
|
return (MinecraftForge.EVENT_BUS.post(event) ? 0 : event.ammount);
|
|
|
|
}
|
|
|
|
|
2013-06-30 12:50:11 +00:00
|
|
|
public static boolean onLivingDeath(EntityLivingBase entity, DamageSource src)
|
2012-08-23 01:02:14 +00:00
|
|
|
{
|
|
|
|
return MinecraftForge.EVENT_BUS.post(new LivingDeathEvent(entity, src));
|
|
|
|
}
|
|
|
|
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
public static boolean onLivingDrops(EntityLivingBase entity, DamageSource source, ArrayList<EntityItem> drops, int lootingLevel, boolean recentlyHit)
|
2012-08-23 01:02:14 +00:00
|
|
|
{
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
return MinecraftForge.EVENT_BUS.post(new LivingDropsEvent(entity, source, drops, lootingLevel, recentlyHit));
|
2012-08-23 01:02:14 +00:00
|
|
|
}
|
|
|
|
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
public static float[] onLivingFall(EntityLivingBase entity, float distance, float damageMultiplier)
|
2012-08-23 01:02:14 +00:00
|
|
|
{
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
LivingFallEvent event = new LivingFallEvent(entity, distance, damageMultiplier);
|
|
|
|
return (MinecraftForge.EVENT_BUS.post(event) ? null : new float[]{event.distance, event.damageMultiplier});
|
2012-08-23 01:02:14 +00:00
|
|
|
}
|
|
|
|
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
public static boolean isLivingOnLadder(Block block, World world, BlockPos pos, EntityLivingBase entity)
|
2013-06-14 18:51:28 +00:00
|
|
|
{
|
2014-12-02 03:11:17 +00:00
|
|
|
boolean isSpectator = (entity instanceof EntityPlayer && ((EntityPlayer)entity).isSpectator());
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
if (isSpectator) return false;
|
2013-12-13 07:32:36 +00:00
|
|
|
if (!ForgeModContainer.fullBoundingBoxLadders)
|
2013-08-11 02:39:06 +00:00
|
|
|
{
|
2014-11-30 07:03:55 +00:00
|
|
|
return block != null && block.isLadder(world, pos, entity);
|
2013-08-11 02:39:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
AxisAlignedBB bb = entity.getEntityBoundingBox();
|
2013-08-11 02:39:06 +00:00
|
|
|
int mX = MathHelper.floor_double(bb.minX);
|
|
|
|
int mY = MathHelper.floor_double(bb.minY);
|
|
|
|
int mZ = MathHelper.floor_double(bb.minZ);
|
2013-09-25 05:46:18 +00:00
|
|
|
for (int y2 = mY; y2 < bb.maxY; y2++)
|
2013-08-11 02:39:06 +00:00
|
|
|
{
|
|
|
|
for (int x2 = mX; x2 < bb.maxX; x2++)
|
|
|
|
{
|
|
|
|
for (int z2 = mZ; z2 < bb.maxZ; z2++)
|
|
|
|
{
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
BlockPos tmp = new BlockPos(x2, y2, z2);
|
|
|
|
if (world.getBlockState(tmp).getBlock().isLadder(world, tmp, entity))
|
2013-08-11 02:39:06 +00:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2013-06-14 18:51:28 +00:00
|
|
|
}
|
2012-08-23 01:02:14 +00:00
|
|
|
|
2013-06-30 12:50:11 +00:00
|
|
|
public static void onLivingJump(EntityLivingBase entity)
|
2012-08-23 01:02:14 +00:00
|
|
|
{
|
|
|
|
MinecraftForge.EVENT_BUS.post(new LivingJumpEvent(entity));
|
|
|
|
}
|
2012-09-11 22:27:34 +00:00
|
|
|
|
2013-12-21 08:10:35 +00:00
|
|
|
public static EntityItem onPlayerTossEvent(EntityPlayer player, ItemStack item, boolean includeName)
|
2012-09-11 22:27:34 +00:00
|
|
|
{
|
|
|
|
player.captureDrops = true;
|
2014-12-02 03:11:17 +00:00
|
|
|
EntityItem ret = player.dropItem(item, false, includeName);
|
2012-09-11 22:27:34 +00:00
|
|
|
player.capturedDrops.clear();
|
|
|
|
player.captureDrops = false;
|
|
|
|
|
2013-08-19 17:45:57 +00:00
|
|
|
if (ret == null)
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2012-09-11 22:27:34 +00:00
|
|
|
ItemTossEvent event = new ItemTossEvent(ret, player);
|
|
|
|
if (MinecraftForge.EVENT_BUS.post(event))
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
player.joinEntityItemWithWorld(event.entityItem);
|
|
|
|
return event.entityItem;
|
|
|
|
}
|
2013-04-10 23:56:31 +00:00
|
|
|
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
public static float getEnchantPower(World world, BlockPos pos)
|
2013-04-10 23:56:31 +00:00
|
|
|
{
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
return world.getBlockState(pos).getBlock().getEnchantPowerBonus(world, pos);
|
2013-04-10 23:56:31 +00:00
|
|
|
}
|
2013-06-30 12:50:11 +00:00
|
|
|
|
2015-11-13 15:13:47 +00:00
|
|
|
@SuppressWarnings("deprecation")
|
2013-12-21 08:10:35 +00:00
|
|
|
public static ChatComponentTranslation onServerChatEvent(NetHandlerPlayServer net, String raw, ChatComponentTranslation comp)
|
2013-06-30 12:50:11 +00:00
|
|
|
{
|
2014-02-05 08:05:37 +00:00
|
|
|
ServerChatEvent event = new ServerChatEvent(net.playerEntity, raw, comp);
|
2013-06-30 12:50:11 +00:00
|
|
|
if (MinecraftForge.EVENT_BUS.post(event))
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return event.component;
|
|
|
|
}
|
2013-12-28 02:26:42 +00:00
|
|
|
|
2014-12-23 23:04:41 +00:00
|
|
|
|
|
|
|
static final Pattern URL_PATTERN = Pattern.compile(
|
|
|
|
// schema ipv4 OR namespace port path ends
|
|
|
|
// |-----------------| |-------------------------| |----------------------------| |---------| |--| |---------------|
|
|
|
|
"((?:[a-z0-9]{2,}:\\/\\/)?(?:(?:[0-9]{1,3}\\.){3}[0-9]{1,3}|(?:[-\\w_\\.]{1,}\\.[a-z]{2,}?))(?::[0-9]{1,5})?.*?(?=[!\"\u00A7 \n]|$))",
|
|
|
|
Pattern.CASE_INSENSITIVE);
|
|
|
|
|
2015-11-04 21:57:47 +00:00
|
|
|
public static IChatComponent newChatWithLinks(String string){ return newChatWithLinks(string, true); }
|
|
|
|
public static IChatComponent newChatWithLinks(String string, boolean allowMissingHeader)
|
2014-12-23 23:04:41 +00:00
|
|
|
{
|
|
|
|
// Includes ipv4 and domain pattern
|
|
|
|
// Matches an ip (xx.xxx.xx.xxx) or a domain (something.com) with or
|
|
|
|
// without a protocol or path.
|
2015-11-04 21:57:47 +00:00
|
|
|
IChatComponent ichat = null;
|
2014-12-23 23:04:41 +00:00
|
|
|
Matcher matcher = URL_PATTERN.matcher(string);
|
|
|
|
int lastEnd = 0;
|
|
|
|
|
|
|
|
// Find all urls
|
|
|
|
while (matcher.find())
|
|
|
|
{
|
|
|
|
int start = matcher.start();
|
|
|
|
int end = matcher.end();
|
|
|
|
|
|
|
|
// Append the previous left overs.
|
2015-11-04 21:57:47 +00:00
|
|
|
String part = string.substring(lastEnd, start);
|
|
|
|
if (part.length() > 0)
|
|
|
|
{
|
|
|
|
if (ichat == null)
|
|
|
|
ichat = new ChatComponentText(part);
|
|
|
|
else
|
|
|
|
ichat.appendText(part);
|
|
|
|
}
|
2014-12-23 23:04:41 +00:00
|
|
|
lastEnd = end;
|
|
|
|
String url = string.substring(start, end);
|
|
|
|
IChatComponent link = new ChatComponentText(url);
|
|
|
|
|
2015-02-17 06:46:55 +00:00
|
|
|
try
|
2014-12-23 23:04:41 +00:00
|
|
|
{
|
2015-02-17 06:46:55 +00:00
|
|
|
// Add schema so client doesn't crash.
|
|
|
|
if ((new URI(url)).getScheme() == null)
|
2015-11-04 21:57:47 +00:00
|
|
|
{
|
|
|
|
if (!allowMissingHeader)
|
|
|
|
{
|
|
|
|
if (ichat == null)
|
|
|
|
ichat = new ChatComponentText(url);
|
|
|
|
else
|
|
|
|
ichat.appendText(url);
|
|
|
|
continue;
|
|
|
|
}
|
2015-02-17 06:46:55 +00:00
|
|
|
url = "http://" + url;
|
2015-11-04 21:57:47 +00:00
|
|
|
}
|
2015-02-17 06:46:55 +00:00
|
|
|
}
|
|
|
|
catch (URISyntaxException e)
|
|
|
|
{
|
|
|
|
// Bad syntax bail out!
|
2015-11-04 21:57:47 +00:00
|
|
|
if (ichat == null) ichat = new ChatComponentText(url);
|
|
|
|
else ichat.appendText(url);
|
2015-02-17 06:46:55 +00:00
|
|
|
continue;
|
2014-12-23 23:04:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Set the click event and append the link.
|
|
|
|
ClickEvent click = new ClickEvent(ClickEvent.Action.OPEN_URL, url);
|
|
|
|
link.getChatStyle().setChatClickEvent(click);
|
2015-11-04 21:57:47 +00:00
|
|
|
link.getChatStyle().setUnderlined(true);
|
|
|
|
link.getChatStyle().setColor(EnumChatFormatting.BLUE);
|
|
|
|
if (ichat == null)
|
|
|
|
ichat = link;
|
|
|
|
else
|
|
|
|
ichat.appendSibling(link);
|
2014-12-23 23:04:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Append the rest of the message.
|
2015-11-04 21:57:47 +00:00
|
|
|
String end = string.substring(lastEnd);
|
|
|
|
if (ichat == null)
|
|
|
|
ichat = new ChatComponentText(end);
|
|
|
|
else if (end.length() > 0)
|
|
|
|
ichat.appendText(string.substring(lastEnd));
|
2014-12-23 23:04:41 +00:00
|
|
|
return ichat;
|
|
|
|
}
|
|
|
|
|
2013-10-05 11:10:00 +00:00
|
|
|
public static boolean canInteractWith(EntityPlayer player, Container openContainer)
|
|
|
|
{
|
|
|
|
PlayerOpenContainerEvent event = new PlayerOpenContainerEvent(player, openContainer);
|
|
|
|
MinecraftForge.EVENT_BUS.post(event);
|
|
|
|
return event.getResult() == Event.Result.DEFAULT ? event.canInteractWith : event.getResult() == Event.Result.ALLOW ? true : false;
|
|
|
|
}
|
2013-12-28 02:26:42 +00:00
|
|
|
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
public static int onBlockBreakEvent(World world, GameType gameType, EntityPlayerMP entityPlayer, BlockPos pos)
|
2013-10-09 00:00:02 +00:00
|
|
|
{
|
|
|
|
// Logic from tryHarvestBlock for pre-canceling the event
|
|
|
|
boolean preCancelEvent = false;
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
if (gameType.isCreative() && entityPlayer.getHeldItem() != null && entityPlayer.getHeldItem().getItem() instanceof ItemSword)
|
2013-10-09 00:00:02 +00:00
|
|
|
preCancelEvent = true;
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
|
|
|
|
if (gameType.isAdventure())
|
2013-10-09 00:00:02 +00:00
|
|
|
{
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
if (gameType == WorldSettings.GameType.SPECTATOR)
|
|
|
|
preCancelEvent = true;
|
|
|
|
|
2014-12-02 03:11:17 +00:00
|
|
|
if (!entityPlayer.isAllowEdit())
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
{
|
|
|
|
ItemStack itemstack = entityPlayer.getCurrentEquippedItem();
|
|
|
|
if (itemstack == null || !itemstack.canDestroy(world.getBlockState(pos).getBlock()))
|
|
|
|
preCancelEvent = true;
|
|
|
|
}
|
2013-10-09 00:00:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Tell client the block is gone immediately then process events
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
if (world.getTileEntity(pos) == null)
|
2013-10-09 00:00:02 +00:00
|
|
|
{
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
S23PacketBlockChange packet = new S23PacketBlockChange(world, pos);
|
2015-11-24 04:18:52 +00:00
|
|
|
packet.blockState = Blocks.air.getDefaultState();
|
2014-02-05 08:05:37 +00:00
|
|
|
entityPlayer.playerNetServerHandler.sendPacket(packet);
|
2013-10-09 00:00:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Post the block break event
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
IBlockState state = world.getBlockState(pos);
|
|
|
|
BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(world, pos, state, entityPlayer);
|
2013-10-09 00:00:02 +00:00
|
|
|
event.setCanceled(preCancelEvent);
|
|
|
|
MinecraftForge.EVENT_BUS.post(event);
|
|
|
|
|
|
|
|
// Handle if the event is canceled
|
|
|
|
if (event.isCanceled())
|
|
|
|
{
|
|
|
|
// Let the client know the block still exists
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
entityPlayer.playerNetServerHandler.sendPacket(new S23PacketBlockChange(world, pos));
|
2013-12-28 02:26:42 +00:00
|
|
|
|
2013-10-09 00:00:02 +00:00
|
|
|
// Update any tile entity data for this block
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
TileEntity tileentity = world.getTileEntity(pos);
|
2013-10-09 00:00:02 +00:00
|
|
|
if (tileentity != null)
|
|
|
|
{
|
2015-11-13 15:13:47 +00:00
|
|
|
Packet<?> pkt = tileentity.getDescriptionPacket();
|
2013-11-16 23:26:00 +00:00
|
|
|
if (pkt != null)
|
|
|
|
{
|
2014-02-05 08:05:37 +00:00
|
|
|
entityPlayer.playerNetServerHandler.sendPacket(pkt);
|
2013-11-16 23:26:00 +00:00
|
|
|
}
|
2013-10-09 00:00:02 +00:00
|
|
|
}
|
|
|
|
}
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
return event.isCanceled() ? -1 : event.getExpToDrop();
|
2013-10-09 00:00:02 +00:00
|
|
|
}
|
2014-04-03 01:33:13 +00:00
|
|
|
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
public static boolean onPlaceItemIntoWorld(ItemStack itemstack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
|
2014-08-27 02:47:22 +00:00
|
|
|
{
|
|
|
|
// handle all placement events here
|
|
|
|
int meta = itemstack.getItemDamage();
|
|
|
|
int size = itemstack.stackSize;
|
|
|
|
NBTTagCompound nbt = null;
|
|
|
|
if (itemstack.getTagCompound() != null)
|
|
|
|
{
|
|
|
|
nbt = (NBTTagCompound)itemstack.getTagCompound().copy();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(itemstack.getItem() instanceof ItemBucket)) // if not bucket
|
|
|
|
{
|
|
|
|
world.captureBlockSnapshots = true;
|
|
|
|
}
|
|
|
|
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
boolean flag = itemstack.getItem().onItemUse(itemstack, player, world, pos, side, hitX, hitY, hitZ);
|
2014-08-27 02:47:22 +00:00
|
|
|
world.captureBlockSnapshots = false;
|
|
|
|
|
|
|
|
if (flag)
|
|
|
|
{
|
|
|
|
// save new item data
|
|
|
|
int newMeta = itemstack.getItemDamage();
|
|
|
|
int newSize = itemstack.stackSize;
|
|
|
|
NBTTagCompound newNBT = null;
|
|
|
|
if (itemstack.getTagCompound() != null)
|
|
|
|
{
|
|
|
|
newNBT = (NBTTagCompound)itemstack.getTagCompound().copy();
|
|
|
|
}
|
|
|
|
net.minecraftforge.event.world.BlockEvent.PlaceEvent placeEvent = null;
|
2015-11-13 15:13:47 +00:00
|
|
|
@SuppressWarnings("unchecked")
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
List<net.minecraftforge.common.util.BlockSnapshot> blockSnapshots = (List<BlockSnapshot>)world.capturedBlockSnapshots.clone();
|
2014-08-27 02:47:22 +00:00
|
|
|
world.capturedBlockSnapshots.clear();
|
|
|
|
|
|
|
|
// make sure to set pre-placement item data for event
|
|
|
|
itemstack.setItemDamage(meta);
|
|
|
|
itemstack.stackSize = size;
|
|
|
|
if (nbt != null)
|
|
|
|
{
|
|
|
|
itemstack.setTagCompound(nbt);
|
|
|
|
}
|
2014-11-05 02:27:02 +00:00
|
|
|
if (blockSnapshots.size() > 1)
|
2014-08-27 02:47:22 +00:00
|
|
|
{
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
placeEvent = ForgeEventFactory.onPlayerMultiBlockPlace(player, blockSnapshots, side);
|
2014-11-05 02:27:02 +00:00
|
|
|
}
|
2014-08-27 02:47:22 +00:00
|
|
|
else if (blockSnapshots.size() == 1)
|
|
|
|
{
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
placeEvent = ForgeEventFactory.onPlayerBlockPlace(player, blockSnapshots.get(0), side);
|
2014-08-27 02:47:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (placeEvent != null && (placeEvent.isCanceled()))
|
|
|
|
{
|
|
|
|
flag = false; // cancel placement
|
|
|
|
// revert back all captured blocks
|
|
|
|
for (net.minecraftforge.common.util.BlockSnapshot blocksnapshot : blockSnapshots)
|
|
|
|
{
|
|
|
|
world.restoringBlockSnapshots = true;
|
|
|
|
blocksnapshot.restore(true, false);
|
|
|
|
world.restoringBlockSnapshots = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Change the stack to its new content
|
|
|
|
itemstack.setItemDamage(newMeta);
|
|
|
|
itemstack.stackSize = newSize;
|
|
|
|
if (nbt != null)
|
|
|
|
{
|
|
|
|
itemstack.setTagCompound(newNBT);
|
|
|
|
}
|
|
|
|
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
for (BlockSnapshot snap : blockSnapshots)
|
2014-08-27 02:47:22 +00:00
|
|
|
{
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
int updateFlag = snap.flag;
|
|
|
|
IBlockState oldBlock = snap.replacedBlock;
|
|
|
|
IBlockState newBlock = world.getBlockState(snap.pos);
|
|
|
|
if (newBlock != null && !(newBlock.getBlock().hasTileEntity(newBlock))) // Containers get placed automatically
|
2014-08-27 02:47:22 +00:00
|
|
|
{
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
newBlock.getBlock().onBlockAdded(world, snap.pos, newBlock);
|
2014-08-27 02:47:22 +00:00
|
|
|
}
|
|
|
|
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
world.markAndNotifyBlock(snap.pos, null, oldBlock, newBlock, updateFlag);
|
2014-08-27 02:47:22 +00:00
|
|
|
}
|
|
|
|
player.addStat(StatList.objectUseStats[Item.getIdFromItem(itemstack.getItem())], 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
world.capturedBlockSnapshots.clear();
|
|
|
|
|
|
|
|
return flag;
|
|
|
|
}
|
|
|
|
|
2014-04-03 01:33:13 +00:00
|
|
|
public static boolean onAnvilChange(ContainerRepair container, ItemStack left, ItemStack right, IInventory outputSlot, String name, int baseCost)
|
|
|
|
{
|
|
|
|
AnvilUpdateEvent e = new AnvilUpdateEvent(left, right, name, baseCost);
|
|
|
|
if (MinecraftForge.EVENT_BUS.post(e)) return false;
|
|
|
|
if (e.output == null) return true;
|
|
|
|
|
|
|
|
outputSlot.setInventorySlotContents(0, e.output);
|
|
|
|
container.maximumCost = e.cost;
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
container.materialCost = e.materialCost;
|
2014-04-03 01:33:13 +00:00
|
|
|
return false;
|
|
|
|
}
|
2014-11-05 02:27:02 +00:00
|
|
|
|
2014-08-04 20:54:35 +00:00
|
|
|
public static float onAnvilRepair(EntityPlayer player, ItemStack output, ItemStack left, ItemStack right)
|
|
|
|
{
|
|
|
|
AnvilRepairEvent e = new AnvilRepairEvent(player, left, right, output);
|
|
|
|
MinecraftForge.EVENT_BUS.post(e);
|
|
|
|
return e.breakChance;
|
|
|
|
}
|
2014-06-02 23:57:04 +00:00
|
|
|
|
|
|
|
public static boolean onNoteChange(TileEntityNote te, byte old)
|
|
|
|
{
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
NoteBlockEvent.Change e = new NoteBlockEvent.Change(te.getWorld(), te.getPos(), te.getWorld().getBlockState(te.getPos()), old, te.note);
|
2014-06-02 23:57:04 +00:00
|
|
|
if (MinecraftForge.EVENT_BUS.post(e))
|
|
|
|
{
|
|
|
|
te.note = old;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
te.note = (byte)e.getVanillaNoteId();
|
|
|
|
return true;
|
|
|
|
}
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Default implementation of IRecipe.func_179532_b {getRemainingItems} because
|
|
|
|
* this is just copy pasted over a lot of recipes.
|
|
|
|
*
|
|
|
|
* Another use case for java 8 but sadly we can't use it!
|
|
|
|
*
|
|
|
|
* @param inv Crafting inventory
|
|
|
|
* @return Crafting inventory contents after the recipe.
|
|
|
|
*/
|
|
|
|
public static ItemStack[] defaultRecipeGetRemainingItems(InventoryCrafting inv)
|
|
|
|
{
|
|
|
|
ItemStack[] ret = new ItemStack[inv.getSizeInventory()];
|
|
|
|
for (int i = 0; i < ret.length; i++)
|
|
|
|
{
|
|
|
|
ret[i] = getContainerItem(inv.getStackInSlot(i));
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
private static ThreadLocal<EntityPlayer> craftingPlayer = new ThreadLocal<EntityPlayer>();
|
|
|
|
public static void setCraftingPlayer(EntityPlayer player)
|
|
|
|
{
|
|
|
|
craftingPlayer.set(player);
|
|
|
|
}
|
|
|
|
public static EntityPlayer getCraftingPlayer()
|
|
|
|
{
|
|
|
|
return craftingPlayer.get();
|
|
|
|
}
|
|
|
|
public static ItemStack getContainerItem(ItemStack stack)
|
|
|
|
{
|
|
|
|
if (stack == null) return null;
|
|
|
|
|
|
|
|
if (stack.getItem().hasContainerItem(stack))
|
|
|
|
{
|
|
|
|
stack = stack.getItem().getContainerItem(stack);
|
|
|
|
if (stack != null && stack.isItemStackDamageable() && stack.getMetadata() > stack.getMaxDamage())
|
|
|
|
{
|
|
|
|
MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(craftingPlayer.get(), stack));
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return stack;
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static WorldGeneratorBonusChest getBonusChest(Random rand)
|
|
|
|
{
|
|
|
|
return new WorldGeneratorBonusChest(ChestGenHooks.getItems(ChestGenHooks.BONUS_CHEST, rand), ChestGenHooks.getCount(ChestGenHooks.BONUS_CHEST, rand));
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean isInsideOfMaterial(Material material, Entity entity, BlockPos pos)
|
|
|
|
{
|
|
|
|
IBlockState state = entity.worldObj.getBlockState(pos);
|
|
|
|
Block block = state.getBlock();
|
|
|
|
double eyes = entity.posY + (double)entity.getEyeHeight();
|
|
|
|
|
|
|
|
double filled = 1.0f; //If it's not a liquid assume it's a solid block
|
|
|
|
if (block instanceof IFluidBlock)
|
|
|
|
{
|
|
|
|
filled = ((IFluidBlock)block).getFilledPercentage(entity.worldObj, pos);
|
|
|
|
}
|
|
|
|
else if (block instanceof BlockLiquid)
|
|
|
|
{
|
|
|
|
filled = BlockLiquid.getLiquidHeightPercent(block.getMetaFromState(state));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (filled < 0)
|
|
|
|
{
|
|
|
|
filled *= -1;
|
|
|
|
//filled -= 0.11111111F; //Why this is needed.. not sure...
|
|
|
|
return eyes > (double)(pos.getY() + 1 + (1 - filled));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return eyes < (double)(pos.getY() + 1 + filled);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean onPlayerAttackTarget(EntityPlayer player, Entity target)
|
|
|
|
{
|
|
|
|
if (MinecraftForge.EVENT_BUS.post(new AttackEntityEvent(player, target))) return false;
|
|
|
|
ItemStack stack = player.getCurrentEquippedItem();
|
|
|
|
if (stack != null && stack.getItem().onLeftClickEntity(stack, player, target)) return false;
|
|
|
|
return true;
|
|
|
|
}
|
2012-08-06 02:15:13 +00:00
|
|
|
}
|