1
0
forked from xjboss/KCauldronX

Initial commit (Forge 1291).

This commit is contained in:
gamerforEA
2015-03-22 20:38:04 +03:00
commit 16773ead6a
611 changed files with 64826 additions and 0 deletions

View File

@ -0,0 +1,42 @@
--- ../src-base/minecraft/net/minecraft/entity/passive/EntityCow.java
+++ ../src-work/minecraft/net/minecraft/entity/passive/EntityCow.java
@@ -17,6 +17,11 @@
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+// CraftBukkit end
+
public class EntityCow extends EntityAnimal
{
private static final String __OBFID = "CL_00001640";
@@ -109,15 +114,25 @@
if (itemstack != null && itemstack.getItem() == Items.bucket && !p_70085_1_.capabilities.isCreativeMode)
{
+ // CraftBukkit start - Got milk?
+ org.bukkit.Location loc = this.getBukkitEntity().getLocation();
+ org.bukkit.event.player.PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent(p_70085_1_, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), -1, itemstack, Items.milk_bucket);
+
+ if (event.isCancelled())
+ {
+ return false;
+ }
+
if (itemstack.stackSize-- == 1)
{
- p_70085_1_.inventory.setInventorySlotContents(p_70085_1_.inventory.currentItem, new ItemStack(Items.milk_bucket));
+ p_70085_1_.inventory.setInventorySlotContents(p_70085_1_.inventory.currentItem, CraftItemStack.asNMSCopy(event.getItemStack()));
}
else if (!p_70085_1_.inventory.addItemStackToInventory(new ItemStack(Items.milk_bucket)))
{
- p_70085_1_.dropPlayerItemWithRandomChoice(new ItemStack(Items.milk_bucket, 1, 0), false);
+ p_70085_1_.dropPlayerItemWithRandomChoice(CraftItemStack.asNMSCopy(event.getItemStack()), false);
}
+ // CraftBukkit end
return true;
}
else

View File

@ -0,0 +1,134 @@
--- ../src-base/minecraft/net/minecraft/entity/passive/EntityHorse.java
+++ ../src-work/minecraft/net/minecraft/entity/passive/EntityHorse.java
@@ -50,7 +50,7 @@
return p_82704_1_ instanceof EntityHorse && ((EntityHorse)p_82704_1_).func_110205_ce();
}
};
- private static final IAttribute horseJumpStrength = (new RangedAttribute("horse.jumpStrength", 0.7D, 0.0D, 2.0D)).setDescription("Jump Strength").setShouldWatch(true);
+ public static final IAttribute horseJumpStrength = (new RangedAttribute("horse.jumpStrength", 0.7D, 0.0D, 2.0D)).setDescription("Jump Strength").setShouldWatch(true); // CraftBukkit - private -> public
private static final String[] horseArmorTextures = new String[] {null, "textures/entity/horse/armor/horse_armor_iron.png", "textures/entity/horse/armor/horse_armor_gold.png", "textures/entity/horse/armor/horse_armor_diamond.png"};
private static final String[] field_110273_bx = new String[] {"", "meo", "goo", "dio"};
private static final int[] armorValues = new int[] {0, 5, 7, 11};
@@ -64,7 +64,7 @@
public int field_110278_bp;
public int field_110279_bq;
protected boolean horseJumping;
- private AnimalChest horseChest;
+ public AnimalChest horseChest; // CraftBukkit - private -> public
private boolean hasReproduced;
protected int temper;
protected float jumpPower;
@@ -78,6 +78,7 @@
private int field_110285_bP;
private String field_110286_bQ;
private String[] field_110280_bR = new String[3];
+ public int maxDomestication = 100; // CraftBukkit - store max domestication value
private static final String __OBFID = "CL_00001641";
public EntityHorse(World p_i1685_1_)
@@ -403,13 +404,13 @@
private int func_110225_cC()
{
int i = this.getHorseType();
- return this.isChested() && (i == 1 || i == 2) ? 17 : 2;
+ return this.isChested() /* && (i == 1 || i == 2) */ ? 17 : 2; // CraftBukkit - Remove type check
}
- private void func_110226_cD()
+ public void func_110226_cD() // CraftBukkit - private -> public
{
AnimalChest animalchest = this.horseChest;
- this.horseChest = new AnimalChest("HorseChest", this.func_110225_cC());
+ this.horseChest = new AnimalChest("HorseChest", this.func_110225_cC(), this); // CraftBukkit - add this horse
this.horseChest.func_110133_a(this.getCommandSenderName());
if (animalchest != null)
@@ -950,12 +951,25 @@
{
super.onDeath(p_70645_1_);
+ /* CraftBukkit start - Handle chest dropping in dropFewItems below
if (!this.worldObj.isRemote)
{
this.dropChestItems();
}
+ // CraftBukkit end */
}
+ // CraftBukkit start - Add method
+ protected void dropFewItems(boolean flag, int i) {
+ super.dropFewItems(flag, i);
+
+ // Moved from die method above
+ if (!this.worldObj.isRemote) {
+ this.dropChestItems();
+ }
+ }
+ // CraftBukkit end
+
public void onLivingUpdate()
{
if (this.rand.nextInt(200) == 0)
@@ -1278,6 +1292,7 @@
p_70014_1_.setInteger("Temper", this.getTemper());
p_70014_1_.setBoolean("Tame", this.isTame());
p_70014_1_.setString("OwnerUUID", this.func_152119_ch());
+ p_70014_1_.setInteger("Bukkit.MaxDomestication", this.maxDomestication); // CraftBukkit
if (this.isChested())
{
@@ -1327,6 +1342,13 @@
this.func_152120_b(p_70037_1_.getString("OwnerUUID"));
}
+ // CraftBukkit start
+ if (p_70037_1_.hasKey("Bukkit.MaxDomestication"))
+ {
+ this.maxDomestication = p_70037_1_.getInteger("Bukkit.MaxDomestication");
+ }
+
+ // CraftBukkit end
IAttributeInstance iattributeinstance = this.getAttributeMap().getAttributeInstanceByName("Speed");
if (iattributeinstance != null)
@@ -1566,24 +1588,33 @@
{
if (this.isHorseSaddled())
{
+ // CraftBukkit start - fire HorseJumpEvent, use event power
if (p_110206_1_ < 0)
{
p_110206_1_ = 0;
}
- else
- {
- this.field_110294_bI = true;
- this.makeHorseRear();
- }
+ float power;
+
if (p_110206_1_ >= 90)
{
- this.jumpPower = 1.0F;
+ power = 1.0F;
}
else
{
- this.jumpPower = 0.4F + 0.4F * (float)p_110206_1_ / 90.0F;
+ power = 0.4F + 0.4F * (float)p_110206_1_ / 90.0F;
}
+
+ org.bukkit.event.entity.HorseJumpEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callHorseJumpEvent(this, power);
+
+ if (!event.isCancelled())
+ {
+ this.field_110294_bI = true;
+ this.makeHorseRear();
+ this.jumpPower = event.getPower();
+ }
+
+ // CraftBukkit end
}
}

View File

@ -0,0 +1,11 @@
--- ../src-base/minecraft/net/minecraft/entity/passive/EntityMooshroom.java
+++ ../src-work/minecraft/net/minecraft/entity/passive/EntityMooshroom.java
@@ -12,6 +12,8 @@
import net.minecraft.world.World;
import net.minecraftforge.common.IShearable;
+import org.bukkit.event.player.PlayerShearEntityEvent; // CraftBukkit
+
public class EntityMooshroom extends EntityCow implements IShearable
{
private static final String __OBFID = "CL_00001645";

View File

@ -0,0 +1,21 @@
--- ../src-base/minecraft/net/minecraft/entity/passive/EntityOcelot.java
+++ ../src-work/minecraft/net/minecraft/entity/passive/EntityOcelot.java
@@ -89,7 +89,7 @@
protected boolean canDespawn()
{
- return !this.isTamed() && this.ticksExisted > 2400;
+ return !this.isTamed(); // CraftBukkit
}
public boolean isAIEnabled()
@@ -188,7 +188,8 @@
if (!this.worldObj.isRemote)
{
- if (this.rand.nextInt(3) == 0)
+ // CraftBukkit - added event call and isCancelled check
+ if (this.rand.nextInt(3) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, p_70085_1_).isCancelled())
{
this.setTamed(true);
this.setTameSkin(1 + this.worldObj.rand.nextInt(3));

View File

@ -0,0 +1,36 @@
--- ../src-base/minecraft/net/minecraft/entity/passive/EntityPig.java
+++ ../src-work/minecraft/net/minecraft/entity/passive/EntityPig.java
@@ -22,6 +22,8 @@
import net.minecraft.stats.AchievementList;
import net.minecraft.world.World;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public class EntityPig extends EntityAnimal
{
private final EntityAIControlledByPlayer aiControlledByPlayer;
@@ -171,9 +173,23 @@
if (!this.worldObj.isRemote)
{
EntityPigZombie entitypigzombie = new EntityPigZombie(this.worldObj);
+
+ // Cauldron start
+ if (p_70077_1_ != null)
+ {
+ // CraftBukkit start
+ if (CraftEventFactory.callPigZapEvent(this, p_70077_1_, entitypigzombie).isCancelled())
+ {
+ return;
+ }
+
+ // CraftBukkit end
+ }
+ // Cauldron end
entitypigzombie.setCurrentItemOrArmor(0, new ItemStack(Items.golden_sword));
entitypigzombie.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch);
- this.worldObj.spawnEntityInWorld(entitypigzombie);
+ // CraftBukkit - added a reason for spawning this creature
+ this.worldObj.addEntity(entitypigzombie, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING);
this.setDead();
}
}

View File

@ -0,0 +1,42 @@
--- ../src-base/minecraft/net/minecraft/entity/passive/EntitySheep.java
+++ ../src-work/minecraft/net/minecraft/entity/passive/EntitySheep.java
@@ -32,6 +32,12 @@
import net.minecraft.world.World;
import net.minecraftforge.common.IShearable;
+// CraftBukkit start
+import net.minecraft.inventory.InventoryCraftResult;
+import org.bukkit.event.entity.SheepRegrowWoolEvent;
+import org.bukkit.event.player.PlayerShearEntityEvent;
+// CraftBukkit end
+
public class EntitySheep extends EntityAnimal implements IShearable
{
private final InventoryCrafting field_90016_e = new InventoryCrafting(new Container()
@@ -63,6 +69,7 @@
this.tasks.addTask(8, new EntityAILookIdle(this));
this.field_90016_e.setInventorySlotContents(0, new ItemStack(Items.dye, 1, 0));
this.field_90016_e.setInventorySlotContents(1, new ItemStack(Items.dye, 1, 0));
+ this.field_90016_e.resultInventory = new InventoryCraftResult(); // CraftBukkit - add result slot for event
}
protected boolean isAIEnabled()
@@ -231,8 +238,17 @@
public void eatGrassBonus()
{
- this.setSheared(false);
+ // CraftBukkit start
+ SheepRegrowWoolEvent event = new SheepRegrowWoolEvent((org.bukkit.entity.Sheep) this.getBukkitEntity());
+ this.worldObj.getServer().getPluginManager().callEvent(event);
+ if (!event.isCancelled())
+ {
+ this.setSheared(false);
+ }
+
+ // CraftBukkit end
+
if (this.isChild())
{
this.addGrowth(60);

View File

@ -0,0 +1,39 @@
--- ../src-base/minecraft/net/minecraft/entity/passive/EntitySquid.java
+++ ../src-work/minecraft/net/minecraft/entity/passive/EntitySquid.java
@@ -8,6 +8,8 @@
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
+import org.bukkit.craftbukkit.TrigMath; // CraftBukkit
+
public class EntitySquid extends EntityWaterMob
{
public float squidPitch;
@@ -79,10 +81,12 @@
}
}
+ /* CraftBukkit start - Delegate to Entity to use existing inWater value
public boolean isInWater()
{
return this.worldObj.handleMaterialAcceleration(this.boundingBox.expand(0.0D, -0.6000000238418579D, 0.0D), Material.water, this);
}
+ // CraftBukkit end */
public void onLivingUpdate()
{
@@ -137,10 +141,12 @@
}
f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
- this.renderYawOffset += (-((float)Math.atan2(this.motionX, this.motionZ)) * 180.0F / (float)Math.PI - this.renderYawOffset) * 0.1F;
+ // CraftBukkit - Math -> TrigMath
+ this.renderYawOffset += (-((float) TrigMath.atan2(this.motionX, this.motionZ)) * 180.0F / (float)Math.PI - this.renderYawOffset) * 0.1F;
this.rotationYaw = this.renderYawOffset;
this.squidYaw += (float)Math.PI * this.field_70871_bB * 1.5F;
- this.squidPitch += (-((float)Math.atan2((double)f, this.motionY)) * 180.0F / (float)Math.PI - this.squidPitch) * 0.1F;
+ // CraftBukkit - Math -> TrigMath
+ this.squidPitch += (-((float) TrigMath.atan2((double) f, this.motionY)) * 180.0F / (float)Math.PI - this.squidPitch) * 0.1F;
}
else
{

View File

@ -0,0 +1,21 @@
--- ../src-base/minecraft/net/minecraft/entity/passive/EntityWolf.java
+++ ../src-work/minecraft/net/minecraft/entity/passive/EntityWolf.java
@@ -139,7 +139,8 @@
protected String getLivingSound()
{
- return this.isAngry() ? "mob.wolf.growl" : (this.rand.nextInt(3) == 0 ? (this.isTamed() && this.dataWatcher.getWatchableObjectFloat(18) < 10.0F ? "mob.wolf.whine" : "mob.wolf.panting") : "mob.wolf.bark");
+ // CraftBukkit - (getFloat(18) < 10) -> (getFloat(18) < this.getMaxHealth() / 2)
+ return this.isAngry() ? "mob.wolf.growl" : (this.rand.nextInt(3) == 0 ? (this.isTamed() && this.dataWatcher.getWatchableObjectFloat(18) < (this.getMaxHealth() / 2) ? "mob.wolf.whine" : "mob.wolf.panting") : "mob.wolf.bark");
}
protected String getHurtSound()
@@ -527,7 +528,7 @@
protected boolean canDespawn()
{
- return !this.isTamed() && this.ticksExisted > 2400;
+ return !this.isTamed(); // CraftBukkit
}
public boolean func_142018_a(EntityLivingBase p_142018_1_, EntityLivingBase p_142018_2_)