Attempt to try to fix the 1.16.3's branch having multiple 'wayoftime' folders.
This commit is contained in:
parent
c159828248
commit
6b4145a67c
224 changed files with 0 additions and 24047 deletions
|
@ -1,271 +0,0 @@
|
|||
package wayoftime.bloodmagic.tile;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.inventory.container.INamedContainerProvider;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.ITickableTileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.fluids.FluidAttributes;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandlerItem;
|
||||
import net.minecraftforge.fluids.capability.templates.FluidTank;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import wayoftime.bloodmagic.api.impl.BloodMagicAPI;
|
||||
import wayoftime.bloodmagic.api.impl.recipe.RecipeARC;
|
||||
import wayoftime.bloodmagic.tile.contailer.ContainerAlchemicalReactionChamber;
|
||||
import wayoftime.bloodmagic.util.Constants;
|
||||
import wayoftime.bloodmagic.util.MultiSlotItemHandler;
|
||||
|
||||
public class TileAlchemicalReactionChamber extends TileInventory implements ITickableTileEntity, INamedContainerProvider
|
||||
{
|
||||
@ObjectHolder("bloodmagic:alchemicalreactionchamber")
|
||||
public static TileEntityType<TileAlchemicalReactionChamber> TYPE;
|
||||
|
||||
public static final int ARC_TOOL_SLOT = 0;
|
||||
public static final int OUTPUT_SLOT = 1;
|
||||
public static final int NUM_OUTPUTS = 5;
|
||||
public static final int INPUT_SLOT = 6;
|
||||
public static final int INPUT_BUCKET_SLOT = 7;
|
||||
public static final int OUTPUT_BUCKET_SLOT = 8;
|
||||
|
||||
public FluidTank inputTank = new FluidTank(FluidAttributes.BUCKET_VOLUME * 20);
|
||||
public FluidTank outputTank = new FluidTank(FluidAttributes.BUCKET_VOLUME * 20);
|
||||
|
||||
public double currentProgress = 0;
|
||||
|
||||
public TileAlchemicalReactionChamber(TileEntityType<?> type)
|
||||
{
|
||||
super(type, 9, "alchemicalreactionchamber");
|
||||
}
|
||||
|
||||
public TileAlchemicalReactionChamber()
|
||||
{
|
||||
this(TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(CompoundNBT tag)
|
||||
{
|
||||
super.deserialize(tag);
|
||||
|
||||
currentProgress = tag.getDouble(Constants.NBT.ARC_PROGRESS);
|
||||
|
||||
CompoundNBT inputTankTag = tag.getCompound("inputtank");
|
||||
inputTank.readFromNBT(inputTankTag);
|
||||
|
||||
CompoundNBT outputTankTag = tag.getCompound("outputtank");
|
||||
outputTank.readFromNBT(outputTankTag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT serialize(CompoundNBT tag)
|
||||
{
|
||||
super.serialize(tag);
|
||||
|
||||
tag.putDouble(Constants.NBT.ARC_PROGRESS, currentProgress);
|
||||
|
||||
CompoundNBT inputTankTag = new CompoundNBT();
|
||||
inputTank.writeToNBT(inputTankTag);
|
||||
tag.put("inputtank", inputTankTag);
|
||||
|
||||
CompoundNBT outputTankTag = new CompoundNBT();
|
||||
outputTank.writeToNBT(outputTankTag);
|
||||
tag.put("outputtank", outputTankTag);
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
if (world.isRemote)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (world.getGameTime() % 20 == 0)
|
||||
{
|
||||
outputTank.fill(new FluidStack(Fluids.WATER, 100), FluidAction.EXECUTE);
|
||||
}
|
||||
|
||||
ItemStack fullBucketStack = this.getStackInSlot(INPUT_BUCKET_SLOT);
|
||||
ItemStack emptyBucketStack = this.getStackInSlot(OUTPUT_BUCKET_SLOT);
|
||||
|
||||
ItemStack[] outputInventory = new ItemStack[]
|
||||
{ getStackInSlot(1), getStackInSlot(2), getStackInSlot(3), getStackInSlot(4), getStackInSlot(5) };
|
||||
|
||||
MultiSlotItemHandler outputSlotHandler = new MultiSlotItemHandler(outputInventory, 64);
|
||||
|
||||
if (!fullBucketStack.isEmpty() && inputTank.getSpace() >= 1000)
|
||||
{
|
||||
ItemStack testFullBucketStack = ItemHandlerHelper.copyStackWithSize(fullBucketStack, 1);
|
||||
LazyOptional<IFluidHandlerItem> fluidHandlerWrapper = FluidUtil.getFluidHandler(testFullBucketStack);
|
||||
if (fluidHandlerWrapper.isPresent())
|
||||
{
|
||||
IFluidHandlerItem fluidHandler = fluidHandlerWrapper.resolve().get();
|
||||
FluidStack transferedStack = FluidUtil.tryFluidTransfer(inputTank, fluidHandler, 1000, false);
|
||||
if (!transferedStack.isEmpty())
|
||||
{
|
||||
fluidHandler.drain(transferedStack, FluidAction.EXECUTE);
|
||||
List<ItemStack> arrayList = new ArrayList<>();
|
||||
arrayList.add(fluidHandler.getContainer());
|
||||
if (outputSlotHandler.canTransferAllItemsToSlots(arrayList, true))
|
||||
{
|
||||
inputTank.fill(transferedStack, FluidAction.EXECUTE);
|
||||
outputSlotHandler.canTransferAllItemsToSlots(arrayList, false);
|
||||
if (fullBucketStack.getCount() > 1)
|
||||
{
|
||||
fullBucketStack.setCount(fullBucketStack.getCount() - 1);
|
||||
} else
|
||||
{
|
||||
setInventorySlotContents(INPUT_BUCKET_SLOT, ItemStack.EMPTY);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!emptyBucketStack.isEmpty() && outputTank.getFluidAmount() >= 1000)
|
||||
{
|
||||
ItemStack testEmptyBucketStack = ItemHandlerHelper.copyStackWithSize(emptyBucketStack, 1);
|
||||
LazyOptional<IFluidHandlerItem> fluidHandlerWrapper = FluidUtil.getFluidHandler(testEmptyBucketStack);
|
||||
if (fluidHandlerWrapper.isPresent())
|
||||
{
|
||||
IFluidHandlerItem fluidHandler = fluidHandlerWrapper.resolve().get();
|
||||
FluidStack transferedStack = FluidUtil.tryFluidTransfer(fluidHandler, outputTank, 1000, false);
|
||||
if (!transferedStack.isEmpty())
|
||||
{
|
||||
fluidHandler.fill(transferedStack, FluidAction.EXECUTE);
|
||||
List<ItemStack> arrayList = new ArrayList<>();
|
||||
arrayList.add(fluidHandler.getContainer());
|
||||
if (outputSlotHandler.canTransferAllItemsToSlots(arrayList, true))
|
||||
{
|
||||
outputTank.drain(transferedStack, FluidAction.EXECUTE);
|
||||
outputSlotHandler.canTransferAllItemsToSlots(arrayList, false);
|
||||
if (emptyBucketStack.getCount() > 1)
|
||||
{
|
||||
emptyBucketStack.setCount(emptyBucketStack.getCount() - 1);
|
||||
} else
|
||||
{
|
||||
setInventorySlotContents(OUTPUT_BUCKET_SLOT, ItemStack.EMPTY);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack inputStack = this.getStackInSlot(INPUT_SLOT);
|
||||
ItemStack toolStack = this.getStackInSlot(ARC_TOOL_SLOT);
|
||||
RecipeARC recipe = BloodMagicAPI.INSTANCE.getRecipeRegistrar().getARC(world, inputStack, toolStack, inputTank.getFluid());
|
||||
if (recipe != null && outputSlotHandler.canTransferAllItemsToSlots(recipe.getAllListedOutputs(), true))
|
||||
{
|
||||
// We have enough fluid (if applicable) and the theoretical outputs can fit.
|
||||
|
||||
}
|
||||
|
||||
for (int i = 0; i < NUM_OUTPUTS; i++)
|
||||
{
|
||||
this.setInventorySlotContents(OUTPUT_SLOT + i, outputSlotHandler.getStackInSlot(i));
|
||||
}
|
||||
|
||||
// FluidUtil.tryEmptyContainer(container, fluidDestination, maxAmount, player, doDrain)
|
||||
}
|
||||
|
||||
private boolean canCraft(RecipeARC recipe, MultiSlotItemHandler outputSlotHandler)
|
||||
{
|
||||
if (recipe == null)
|
||||
return false;
|
||||
|
||||
if (outputSlotHandler.canTransferAllItemsToSlots(recipe.getAllListedOutputs(), true))
|
||||
{
|
||||
FluidStack outputStack = recipe.getFluidOutput();
|
||||
return outputStack.isEmpty() ? true
|
||||
: outputTank.fill(outputStack, FluidAction.SIMULATE) >= outputStack.getAmount();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void craftItem(RecipeARC recipe, MultiSlotItemHandler outputSlotHandler)
|
||||
{
|
||||
if (this.canCraft(recipe, outputSlotHandler))
|
||||
{
|
||||
outputSlotHandler.canTransferAllItemsToSlots(recipe.getAllOutputs(world.rand), false);
|
||||
outputTank.fill(recipe.getFluidOutput().copy(), FluidAction.EXECUTE);
|
||||
consumeInventory();
|
||||
}
|
||||
}
|
||||
|
||||
public void consumeInventory()
|
||||
{
|
||||
ItemStack inputStack = getStackInSlot(INPUT_SLOT);
|
||||
if (!inputStack.isEmpty())
|
||||
{
|
||||
if (inputStack.getItem().hasContainerItem(inputStack))
|
||||
{
|
||||
setInventorySlotContents(INPUT_SLOT, inputStack.getItem().getContainerItem(inputStack));
|
||||
} else
|
||||
{
|
||||
inputStack.shrink(1);
|
||||
if (inputStack.isEmpty())
|
||||
{
|
||||
setInventorySlotContents(INPUT_SLOT, ItemStack.EMPTY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack toolStack = getStackInSlot(ARC_TOOL_SLOT);
|
||||
if (!toolStack.isEmpty())
|
||||
{
|
||||
if (toolStack.isDamageable())
|
||||
{
|
||||
toolStack.setDamage(toolStack.getDamage() + 1);
|
||||
if (toolStack.getDamage() >= toolStack.getMaxDamage())
|
||||
{
|
||||
setInventorySlotContents(ARC_TOOL_SLOT, ItemStack.EMPTY);
|
||||
}
|
||||
} else if (toolStack.getItem().hasContainerItem(toolStack))
|
||||
{
|
||||
setInventorySlotContents(ARC_TOOL_SLOT, toolStack.getItem().getContainerItem(inputStack));
|
||||
} else
|
||||
{
|
||||
toolStack.shrink(1);
|
||||
if (toolStack.isEmpty())
|
||||
{
|
||||
setInventorySlotContents(ARC_TOOL_SLOT, ItemStack.EMPTY);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container createMenu(int p_createMenu_1_, PlayerInventory p_createMenu_2_, PlayerEntity p_createMenu_3_)
|
||||
{
|
||||
assert world != null;
|
||||
return new ContainerAlchemicalReactionChamber(this, p_createMenu_1_, p_createMenu_2_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITextComponent getDisplayName()
|
||||
{
|
||||
return new StringTextComponent("Alchemical Reaction Chamber");
|
||||
}
|
||||
|
||||
public double getProgressForGui()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -1,566 +0,0 @@
|
|||
package wayoftime.bloodmagic.tile;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.common.item.ItemActivationCrystal;
|
||||
import wayoftime.bloodmagic.core.data.Binding;
|
||||
import wayoftime.bloodmagic.core.data.SoulNetwork;
|
||||
import wayoftime.bloodmagic.demonaura.WorldDemonWillHandler;
|
||||
import wayoftime.bloodmagic.event.RitualEvent;
|
||||
import wayoftime.bloodmagic.iface.IBindable;
|
||||
import wayoftime.bloodmagic.ritual.AreaDescriptor;
|
||||
import wayoftime.bloodmagic.ritual.EnumReaderBoundaries;
|
||||
import wayoftime.bloodmagic.ritual.IMasterRitualStone;
|
||||
import wayoftime.bloodmagic.ritual.Ritual;
|
||||
import wayoftime.bloodmagic.tile.base.TileTicking;
|
||||
import wayoftime.bloodmagic.util.ChatUtil;
|
||||
import wayoftime.bloodmagic.util.Constants;
|
||||
import wayoftime.bloodmagic.util.helper.BindableHelper;
|
||||
import wayoftime.bloodmagic.util.helper.NBTHelper;
|
||||
import wayoftime.bloodmagic.util.helper.NetworkHelper;
|
||||
import wayoftime.bloodmagic.util.helper.PlayerHelper;
|
||||
import wayoftime.bloodmagic.util.helper.RitualHelper;
|
||||
import wayoftime.bloodmagic.will.DemonWillHolder;
|
||||
import wayoftime.bloodmagic.will.EnumDemonWillType;
|
||||
|
||||
public class TileMasterRitualStone extends TileTicking implements IMasterRitualStone
|
||||
{
|
||||
@ObjectHolder("bloodmagic:masterritualstone")
|
||||
public static TileEntityType<TileMasterRitualStone> TYPE;
|
||||
protected final Map<String, AreaDescriptor> modableRangeMap = new HashMap<>();
|
||||
private UUID owner;
|
||||
private SoulNetwork cachedNetwork;
|
||||
private boolean active;
|
||||
private boolean redstoned;
|
||||
private int activeTime;
|
||||
private int cooldown;
|
||||
private Ritual currentRitual;
|
||||
private Direction direction = Direction.NORTH;
|
||||
private boolean inverted;
|
||||
private List<EnumDemonWillType> currentActiveWillConfig = new ArrayList<>();
|
||||
|
||||
public TileMasterRitualStone(TileEntityType<?> type)
|
||||
{
|
||||
super(type);
|
||||
}
|
||||
|
||||
public TileMasterRitualStone()
|
||||
{
|
||||
this(TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
if (getWorld().isRemote)
|
||||
return;
|
||||
|
||||
if (isPowered() && isActive())
|
||||
{
|
||||
active = false;
|
||||
redstoned = true;
|
||||
stopRitual(Ritual.BreakType.REDSTONE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isActive() && !isPowered() && isRedstoned() && getCurrentRitual() != null)
|
||||
{
|
||||
active = true;
|
||||
ItemStack crystalStack = NBTHelper.checkNBT(ItemActivationCrystal.CrystalType.getStack(getCurrentRitual().getCrystalLevel()));
|
||||
BindableHelper.applyBinding(crystalStack, new Binding(owner, PlayerHelper.getUsernameFromUUID(owner)));
|
||||
activateRitual(crystalStack, null, getCurrentRitual());
|
||||
redstoned = false;
|
||||
}
|
||||
|
||||
if (getCurrentRitual() != null && isActive())
|
||||
{
|
||||
if (activeTime % getCurrentRitual().getRefreshTime() == 0)
|
||||
performRitual(getWorld(), getPos());
|
||||
|
||||
activeTime++;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(CompoundNBT tag)
|
||||
{
|
||||
owner = tag.hasUniqueId("owner") ? tag.getUniqueId("owner") : null;
|
||||
if (owner != null)
|
||||
cachedNetwork = NetworkHelper.getSoulNetwork(owner);
|
||||
currentRitual = BloodMagic.RITUAL_MANAGER.getRitual(tag.getString(Constants.NBT.CURRENT_RITUAL));
|
||||
if (currentRitual != null)
|
||||
{
|
||||
CompoundNBT ritualTag = tag.getCompound(Constants.NBT.CURRENT_RITUAL_TAG);
|
||||
if (!ritualTag.isEmpty())
|
||||
{
|
||||
currentRitual.readFromNBT(ritualTag);
|
||||
}
|
||||
}
|
||||
active = tag.getBoolean(Constants.NBT.IS_RUNNING);
|
||||
activeTime = tag.getInt(Constants.NBT.RUNTIME);
|
||||
direction = Direction.values()[tag.getInt(Constants.NBT.DIRECTION)];
|
||||
redstoned = tag.getBoolean(Constants.NBT.IS_REDSTONED);
|
||||
|
||||
for (EnumDemonWillType type : EnumDemonWillType.values())
|
||||
{
|
||||
if (tag.getBoolean("EnumWill" + type))
|
||||
{
|
||||
currentActiveWillConfig.add(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT serialize(CompoundNBT tag)
|
||||
{
|
||||
String ritualId = BloodMagic.RITUAL_MANAGER.getId(getCurrentRitual());
|
||||
if (owner != null)
|
||||
tag.putUniqueId("owner", owner);
|
||||
tag.putString(Constants.NBT.CURRENT_RITUAL, Strings.isNullOrEmpty(ritualId) ? "" : ritualId);
|
||||
if (currentRitual != null)
|
||||
{
|
||||
CompoundNBT ritualTag = new CompoundNBT();
|
||||
currentRitual.writeToNBT(ritualTag);
|
||||
tag.put(Constants.NBT.CURRENT_RITUAL_TAG, ritualTag);
|
||||
}
|
||||
tag.putBoolean(Constants.NBT.IS_RUNNING, isActive());
|
||||
tag.putInt(Constants.NBT.RUNTIME, getActiveTime());
|
||||
tag.putInt(Constants.NBT.DIRECTION, direction.getIndex());
|
||||
tag.putBoolean(Constants.NBT.IS_REDSTONED, redstoned);
|
||||
|
||||
for (EnumDemonWillType type : currentActiveWillConfig)
|
||||
{
|
||||
tag.putBoolean("EnumWill" + type, true);
|
||||
}
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean activateRitual(ItemStack activationCrystal, @Nullable PlayerEntity activator, Ritual ritual)
|
||||
{
|
||||
if (PlayerHelper.isFakePlayer(activator))
|
||||
return false;
|
||||
|
||||
Binding binding = ((IBindable) activationCrystal.getItem()).getBinding(activationCrystal);
|
||||
if (binding != null && ritual != null)
|
||||
{
|
||||
if (activationCrystal.getItem() instanceof ItemActivationCrystal)
|
||||
{
|
||||
int crystalLevel = ((ItemActivationCrystal) activationCrystal.getItem()).getCrystalLevel(activationCrystal);
|
||||
if (RitualHelper.canCrystalActivate(ritual, crystalLevel))
|
||||
{
|
||||
if (!getWorld().isRemote)
|
||||
{
|
||||
SoulNetwork network = NetworkHelper.getSoulNetwork(binding);
|
||||
|
||||
if (!isRedstoned() && network.getCurrentEssence() < ritual.getActivationCost()
|
||||
&& (activator != null && !activator.isCreative()))
|
||||
{
|
||||
activator.sendStatusMessage(new TranslationTextComponent("chat.bloodmagic.ritual.weak"), true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (currentRitual != null)
|
||||
currentRitual.stopRitual(this, Ritual.BreakType.ACTIVATE);
|
||||
|
||||
RitualEvent.RitualActivatedEvent event = new RitualEvent.RitualActivatedEvent(this, binding.getOwnerId(), ritual, activator, activationCrystal, crystalLevel);
|
||||
|
||||
if (MinecraftForge.EVENT_BUS.post(event))
|
||||
{
|
||||
if (activator != null)
|
||||
activator.sendStatusMessage(new TranslationTextComponent("chat.bloodmagic.ritual.prevent"), true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ritual.activateRitual(this, activator, binding.getOwnerId()))
|
||||
{
|
||||
if (!isRedstoned() && (activator != null && !activator.isCreative()))
|
||||
network.syphon(ticket(ritual.getActivationCost()));
|
||||
|
||||
if (activator != null)
|
||||
activator.sendStatusMessage(new TranslationTextComponent("chat.bloodmagic.ritual.activate"), true);
|
||||
|
||||
this.active = true;
|
||||
this.owner = binding.getOwnerId();
|
||||
this.cachedNetwork = network;
|
||||
this.currentRitual = ritual;
|
||||
|
||||
if (!checkBlockRanges(ritual.getModableRangeMap()))
|
||||
addBlockRanges(ritual.getModableRangeMap());
|
||||
|
||||
notifyUpdate();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
notifyUpdate();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
if (activator != null)
|
||||
activator.sendStatusMessage(new TranslationTextComponent("chat.bloodmagic.ritual.notvalid"), true);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void performRitual(World world, BlockPos pos)
|
||||
{
|
||||
if (!world.isRemote && getCurrentRitual() != null
|
||||
&& BloodMagic.RITUAL_MANAGER.enabled(BloodMagic.RITUAL_MANAGER.getId(currentRitual), false))
|
||||
{
|
||||
if (RitualHelper.checkValidRitual(getWorld(), getPos(), currentRitual, getDirection()))
|
||||
{
|
||||
Ritual ritual = getCurrentRitual();
|
||||
RitualEvent.RitualRunEvent event = new RitualEvent.RitualRunEvent(this, getOwner(), ritual);
|
||||
|
||||
if (MinecraftForge.EVENT_BUS.post(event))
|
||||
return;
|
||||
|
||||
if (!checkBlockRanges(getCurrentRitual().getModableRangeMap()))
|
||||
addBlockRanges(getCurrentRitual().getModableRangeMap());
|
||||
|
||||
getCurrentRitual().performRitual(this);
|
||||
} else
|
||||
{
|
||||
stopRitual(Ritual.BreakType.BREAK_STONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopRitual(Ritual.BreakType breakType)
|
||||
{
|
||||
if (!getWorld().isRemote && getCurrentRitual() != null)
|
||||
{
|
||||
RitualEvent.RitualStopEvent event = new RitualEvent.RitualStopEvent(this, getOwner(), getCurrentRitual(), breakType);
|
||||
|
||||
if (MinecraftForge.EVENT_BUS.post(event))
|
||||
return;
|
||||
|
||||
getCurrentRitual().stopRitual(this, breakType);
|
||||
if (breakType != Ritual.BreakType.REDSTONE)
|
||||
{
|
||||
this.currentRitual = null;
|
||||
this.active = false;
|
||||
this.activeTime = 0;
|
||||
}
|
||||
notifyUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCooldown()
|
||||
{
|
||||
return cooldown;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCooldown(int cooldown)
|
||||
{
|
||||
this.cooldown = cooldown;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Direction getDirection()
|
||||
{
|
||||
return direction;
|
||||
}
|
||||
|
||||
public void setDirection(Direction direction)
|
||||
{
|
||||
this.direction = direction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean areTanksEmpty()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRunningTime()
|
||||
{
|
||||
return activeTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getOwner()
|
||||
{
|
||||
return owner;
|
||||
}
|
||||
|
||||
public void setOwner(UUID owner)
|
||||
{
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SoulNetwork getOwnerNetwork()
|
||||
{
|
||||
return cachedNetwork;
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld()
|
||||
{
|
||||
return super.getWorld();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getPos()
|
||||
{
|
||||
return super.getPos();
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorldObj()
|
||||
{
|
||||
return getWorld();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getBlockPos()
|
||||
{
|
||||
return getPos();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNextBlockRange(String range)
|
||||
{
|
||||
if (this.currentRitual != null)
|
||||
{
|
||||
return this.currentRitual.getNextBlockRange(range);
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void provideInformationOfRitualToPlayer(PlayerEntity player)
|
||||
{
|
||||
if (this.currentRitual != null)
|
||||
{
|
||||
ChatUtil.sendNoSpam(player, this.currentRitual.provideInformationOfRitualToPlayer(player));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void provideInformationOfRangeToPlayer(PlayerEntity player, String range)
|
||||
{
|
||||
if (this.currentRitual != null && this.currentRitual.getListOfRanges().contains(range))
|
||||
{
|
||||
ChatUtil.sendNoSpam(player, this.currentRitual.provideInformationOfRangeToPlayer(player, range));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActiveWillConfig(PlayerEntity player, List<EnumDemonWillType> typeList)
|
||||
{
|
||||
this.currentActiveWillConfig = typeList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumReaderBoundaries setBlockRangeByBounds(PlayerEntity player, String range, BlockPos offset1, BlockPos offset2)
|
||||
{
|
||||
AreaDescriptor descriptor = this.getBlockRange(range);
|
||||
DemonWillHolder holder = WorldDemonWillHandler.getWillHolder(world, getBlockPos());
|
||||
|
||||
EnumReaderBoundaries modificationType = currentRitual.canBlockRangeBeModified(range, descriptor, this, offset1, offset2, holder);
|
||||
if (modificationType == EnumReaderBoundaries.SUCCESS)
|
||||
descriptor.modifyAreaByBlockPositions(offset1, offset2);
|
||||
|
||||
return modificationType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EnumDemonWillType> getActiveWillConfig()
|
||||
{
|
||||
return new ArrayList<>(currentActiveWillConfig);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void provideInformationOfWillConfigToPlayer(PlayerEntity player, List<EnumDemonWillType> typeList)
|
||||
{
|
||||
// There is probably an easier way to make expanded chat messages
|
||||
if (typeList.size() >= 1)
|
||||
{
|
||||
Object[] translations = new TranslationTextComponent[typeList.size()];
|
||||
StringBuilder constructedString = new StringBuilder("%s");
|
||||
|
||||
for (int i = 1; i < typeList.size(); i++)
|
||||
{
|
||||
constructedString.append(", %s");
|
||||
}
|
||||
|
||||
for (int i = 0; i < typeList.size(); i++)
|
||||
{
|
||||
translations[i] = new TranslationTextComponent("tooltip.bloodmagic.currentBaseType." + typeList.get(i).name.toLowerCase());
|
||||
}
|
||||
|
||||
ChatUtil.sendNoSpam(player, new TranslationTextComponent("ritual.bloodmagic.willConfig.set", new TranslationTextComponent(constructedString.toString(), translations)));
|
||||
} else
|
||||
{
|
||||
ChatUtil.sendNoSpam(player, new TranslationTextComponent("ritual.bloodmagic.willConfig.void"));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isPowered()
|
||||
{
|
||||
if (inverted)
|
||||
return !getWorld().isBlockPowered(getPos());
|
||||
|
||||
return getWorld().isBlockPowered(getPos());
|
||||
}
|
||||
|
||||
public SoulNetwork getCachedNetwork()
|
||||
{
|
||||
return cachedNetwork;
|
||||
}
|
||||
|
||||
public void setCachedNetwork(SoulNetwork cachedNetwork)
|
||||
{
|
||||
this.cachedNetwork = cachedNetwork;
|
||||
}
|
||||
|
||||
public boolean isActive()
|
||||
{
|
||||
return active;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActive(boolean active)
|
||||
{
|
||||
this.active = active;
|
||||
}
|
||||
|
||||
public boolean isRedstoned()
|
||||
{
|
||||
return redstoned;
|
||||
}
|
||||
|
||||
public void setRedstoned(boolean redstoned)
|
||||
{
|
||||
this.redstoned = redstoned;
|
||||
}
|
||||
|
||||
public int getActiveTime()
|
||||
{
|
||||
return activeTime;
|
||||
}
|
||||
|
||||
public void setActiveTime(int activeTime)
|
||||
{
|
||||
this.activeTime = activeTime;
|
||||
}
|
||||
|
||||
public Ritual getCurrentRitual()
|
||||
{
|
||||
return currentRitual;
|
||||
}
|
||||
|
||||
public void setCurrentRitual(Ritual currentRitual)
|
||||
{
|
||||
this.currentRitual = currentRitual;
|
||||
}
|
||||
|
||||
public boolean isInverted()
|
||||
{
|
||||
return inverted;
|
||||
}
|
||||
|
||||
public void setInverted(boolean inverted)
|
||||
{
|
||||
this.inverted = inverted;
|
||||
}
|
||||
|
||||
public List<EnumDemonWillType> getCurrentActiveWillConfig()
|
||||
{
|
||||
return currentActiveWillConfig;
|
||||
}
|
||||
|
||||
public void setCurrentActiveWillConfig(List<EnumDemonWillType> currentActiveWillConfig)
|
||||
{
|
||||
this.currentActiveWillConfig = currentActiveWillConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to grab the range of a ritual for a given effect.
|
||||
*
|
||||
* @param range - Range that needs to be pulled.
|
||||
* @return -
|
||||
*/
|
||||
public AreaDescriptor getBlockRange(String range)
|
||||
{
|
||||
if (modableRangeMap.containsKey(range))
|
||||
{
|
||||
return modableRangeMap.get(range);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBlockRange(String range, AreaDescriptor defaultRange)
|
||||
{
|
||||
modableRangeMap.putIfAbsent(range, defaultRange.copy());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBlockRanges(Map<String, AreaDescriptor> blockRanges)
|
||||
{
|
||||
for (Map.Entry<String, AreaDescriptor> entry : blockRanges.entrySet())
|
||||
{
|
||||
modableRangeMap.putIfAbsent(entry.getKey(), entry.getValue().copy());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockRange(String range, AreaDescriptor defaultRange)
|
||||
{
|
||||
modableRangeMap.put(range, defaultRange.copy());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockRanges(Map<String, AreaDescriptor> blockRanges)
|
||||
{
|
||||
for (Map.Entry<String, AreaDescriptor> entry : blockRanges.entrySet())
|
||||
{
|
||||
modableRangeMap.put(entry.getKey(), entry.getValue().copy());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkBlockRanges(Map<String, AreaDescriptor> blockRanges)
|
||||
{
|
||||
for (Map.Entry<String, AreaDescriptor> entry : blockRanges.entrySet())
|
||||
{
|
||||
if (modableRangeMap.get(entry.getKey()) == null)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
package wayoftime.bloodmagic.tile.base;
|
||||
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.ITickableTileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
|
||||
/**
|
||||
* Base class for tiles that tick. Allows disabling the ticking
|
||||
* programmatically.
|
||||
*/
|
||||
// TODO - Move implementations that depend on existed ticks to new methods from here.
|
||||
public abstract class TileTicking extends TileBase implements ITickableTileEntity
|
||||
{
|
||||
private int ticksExisted;
|
||||
private boolean shouldTick = true;
|
||||
|
||||
public TileTicking(TileEntityType<?> type)
|
||||
{
|
||||
super(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void tick()
|
||||
{
|
||||
if (shouldTick())
|
||||
{
|
||||
ticksExisted++;
|
||||
onUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
void deserializeBase(CompoundNBT tagCompound)
|
||||
{
|
||||
this.ticksExisted = tagCompound.getInt("ticksExisted");
|
||||
this.shouldTick = tagCompound.getBoolean("shouldTick");
|
||||
}
|
||||
|
||||
@Override
|
||||
CompoundNBT serializeBase(CompoundNBT tagCompound)
|
||||
{
|
||||
tagCompound.putInt("ticksExisted", getTicksExisted());
|
||||
tagCompound.putBoolean("shouldTick", shouldTick());
|
||||
return tagCompound;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called every tick that {@link #shouldTick()} is true.
|
||||
*/
|
||||
public abstract void onUpdate();
|
||||
|
||||
public int getTicksExisted()
|
||||
{
|
||||
return ticksExisted;
|
||||
}
|
||||
|
||||
public void resetLifetime()
|
||||
{
|
||||
ticksExisted = 0;
|
||||
}
|
||||
|
||||
public boolean shouldTick()
|
||||
{
|
||||
return shouldTick;
|
||||
}
|
||||
|
||||
public void setShouldTick(boolean shouldTick)
|
||||
{
|
||||
this.shouldTick = shouldTick;
|
||||
}
|
||||
}
|
|
@ -1,198 +0,0 @@
|
|||
package wayoftime.bloodmagic.tile.contailer;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
|
||||
import wayoftime.bloodmagic.common.tags.BloodMagicTags;
|
||||
import wayoftime.bloodmagic.tile.TileAlchemicalReactionChamber;
|
||||
|
||||
public class ContainerAlchemicalReactionChamber extends Container
|
||||
{
|
||||
public final TileAlchemicalReactionChamber tileARC;
|
||||
|
||||
// public ContainerSoulForge(InventoryPlayer inventoryPlayer, IInventory tileARC)
|
||||
// {
|
||||
// this.tileARC = tileARC;
|
||||
//
|
||||
// }
|
||||
|
||||
public ContainerAlchemicalReactionChamber(int windowId, PlayerInventory playerInventory, PacketBuffer extraData)
|
||||
{
|
||||
this((TileAlchemicalReactionChamber) playerInventory.player.world.getTileEntity(extraData.readBlockPos()), windowId, playerInventory);
|
||||
}
|
||||
|
||||
public ContainerAlchemicalReactionChamber(@Nullable TileAlchemicalReactionChamber tile, int windowId, PlayerInventory playerInventory)
|
||||
{
|
||||
super(BloodMagicBlocks.ARC_CONTAINER.get(), windowId);
|
||||
this.tileARC = tile;
|
||||
this.setup(playerInventory, tile);
|
||||
}
|
||||
|
||||
public void setup(PlayerInventory inventory, IInventory tileARC)
|
||||
{
|
||||
this.addSlot(new SlotARCTool(tileARC, TileAlchemicalReactionChamber.ARC_TOOL_SLOT, 35, 51));
|
||||
for (int i = 0; i < TileAlchemicalReactionChamber.NUM_OUTPUTS; i++)
|
||||
{
|
||||
this.addSlot(new SlotOutput(tileARC, TileAlchemicalReactionChamber.OUTPUT_SLOT + i, 116, 15 + i * 18));
|
||||
}
|
||||
this.addSlot(new Slot(tileARC, TileAlchemicalReactionChamber.INPUT_SLOT, 71, 15));
|
||||
this.addSlot(new SlotBucket(tileARC, TileAlchemicalReactionChamber.INPUT_BUCKET_SLOT, 8, 15, true));
|
||||
this.addSlot(new SlotBucket(tileARC, TileAlchemicalReactionChamber.OUTPUT_BUCKET_SLOT, 152, 87, false));
|
||||
|
||||
// this.addSlot(new SlotSoul(tileARC, TileSoulForge.soulSlot, 152, 51));
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
for (int j = 0; j < 9; j++)
|
||||
{
|
||||
addSlot(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 123 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 9; i++)
|
||||
{
|
||||
addSlot(new Slot(inventory, i, 8 + i * 18, 181));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(PlayerEntity playerIn, int index)
|
||||
{
|
||||
ItemStack itemstack = ItemStack.EMPTY;
|
||||
Slot slot = this.inventorySlots.get(index);
|
||||
|
||||
if (slot != null && slot.getHasStack())
|
||||
{
|
||||
ItemStack itemstack1 = slot.getStack();
|
||||
itemstack = itemstack1.copy();
|
||||
|
||||
if ((index >= 1 && index < 1 + 5) || (index == 7 || index == 8))// Attempting to transfer from output slots
|
||||
// or bucket slots
|
||||
{
|
||||
if (!this.mergeItemStack(itemstack1, 9, 9 + 36, true))
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
slot.onSlotChange(itemstack1, itemstack);
|
||||
} else if (index > 9) // Attempting to transfer from main inventory
|
||||
{
|
||||
if (itemstack1.getItem().isIn(BloodMagicTags.ARC_TOOL)) // Try the tool slot first
|
||||
{
|
||||
if (!this.mergeItemStack(itemstack1, 0, 1, false))
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
} else if (isBucket(itemstack1, true)) // If it's a full bucket, transfer to tank filler slot.
|
||||
{
|
||||
if (!this.mergeItemStack(itemstack1, 7, 8, false))
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
} else if (isBucket(itemstack1, false)) // If it's an empty bucket, transfer to tank emptier slot.
|
||||
{
|
||||
if (!this.mergeItemStack(itemstack1, 8, 9, false))
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
} else if (!this.mergeItemStack(itemstack1, 6, 7, false))
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
} else if (!this.mergeItemStack(itemstack1, 9, 45, false)) // Attempting to transfer from input slots
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
if (itemstack1.getCount() == 0)
|
||||
{
|
||||
slot.putStack(ItemStack.EMPTY);
|
||||
} else
|
||||
{
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
|
||||
if (itemstack1.getCount() == itemstack.getCount())
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
slot.onTake(playerIn, itemstack1);
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(PlayerEntity playerIn)
|
||||
{
|
||||
return this.tileARC.isUsableByPlayer(playerIn);
|
||||
}
|
||||
|
||||
private class SlotARCTool extends Slot
|
||||
{
|
||||
public SlotARCTool(IInventory inventory, int slotIndex, int x, int y)
|
||||
{
|
||||
super(inventory, slotIndex, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack itemStack)
|
||||
{
|
||||
return itemStack.getItem().isIn(BloodMagicTags.ARC_TOOL);
|
||||
}
|
||||
}
|
||||
|
||||
private class SlotBucket extends Slot
|
||||
{
|
||||
private final boolean needsFullBucket;
|
||||
|
||||
public SlotBucket(IInventory inventory, int slotIndex, int x, int y, boolean needsFullBucket)
|
||||
{
|
||||
super(inventory, slotIndex, x, y);
|
||||
this.needsFullBucket = needsFullBucket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack itemStack)
|
||||
{
|
||||
Optional<FluidStack> fluidStackOptional = FluidUtil.getFluidContained(itemStack);
|
||||
|
||||
return fluidStackOptional.isPresent() && ((needsFullBucket && !fluidStackOptional.get().isEmpty())
|
||||
|| (!needsFullBucket && fluidStackOptional.get().isEmpty()));
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isBucket(ItemStack stack, boolean requiredFull)
|
||||
{
|
||||
Optional<FluidStack> fluidStackOptional = FluidUtil.getFluidContained(stack);
|
||||
|
||||
return fluidStackOptional.isPresent() && ((requiredFull && !fluidStackOptional.get().isEmpty())
|
||||
|| (!requiredFull && fluidStackOptional.get().isEmpty()));
|
||||
}
|
||||
|
||||
private class SlotOutput extends Slot
|
||||
{
|
||||
public SlotOutput(IInventory inventory, int slotIndex, int x, int y)
|
||||
{
|
||||
super(inventory, slotIndex, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack stack)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,154 +0,0 @@
|
|||
package wayoftime.bloodmagic.tile.contailer;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.IIntArray;
|
||||
import net.minecraft.util.IntArray;
|
||||
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
|
||||
import wayoftime.bloodmagic.tile.TileSoulForge;
|
||||
import wayoftime.bloodmagic.will.IDemonWill;
|
||||
import wayoftime.bloodmagic.will.IDemonWillGem;
|
||||
|
||||
public class ContainerSoulForge extends Container
|
||||
{
|
||||
public final IInventory tileForge;
|
||||
public final IIntArray data;
|
||||
|
||||
// public ContainerSoulForge(InventoryPlayer inventoryPlayer, IInventory tileForge)
|
||||
// {
|
||||
// this.tileForge = tileForge;
|
||||
//
|
||||
// }
|
||||
|
||||
public ContainerSoulForge(int windowId, PlayerInventory playerInventory, PacketBuffer extraData)
|
||||
{
|
||||
this((TileSoulForge) playerInventory.player.world.getTileEntity(extraData.readBlockPos()), new IntArray(5), windowId, playerInventory);
|
||||
}
|
||||
|
||||
public ContainerSoulForge(@Nullable TileSoulForge tile, IIntArray data, int windowId, PlayerInventory playerInventory)
|
||||
{
|
||||
super(BloodMagicBlocks.SOUL_FORGE_CONTAINER.get(), windowId);
|
||||
this.tileForge = tile;
|
||||
this.setup(playerInventory, tile);
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public void setup(PlayerInventory inventory, IInventory tileForge)
|
||||
{
|
||||
this.addSlot(new Slot(tileForge, 0, 8, 15));
|
||||
this.addSlot(new Slot(tileForge, 1, 80, 15));
|
||||
this.addSlot(new Slot(tileForge, 2, 8, 87));
|
||||
this.addSlot(new Slot(tileForge, 3, 80, 87));
|
||||
this.addSlot(new SlotSoul(tileForge, TileSoulForge.soulSlot, 152, 51));
|
||||
this.addSlot(new SlotOutput(tileForge, TileSoulForge.outputSlot, 44, 51));
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
for (int j = 0; j < 9; j++)
|
||||
{
|
||||
addSlot(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 123 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 9; i++)
|
||||
{
|
||||
addSlot(new Slot(inventory, i, 8 + i * 18, 181));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(PlayerEntity playerIn, int index)
|
||||
{
|
||||
ItemStack itemstack = ItemStack.EMPTY;
|
||||
Slot slot = this.inventorySlots.get(index);
|
||||
|
||||
if (slot != null && slot.getHasStack())
|
||||
{
|
||||
ItemStack itemstack1 = slot.getStack();
|
||||
itemstack = itemstack1.copy();
|
||||
|
||||
if (index == 5)
|
||||
{
|
||||
if (!this.mergeItemStack(itemstack1, 6, 6 + 36, true))
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
slot.onSlotChange(itemstack1, itemstack);
|
||||
} else if (index > 5)
|
||||
{
|
||||
if (itemstack1.getItem() instanceof IDemonWill || itemstack1.getItem() instanceof IDemonWillGem)
|
||||
{
|
||||
if (!this.mergeItemStack(itemstack1, 4, 5, false))
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
} else if (!this.mergeItemStack(itemstack1, 0, 4, false))
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
} else if (!this.mergeItemStack(itemstack1, 6, 42, false))
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
if (itemstack1.getCount() == 0)
|
||||
{
|
||||
slot.putStack(ItemStack.EMPTY);
|
||||
} else
|
||||
{
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
|
||||
if (itemstack1.getCount() == itemstack.getCount())
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
slot.onTake(playerIn, itemstack1);
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(PlayerEntity playerIn)
|
||||
{
|
||||
return this.tileForge.isUsableByPlayer(playerIn);
|
||||
}
|
||||
|
||||
private class SlotSoul extends Slot
|
||||
{
|
||||
public SlotSoul(IInventory inventory, int slotIndex, int x, int y)
|
||||
{
|
||||
super(inventory, slotIndex, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack itemStack)
|
||||
{
|
||||
return itemStack.getItem() instanceof IDemonWillGem || itemStack.getItem() instanceof IDemonWill;
|
||||
}
|
||||
}
|
||||
|
||||
private class SlotOutput extends Slot
|
||||
{
|
||||
public SlotOutput(IInventory inventory, int slotIndex, int x, int y)
|
||||
{
|
||||
super(inventory, slotIndex, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack stack)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue