From c191851ec0d188b768d25a148e2a607f0c6a3636 Mon Sep 17 00:00:00 2001 From: LexManos Date: Fri, 21 Sep 2018 15:50:37 -0700 Subject: [PATCH] Fixed all compile errors except the 4 in KeyBinding. --- .../net/minecraft/block/Block.java.patch | 10 +- .../net/minecraft/entity/Entity.java.patch | 159 ++++++++++++++++-- .../entity/item/EntityMinecart.java.patch | 18 ++ .../net/minecraft/fluid/Fluid.java.patch | 11 ++ .../minecraft/fluid/IFluidState.java.patch | 11 ++ .../net/minecraft/item/ItemStack.java.patch | 74 ++------ .../net/minecraft/world/Explosion.java.patch | 11 ++ .../world/storage/loot/LootContext.java.patch | 13 ++ .../world/storage/loot/LootEntry.java.patch | 49 ++++++ .../storage/loot/LootEntryEmpty.java.patch | 21 +++ .../storage/loot/LootEntryItem.java.patch | 30 ++++ .../storage/loot/LootEntryTable.java.patch | 21 +++ .../world/storage/loot/LootPool.java.patch | 91 ++++++++++ .../world/storage/loot/LootTable.java.patch | 57 +++++++ .../storage/loot/LootTableManager.java.patch | 11 ++ .../LootConditionManager.java.patch | 13 ++ .../RandomChanceWithLooting.java.patch | 15 ++ .../functions/LootingEnchantBonus.java.patch | 11 ++ .../net/minecraftforge/common/ForgeHooks.java | 48 +----- .../common/crafting/CraftingHelper.java | 2 +- .../common/extensions/IForgeBlock.java | 110 ++++-------- .../common/extensions/IForgeBlockState.java | 48 ------ .../common/extensions/IForgeEntity.java | 126 ++++++++++++++ .../common/extensions/IForgeFluid.java | 101 +++++++++++ .../common/extensions/IForgeFluidState.java | 71 ++++++++ .../common/extensions/IForgeItem.java | 2 +- .../common/extensions/IForgeItemStack.java | 31 ++++ .../minecart/MinecartCollisionEvent.java | 54 ------ .../event/entity/minecart/MinecartEvent.java | 50 ------ .../minecart/MinecartInteractEvent.java | 63 ------- .../entity/minecart/MinecartUpdateEvent.java | 54 ------ 31 files changed, 921 insertions(+), 465 deletions(-) create mode 100644 patches/minecraft/net/minecraft/entity/item/EntityMinecart.java.patch create mode 100644 patches/minecraft/net/minecraft/fluid/Fluid.java.patch create mode 100644 patches/minecraft/net/minecraft/fluid/IFluidState.java.patch create mode 100644 patches/minecraft/net/minecraft/world/Explosion.java.patch create mode 100644 patches/minecraft/net/minecraft/world/storage/loot/LootContext.java.patch create mode 100644 patches/minecraft/net/minecraft/world/storage/loot/LootEntry.java.patch create mode 100644 patches/minecraft/net/minecraft/world/storage/loot/LootEntryEmpty.java.patch create mode 100644 patches/minecraft/net/minecraft/world/storage/loot/LootEntryItem.java.patch create mode 100644 patches/minecraft/net/minecraft/world/storage/loot/LootEntryTable.java.patch create mode 100644 patches/minecraft/net/minecraft/world/storage/loot/LootPool.java.patch create mode 100644 patches/minecraft/net/minecraft/world/storage/loot/LootTable.java.patch create mode 100644 patches/minecraft/net/minecraft/world/storage/loot/LootTableManager.java.patch create mode 100644 patches/minecraft/net/minecraft/world/storage/loot/conditions/LootConditionManager.java.patch create mode 100644 patches/minecraft/net/minecraft/world/storage/loot/conditions/RandomChanceWithLooting.java.patch create mode 100644 patches/minecraft/net/minecraft/world/storage/loot/functions/LootingEnchantBonus.java.patch create mode 100644 src/main/java/net/minecraftforge/common/extensions/IForgeFluid.java create mode 100644 src/main/java/net/minecraftforge/common/extensions/IForgeFluidState.java delete mode 100644 src/main/java/net/minecraftforge/event/entity/minecart/MinecartCollisionEvent.java delete mode 100644 src/main/java/net/minecraftforge/event/entity/minecart/MinecartEvent.java delete mode 100644 src/main/java/net/minecraftforge/event/entity/minecart/MinecartInteractEvent.java delete mode 100644 src/main/java/net/minecraftforge/event/entity/minecart/MinecartUpdateEvent.java diff --git a/patches/minecraft/net/minecraft/block/Block.java.patch b/patches/minecraft/net/minecraft/block/Block.java.patch index 7d66e87c2..a070e9a63 100644 --- a/patches/minecraft/net/minecraft/block/Block.java.patch +++ b/patches/minecraft/net/minecraft/block/Block.java.patch @@ -28,7 +28,15 @@ protected boolean canSilkHarvest() { return this.getDefaultState().isFullCube() && !this.hasTileEntity(); } -@@ -1604,4 +1605,56 @@ +@@ -755,6 +756,7 @@ + } + } + ++ @Deprecated //Forge: Use more sensitive version {@link IForgeBlockState#getSoundType(IWorldReader, BlockPos, Entity) } + public SoundType getSoundType() { + return this.blockSoundType; + } +@@ -1604,4 +1606,56 @@ return Objects.hash(this.field_212164_a, this.field_212165_b, this.field_212166_c); } } diff --git a/patches/minecraft/net/minecraft/entity/Entity.java.patch b/patches/minecraft/net/minecraft/entity/Entity.java.patch index 25a96757a..1e936ba8b 100644 --- a/patches/minecraft/net/minecraft/entity/Entity.java.patch +++ b/patches/minecraft/net/minecraft/entity/Entity.java.patch @@ -1,14 +1,6 @@ --- a/net/minecraft/entity/Entity.java +++ b/net/minecraft/entity/Entity.java -@@ -12,6 +12,7 @@ - import java.util.Random; - import java.util.Set; - import java.util.UUID; -+ - import javax.annotation.Nullable; - import net.minecraft.advancements.CriteriaTriggers; - import net.minecraft.block.Block; -@@ -97,7 +98,7 @@ +@@ -97,7 +97,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -17,7 +9,16 @@ protected static final Logger LOGGER = LogManager.getLogger(); private static final List EMPTY_EQUIPMENT = Collections.emptyList(); private static final AxisAlignedBB ZERO_AABB = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D); -@@ -221,6 +222,8 @@ +@@ -210,7 +210,7 @@ + this.world = p_i48580_2_; + this.setPosition(0.0D, 0.0D, 0.0D); + if (p_i48580_2_ != null) { +- this.dimension = p_i48580_2_.provider.getDimensionType().getId(); ++ this.dimension = p_i48580_2_.provider.getId(); + } + + this.dataManager = new EntityDataManager(this); +@@ -221,6 +221,8 @@ this.dataManager.register(SILENT, false); this.dataManager.register(NO_GRAVITY, false); this.entityInit(); @@ -26,14 +27,100 @@ } public EntityType func_200600_R() { -@@ -2053,6 +2056,14 @@ +@@ -845,7 +847,7 @@ + + protected void playStepSound(BlockPos pos, IBlockState blockIn) { + if (!blockIn.getMaterial().isLiquid()) { +- SoundType soundtype = this.world.getBlockState(pos.up()).getBlock() == Blocks.SNOW ? Blocks.SNOW.getSoundType() : blockIn.getBlock().getSoundType(); ++ SoundType soundtype = this.world.getBlockState(pos.up()).getBlock() == Blocks.SNOW ? Blocks.SNOW.getSoundType() : blockIn.getSoundType(world, pos, this); + this.playSound(soundtype.getStepSound(), soundtype.getVolume() * 0.15F, soundtype.getPitch()); + } + } +@@ -1040,6 +1042,7 @@ + int k = MathHelper.floor(this.posZ); + BlockPos blockpos = new BlockPos(i, j, k); + IBlockState iblockstate = this.world.getBlockState(blockpos); ++ if (!iblockstate.addRunningEffects(world, blockpos, this)) + if (iblockstate.getRenderType() != EnumBlockRenderType.INVISIBLE) { + this.world.func_195594_a(new BlockParticleData(Particles.field_197611_d, iblockstate), this.posX + ((double)this.rand.nextFloat() - 0.5D) * (double)this.width, this.getEntityBoundingBox().minY + 0.1D, this.posZ + ((double)this.rand.nextFloat() - 0.5D) * (double)this.width, -this.motionX * 4.0D, 1.5D, -this.motionZ * 4.0D); + } +@@ -1053,7 +1056,7 @@ + double d0 = this.posY + (double)this.getEyeHeight(); + BlockPos blockpos = new BlockPos(this.posX, d0, this.posZ); + IFluidState ifluidstate = this.world.func_204610_c(blockpos); +- return ifluidstate.func_206884_a(p_208600_1_) && d0 < (double)((float)blockpos.getY() + ifluidstate.func_206885_f() + 0.11111111F); ++ return ifluidstate.isEntityInside(world, blockpos, this, d0, p_208600_1_, true); + } + } + +@@ -1370,6 +1373,7 @@ + if (this.glowing) { + compound.setBoolean("Glowing", this.glowing); + } ++ compound.setBoolean("CanUpdate", canUpdate); + + if (!this.tags.isEmpty()) { + NBTTagList nbttaglist = new NBTTagList(); +@@ -1381,6 +1385,9 @@ + compound.setTag("Tags", nbttaglist); + } + ++ NBTTagCompound caps = serializeCaps(); ++ if (caps != null) compound.setTag("ForgeCaps", caps); ++ + this.writeEntityToNBT(compound); + if (this.isBeingRidden()) { + NBTTagList nbttaglist1 = new NBTTagList(); +@@ -1466,6 +1473,8 @@ + this.setSilent(compound.getBoolean("Silent")); + this.setNoGravity(compound.getBoolean("NoGravity")); + this.setGlowing(compound.getBoolean("Glowing")); ++ if (compound.hasKey("CanUpdate", 99)) this.canUpdate(compound.getBoolean("CanUpdate")); ++ if (compound.hasKey("ForgeCaps", 10)) deserializeCaps(compound.getCompoundTag("ForgeCaps")); + if (compound.hasKey("Tags", 9)) { + this.tags.clear(); + NBTTagList nbttaglist1 = compound.getTagList("Tags", 8); +@@ -1546,6 +1555,8 @@ + } else { + EntityItem entityitem = new EntityItem(this.world, this.posX, this.posY + (double)offsetY, this.posZ, stack); + entityitem.setDefaultPickupDelay(); ++ if (captureDrops() != null) captureDrops().add(entityitem); ++ else + this.world.spawnEntity(entityitem); + return entityitem; + } +@@ -1595,6 +1606,7 @@ + this.motionX = 0.0D; + this.motionY = 0.0D; + this.motionZ = 0.0D; ++ if (canUpdate()) + this.onUpdate(); + if (this.isRiding()) { + entity.updatePassenger(this); +@@ -1636,6 +1648,7 @@ + } + } + ++ if (!net.minecraftforge.event.ForgeEventFactory.canMountEntity(this, entityIn, true)) return false; + if (force || this.canBeRidden(entityIn) && entityIn.canFitPassenger(this)) { + if (this.isRiding()) { + this.dismountRidingEntity(); +@@ -1663,6 +1676,7 @@ + public void dismountRidingEntity() { + if (this.ridingEntity != null) { + Entity entity = this.ridingEntity; ++ if (!net.minecraftforge.event.ForgeEventFactory.canMountEntity(this, entity, false)) return; + this.ridingEntity = null; + entity.removePassenger(this); + } +@@ -2053,6 +2067,14 @@ @Nullable public Entity changeDimension(int dimensionIn) { + if (this.world.isRemote || this.isDead) return null; + return changeDimension(dimensionIn, this.getServer().getWorld(dimensionIn).getDefaultTeleporter()); + } -+ ++ + @Nullable // Forge: Entities that require custom handling should override this method, not the other + public Entity changeDimension(int dimensionIn, net.minecraftforge.common.util.ITeleporter teleporter) + { @@ -41,7 +128,7 @@ if (!this.world.isRemote && !this.isDead) { this.world.profiler.startSection("changeDimension"); MinecraftServer minecraftserver = this.getServer(); -@@ -2060,7 +2071,7 @@ +@@ -2060,7 +2082,7 @@ WorldServer worldserver = minecraftserver.getWorld(i); WorldServer worldserver1 = minecraftserver.getWorld(dimensionIn); this.dimension = dimensionIn; @@ -50,7 +137,7 @@ worldserver1 = minecraftserver.func_200667_a(DimensionType.OVERWORLD); this.dimension = 0; } -@@ -2069,16 +2080,17 @@ +@@ -2069,16 +2091,17 @@ this.isDead = false; this.world.profiler.startSection("reposition"); BlockPos blockpos; @@ -73,7 +160,7 @@ d0 = MathHelper.clamp(d0 * 8.0D, worldserver1.getWorldBorder().minX() + 16.0D, worldserver1.getWorldBorder().maxX() - 16.0D); d1 = MathHelper.clamp(d1 * 8.0D, worldserver1.getWorldBorder().minZ() + 16.0D, worldserver1.getWorldBorder().maxZ() - 16.0D); } -@@ -2087,8 +2099,7 @@ +@@ -2087,8 +2110,7 @@ d1 = (double)MathHelper.clamp((int)d1, -29999872, 29999872); float f = this.rotationYaw; this.setLocationAndAngles(d0, this.posY, d1, 90.0F, 0.0F); @@ -83,3 +170,45 @@ blockpos = new BlockPos(this); } +@@ -2097,7 +2119,7 @@ + Entity entity = this.func_200600_R().func_200721_a(worldserver1); + if (entity != null) { + entity.copyDataFromOld(this); +- if (i == 1 && dimensionIn == 1) { ++ if (i == 1 && dimensionIn == 1 && teleporter.isVanilla()) { + BlockPos blockpos1 = worldserver1.func_205770_a(Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver1.getSpawnPoint()); + entity.moveToBlockPosAndAngles(blockpos1, entity.rotationYaw, entity.rotationPitch); + } else { +@@ -2591,4 +2613,32 @@ + public double func_212107_bY() { + return this.field_211517_W; + } ++ ++ private boolean canUpdate = false; ++ @Override ++ public void canUpdate(boolean value) { ++ this.canUpdate = value; ++ } ++ @Override ++ public boolean canUpdate() { ++ return this.canUpdate; ++ } ++ private Collection captureDrops = null; ++ @Override ++ public Collection captureDrops() { ++ return captureDrops; ++ } ++ @Override ++ public Collection captureDrops(Collection value) { ++ Collection ret = captureDrops; ++ this.captureDrops = value; ++ return ret; ++ } ++ @Override ++ public boolean canTrample(IBlockState state, BlockPos pos, float fallDistance) { ++ return world.rand.nextFloat() < fallDistance - 0.5F ++ && this instanceof EntityLivingBase ++ && (this instanceof EntityPlayer || net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(world, this)) ++ && this.width * this.width * this.height > 0.512F; ++ } + } diff --git a/patches/minecraft/net/minecraft/entity/item/EntityMinecart.java.patch b/patches/minecraft/net/minecraft/entity/item/EntityMinecart.java.patch new file mode 100644 index 000000000..dc945f1a0 --- /dev/null +++ b/patches/minecraft/net/minecraft/entity/item/EntityMinecart.java.patch @@ -0,0 +1,18 @@ +--- a/net/minecraft/entity/item/EntityMinecart.java ++++ b/net/minecraft/entity/item/EntityMinecart.java +@@ -808,4 +808,15 @@ + return idIn >= 0 && idIn < BY_ID.length ? BY_ID[idIn] : RIDEABLE; + } + } ++ ++ public ItemStack getCartItem() { ++ switch (getType()) { ++ case FURNACE: return new ItemStack(Items.FURNACE_MINECART); ++ case CHEST: return new ItemStack(Items.CHEST_MINECART); ++ case TNT: return new ItemStack(Items.TNT_MINECART); ++ case HOPPER: return new ItemStack(Items.HOPPER_MINECART); ++ case COMMAND_BLOCK: return new ItemStack(Items.COMMAND_BLOCK_MINECART); ++ default: return new ItemStack(Items.MINECART); ++ } ++ } + } diff --git a/patches/minecraft/net/minecraft/fluid/Fluid.java.patch b/patches/minecraft/net/minecraft/fluid/Fluid.java.patch new file mode 100644 index 000000000..f2ea69f51 --- /dev/null +++ b/patches/minecraft/net/minecraft/fluid/Fluid.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/fluid/Fluid.java ++++ b/net/minecraft/fluid/Fluid.java +@@ -19,7 +19,7 @@ + import net.minecraftforge.api.distmarker.Dist; + import net.minecraftforge.api.distmarker.OnlyIn; + +-public abstract class Fluid { ++public abstract class Fluid implements net.minecraftforge.common.extensions.IForgeFluid { + private static final ResourceLocation field_207199_a = new ResourceLocation("empty"); + public static final RegistryNamespacedDefaultedByKey field_205588_a = new RegistryNamespacedDefaultedByKey(field_207199_a); + public static final ObjectIntIdentityMap field_207201_d = new ObjectIntIdentityMap(); diff --git a/patches/minecraft/net/minecraft/fluid/IFluidState.java.patch b/patches/minecraft/net/minecraft/fluid/IFluidState.java.patch new file mode 100644 index 000000000..05846306c --- /dev/null +++ b/patches/minecraft/net/minecraft/fluid/IFluidState.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/fluid/IFluidState.java ++++ b/net/minecraft/fluid/IFluidState.java +@@ -16,7 +16,7 @@ + import net.minecraftforge.api.distmarker.Dist; + import net.minecraftforge.api.distmarker.OnlyIn; + +-public interface IFluidState extends IStateHolder { ++public interface IFluidState extends IStateHolder, net.minecraftforge.common.extensions.IForgeFluidState { + Fluid func_206886_c(); + + default boolean func_206889_d() { diff --git a/patches/minecraft/net/minecraft/item/ItemStack.java.patch b/patches/minecraft/net/minecraft/item/ItemStack.java.patch index 89ec66f43..1d7c50ae8 100644 --- a/patches/minecraft/net/minecraft/item/ItemStack.java.patch +++ b/patches/minecraft/net/minecraft/item/ItemStack.java.patch @@ -72,31 +72,7 @@ EntityPlayer entityplayer = p_196084_1_.func_195999_j(); BlockPos blockpos = p_196084_1_.func_195995_a(); BlockWorldState blockworldstate = new BlockWorldState(p_196084_1_.func_195991_k(), blockpos, false); -@@ -164,6 +173,23 @@ - } - } - -+ public EnumActionResult onItemUseFirst(ItemUseContext p_196084_1_) { -+ EntityPlayer entityplayer = p_196084_1_.func_195999_j(); -+ BlockPos blockpos = p_196084_1_.func_195995_a(); -+ BlockWorldState blockworldstate = new BlockWorldState(p_196084_1_.func_195991_k(), blockpos, false); -+ if (entityplayer != null && !entityplayer.capabilities.allowEdit && !this.func_206847_b(p_196084_1_.func_195991_k().func_205772_D(), blockworldstate)) { -+ return EnumActionResult.PASS; -+ } else { -+ Item item = this.getItem(); -+ EnumActionResult enumactionresult = item.onItemUseFirst(p_196084_1_); -+ if (entityplayer != null && enumactionresult == EnumActionResult.SUCCESS) { -+ entityplayer.addStat(StatList.OBJECT_USE_STATS.func_199076_b(item)); -+ } -+ -+ return enumactionresult; -+ } -+ } -+ - public float getDestroySpeed(IBlockState blockIn) { - return this.getItem().getDestroySpeed(this, blockIn); - } -@@ -183,12 +209,15 @@ +@@ -183,12 +192,15 @@ if (this.stackTagCompound != null) { nbt.setTag("tag", this.stackTagCompound); } @@ -114,7 +90,7 @@ } public boolean isStackable() { -@@ -196,7 +225,7 @@ +@@ -196,7 +208,7 @@ } public boolean isItemStackDamageable() { @@ -123,7 +99,7 @@ NBTTagCompound nbttagcompound = this.getTagCompound(); return nbttagcompound == null || !nbttagcompound.getBoolean("Unbreakable"); } else { -@@ -205,19 +234,19 @@ +@@ -205,7 +217,7 @@ } public boolean isItemDamaged() { @@ -131,15 +107,8 @@ + return this.isItemStackDamageable() && getItem().isDamaged(this); } -- public int getItemDamage() { -- return this.stackTagCompound == null ? 0 : this.stackTagCompound.getInteger("Damage"); -+ public int getItemDamage() { // TODO evaluate the necessity of this patch -+ return this.getItem().getDamage(this); - } - - public void func_196085_b(int p_196085_1_) { -- this.func_196082_o().setInteger("Damage", Math.max(0, p_196085_1_)); -+ getItem().setDamage(this, p_196085_1_); + public int getItemDamage() { +@@ -217,7 +229,7 @@ } public int getMaxDamage() { @@ -148,7 +117,7 @@ } public boolean attemptDamageItem(int amount, Random rand, @Nullable EntityPlayerMP damager) { -@@ -285,7 +314,7 @@ +@@ -285,7 +297,7 @@ } public boolean canHarvestBlock(IBlockState blockIn) { @@ -157,7 +126,7 @@ } public boolean interactWithEntity(EntityPlayer playerIn, EntityLivingBase entityIn, EnumHand hand) { -@@ -293,7 +322,7 @@ +@@ -293,7 +305,7 @@ } public ItemStack copy() { @@ -166,7 +135,7 @@ itemstack.setAnimationsToGo(this.getAnimationsToGo()); if (this.stackTagCompound != null) { itemstack.stackTagCompound = this.stackTagCompound.copy(); -@@ -309,7 +338,7 @@ +@@ -309,7 +321,7 @@ if (stackA.stackTagCompound == null && stackB.stackTagCompound != null) { return false; } else { @@ -175,7 +144,7 @@ } } else { return false; -@@ -332,7 +361,7 @@ +@@ -332,7 +344,7 @@ } else if (this.stackTagCompound == null && other.stackTagCompound != null) { return false; } else { @@ -184,7 +153,7 @@ } } -@@ -633,6 +662,7 @@ +@@ -633,6 +645,7 @@ } } @@ -192,35 +161,26 @@ return list; } -@@ -743,7 +773,7 @@ +@@ -743,7 +756,7 @@ } } } else { - multimap = this.getItem().getItemAttributeModifiers(equipmentSlot); -+ multimap = this.getItem().getAttributeModifiers(equipmentSlot, this); ++ multimap = this.getItem().getAttributeModifiers(equipmentSlot, this); } return multimap; -@@ -874,4 +904,98 @@ +@@ -874,4 +887,89 @@ public void shrink(int quantity) { this.grow(-quantity); } + + // FORGE START -+ + public void deserializeNBT(NBTTagCompound nbt) + { -+ // TODO do this better while respecting new rules -+ final ItemStack itemStack = new ItemStack(nbt); -+ this.stackTagCompound = itemStack.stackTagCompound; -+ this.capNBT = itemStack.capNBT; - } -+ -+ public NBTTagCompound serializeNBT() -+ { -+ NBTTagCompound ret = new NBTTagCompound(); -+ this.writeToNBT(ret); -+ return ret; ++ final ItemStack itemStack = ItemStack.func_199557_a(nbt); ++ getStack().setTagCompound(itemStack.getTagCompound()); ++ if (itemStack.capNBT != null) deserializeCaps(itemStack.capNBT); + } + + /** @@ -299,4 +259,4 @@ + { + return this.isEmpty() || this.getItem().doesSneakBypassUse(this, world, pos, player); + } -+} + } diff --git a/patches/minecraft/net/minecraft/world/Explosion.java.patch b/patches/minecraft/net/minecraft/world/Explosion.java.patch new file mode 100644 index 000000000..62bc0a9dd --- /dev/null +++ b/patches/minecraft/net/minecraft/world/Explosion.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/Explosion.java ++++ b/net/minecraft/world/Explosion.java +@@ -92,7 +92,7 @@ + BlockPos blockpos = new BlockPos(d4, d6, d8); + IBlockState iblockstate = this.world.getBlockState(blockpos); + IFluidState ifluidstate = this.world.func_204610_c(blockpos); +- float f2 = Math.max(iblockstate.getBlock().getExplosionResistance(), ifluidstate.func_210200_l()); ++ float f2 = Math.max(iblockstate.getExplosionResistance(world, blockpos, exploder, this), ifluidstate.getExplosionResistance(world, blockpos, exploder, this)); + if (f2 > 0.0F) { + if (this.exploder != null) { + f2 = this.exploder.getExplosionResistance(this, this.world, blockpos, iblockstate, ifluidstate, f2); diff --git a/patches/minecraft/net/minecraft/world/storage/loot/LootContext.java.patch b/patches/minecraft/net/minecraft/world/storage/loot/LootContext.java.patch new file mode 100644 index 000000000..3d6d5de1b --- /dev/null +++ b/patches/minecraft/net/minecraft/world/storage/loot/LootContext.java.patch @@ -0,0 +1,13 @@ +--- a/net/minecraft/world/storage/loot/LootContext.java ++++ b/net/minecraft/world/storage/loot/LootContext.java +@@ -91,6 +91,10 @@ + } + } + ++ public int getLootingModifier() { ++ return net.minecraftforge.common.ForgeHooks.getLootingLevel(getLootedEntity(), getKiller(), damageSource); ++ } ++ + public static class Builder { + private final WorldServer world; + private float luck; diff --git a/patches/minecraft/net/minecraft/world/storage/loot/LootEntry.java.patch b/patches/minecraft/net/minecraft/world/storage/loot/LootEntry.java.patch new file mode 100644 index 000000000..501cce4af --- /dev/null +++ b/patches/minecraft/net/minecraft/world/storage/loot/LootEntry.java.patch @@ -0,0 +1,49 @@ +--- a/net/minecraft/world/storage/loot/LootEntry.java ++++ b/net/minecraft/world/storage/loot/LootEntry.java +@@ -20,13 +20,17 @@ + protected final int weight; + protected final int quality; + protected final LootCondition[] conditions; ++ protected final String entryName; + +- protected LootEntry(int weightIn, int qualityIn, LootCondition[] conditionsIn) { ++ protected LootEntry(int weightIn, int qualityIn, LootCondition[] conditionsIn, String entryName) { + this.weight = weightIn; + this.quality = qualityIn; + this.conditions = conditionsIn; ++ this.entryName = entryName; + } + ++ public String getEntryName() { return this.entryName; } ++ + public int getEffectiveWeight(float luck) { + return Math.max(MathHelper.floor((float)this.weight + (float)this.quality * luck), 0); + } +@@ -48,6 +52,9 @@ + alootcondition = new LootCondition[0]; + } + ++ LootEntry ret = net.minecraftforge.common.ForgeHooks.deserializeJsonLootEntry(s, jsonobject, i, j, alootcondition); ++ if (ret != null) return ret; ++ + if ("item".equals(s)) { + return LootEntryItem.deserialize(jsonobject, p_deserialize_3_, i, j, alootcondition); + } else if ("loot_table".equals(s)) { +@@ -61,12 +68,17 @@ + + public JsonElement serialize(LootEntry p_serialize_1_, Type p_serialize_2_, JsonSerializationContext p_serialize_3_) { + JsonObject jsonobject = new JsonObject(); ++ if (p_serialize_1_.entryName != null && !p_serialize_1_.entryName.startsWith("custom#")) ++ jsonobject.addProperty("entryName", p_serialize_1_.entryName); + jsonobject.addProperty("weight", p_serialize_1_.weight); + jsonobject.addProperty("quality", p_serialize_1_.quality); + if (p_serialize_1_.conditions.length > 0) { + jsonobject.add("conditions", p_serialize_3_.serialize(p_serialize_1_.conditions)); + } + ++ String type = net.minecraftforge.common.ForgeHooks.getLootEntryType(p_serialize_1_); ++ if (type != null) jsonobject.addProperty("type", type); ++ else + if (p_serialize_1_ instanceof LootEntryItem) { + jsonobject.addProperty("type", "item"); + } else if (p_serialize_1_ instanceof LootEntryTable) { diff --git a/patches/minecraft/net/minecraft/world/storage/loot/LootEntryEmpty.java.patch b/patches/minecraft/net/minecraft/world/storage/loot/LootEntryEmpty.java.patch new file mode 100644 index 000000000..7037a0333 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/storage/loot/LootEntryEmpty.java.patch @@ -0,0 +1,21 @@ +--- a/net/minecraft/world/storage/loot/LootEntryEmpty.java ++++ b/net/minecraft/world/storage/loot/LootEntryEmpty.java +@@ -9,8 +9,8 @@ + import net.minecraft.world.storage.loot.conditions.LootCondition; + + public class LootEntryEmpty extends LootEntry { +- public LootEntryEmpty(int weightIn, int qualityIn, LootCondition[] conditionsIn) { +- super(weightIn, qualityIn, conditionsIn); ++ public LootEntryEmpty(int weightIn, int qualityIn, LootCondition[] conditionsIn, String entryName) { ++ super(weightIn, qualityIn, conditionsIn, entryName); + } + + public void addLoot(Collection stacks, Random rand, LootContext context) { +@@ -20,6 +20,6 @@ + } + + public static LootEntryEmpty deserialize(JsonObject object, JsonDeserializationContext deserializationContext, int weightIn, int qualityIn, LootCondition[] conditionsIn) { +- return new LootEntryEmpty(weightIn, qualityIn, conditionsIn); ++ return new LootEntryEmpty(weightIn, qualityIn, conditionsIn, net.minecraftforge.common.ForgeHooks.readLootEntryName(object, "empty")); + } + } diff --git a/patches/minecraft/net/minecraft/world/storage/loot/LootEntryItem.java.patch b/patches/minecraft/net/minecraft/world/storage/loot/LootEntryItem.java.patch new file mode 100644 index 000000000..425a1861a --- /dev/null +++ b/patches/minecraft/net/minecraft/world/storage/loot/LootEntryItem.java.patch @@ -0,0 +1,30 @@ +--- a/net/minecraft/world/storage/loot/LootEntryItem.java ++++ b/net/minecraft/world/storage/loot/LootEntryItem.java +@@ -17,8 +17,8 @@ + protected final Item item; + protected final LootFunction[] functions; + +- public LootEntryItem(Item itemIn, int weightIn, int qualityIn, LootFunction[] functionsIn, LootCondition[] conditionsIn) { +- super(weightIn, qualityIn, conditionsIn); ++ public LootEntryItem(Item itemIn, int weightIn, int qualityIn, LootFunction[] functionsIn, LootCondition[] conditionsIn, String entryName) { ++ super(weightIn, qualityIn, conditionsIn, entryName); + this.item = itemIn; + this.functions = functionsIn; + } +@@ -33,7 +33,7 @@ + } + + if (!itemstack.isEmpty()) { +- if (itemstack.getCount() < this.item.getItemStackLimit()) { ++ if (itemstack.getCount() < itemstack.getMaxStackSize()) { + stacks.add(itemstack); + } else { + int i = itemstack.getCount(); +@@ -71,6 +71,6 @@ + alootfunction = new LootFunction[0]; + } + +- return new LootEntryItem(item, weightIn, qualityIn, alootfunction, conditionsIn); ++ return new LootEntryItem(item, weightIn, qualityIn, alootfunction, conditionsIn, net.minecraftforge.common.ForgeHooks.readLootEntryName(object, "item")); + } + } diff --git a/patches/minecraft/net/minecraft/world/storage/loot/LootEntryTable.java.patch b/patches/minecraft/net/minecraft/world/storage/loot/LootEntryTable.java.patch new file mode 100644 index 000000000..f5a79fc1a --- /dev/null +++ b/patches/minecraft/net/minecraft/world/storage/loot/LootEntryTable.java.patch @@ -0,0 +1,21 @@ +--- a/net/minecraft/world/storage/loot/LootEntryTable.java ++++ b/net/minecraft/world/storage/loot/LootEntryTable.java +@@ -13,8 +13,8 @@ + public class LootEntryTable extends LootEntry { + protected final ResourceLocation table; + +- public LootEntryTable(ResourceLocation tableIn, int weightIn, int qualityIn, LootCondition[] conditionsIn) { +- super(weightIn, qualityIn, conditionsIn); ++ public LootEntryTable(ResourceLocation tableIn, int weightIn, int qualityIn, LootCondition[] conditionsIn, String entryName) { ++ super(weightIn, qualityIn, conditionsIn, entryName); + this.table = tableIn; + } + +@@ -29,6 +29,6 @@ + + public static LootEntryTable deserialize(JsonObject object, JsonDeserializationContext deserializationContext, int weightIn, int qualityIn, LootCondition[] conditionsIn) { + ResourceLocation resourcelocation = new ResourceLocation(JsonUtils.getString(object, "name")); +- return new LootEntryTable(resourcelocation, weightIn, qualityIn, conditionsIn); ++ return new LootEntryTable(resourcelocation, weightIn, qualityIn, conditionsIn, net.minecraftforge.common.ForgeHooks.readLootEntryName(object, "loot_table")); + } + } diff --git a/patches/minecraft/net/minecraft/world/storage/loot/LootPool.java.patch b/patches/minecraft/net/minecraft/world/storage/loot/LootPool.java.patch new file mode 100644 index 000000000..b4707f72c --- /dev/null +++ b/patches/minecraft/net/minecraft/world/storage/loot/LootPool.java.patch @@ -0,0 +1,91 @@ +--- a/net/minecraft/world/storage/loot/LootPool.java ++++ b/net/minecraft/world/storage/loot/LootPool.java +@@ -20,14 +20,16 @@ + import org.apache.commons.lang3.ArrayUtils; + + public class LootPool { +- private final LootEntry[] lootEntries; +- private final LootCondition[] poolConditions; ++ private final String name; ++ private final List lootEntries; ++ private final List poolConditions; + private RandomValueRange rolls; + private RandomValueRange bonusRolls; + +- public LootPool(LootEntry[] lootEntriesIn, LootCondition[] poolConditionsIn, RandomValueRange rollsIn, RandomValueRange bonusRollsIn) { +- this.lootEntries = lootEntriesIn; +- this.poolConditions = poolConditionsIn; ++ public LootPool(LootEntry[] lootEntriesIn, LootCondition[] poolConditionsIn, RandomValueRange rollsIn, RandomValueRange bonusRollsIn, String name) { ++ this.name = name; ++ this.lootEntries = Lists.newArrayList(lootEntriesIn); ++ this.poolConditions = Lists.newArrayList(poolConditionsIn); + this.rolls = rollsIn; + this.bonusRolls = bonusRollsIn; + } +@@ -71,6 +73,43 @@ + } + } + ++ ++ ++ //======================== FORGE START ============================================= ++ private boolean isFrozen = false; ++ public void freeze() { this.isFrozen = true; } ++ public boolean isFrozen(){ return this.isFrozen; } ++ private void checkFrozen() { ++ if (this.isFrozen()) ++ throw new RuntimeException("Attempted to modify LootPool after being frozen!"); ++ } ++ public String getName(){ return this.name; } ++ public RandomValueRange getRolls() { return this.rolls; } ++ public RandomValueRange getBonusRolls() { return this.bonusRolls; } ++ public void setRolls (RandomValueRange v){ checkFrozen(); this.rolls = v; } ++ public void setBonusRolls(RandomValueRange v){ checkFrozen(); this.bonusRolls = v; } ++ public LootEntry getEntry(String name) { ++ return lootEntries.stream().filter(e -> name.equals(e.getEntryName())).findFirst().orElse(null); ++ } ++ public LootEntry removeEntry(String name) { ++ checkFrozen(); ++ for (LootEntry entry : this.lootEntries) { ++ if (name.equals(entry.getEntryName())) { ++ this.lootEntries.remove(entry); ++ return entry; ++ } ++ } ++ return null; ++ } ++ public void addEntry(LootEntry entry) { ++ checkFrozen(); ++ if (lootEntries.stream().anyMatch(e -> e == entry || e.getEntryName().equals(entry.getEntryName()))) ++ throw new RuntimeException("Attempted to add a duplicate entry to pool: " + entry.getEntryName()); ++ this.lootEntries.add(entry); ++ } ++ //TODO: Allow modifications of conditions? If so need a way to uniquely identify them. ++ //======================== FORGE END =============================================== ++ + public static class Serializer implements JsonDeserializer, JsonSerializer { + public LootPool deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException { + JsonObject jsonobject = JsonUtils.getJsonObject(p_deserialize_1_, "loot pool"); +@@ -78,18 +117,20 @@ + LootCondition[] alootcondition = (LootCondition[])JsonUtils.deserializeClass(jsonobject, "conditions", new LootCondition[0], p_deserialize_3_, LootCondition[].class); + RandomValueRange randomvaluerange = (RandomValueRange)JsonUtils.deserializeClass(jsonobject, "rolls", p_deserialize_3_, RandomValueRange.class); + RandomValueRange randomvaluerange1 = (RandomValueRange)JsonUtils.deserializeClass(jsonobject, "bonus_rolls", new RandomValueRange(0.0F, 0.0F), p_deserialize_3_, RandomValueRange.class); +- return new LootPool(alootentry, alootcondition, randomvaluerange, randomvaluerange1); ++ return new LootPool(alootentry, alootcondition, randomvaluerange, randomvaluerange1, net.minecraftforge.common.ForgeHooks.readPoolName(jsonobject)); + } + + public JsonElement serialize(LootPool p_serialize_1_, Type p_serialize_2_, JsonSerializationContext p_serialize_3_) { + JsonObject jsonobject = new JsonObject(); ++ if (p_serialize_1_.name != null && !p_serialize_1_.name.startsWith("custom#")) ++ jsonobject.add("name", p_serialize_3_.serialize(p_serialize_1_.name)); + jsonobject.add("entries", p_serialize_3_.serialize(p_serialize_1_.lootEntries)); + jsonobject.add("rolls", p_serialize_3_.serialize(p_serialize_1_.rolls)); + if (p_serialize_1_.bonusRolls.getMin() != 0.0F && p_serialize_1_.bonusRolls.getMax() != 0.0F) { + jsonobject.add("bonus_rolls", p_serialize_3_.serialize(p_serialize_1_.bonusRolls)); + } + +- if (!ArrayUtils.isEmpty((Object[])p_serialize_1_.poolConditions)) { ++ if (!p_serialize_1_.poolConditions.isEmpty()) { + jsonobject.add("conditions", p_serialize_3_.serialize(p_serialize_1_.poolConditions)); + } + diff --git a/patches/minecraft/net/minecraft/world/storage/loot/LootTable.java.patch b/patches/minecraft/net/minecraft/world/storage/loot/LootTable.java.patch new file mode 100644 index 000000000..0077927ff --- /dev/null +++ b/patches/minecraft/net/minecraft/world/storage/loot/LootTable.java.patch @@ -0,0 +1,57 @@ +--- a/net/minecraft/world/storage/loot/LootTable.java ++++ b/net/minecraft/world/storage/loot/LootTable.java +@@ -23,10 +23,10 @@ + public class LootTable { + private static final Logger LOGGER = LogManager.getLogger(); + public static final LootTable EMPTY_LOOT_TABLE = new LootTable(new LootPool[0]); +- private final LootPool[] pools; ++ private final List pools; + + public LootTable(LootPool[] poolsIn) { +- this.pools = poolsIn; ++ this.pools = Lists.newArrayList(poolsIn); + } + + public List generateLootForPools(Random rand, LootContext context) { +@@ -112,6 +112,41 @@ + return list; + } + ++ //======================== FORGE START ============================================= ++ private boolean isFrozen = false; ++ public void freeze() { ++ this.isFrozen = true; ++ this.pools.forEach(LootPool::freeze); ++ } ++ public boolean isFrozen(){ return this.isFrozen; } ++ private void checkFrozen() { ++ if (this.isFrozen()) ++ throw new RuntimeException("Attempted to modify LootTable after being finalized!"); ++ } ++ ++ public LootPool getPool(String name) { ++ return pools.stream().filter(e -> name.equals(e.getName())).findFirst().orElse(null); ++ } ++ ++ public LootPool removePool(String name) { ++ checkFrozen(); ++ for (LootPool pool : this.pools) { ++ if (name.equals(pool.getName())) { ++ this.pools.remove(pool); ++ return pool; ++ } ++ } ++ return null; ++ } ++ ++ public void addPool(LootPool pool) { ++ checkFrozen(); ++ if (pools.stream().anyMatch(e -> e == pool || e.getName().equals(pool.getName()))) ++ throw new RuntimeException("Attempted to add a duplicate pool to loot table: " + pool.getName()); ++ this.pools.add(pool); ++ } ++ //======================== FORGE END =============================================== ++ + public static class Serializer implements JsonDeserializer, JsonSerializer { + public LootTable deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException { + JsonObject jsonobject = JsonUtils.getJsonObject(p_deserialize_1_, "loot table"); diff --git a/patches/minecraft/net/minecraft/world/storage/loot/LootTableManager.java.patch b/patches/minecraft/net/minecraft/world/storage/loot/LootTableManager.java.patch new file mode 100644 index 000000000..84e10d557 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/storage/loot/LootTableManager.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/storage/loot/LootTableManager.java ++++ b/net/minecraft/world/storage/loot/LootTableManager.java +@@ -39,7 +39,7 @@ + ResourceLocation resourcelocation1 = new ResourceLocation(resourcelocation.getNamespace(), s.substring(field_195435_a, s.length() - field_195436_b)); + + try (IResource iresource = p_195410_1_.func_199002_a(resourcelocation)) { +- LootTable loottable = (LootTable)JsonUtils.gsonDeserialize(GSON_INSTANCE, IOUtils.toString(iresource.func_199027_b(), StandardCharsets.UTF_8), LootTable.class); ++ LootTable loottable = net.minecraftforge.common.ForgeHooks.loadLootTable(GSON_INSTANCE, resourcelocation, IOUtils.toString(iresource.func_199027_b(), StandardCharsets.UTF_8), iresource.func_199026_d().equals("Default"), this); + if (loottable != null) { + this.registeredLootTables.put(resourcelocation1, loottable); + } diff --git a/patches/minecraft/net/minecraft/world/storage/loot/conditions/LootConditionManager.java.patch b/patches/minecraft/net/minecraft/world/storage/loot/conditions/LootConditionManager.java.patch new file mode 100644 index 000000000..ea0a6b36e --- /dev/null +++ b/patches/minecraft/net/minecraft/world/storage/loot/conditions/LootConditionManager.java.patch @@ -0,0 +1,13 @@ +--- a/net/minecraft/world/storage/loot/conditions/LootConditionManager.java ++++ b/net/minecraft/world/storage/loot/conditions/LootConditionManager.java +@@ -34,6 +34,10 @@ + } + } + ++ public static boolean testAllConditions(@Nullable Iterable conditions, Random rand, LootContext context) { ++ return conditions == null || java.util.stream.StreamSupport.stream(conditions.spliterator(), false).allMatch(c -> c.testCondition(rand, context)); ++ } ++ + public static boolean testAllConditions(@Nullable LootCondition[] conditions, Random rand, LootContext context) { + if (conditions == null) { + return true; diff --git a/patches/minecraft/net/minecraft/world/storage/loot/conditions/RandomChanceWithLooting.java.patch b/patches/minecraft/net/minecraft/world/storage/loot/conditions/RandomChanceWithLooting.java.patch new file mode 100644 index 000000000..7f282ca29 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/storage/loot/conditions/RandomChanceWithLooting.java.patch @@ -0,0 +1,15 @@ +--- a/net/minecraft/world/storage/loot/conditions/RandomChanceWithLooting.java ++++ b/net/minecraft/world/storage/loot/conditions/RandomChanceWithLooting.java +@@ -20,11 +20,7 @@ + } + + public boolean testCondition(Random rand, LootContext context) { +- int i = 0; +- if (context.getKiller() instanceof EntityLivingBase) { +- i = EnchantmentHelper.getLootingModifier((EntityLivingBase)context.getKiller()); +- } +- ++ int i = context.getLootingModifier(); + return rand.nextFloat() < this.chance + (float)i * this.lootingMultiplier; + } + diff --git a/patches/minecraft/net/minecraft/world/storage/loot/functions/LootingEnchantBonus.java.patch b/patches/minecraft/net/minecraft/world/storage/loot/functions/LootingEnchantBonus.java.patch new file mode 100644 index 000000000..4969810f0 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/storage/loot/functions/LootingEnchantBonus.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/storage/loot/functions/LootingEnchantBonus.java ++++ b/net/minecraft/world/storage/loot/functions/LootingEnchantBonus.java +@@ -27,7 +27,7 @@ + public ItemStack apply(ItemStack stack, Random rand, LootContext context) { + Entity entity = context.getKiller(); + if (entity instanceof EntityLivingBase) { +- int i = EnchantmentHelper.getLootingModifier((EntityLivingBase)entity); ++ int i = context.getLootingModifier(); + if (i == 0) { + return stack; + } diff --git a/src/main/java/net/minecraftforge/common/ForgeHooks.java b/src/main/java/net/minecraftforge/common/ForgeHooks.java index 444a1b575..53b2110c7 100644 --- a/src/main/java/net/minecraftforge/common/ForgeHooks.java +++ b/src/main/java/net/minecraftforge/common/ForgeHooks.java @@ -28,6 +28,7 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; +import java.util.Collection; import java.util.Deque; import java.util.HashSet; import java.util.List; @@ -53,6 +54,7 @@ import net.minecraft.advancements.AdvancementManager; import net.minecraft.block.Block; import net.minecraft.block.BlockFarmland; import net.minecraft.block.material.Material; +import net.minecraft.block.state.BlockWorldState; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; @@ -591,13 +593,9 @@ public class ForgeHooks { int looting = 0; if (killer instanceof EntityLivingBase) - { looting = EnchantmentHelper.getLootingModifier((EntityLivingBase)killer); - } if (target instanceof EntityLivingBase) - { looting = getLootingLevel((EntityLivingBase)target, cause, looting); - } return looting; } @@ -657,26 +655,19 @@ public class ForgeHooks @Nullable public static EntityItem onPlayerTossEvent(@Nonnull EntityPlayer player, @Nonnull ItemStack item, boolean includeName) { - player.captureDrops = true; + player.captureDrops(Lists.newArrayList()); EntityItem ret = player.dropItem(item, false, includeName); - player.capturedDrops.clear(); - player.captureDrops = false; + player.captureDrops(null); if (ret == null) - { return null; - } ItemTossEvent event = new ItemTossEvent(ret, player); if (MinecraftForge.EVENT_BUS.post(event)) - { return null; - } if (!player.world.isRemote) - { player.getEntityWorld().spawnEntity(event.getEntityItem()); - } return event.getEntityItem(); } @@ -792,7 +783,7 @@ public class ForgeHooks if (!entityPlayer.isAllowEdit()) { - if (itemstack.isEmpty() || !itemstack.canDestroy(world.getBlockState(pos).getBlock())) + if (itemstack.isEmpty() || !itemstack.func_206848_a(world.func_205772_D(), new BlockWorldState(world, pos, false))) preCancelEvent = true; } } @@ -973,32 +964,6 @@ public class ForgeHooks return ItemStack.EMPTY; } - public static boolean isInsideOfMaterial(Material material, Entity entity, BlockPos pos) - { - IBlockState state = entity.world.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.world, pos); - } - /*else if (block instanceof BlockLiquid) - { - filled = 1.0 - (BlockLiquid.getLiquidHeightPercent(block.getMetaFromState(state)) - (1.0 / 9.0)); - }*/ - - if (filled < 0) - { - return eyes > pos.getY() + (filled + 1); - } - else - { - return eyes < pos.getY() + filled; - } - } - public static boolean onPlayerAttackTarget(EntityPlayer player, Entity target) { if (MinecraftForge.EVENT_BUS.post(new AttackEntityEvent(player, target))) return false; @@ -1215,7 +1180,6 @@ public class ForgeHooks return ctx.validateEntryName(name); } - //TODO: Some registry to support custom LootEntry types? public static LootEntry deserializeJsonLootEntry(String type, JsonObject json, int weight, int quality, LootCondition[] conditions){ return null; } public static String getLootEntryType(LootEntry entry){ return null; } //Companion to above function @@ -1318,7 +1282,7 @@ public class ForgeHooks public static boolean onFarmlandTrample(World world, BlockPos pos, IBlockState state, float fallDistance, Entity entity) { - if (entity.canTrample(world, state.getBlock(), pos, fallDistance)) + if (entity.canTrample(state, pos, fallDistance)) { BlockEvent.FarmlandTrampleEvent event = new BlockEvent.FarmlandTrampleEvent(world, pos, state, fallDistance, entity); MinecraftForge.EVENT_BUS.post(event); diff --git a/src/main/java/net/minecraftforge/common/crafting/CraftingHelper.java b/src/main/java/net/minecraftforge/common/crafting/CraftingHelper.java index 25a6aa079..af1ae1fba 100644 --- a/src/main/java/net/minecraftforge/common/crafting/CraftingHelper.java +++ b/src/main/java/net/minecraftforge/common/crafting/CraftingHelper.java @@ -295,7 +295,7 @@ public class CraftingHelper for(ResourceLocation key : manager.func_199003_a("recipes", filename -> filename.equals("_constants.json"))) { String path = key.getPath(); - if (!path.equals("rrecipes/_constants.json")) //Top level only + if (!path.equals("recipes/_constants.json")) //Top level only continue; try (IResource iresource = manager.func_199002_a(key)) diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeBlock.java b/src/main/java/net/minecraftforge/common/extensions/IForgeBlock.java index f17f8f4aa..8da283e4f 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeBlock.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeBlock.java @@ -670,7 +670,6 @@ public interface IForgeBlock return false; } - /** * Determines the amount of enchanting power this block can provide to an enchanting table. * @param world The World @@ -728,98 +727,51 @@ public interface IForgeBlock return state.isTopSolid(); } - /** - * If this block should be notified of weak changes. - * Weak changes are changes 1 block away through a solid block. - * Similar to comparators. - * - * @param world The current world - * @param pos Block position in world - * @return true To be notified of changes - */ - default boolean getWeakChanges(IBlockState state, IWorldReader world, BlockPos pos) - { - return false; - } - /** - * Queries the class of tool required to harvest this block, if null is returned - * we assume that anything can harvest this block. - */ - ToolType getHarvestTool(IBlockState state); - - /** - * Queries the harvest level of this item stack for the specified tool class, - * Returns -1 if this tool is not of the specified type - * - * @return Harvest level, or -1 if not the specified tool type. - */ - int getHarvestLevel(IBlockState state); - - /** - * Checks if the specified tool type is efficient on this block, - * meaning that it digs at full speed. - */ - default boolean isToolEffective(IBlockState state, ToolType tool) - { - if (tool == ToolType.PICKAXE && (this.getBlock() == Blocks.REDSTONE_ORE || this.getBlock() == Blocks.REDSTONE_LAMP || this.getBlock() == Blocks.OBSIDIAN)) - return false; - return tool == getHarvestTool(state); - } - - /** - * Can return IExtendedBlockState - */ - default IBlockState getExtendedState(IBlockState state, IBlockReader world, BlockPos pos) - { - return state; - } - /** - * Called when the entity is inside this block, may be used to determined if the entity can breathing, - * display material overlays, or if the entity can swim inside a block. + * If this block should be notified of weak changes. + * Weak changes are changes 1 block away through a solid block. + * Similar to comparators. * - * @param world that is being tested. - * @param blockpos position thats being tested. - * @param entity that is being tested. - * @param yToTest, primarily for testingHead, which sends the the eye level of the entity, other wise it sends a y that can be tested vs liquid height. - * @param materialIn to test for. - * @param testingHead when true, its testing the entities head for vision, breathing ect... otherwise its testing the body, for swimming and movement adjustment. - * @return null for default behavior, true if the entity is within the material, false if it was not. + * @param world The current world + * @param pos Block position in world + * @return true To be notified of changes */ - @Nullable - default Boolean isEntityInsideMaterial(IBlockState state, IWorldReader world, BlockPos blockpos, Entity entity, double yToTest, Material materialIn, boolean testingHead) + default boolean getWeakChanges(IBlockState state, IWorldReader world, BlockPos pos) { - return null; + return false; } /** - * Called when boats or fishing hooks are inside the block to check if they are inside - * the material requested. - * - * @param world world that is being tested. - * @param pos block thats being tested. - * @param boundingBox box to test, generally the bounds of an entity that are besting tested. - * @param materialIn to check for. - * @return null for default behavior, true if the box is within the material, false if it was not. + * Queries the class of tool required to harvest this block, if null is returned + * we assume that anything can harvest this block. */ - @Nullable - default Boolean isAABBInsideMaterial(IBlockState state, IWorldReader world, BlockPos pos, AxisAlignedBB boundingBox, Material materialIn) + ToolType getHarvestTool(IBlockState state); + + /** + * Queries the harvest level of this item stack for the specified tool class, + * Returns -1 if this tool is not of the specified type + * + * @return Harvest level, or -1 if not the specified tool type. + */ + int getHarvestLevel(IBlockState state); + + /** + * Checks if the specified tool type is efficient on this block, + * meaning that it digs at full speed. + */ + default boolean isToolEffective(IBlockState state, ToolType tool) { - return null; + if (tool == ToolType.PICKAXE && (this.getBlock() == Blocks.REDSTONE_ORE || this.getBlock() == Blocks.REDSTONE_LAMP || this.getBlock() == Blocks.OBSIDIAN)) + return false; + return tool == getHarvestTool(state); } /** - * Called when entities are moving to check if they are inside a liquid - * - * @param world world that is being tested. - * @param pos block thats being tested. - * @param boundingBox box to test, generally the bounds of an entity that are besting tested. - * @return null for default behavior, true if the box is within the material, false if it was not. + * Can return IExtendedBlockState */ - @Nullable - default Boolean isAABBInsideLiquid(IBlockState state, IWorldReader world, BlockPos pos, AxisAlignedBB boundingBox) + default IBlockState getExtendedState(IBlockState state, IBlockReader world, BlockPos pos) { - return null; + return state; } /** diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeBlockState.java b/src/main/java/net/minecraftforge/common/extensions/IForgeBlockState.java index d591ab2f1..523996c4e 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeBlockState.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeBlockState.java @@ -641,54 +641,6 @@ public interface IForgeBlockState return getBlockState().getBlock().getExtendedState(getBlockState(), world, pos); } - /** - * Called when the entity is inside this block, may be used to determined if the entity can breathing, - * display material overlays, or if the entity can swim inside a block. - * - * @param world that is being tested. - * @param pos position thats being tested. - * @param entity that is being tested. - * @param yToTest, primarily for testingHead, which sends the the eye level of the entity, other wise it sends a y that can be tested vs liquid height. - * @param material to test for. - * @param testingHead when true, its testing the entities head for vision, breathing ect... otherwise its testing the body, for swimming and movement adjustment. - * @return null for default behavior, true if the entity is within the material, false if it was not. - */ - @Nullable - default Boolean isEntityInsideMaterial(IWorldReader world, BlockPos pos, Entity entity, double yToTest, Material material, boolean testingHead) - { - return getBlockState().getBlock().isEntityInsideMaterial(getBlockState(), world, pos, entity, yToTest, material, testingHead); - } - - /** - * Called when boats or fishing hooks are inside the block to check if they are inside - * the material requested. - * - * @param world world that is being tested. - * @param pos block thats being tested. - * @param boundingBox box to test, generally the bounds of an entity that are besting tested. - * @param material to check for. - * @return null for default behavior, true if the box is within the material, false if it was not. - */ - @Nullable - default Boolean isAABBInsideMaterial(IWorldReader world, BlockPos pos, AxisAlignedBB boundingBox, Material material) - { - return getBlockState().getBlock().isAABBInsideMaterial(getBlockState(), world, pos, boundingBox, material); - } - - /** - * Called when entities are moving to check if they are inside a liquid - * - * @param world world that is being tested. - * @param pos block thats being tested. - * @param boundingBox box to test, generally the bounds of an entity that are besting tested. - * @return null for default behavior, true if the box is within the material, false if it was not. - */ - @Nullable - default Boolean isAABBInsideLiquid(IWorldReader world, BlockPos pos, AxisAlignedBB boundingBox) - { - return getBlockState().getBlock().isAABBInsideLiquid(getBlockState(), world, pos, boundingBox); - } - /** * Queries if this block should render in a given layer. * ISmartBlockModel can use {@link net.minecraftforge.client.MinecraftForgeClient#getRenderLayer()} to alter their model based on layer. diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeEntity.java b/src/main/java/net/minecraftforge/common/extensions/IForgeEntity.java index 9c09a7a6d..c54890ad6 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeEntity.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeEntity.java @@ -19,9 +19,32 @@ package net.minecraftforge.common.extensions; +import java.util.Collection; + +import javax.annotation.Nullable; + +import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLeashKnot; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityArmorStand; +import net.minecraft.entity.item.EntityBoat; +import net.minecraft.entity.item.EntityEnderCrystal; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.item.EntityItemFrame; +import net.minecraft.entity.item.EntityMinecart; +import net.minecraft.entity.item.EntityPainting; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.ItemSpawnEgg; +import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.RayTraceResult; +import net.minecraft.world.IWorldReader; import net.minecraftforge.common.capabilities.ICapabilitySerializable; +import net.minecraftforge.common.util.INBTSerializable; public interface IForgeEntity extends ICapabilitySerializable { @@ -42,4 +65,107 @@ public interface IForgeEntity extends ICapabilitySerializable } return getEntity().writeToNBT(ret); } + + boolean canUpdate(); + void canUpdate(boolean value); + + @Nullable + Collection captureDrops(); + Collection captureDrops(@Nullable Collection captureDrops); + + /** + * Used in model rendering to determine if the entity riding this entity should be in the 'sitting' position. + * @return false to prevent an entity that is mounted to this entity from displaying the 'sitting' animation. + */ + default boolean shouldRiderSit() + { + return true; + } + + + /** + * Called when a user uses the creative pick block button on this entity. + * + * @param target The full target the player is looking at + * @return A ItemStack to add to the player's inventory, empty ItemStack if nothing should be added. + */ + default ItemStack getPickedResult(RayTraceResult target) + { + if (this instanceof EntityPainting) + { + return new ItemStack(Items.PAINTING); + } + else if (this instanceof EntityLeashKnot) + { + return new ItemStack(Items.LEAD); + } + else if (this instanceof EntityItemFrame) + { + ItemStack held = ((EntityItemFrame)this).getDisplayedItem(); + if (held.isEmpty()) + return new ItemStack(Items.ITEM_FRAME); + else + return held.copy(); + } + else if (this instanceof EntityMinecart) + { + return ((EntityMinecart)this).getCartItem(); + } + else if (this instanceof EntityBoat) + { + return new ItemStack(((EntityBoat)this).getItemBoat()); + } + else if (this instanceof EntityArmorStand) + { + return new ItemStack(Items.ARMOR_STAND); + } + else if (this instanceof EntityEnderCrystal) + { + return new ItemStack(Items.END_CRYSTAL); + } + else + { + ItemSpawnEgg egg = ItemSpawnEgg.func_200889_b(getEntity().func_200600_R()); + if (egg != null) return new ItemStack(egg); + } + return ItemStack.EMPTY; + } + + default boolean shouldRenderInPass(int pass) + { + return pass == 0; + } + + /** + * If a rider of this entity can interact with this entity. Should return true on the + * ridden entity if so. + * + * @return if the entity can be interacted with from a rider + */ + default boolean canRiderInteract() + { + return false; + } + + /** + * If the rider should be dismounted from the entity when the entity goes under water + * + * @param rider The entity that is riding + * @return if the entity should be dismounted when under water + */ + default boolean shouldDismountInWater(Entity rider) + { + return this instanceof EntityLivingBase; + } + + + /** + * Checks if this {@link Entity} can trample a {@link Block}. + * + * @param block The block being tested + * @param pos The block pos + * @param fallDistance The fall distance + * @return {@code true} if this entity can trample, {@code false} otherwise + */ + boolean canTrample(IBlockState state, BlockPos pos, float fallDistance); } diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeFluid.java b/src/main/java/net/minecraftforge/common/extensions/IForgeFluid.java new file mode 100644 index 000000000..e85163f9c --- /dev/null +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeFluid.java @@ -0,0 +1,101 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2018. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.common.extensions; + +import javax.annotation.Nullable; + +import net.minecraft.block.material.Material; +import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.Entity; +import net.minecraft.fluid.Fluid; +import net.minecraft.fluid.IFluidState; +import net.minecraft.tags.Tag; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.Explosion; +import net.minecraft.world.IWorldReader; + +public interface IForgeFluid +{ + default Fluid getFluid() + { + return (Fluid) this; + } + + /** + * Called when the entity is inside this block, may be used to determined if the entity can breathing, + * display material overlays, or if the entity can swim inside a block. + * + * @param world that is being tested. + * @param pos position thats being tested. + * @param entity that is being tested. + * @param yToTest, primarily for testingHead, which sends the the eye level of the entity, other wise it sends a y that can be tested vs liquid height. + * @param tag Fluid category + * @param testingHead when true, its testing the entities head for vision, breathing ect... otherwise its testing the body, for swimming and movement adjustment. + */ + default boolean isEntityInside(IFluidState state, IWorldReader world, BlockPos pos, Entity entity, double yToTest, Tag tag, boolean testingHead) + { + return state.func_206884_a(tag) && yToTest - pos.getY() < state.func_206885_f() + 0.1F; + } + + /** + * Called when boats or fishing hooks are inside the block to check if they are inside + * the material requested. + * + * @param world world that is being tested. + * @param pos block thats being tested. + * @param boundingBox box to test, generally the bounds of an entity that are besting tested. + * @param materialIn to check for. + * @return null for default behavior, true if the box is within the material, false if it was not. + */ + @Nullable + default Boolean isAABBInsideMaterial(IFluidState state, IWorldReader world, BlockPos pos, AxisAlignedBB boundingBox, Material materialIn) + { + return null; + } + + /** + * Called when entities are moving to check if they are inside a liquid + * + * @param world world that is being tested. + * @param pos block thats being tested. + * @param boundingBox box to test, generally the bounds of an entity that are besting tested. + * @return null for default behavior, true if the box is within the material, false if it was not. + */ + @Nullable + default Boolean isAABBInsideLiquid(IFluidState state, IWorldReader world, BlockPos pos, AxisAlignedBB boundingBox) + { + return null; + } + + /** + * Location sensitive version of getExplosionResistance + * + * @param world The current world + * @param pos Block position in world + * @param exploder The entity that caused the explosion, can be null + * @param explosion The explosion + * @return The amount of the explosion absorbed. + */ + default float getExplosionResistance(IFluidState state, IWorldReader world, BlockPos pos, @Nullable Entity exploder, Explosion explosion) + { + return state.func_210200_l(); + } +} diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeFluidState.java b/src/main/java/net/minecraftforge/common/extensions/IForgeFluidState.java new file mode 100644 index 000000000..77d7b832b --- /dev/null +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeFluidState.java @@ -0,0 +1,71 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2018. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.common.extensions; + +import javax.annotation.Nullable; + +import net.minecraft.entity.Entity; +import net.minecraft.fluid.Fluid; +import net.minecraft.fluid.IFluidState; +import net.minecraft.tags.Tag; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.Explosion; +import net.minecraft.world.IWorldReader; + +public interface IForgeFluidState +{ + default IFluidState getFluidState() + { + return (IFluidState)this; + } + + /** + * Called when the entity is inside this block, may be used to determined if the entity can breathing, + * display material overlays, or if the entity can swim inside a block. + * + * @param world that is being tested. + * @param pos position thats being tested. + * @param entity that is being tested. + * @param yToTest, primarily for testingHead, which sends the the eye level of the entity, other wise it sends a y that can be tested vs liquid height. + * @param material to test for. + * @param testingHead when true, its testing the entities head for vision, breathing ect... otherwise its testing the body, for swimming and movement adjustment. + */ + @Nullable + default boolean isEntityInside(IWorldReader world, BlockPos pos, Entity entity, double yToTest, Tag tag, boolean testingHead) + { + return getFluidState().func_206886_c().isEntityInside(getFluidState(), world, pos, entity, yToTest, tag, testingHead); + } + + + + /** + * Location sensitive version of getExplosionResistance + * + * @param world The current world + * @param pos Block position in world + * @param exploder The entity that caused the explosion, can be null + * @param explosion The explosion + * @return The amount of the explosion absorbed. + */ + default float getExplosionResistance(IWorldReader world, BlockPos pos, @Nullable Entity exploder, Explosion explosion) + { + return getFluidState().func_206886_c().getExplosionResistance(getFluidState(), world, pos, exploder, explosion); + } +} diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeItem.java b/src/main/java/net/minecraftforge/common/extensions/IForgeItem.java index 08128a01b..903b73a3a 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeItem.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeItem.java @@ -105,7 +105,7 @@ public interface IForgeItem * * @return Return PASS to allow vanilla handling, any other to skip normal code. */ - default EnumActionResult onItemUseFirst(ItemUseContext context) + default EnumActionResult onItemUseFirst(ItemStack stack, ItemUseContext context) { return EnumActionResult.PASS; } diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeItemStack.java b/src/main/java/net/minecraftforge/common/extensions/IForgeItemStack.java index 87ee40c7f..b6d6bf568 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeItemStack.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeItemStack.java @@ -23,10 +23,16 @@ import java.util.Set; import javax.annotation.Nullable; +import net.minecraft.block.state.BlockWorldState; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemUseContext; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.stats.StatList; +import net.minecraft.util.EnumActionResult; +import net.minecraft.util.math.BlockPos; import net.minecraftforge.common.ToolType; import net.minecraftforge.common.capabilities.ICapabilitySerializable; @@ -93,4 +99,29 @@ public interface IForgeItemStack extends ICapabilitySerializable return getStack().getItem().getToolTypes(getStack()); } + default EnumActionResult onItemUseFirst(ItemUseContext context) + { + EntityPlayer entityplayer = context.func_195999_j(); + BlockPos blockpos = context.func_195995_a(); + BlockWorldState blockworldstate = new BlockWorldState(context.func_195991_k(), blockpos, false); + if (entityplayer != null && !entityplayer.capabilities.allowEdit && !getStack().func_206847_b(context.func_195991_k().func_205772_D(), blockworldstate)) { + return EnumActionResult.PASS; + } else { + Item item = getStack().getItem(); + EnumActionResult enumactionresult = item.onItemUseFirst(getStack(), context); + if (entityplayer != null && enumactionresult == EnumActionResult.SUCCESS) { + entityplayer.addStat(StatList.OBJECT_USE_STATS.func_199076_b(item)); + } + + return enumactionresult; + } + } + + default NBTTagCompound serializeNBT() + { + NBTTagCompound ret = new NBTTagCompound(); + getStack().writeToNBT(ret); + return ret; + } + } diff --git a/src/main/java/net/minecraftforge/event/entity/minecart/MinecartCollisionEvent.java b/src/main/java/net/minecraftforge/event/entity/minecart/MinecartCollisionEvent.java deleted file mode 100644 index e7bd43cfb..000000000 --- a/src/main/java/net/minecraftforge/event/entity/minecart/MinecartCollisionEvent.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2018. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.event.entity.minecart; - -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.EntityMinecart; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.eventbus.api.Cancelable; - -/** - * MinecartCollisionEvent is fired when a minecart collides with an Entity. - * This event is fired whenever a minecraft collides in - * {@link EntityMinecart#applyEntityCollision(Entity)}. - * - * {@link #collider} contains the Entity the Minecart collided with. - * - * This event is not {@link Cancelable}. - * - * This event does not have a result. {@link HasResult} - * - * This event is fired on the {@link MinecraftForge#EVENT_BUS}. - **/ -public class MinecartCollisionEvent extends MinecartEvent -{ - private final Entity collider; - - public MinecartCollisionEvent(EntityMinecart minecart, Entity collider) - { - super(minecart); - this.collider = collider; - } - - public Entity getCollider() - { - return collider; - } -} diff --git a/src/main/java/net/minecraftforge/event/entity/minecart/MinecartEvent.java b/src/main/java/net/minecraftforge/event/entity/minecart/MinecartEvent.java deleted file mode 100644 index 44a282d02..000000000 --- a/src/main/java/net/minecraftforge/event/entity/minecart/MinecartEvent.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2018. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.event.entity.minecart; - -import net.minecraft.entity.item.EntityMinecart; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.entity.EntityEvent; -import net.minecraftforge.eventbus.api.Event; - -/** - * MinecartEvent is fired whenever an event involving minecart entities occurs.
- * If a method utilizes this {@link net.minecraftforge.eventbus.api.Event} as its parameter, the method will
- * receive every child event of this class.
- *
- * {@link #minecart} contains the minecart entity involved with this event.
- *
- * All children of this event are fired on the {@link MinecraftForge#EVENT_BUS}.
- **/ -public class MinecartEvent extends EntityEvent -{ - private final EntityMinecart minecart; - - public MinecartEvent(EntityMinecart minecart) - { - super(minecart); - this.minecart = minecart; - } - - public EntityMinecart getMinecart() - { - return minecart; - } -} diff --git a/src/main/java/net/minecraftforge/event/entity/minecart/MinecartInteractEvent.java b/src/main/java/net/minecraftforge/event/entity/minecart/MinecartInteractEvent.java deleted file mode 100644 index 1d5c558a5..000000000 --- a/src/main/java/net/minecraftforge/event/entity/minecart/MinecartInteractEvent.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2018. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.event.entity.minecart; - -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.eventbus.api.Cancelable; -import net.minecraft.entity.item.EntityMinecart; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumHand; - -import javax.annotation.Nonnull; - -/** - * MinecartInteractEvent is fired when a player interacts with a minecart.
- * This event is fired whenever a player interacts with a minecart in - * {@link EntityMinecart#processInitialInteract(EntityPlayer, EnumHand)}. - *
- *
- * {@link #player} contains the EntityPlayer that is involved with this minecart interaction.
- *
- * This event is {@link net.minecraftforge.eventbus.api.Cancelable}.
- * If this event is canceled, the player does not interact with the minecart.
- *
- * This event does not have a result. {@link HasResult}
- *
- * This event is fired on the {@link MinecraftForge#EVENT_BUS}. - **/ -@net.minecraftforge.eventbus.api.Cancelable -public class MinecartInteractEvent extends MinecartEvent -{ - private final EntityPlayer player; - private final EnumHand hand; - - public MinecartInteractEvent(EntityMinecart minecart, EntityPlayer player, EnumHand hand) - { - super(minecart); - this.player = player; - this.hand = hand; - } - - public EntityPlayer getPlayer() { return player; } - @Nonnull - public ItemStack getItem() { return player.getHeldItem(hand); } - public EnumHand getHand() { return hand; } -} diff --git a/src/main/java/net/minecraftforge/event/entity/minecart/MinecartUpdateEvent.java b/src/main/java/net/minecraftforge/event/entity/minecart/MinecartUpdateEvent.java deleted file mode 100644 index 575991840..000000000 --- a/src/main/java/net/minecraftforge/event/entity/minecart/MinecartUpdateEvent.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2018. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.event.entity.minecart; - -import net.minecraft.entity.item.EntityMinecart; -import net.minecraft.util.math.BlockPos; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.eventbus.api.Cancelable; - -/** - * MinecartUpdateEvent is fired when a minecart is updated.
- * This event is fired whenever a minecart is updated in - * {@link EntityMinecart#onUpdate()}.
- *
- * {@link #pos} contains the coordinate of the track the entity is on {if applicable}.
- *
- * This event is not {@link net.minecraftforge.eventbus.api.Cancelable}.
- *
- * This event does not have a result. {@link HasResult}
- *
- * This event is fired on the {@link MinecraftForge#EVENT_BUS}. - **/ -public class MinecartUpdateEvent extends MinecartEvent -{ - private final BlockPos pos; - - public MinecartUpdateEvent(EntityMinecart minecart, BlockPos pos) - { - super(minecart); - this.pos = pos; - } - - public BlockPos getPos() - { - return pos; - } -}