mirror of
https://github.com/GTNewHorizons/ThaumicTinkerer.git
synced 2026-10-25 20:32:29 +00:00
Infused seeds harvest fix by @Barokko
This commit is contained in:
1 parent
d4f5857ec0
commit
f1751ce5bc
1 file changed
+48
-7
@@ -39,6 +39,7 @@ public class BlockInfusedGrain extends BlockCrops implements ITTinkererBlock {
|
||||
|
||||
public static final int BREEDING_CHANCE = 10;
|
||||
private IIcon[][] icons;
|
||||
private TileInfusedGrain tileEntity;
|
||||
|
||||
//Returns 0-5 for primal aspects, or 6 if compound aspect
|
||||
public static int getNumberFromAspectForTexture(Aspect aspect) {
|
||||
@@ -115,9 +116,11 @@ public class BlockInfusedGrain extends BlockCrops implements ITTinkererBlock {
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, Block block, int metadata) {
|
||||
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if (tile instanceof TileInfusedGrain) {
|
||||
tileEntity = (TileInfusedGrain)tile;
|
||||
}
|
||||
super.breakBlock(world, x, y, z, block, metadata);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -128,9 +131,12 @@ public class BlockInfusedGrain extends BlockCrops implements ITTinkererBlock {
|
||||
Random rand = new Random();
|
||||
int count = 1;
|
||||
for (int i = 0; i < count; i++) {
|
||||
TileInfusedGrain tileGrain = getTileEntitySafe(world, x, y, z);
|
||||
ItemStack seedStack = new ItemStack(ThaumicTinkerer.registry.getFirstItemFromClass(ItemInfusedSeeds.class));
|
||||
ItemInfusedSeeds.setAspect(seedStack, getAspectDropped(world, x, y, z, metadata));
|
||||
ItemInfusedSeeds.setAspectTendencies(seedStack, ((TileInfusedGrain) world.getTileEntity(x, y, z)).primalTendencies);
|
||||
if (tileGrain != null) {
|
||||
ItemInfusedSeeds.setAspectTendencies(seedStack, tileGrain.primalTendencies);
|
||||
}
|
||||
while (rand.nextInt(10000) < Math.pow(getPrimalTendencyCount(world, x, y, z, Aspect.ENTROPY), 2)) {
|
||||
seedStack.stackSize++;
|
||||
}
|
||||
@@ -139,24 +145,28 @@ public class BlockInfusedGrain extends BlockCrops implements ITTinkererBlock {
|
||||
}
|
||||
if (metadata >= 7) {
|
||||
do {
|
||||
ItemStack retItem=AspectCropLootManager.getLootForAspect(getAspect(world, x, y, z));
|
||||
Aspect aspect = getAspectSafe(world, x, y, z);
|
||||
ItemStack retItem=AspectCropLootManager.getLootForAspect(aspect);
|
||||
if(retItem!=null)
|
||||
ret.add(retItem);
|
||||
|
||||
} while (world.rand.nextInt(75) < getPrimalTendencyCount(world, x, y, z, Aspect.ORDER));
|
||||
}
|
||||
tileEntity = null;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public int getPrimalTendencyCount(World world, int x, int y, int z, Aspect aspect) {
|
||||
return world.getTileEntity(x, y, z) instanceof TileInfusedGrain ? ((TileInfusedGrain) world.getTileEntity(x, y, z)).primalTendencies.getAmount(aspect) : 0;
|
||||
TileInfusedGrain tileGrain = getTileEntitySafe(world, x, y, z);
|
||||
return tileGrain != null ? tileGrain.primalTendencies.getAmount(aspect) : 0;
|
||||
}
|
||||
|
||||
private void fertilizeSoil(World world, int x, int y, int z, int metadata) {
|
||||
if (metadata >= 7) {
|
||||
do {
|
||||
if (world.getTileEntity(x, y - 1, z) instanceof TileInfusedFarmland) {
|
||||
Aspect currentAspect = getAspect(world, x, y, z);
|
||||
Aspect currentAspect = getAspectSafe(world, x, y, z);
|
||||
((TileInfusedFarmland) world.getTileEntity(x, y - 1, z)).aspectList.add(currentAspect, 1);
|
||||
((TileInfusedFarmland) world.getTileEntity(x, y - 1, z)).reduceSaturatedAspects();
|
||||
world.markBlockForUpdate(x, y - 1, z);
|
||||
@@ -173,7 +183,7 @@ public class BlockInfusedGrain extends BlockCrops implements ITTinkererBlock {
|
||||
}
|
||||
|
||||
public Aspect getAspectDropped(World world, int x, int y, int z, int metadata) {
|
||||
Aspect currentAspect = getAspect(world, x, y, z);
|
||||
Aspect currentAspect = getAspectSafe(world, x, y, z);
|
||||
if (metadata >= 7 && currentAspect != null) {
|
||||
if (world.getTileEntity(x, y - 1, z) instanceof TileInfusedFarmland) {
|
||||
AspectList farmlandAspectList = ((TileInfusedFarmland) world.getTileEntity(x, y - 1, z)).aspectList;
|
||||
@@ -240,4 +250,35 @@ public class BlockInfusedGrain extends BlockCrops implements ITTinkererBlock {
|
||||
return null;
|
||||
}
|
||||
|
||||
private TileInfusedGrain getTileEntitySafe(World world, int x, int y, int z)
|
||||
{
|
||||
if (tileEntity != null) {
|
||||
return tileEntity;
|
||||
}
|
||||
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
|
||||
if (tile != null && tile instanceof TileInfusedGrain)
|
||||
{
|
||||
return (TileInfusedGrain)tile;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private Aspect getAspectSafe(World world, int x, int y, int z) {
|
||||
if (tileEntity != null) {
|
||||
return tileEntity.aspect;
|
||||
}
|
||||
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
|
||||
if (tile != null && tile instanceof TileInfusedGrain)
|
||||
{
|
||||
return ((TileInfusedGrain)tile).aspect;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user