mirror of
https://github.com/barkeser2002/CatServer.git
synced 2026-09-25 01:39:52 +03:00
81 lines
3.8 KiB
Diff
81 lines
3.8 KiB
Diff
--- ../src-base/minecraft/net/minecraft/item/ItemDye.java
|
|
+++ ../src-work/minecraft/net/minecraft/item/ItemDye.java
|
|
@@ -20,6 +20,7 @@
|
|
import net.minecraft.world.World;
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
+import org.bukkit.event.entity.SheepDyeWoolEvent;
|
|
|
|
public class ItemDye extends Item
|
|
{
|
|
@@ -52,7 +53,7 @@
|
|
|
|
if (enumdyecolor == EnumDyeColor.WHITE)
|
|
{
|
|
- if (applyBonemeal(itemstack, worldIn, pos))
|
|
+ if (applyBonemeal(itemstack, worldIn, pos, player, hand))
|
|
{
|
|
if (!worldIn.isRemote)
|
|
{
|
|
@@ -78,7 +79,7 @@
|
|
|
|
if (worldIn.isAirBlock(pos))
|
|
{
|
|
- IBlockState iblockstate1 = Blocks.COCOA.getStateForPlacement(worldIn, pos, facing, hitX, hitY, hitZ, 0, player);
|
|
+ IBlockState iblockstate1 = Blocks.COCOA.getStateForPlacement(worldIn, pos, facing, hitX, hitY, hitZ, 0, player, hand);
|
|
worldIn.setBlockState(pos, iblockstate1, 10);
|
|
|
|
if (!player.capabilities.isCreativeMode)
|
|
@@ -99,8 +100,18 @@
|
|
|
|
public static boolean applyBonemeal(ItemStack stack, World worldIn, BlockPos target)
|
|
{
|
|
+ if (worldIn instanceof net.minecraft.world.WorldServer)
|
|
+ return applyBonemeal(stack, worldIn, target, net.minecraftforge.common.util.FakePlayerFactory.getMinecraft((net.minecraft.world.WorldServer)worldIn), null);
|
|
+ return false;
|
|
+ }
|
|
+
|
|
+ public static boolean applyBonemeal(ItemStack stack, World worldIn, BlockPos target, EntityPlayer player, @javax.annotation.Nullable EnumHand hand)
|
|
+ {
|
|
IBlockState iblockstate = worldIn.getBlockState(target);
|
|
|
|
+ int hook = net.minecraftforge.event.ForgeEventFactory.onApplyBonemeal(player, worldIn, target, iblockstate, stack, hand);
|
|
+ if (hook != 0) return hook > 0;
|
|
+
|
|
if (iblockstate.getBlock() instanceof IGrowable)
|
|
{
|
|
IGrowable igrowable = (IGrowable)iblockstate.getBlock();
|
|
@@ -144,6 +155,16 @@
|
|
worldIn.spawnParticle(EnumParticleTypes.VILLAGER_HAPPY, (double)((float)pos.getX() + itemRand.nextFloat()), (double)pos.getY() + (double)itemRand.nextFloat() * iblockstate.getBoundingBox(worldIn, pos).maxY, (double)((float)pos.getZ() + itemRand.nextFloat()), d0, d1, d2);
|
|
}
|
|
}
|
|
+ else
|
|
+ {
|
|
+ for (int i1 = 0; i1 < amount; ++i1)
|
|
+ {
|
|
+ double d0 = itemRand.nextGaussian() * 0.02D;
|
|
+ double d1 = itemRand.nextGaussian() * 0.02D;
|
|
+ double d2 = itemRand.nextGaussian() * 0.02D;
|
|
+ worldIn.spawnParticle(EnumParticleTypes.VILLAGER_HAPPY, (double)((float)pos.getX() + itemRand.nextFloat()), (double)pos.getY() + (double)itemRand.nextFloat() * 1.0f, (double)((float)pos.getZ() + itemRand.nextFloat()), d0, d1, d2, new int[0]);
|
|
+ }
|
|
+ }
|
|
}
|
|
|
|
public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer playerIn, EntityLivingBase target, EnumHand hand)
|
|
@@ -155,6 +176,15 @@
|
|
|
|
if (!entitysheep.getSheared() && entitysheep.getFleeceColor() != enumdyecolor)
|
|
{
|
|
+ byte bColor = (byte) enumdyecolor.getMetadata();
|
|
+ SheepDyeWoolEvent event = new SheepDyeWoolEvent((org.bukkit.entity.Sheep) entitysheep.getBukkitEntity(), org.bukkit.DyeColor.getByWoolData(bColor));
|
|
+ entitysheep.world.getServer().getPluginManager().callEvent(event);
|
|
+
|
|
+ if (event.isCancelled()) {
|
|
+ return false;
|
|
+ }
|
|
+
|
|
+ enumdyecolor = EnumDyeColor.byMetadata(event.getColor().getWoolData());
|
|
entitysheep.setFleeceColor(enumdyecolor);
|
|
stack.shrink(1);
|
|
}
|