Skip to content

Commit

Permalink
Rename IAgriCrop methods with AbstractMethodErrors
Browse files Browse the repository at this point in the history
For the IAgriCrop interface, this renames the getPos and getWorld
methods so as to not match the methods inherited from TileEntity.
The only uses so far were in the mutation strategies. And the newly
named methods just call the original named methods via 'this'.

This workaround is for a re-obfuscation bug in Special Source, a
program that ForgeGradle depends on.

MinecraftForge/ForgeGradle#205
md-5/SpecialSource#12
  • Loading branch information
CodesCubesAndCrashes committed Jun 15, 2017
1 parent 185f370 commit 44980e6
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,21 @@ public interface IAgriCrop extends IAgriSeedProvider, IAgriSeedAcceptor, IAgriFe

/**
* Retrieves the location of the crop instance.
* Implementors can just call getPos() if possible. Renamed because of ForgeGradle obfuscation bug.
* https://github.com/MinecraftForge/ForgeGradle/issues/205
*
* @return the crop's position.
*/
BlockPos getPos();
BlockPos getPosDeobf();

/**
* Retrieves the world that the crop is in.
* Implementors can just call getWorld() if possible. Renamed because of ForgeGradle obfuscation bug.
* https://github.com/MinecraftForge/ForgeGradle/issues/205
*
* @return The world in which the crop is located.
*/
World getWorld();
World getWorldDeobf();

/**
* @return The growth stage of the crop, between 0 and 7 (both inclusive).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public Optional<AgriSeed> executeStrategy(IAgriCrop crop, Random rand) {
Objects.requireNonNull(rand, "The random passed to a mutation strategy should not be null!");

// Fetch all neighboring crop instances.
final List<IAgriCrop> neighbors = WorldHelper.getTileNeighbors(crop.getWorld(), crop.getPos(), IAgriCrop.class);
final List<IAgriCrop> neighbors = WorldHelper.getTileNeighbors(crop.getWorldDeobf(), crop.getPosDeobf(), IAgriCrop.class);

// Determine all possible parents.
final List<IAgriPlant> parents = neighbors.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public double getRollChance() {

@Override
public Optional<AgriSeed> executeStrategy(IAgriCrop crop, Random rand) {
List<IAgriCrop> matureNeighbours = WorldHelper.getTileNeighbors(crop.getWorld(), crop.getPos(), IAgriCrop.class);
List<IAgriCrop> matureNeighbours = WorldHelper.getTileNeighbors(crop.getWorldDeobf(), crop.getPosDeobf(), IAgriCrop.class);
matureNeighbours.removeIf(c -> !c.isMature());
if (!matureNeighbours.isEmpty()) {
int index = rand.nextInt(matureNeighbours.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

Expand Down Expand Up @@ -199,6 +201,23 @@ public boolean setSeed(AgriSeed seed) {
// </editor-fold>
// =========================================================================
// =========================================================================
// IAgriCrop Methods
// <editor-fold>
// =========================================================================

public BlockPos getPosDeobf() {
return this.getPos();
}

public World getWorldDeobf() {
return this.getWorld();
}

// =========================================================================
// IAgriCrop Methods
// </editor-fold>
// =========================================================================
// =========================================================================
// Misc.
// =========================================================================
@Override
Expand Down

0 comments on commit 44980e6

Please sign in to comment.