Bandaid crushing ritual to pass a valid player instance (#1345)
This entire thing needs to be cleaned up. It's so bad right now :(
This commit is contained in:
parent
954f2c87e1
commit
d1e77acc73
|
@ -9,6 +9,7 @@ import WayofTime.bloodmagic.soul.EnumDemonWillType;
|
||||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks;
|
import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks;
|
||||||
import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler;
|
import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler;
|
||||||
import WayofTime.bloodmagic.util.Utils;
|
import WayofTime.bloodmagic.util.Utils;
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
@ -19,6 +20,9 @@ import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
import net.minecraft.util.text.TextComponentTranslation;
|
import net.minecraft.util.text.TextComponentTranslation;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraft.world.WorldServer;
|
||||||
|
import net.minecraftforge.common.util.FakePlayer;
|
||||||
|
import net.minecraftforge.common.util.FakePlayerFactory;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -40,6 +44,7 @@ public class RitualCrushing extends Ritual {
|
||||||
public static Map<ItemStack, Integer> cuttingFluidLPMap = new HashMap<>();
|
public static Map<ItemStack, Integer> cuttingFluidLPMap = new HashMap<>();
|
||||||
public static Map<ItemStack, Double> cuttingFluidWillMap = new HashMap<>();
|
public static Map<ItemStack, Double> cuttingFluidWillMap = new HashMap<>();
|
||||||
public static int defaultRefreshTime = 40;
|
public static int defaultRefreshTime = 40;
|
||||||
|
private FakePlayer fakePlayer;
|
||||||
public int refreshTime = 40;
|
public int refreshTime = 40;
|
||||||
|
|
||||||
public RitualCrushing() {
|
public RitualCrushing() {
|
||||||
|
@ -154,7 +159,7 @@ public class RitualCrushing extends Ritual {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isBlockClaimed && isSilkTouch && block.canSilkHarvest(world, newPos, state, null)) {
|
if (!isBlockClaimed && isSilkTouch && block.canSilkHarvest(world, newPos, state, getFakePlayer((WorldServer) world))) {
|
||||||
ItemStack checkStack = block.getItem(world, newPos, state);
|
ItemStack checkStack = block.getItem(world, newPos, state);
|
||||||
if (checkStack.isEmpty()) {
|
if (checkStack.isEmpty()) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -280,4 +285,8 @@ public class RitualCrushing extends Ritual {
|
||||||
cuttingFluidLPMap.put(stack, lpDrain);
|
cuttingFluidLPMap.put(stack, lpDrain);
|
||||||
cuttingFluidWillMap.put(stack, willDrain);
|
cuttingFluidWillMap.put(stack, willDrain);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private FakePlayer getFakePlayer(WorldServer world) {
|
||||||
|
return fakePlayer == null ? fakePlayer = FakePlayerFactory.get(world, new GameProfile(null, BloodMagic.MODID + "_ritual_crushing")) : fakePlayer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue