Port GT6 timber changes
This commit is contained in:
parent
ead3fa6ad7
commit
9209d0843f
6 changed files with 76 additions and 0 deletions
|
@ -8,6 +8,7 @@ import net.minecraft.entity.EntityLivingBase;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -156,4 +157,6 @@ public interface IToolStats {
|
|||
public IIconContainer getIcon(boolean aIsToolHead, ItemStack aStack);
|
||||
|
||||
public short[] getRGBa(boolean aIsToolHead, ItemStack aStack);
|
||||
|
||||
public float getMiningSpeed(Block aBlock, byte aMetaData, float aDefault, EntityPlayer aPlayer, World worldObj, int aX, int aY, int aZ);
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package gregtech.api.items;
|
||||
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
@ -42,6 +43,7 @@ import net.minecraft.util.IIcon;
|
|||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.IShearable;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -208,12 +210,22 @@ public abstract class GT_MetaGenerated_Tool extends GT_MetaBase_Item implements
|
|||
/**
|
||||
* Called by the Block Harvesting Event within the GT_Proxy
|
||||
*/
|
||||
@Mod.EventHandler
|
||||
public void onHarvestBlockEvent(ArrayList<ItemStack> aDrops, ItemStack aStack, EntityPlayer aPlayer, Block aBlock, int aX, int aY, int aZ, byte aMetaData, int aFortune, boolean aSilkTouch, BlockEvent.HarvestDropsEvent aEvent) {
|
||||
IToolStats tStats = getToolStats(aStack);
|
||||
if (isItemStackUsable(aStack) && getDigSpeed(aStack, aBlock, aMetaData) > 0.0F)
|
||||
doDamage(aStack, tStats.convertBlockDrops(aDrops, aStack, aPlayer, aBlock, aX, aY, aZ, aMetaData, aFortune, aSilkTouch, aEvent) * tStats.getToolDamagePerDropConversion());
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public float onBlockBreakSpeedEvent(float aDefault, ItemStack aStack, EntityPlayer aPlayer, Block aBlock, int aX, int aY, int aZ, byte aMetaData, PlayerEvent.BreakSpeed aEvent)
|
||||
{
|
||||
IToolStats tStats = getToolStats(aStack);
|
||||
float tTest = tStats == null ? aDefault : tStats.getMiningSpeed(aBlock, aMetaData, aDefault, aPlayer, aPlayer.worldObj, aX, aY, aZ);
|
||||
System.out.println("test: "+tTest+" default: "+aDefault);
|
||||
return tTest;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockStartBreak(ItemStack aStack, int aX, int aY, int aZ, EntityPlayer aPlayer)
|
||||
{
|
||||
|
|
|
@ -38,6 +38,7 @@ import gregtech.common.items.armor.gui.ContainerElectricArmor1;
|
|||
import gregtech.common.items.armor.gui.GuiElectricArmor1;
|
||||
import gregtech.common.items.armor.gui.GuiModularArmor;
|
||||
import gregtech.common.items.armor.gui.InventoryArmor;
|
||||
import gregtech.common.tools.GT_Tool;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
|
@ -69,6 +70,7 @@ import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
|||
import net.minecraftforge.event.entity.living.EnderTeleportEvent;
|
||||
import net.minecraftforge.event.entity.player.ArrowLooseEvent;
|
||||
import net.minecraftforge.event.entity.player.ArrowNockEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.minecraftforge.event.terraingen.OreGenEvent;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
|
@ -1796,6 +1798,21 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler {
|
|||
////DO NOTHING - this chunk data was already loaded and stored in hash map
|
||||
//}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onBlockBreakSpeedEvent(PlayerEvent.BreakSpeed aEvent)
|
||||
{
|
||||
if (aEvent.newSpeed > 0.0F)
|
||||
{
|
||||
if (aEvent.entityPlayer != null)
|
||||
{
|
||||
ItemStack aStack = aEvent.entityPlayer.getCurrentEquippedItem();
|
||||
if ((aStack != null) && ((aStack.getItem() instanceof GT_MetaGenerated_Tool))) {
|
||||
aEvent.newSpeed = ((GT_MetaGenerated_Tool)aStack.getItem()).onBlockBreakSpeedEvent(aEvent.newSpeed, aStack, aEvent.entityPlayer, aEvent.block, aEvent.x, aEvent.y, aEvent.z, (byte)aEvent.metadata, aEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class OreDictEventContainer {
|
||||
public final OreDictionary.OreRegisterEvent mEvent;
|
||||
|
|
|
@ -14,6 +14,7 @@ import net.minecraft.stats.AchievementList;
|
|||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.EntityDamageSource;
|
||||
import net.minecraft.util.IChatComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -145,4 +146,15 @@ public abstract class GT_Tool
|
|||
public float getMagicDamageAgainstEntity(float aOriginalDamage, Entity aEntity, ItemStack aStack, EntityPlayer aPlayer) {
|
||||
return aOriginalDamage;
|
||||
}
|
||||
|
||||
public float getMiningSpeed(Block aBlock, byte aMetaData)
|
||||
{
|
||||
return isMinableBlock(aBlock, aMetaData) ? 1.0F : 0.0F;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public float getMiningSpeed(Block aBlock, byte aMetaData, float aDefault, EntityPlayer aPlayer, World worldObj, int aX, int aY, int aZ) {
|
||||
return getMiningSpeed(aBlock, aMetaData);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.IChatComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -96,6 +97,21 @@ public class GT_Tool_Axe
|
|||
}
|
||||
return rAmount;
|
||||
}
|
||||
|
||||
public float getMiningSpeed(Block aBlock, byte aMetaData, float aDefault, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ)
|
||||
{
|
||||
if (aBlock.isWood(aPlayer.worldObj, aX, aY, aZ) && OrePrefixes.log.contains(new ItemStack(aBlock, 1, aMetaData))){
|
||||
float rAmount = 1.0F;float tIncrement = 1.0F;
|
||||
if ((GregTech_API.sTimber) && !aPlayer.isSneaking()){
|
||||
int tY = aY + 1;
|
||||
for (int tH = aPlayer.worldObj.getHeight(); (tY < tH) && (aPlayer.worldObj.getBlock(aX, tY, aZ) == aBlock); tY++){
|
||||
tIncrement += 0.1F;rAmount += tIncrement;
|
||||
}
|
||||
}
|
||||
return 2.0F * aDefault / rAmount;
|
||||
}
|
||||
return (aBlock.getMaterial() == Material.leaves) || (aBlock.getMaterial() == Material.vine) || (aBlock.getMaterial() == Material.plants) || (aBlock.getMaterial() == Material.gourd) ? aDefault / 4.0F : aDefault;
|
||||
}
|
||||
|
||||
public ItemStack getBrokenItem(ItemStack aStack) {
|
||||
return null;
|
||||
|
|
|
@ -20,6 +20,7 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.IChatComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.IShearable;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
|
||||
|
@ -135,6 +136,21 @@ public class GT_Tool_Chainsaw_LV
|
|||
}
|
||||
return rAmount;
|
||||
}
|
||||
|
||||
public float getMiningSpeed(Block aBlock, byte aMetaData, float aDefault, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ)
|
||||
{
|
||||
if (aBlock.isWood(aPlayer.worldObj, aX, aY, aZ) && OrePrefixes.log.contains(new ItemStack(aBlock, 1, aMetaData))){
|
||||
float rAmount = 1.0F;float tIncrement = 1.0F;
|
||||
if ((GregTech_API.sTimber) && !aPlayer.isSneaking()){
|
||||
int tY = aY + 1;
|
||||
for (int tH = aPlayer.worldObj.getHeight(); (tY < tH) && (aPlayer.worldObj.getBlock(aX, tY, aZ) == aBlock); tY++){
|
||||
tIncrement += 0.1F;rAmount += tIncrement;
|
||||
}
|
||||
}
|
||||
return 2.0F * aDefault / rAmount;
|
||||
}
|
||||
return (aBlock.getMaterial() == Material.leaves) || (aBlock.getMaterial() == Material.vine) || (aBlock.getMaterial() == Material.plants) || (aBlock.getMaterial() == Material.gourd) ? aDefault / 4.0F : aDefault;
|
||||
}
|
||||
|
||||
public IIconContainer getIcon(boolean aIsToolHead, ItemStack aStack) {
|
||||
return aIsToolHead ? GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mIconSet.mTextures[gregtech.api.enums.OrePrefixes.toolHeadChainsaw.mTextureIndex] : Textures.ItemIcons.POWER_UNIT_LV;
|
||||
|
|
Loading…
Reference in a new issue