Work on the ore tripling and various other things
Finished adding items required for the ore processing systems. Almost to the point where things are finalized for the first alpha release.
This commit is contained in:
parent
5e8437fe58
commit
15e538c800
77 changed files with 1151 additions and 36 deletions
|
@ -6,6 +6,7 @@ import java.util.Optional;
|
|||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.inventory.container.INamedContainerProvider;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -14,6 +15,7 @@ import net.minecraft.item.crafting.IRecipeType;
|
|||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.ITickableTileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
|
@ -35,7 +37,7 @@ import wayoftime.bloodmagic.tile.contailer.ContainerAlchemicalReactionChamber;
|
|||
import wayoftime.bloodmagic.util.Constants;
|
||||
import wayoftime.bloodmagic.util.MultiSlotItemHandler;
|
||||
|
||||
public class TileAlchemicalReactionChamber extends TileInventory implements ITickableTileEntity, INamedContainerProvider
|
||||
public class TileAlchemicalReactionChamber extends TileInventory implements ITickableTileEntity, INamedContainerProvider, ISidedInventory
|
||||
{
|
||||
@ObjectHolder("bloodmagic:alchemicalreactionchamber")
|
||||
public static TileEntityType<TileAlchemicalReactionChamber> TYPE;
|
||||
|
@ -113,8 +115,8 @@ public class TileAlchemicalReactionChamber extends TileInventory implements ITic
|
|||
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) };
|
||||
ItemStack[] outputInventory = new ItemStack[] { getStackInSlot(1), getStackInSlot(2), getStackInSlot(3),
|
||||
getStackInSlot(4), getStackInSlot(5) };
|
||||
|
||||
MultiSlotItemHandler outputSlotHandler = new MultiSlotItemHandler(outputInventory, 64);
|
||||
|
||||
|
@ -365,4 +367,49 @@ public class TileAlchemicalReactionChamber extends TileInventory implements ITic
|
|||
{
|
||||
return currentProgress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSlotsForFace(Direction side)
|
||||
{
|
||||
switch (side)
|
||||
{
|
||||
case UP:
|
||||
return new int[] { ARC_TOOL_SLOT };
|
||||
case DOWN:
|
||||
return new int[] { 1, 2, 3, 4, 5 };
|
||||
default:
|
||||
return new int[] { 6, 7, 8 };
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int index, ItemStack itemStack, Direction direction)
|
||||
{
|
||||
if (index == INPUT_BUCKET_SLOT || index == OUTPUT_BUCKET_SLOT)
|
||||
{
|
||||
Optional<FluidStack> fluidStackOptional = FluidUtil.getFluidContained(itemStack);
|
||||
|
||||
return fluidStackOptional.isPresent()
|
||||
&& ((index == OUTPUT_BUCKET_SLOT && !fluidStackOptional.get().isEmpty())
|
||||
|| (index == INPUT_BUCKET_SLOT && fluidStackOptional.get().isEmpty()));
|
||||
}
|
||||
|
||||
if (index >= OUTPUT_SLOT && index < OUTPUT_SLOT + NUM_OUTPUTS)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (index == ARC_TOOL_SLOT)
|
||||
{
|
||||
return itemStack.getItem().isIn(BloodMagicTags.ARC_TOOL);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int index, ItemStack stack, Direction direction)
|
||||
{
|
||||
return index >= OUTPUT_SLOT && index < OUTPUT_SLOT + NUM_OUTPUTS;
|
||||
}
|
||||
}
|
|
@ -15,8 +15,8 @@ import wayoftime.bloodmagic.will.EnumDemonWillType;
|
|||
|
||||
public class TileDemonCrystal extends TileTicking
|
||||
{
|
||||
public static final double sameWillConversionRate = 50;
|
||||
public static final double defaultWillConversionRate = 100;
|
||||
public static final double sameWillConversionRate = 45;
|
||||
public static final double defaultWillConversionRate = 90;
|
||||
public static final double timeDelayForWrongWill = 0.6;
|
||||
public final int maxWill = 100;
|
||||
public final double drainRate = 1;
|
||||
|
@ -49,7 +49,7 @@ public class TileDemonCrystal extends TileTicking
|
|||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
if (getWorld().isRemote)
|
||||
if (world.isRemote)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -163,7 +163,6 @@ public class TileDemonCrystal extends TileTicking
|
|||
int crystalCount = getCrystalCount();
|
||||
if (!getWorld().isRemote && crystalCount > 1)
|
||||
{
|
||||
BlockState state = getWorld().getBlockState(pos);
|
||||
EnumDemonWillType type = getWillType();
|
||||
// EnumDemonWillType type = state.getValue(BlockDemonCrystal.TYPE);
|
||||
ItemStack stack = BlockDemonCrystal.getItemStackDropped(type, 1);
|
||||
|
@ -181,6 +180,7 @@ public class TileDemonCrystal extends TileTicking
|
|||
|
||||
public double getCrystalGrowthPerSecond(double will)
|
||||
{
|
||||
// return 0.1;
|
||||
return 1.0 / 200 * Math.sqrt(will / 200);
|
||||
}
|
||||
|
||||
|
@ -204,7 +204,7 @@ public class TileDemonCrystal extends TileTicking
|
|||
public int getCrystalCount()
|
||||
{
|
||||
BlockState state = world.getBlockState(getPos());
|
||||
return state.get(BlockDemonCrystal.AGE);
|
||||
return state.get(BlockDemonCrystal.AGE) + 1;
|
||||
}
|
||||
|
||||
public void setCrystalCount(int crystalCount)
|
||||
|
|
|
@ -0,0 +1,187 @@
|
|||
package wayoftime.bloodmagic.tile;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
|
||||
import wayoftime.bloodmagic.demonaura.WorldDemonWillHandler;
|
||||
import wayoftime.bloodmagic.tile.base.TileTicking;
|
||||
import wayoftime.bloodmagic.will.DemonWillHolder;
|
||||
import wayoftime.bloodmagic.will.EnumDemonWillType;
|
||||
import wayoftime.bloodmagic.will.IDemonWillConduit;
|
||||
|
||||
public class TileDemonCrystallizer extends TileTicking implements IDemonWillConduit
|
||||
{
|
||||
@ObjectHolder("bloodmagic:demoncrystallizer")
|
||||
public static TileEntityType<TileDemonCrystallizer> TYPE;
|
||||
|
||||
public static final int maxWill = 100;
|
||||
public static final double drainRate = 1;
|
||||
public static final double willToFormCrystal = 99;
|
||||
public static final double totalFormationTime = 1000;
|
||||
// The whole purpose of this block is to grow a crystal initially. The
|
||||
// acceleration and crystal growing is up to the crystal itself afterwards.
|
||||
public DemonWillHolder holder = new DemonWillHolder();
|
||||
public double internalCounter = 0;
|
||||
|
||||
public TileDemonCrystallizer(TileEntityType<?> type)
|
||||
{
|
||||
super(type);
|
||||
}
|
||||
|
||||
public TileDemonCrystallizer()
|
||||
{
|
||||
this(TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
if (world.isRemote)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
BlockPos offsetPos = pos.offset(Direction.UP);
|
||||
if (getWorld().isAirBlock(offsetPos)) // Room for a crystal to grow
|
||||
{
|
||||
EnumDemonWillType highestType = WorldDemonWillHandler.getHighestDemonWillType(getWorld(), pos);
|
||||
double amount = WorldDemonWillHandler.getCurrentWill(getWorld(), pos, highestType);
|
||||
if (amount >= willToFormCrystal)
|
||||
{
|
||||
internalCounter += getCrystalFormationRate(amount);
|
||||
if (internalCounter >= totalFormationTime)
|
||||
{
|
||||
if (WorldDemonWillHandler.drainWill(getWorld(), getPos(), highestType, willToFormCrystal, false) >= willToFormCrystal)
|
||||
{
|
||||
if (formCrystal(highestType, offsetPos))
|
||||
{
|
||||
WorldDemonWillHandler.drainWill(getWorld(), getPos(), highestType, willToFormCrystal, true);
|
||||
internalCounter = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean formCrystal(EnumDemonWillType type, BlockPos position)
|
||||
{
|
||||
Block block = BloodMagicBlocks.RAW_CRYSTAL_BLOCK.get();
|
||||
switch (type)
|
||||
{
|
||||
case CORROSIVE:
|
||||
block = BloodMagicBlocks.CORROSIVE_CRYSTAL_BLOCK.get();
|
||||
break;
|
||||
case DESTRUCTIVE:
|
||||
block = BloodMagicBlocks.DESTRUCTIVE_CRYSTAL_BLOCK.get();
|
||||
break;
|
||||
case STEADFAST:
|
||||
block = BloodMagicBlocks.STEADFAST_CRYSTAL_BLOCK.get();
|
||||
break;
|
||||
case VENGEFUL:
|
||||
block = BloodMagicBlocks.VENGEFUL_CRYSTAL_BLOCK.get();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
getWorld().setBlockState(position, block.getDefaultState());
|
||||
TileEntity tile = getWorld().getTileEntity(position);
|
||||
if (tile instanceof TileDemonCrystal)
|
||||
{
|
||||
((TileDemonCrystal) tile).setPlacement(Direction.UP);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public double getCrystalFormationRate(double currentWill)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(CompoundNBT tag)
|
||||
{
|
||||
holder.readFromNBT(tag, "Will");
|
||||
internalCounter = tag.getDouble("internalCounter");
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT serialize(CompoundNBT tag)
|
||||
{
|
||||
holder.writeToNBT(tag, "Will");
|
||||
tag.putDouble("internalCounter", internalCounter);
|
||||
return tag;
|
||||
}
|
||||
|
||||
// IDemonWillConduit
|
||||
|
||||
@Override
|
||||
public int getWeight()
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double fillDemonWill(EnumDemonWillType type, double amount, boolean doFill)
|
||||
{
|
||||
if (amount <= 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!canFill(type))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!doFill)
|
||||
{
|
||||
return Math.min(maxWill - holder.getWill(type), amount);
|
||||
}
|
||||
|
||||
return holder.addWill(type, amount, maxWill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double drainDemonWill(EnumDemonWillType type, double amount, boolean doDrain)
|
||||
{
|
||||
double drained = amount;
|
||||
double current = holder.getWill(type);
|
||||
if (current < drained)
|
||||
{
|
||||
drained = current;
|
||||
}
|
||||
|
||||
if (doDrain)
|
||||
{
|
||||
return holder.drainWill(type, amount);
|
||||
}
|
||||
|
||||
return drained;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(EnumDemonWillType type)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(EnumDemonWillType type)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getCurrentWill(EnumDemonWillType type)
|
||||
{
|
||||
return holder.getWill(type);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue