use of mcjty.rftools.items.dimlets.DimletKey in project RFTools by McJty.
the class TimeDimletType method constructDimension.
@Override
public void constructDimension(List<Pair<DimletKey, List<DimletKey>>> dimlets, Random random, DimensionInformation dimensionInformation) {
Float celestialAngle = null;
Float timeSpeed = null;
dimlets = DimensionInformation.extractType(DimletType.DIMLET_TIME, dimlets);
if (dimlets.isEmpty()) {
if (random.nextFloat() < DimletConfiguration.randomSpecialTimeChance) {
// Default
celestialAngle = null;
timeSpeed = null;
} else {
List<DimletKey> keys = new ArrayList<DimletKey>(DimletObjectMapping.idToCelestialAngle.keySet());
DimletKey key = keys.get(random.nextInt(keys.size()));
celestialAngle = DimletObjectMapping.idToCelestialAngle.get(key);
timeSpeed = DimletObjectMapping.idToSpeed.get(key);
}
} else {
DimletKey key = dimlets.get(random.nextInt(dimlets.size())).getKey();
celestialAngle = DimletObjectMapping.idToCelestialAngle.get(key);
timeSpeed = DimletObjectMapping.idToSpeed.get(key);
}
dimensionInformation.setCelestialAngle(celestialAngle);
dimensionInformation.setTimeSpeed(timeSpeed);
}
use of mcjty.rftools.items.dimlets.DimletKey in project RFTools by McJty.
the class DimletScramblerTileEntity method startScrambling.
private void startScrambling() {
int rf = DimletConfiguration.rfScrambleOperation;
rf = (int) (rf * (2.0f - getInfusedFactor()) / 2.0f);
if (getEnergyStored(ForgeDirection.DOWN) < rf) {
// Not enough energy.
return;
}
ItemStack input0 = inventoryHelper.getStackInSlot(0);
ItemStack input1 = inventoryHelper.getStackInSlot(1);
ItemStack input2 = inventoryHelper.getStackInSlot(2);
DimletKey key1 = KnownDimletConfiguration.getDimletKey(input0, worldObj);
DimletKey key2 = KnownDimletConfiguration.getDimletKey(input1, worldObj);
DimletKey key3 = KnownDimletConfiguration.getDimletKey(input2, worldObj);
DimletEntry entry1 = KnownDimletConfiguration.getEntry(key1);
if (entry1 == null) {
// Protect against blacklisted dimlets.
return;
}
DimletEntry entry2 = KnownDimletConfiguration.getEntry(key2);
if (entry2 == null) {
// Protect against blacklisted dimlets.
return;
}
DimletEntry entry3 = KnownDimletConfiguration.getEntry(key3);
if (entry3 == null) {
// Protect against blacklisted dimlets.
return;
}
consumeEnergy(rf);
input0.splitStack(1);
if (input0.stackSize == 0) {
inventoryHelper.setStackInSlot(0, null);
}
input1.splitStack(1);
if (input1.stackSize == 0) {
inventoryHelper.setStackInSlot(1, null);
}
input2.splitStack(1);
if (input2.stackSize == 0) {
inventoryHelper.setStackInSlot(2, null);
}
int rarity1 = entry1.getRarity();
int rarity2 = entry2.getRarity();
int rarity3 = entry3.getRarity();
float b = (rarity1 + rarity2 + rarity3) / 3.0f;
// An average of rarity 5 will give the best bonus which is 0.1
bonus = (b / 50.0f) * (getInfusedFactor() / 3.0f + 1.0f);
scrambling = 64;
markDirty();
}
use of mcjty.rftools.items.dimlets.DimletKey in project RFTools by McJty.
the class DimletScramblerTileEntity method checkStateServer.
@Override
protected void checkStateServer() {
if (scrambling > 0) {
scrambling--;
if (scrambling == 0) {
DimletKey key = DimletRandomizer.getRandomDimlet(bonus, worldObj.rand);
InventoryHelper.mergeItemStack(this, false, KnownDimletConfiguration.makeKnownDimlet(key, worldObj), 3, 4, null);
}
markDirty();
} else {
ItemStack input1 = inventoryHelper.getStackInSlot(0);
ItemStack input2 = inventoryHelper.getStackInSlot(1);
ItemStack input3 = inventoryHelper.getStackInSlot(2);
ItemStack outputStack = inventoryHelper.getStackInSlot(3);
if (isValidInput(input1, input2, input3) && outputStack == null) {
startScrambling();
}
}
}
use of mcjty.rftools.items.dimlets.DimletKey in project RFTools by McJty.
the class GuiDimensionEnscriber method extractModifiersForType.
private List<DimletKey> extractModifiersForType(List<DimletKey> modifiers, DimletType type) {
List<DimletKey> modifiersForType = new ArrayList<DimletKey>();
int i = 0;
while (i < modifiers.size()) {
DimletKey modifier = modifiers.get(i);
if (type.dimletType.isModifiedBy(modifier.getType())) {
modifiersForType.add(modifier);
modifiers.remove(i);
} else {
i++;
}
}
return modifiersForType;
}
use of mcjty.rftools.items.dimlets.DimletKey in project RFTools by McJty.
the class DimletResearcherTileEntity method checkStateServer.
@Override
protected void checkStateServer() {
if (researching > 0) {
researching--;
if (researching == 0) {
DimletKey key = DimletRandomizer.getRandomDimlet(worldObj.rand);
InventoryHelper.mergeItemStack(this, false, KnownDimletConfiguration.makeKnownDimlet(key, worldObj), 1, 2, null);
}
markDirty();
} else {
ItemStack inputStack = inventoryHelper.getStackInSlot(0);
ItemStack outputStack = inventoryHelper.getStackInSlot(1);
if (inputStack != null && inputStack.getItem() == DimletSetup.unknownDimlet && outputStack == null) {
startResearching();
}
}
}
Aggregations