use of mcjty.rftoolsdim.config.Settings in project RFToolsDimensions by McJty.
the class GuiDimletWorkbench method updateList.
private void updateList() {
if (!listDirty) {
return;
}
listDirty = false;
itemList.removeChildren();
Map<DimletKey, Settings> dimlets = KnownDimletConfiguration.getKnownDimlets();
String filter = searchBar.getText().toLowerCase();
// First remove all dimlets with the same name and also apply the filter already
Map<Pair<DimletType, String>, DimletKey> uniquelyNamedDimlets = new HashMap<>();
for (DimletKey key : dimlets.keySet()) {
String name = KnownDimletConfiguration.getDisplayName(key);
if (dimletMatches(filter, key, name)) {
Pair<DimletType, String> k = Pair.of(key.getType(), name);
if (!uniquelyNamedDimlets.containsKey(k)) {
uniquelyNamedDimlets.put(k, key);
}
}
}
List<DimletKey> keys = new ArrayList<>(uniquelyNamedDimlets.values());
keys.sort((a, b) -> {
int rc = a.getType().compareTo(b.getType());
if (rc == 0) {
return a.getId().compareTo(b.getId());
} else {
return rc;
}
});
keys.stream().forEach(key -> addItemToList(key, itemList));
if (itemList.getFirstSelected() >= itemList.getChildCount()) {
itemList.setFirstSelected(0);
}
}
use of mcjty.rftoolsdim.config.Settings in project RFToolsDimensions by McJty.
the class DimensionEditorTileEntity method update.
@Override
public void update() {
if (getWorld().isRemote) {
return;
}
ItemStack injectableItemStack = validateInjectableItemStack();
if (injectableItemStack.isEmpty()) {
return;
}
ItemStack dimensionItemStack = validateDimensionItemStack();
if (dimensionItemStack.isEmpty()) {
return;
}
if (ticksLeft == -1) {
// We were not injecting. Start now.
RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(getWorld());
int id = dimensionItemStack.getTagCompound().getInteger("id");
if (dimensionManager.getDimensionInformation(id).isCheater()) {
ticksCost = 1;
rfPerTick = 0;
} else if (isMatterReceiver(injectableItemStack)) {
ticksCost = DimletCosts.baseDimensionTickCost + 1000;
rfPerTick = DimletCosts.baseDimensionCreationCost + 200;
} else if (isTNT(injectableItemStack)) {
ticksCost = 600;
rfPerTick = 10;
} else {
DimletKey key = KnownDimletConfiguration.getDimletKey(injectableItemStack);
Settings settings = KnownDimletConfiguration.getSettings(key);
if (DimletObjectMapping.getSpecial(key) == SpecialType.SPECIAL_CHEATER) {
ticksCost = 1;
rfPerTick = 0;
} else {
ticksCost = DimletCosts.baseDimensionTickCost + settings.getTickCost();
rfPerTick = DimletCosts.baseDimensionCreationCost + settings.getCreateCost();
}
}
ticksLeft = ticksCost;
} else {
int rf = getEnergyStored();
int rfpt = rfPerTick;
rfpt = (int) (rfpt * (2.0f - getInfusedFactor()) / 2.0f);
if (rf >= rfpt) {
// Enough energy.
consumeEnergy(rfpt);
ticksLeft--;
if (ticksLeft <= 0) {
RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(getWorld());
NBTTagCompound tagCompound = dimensionItemStack.getTagCompound();
int id = tagCompound.getInteger("id");
if (isMatterReceiver(injectableItemStack)) {
World dimWorld = RfToolsDimensionManager.getWorldForDimension(getWorld(), id);
int y = findGoodReceiverLocation(dimWorld);
if (y == -1) {
y = dimWorld.getHeight() / 2;
}
Item item = injectableItemStack.getItem();
if (item instanceof ItemBlock) {
ItemBlock itemBlock = (ItemBlock) item;
IBlockState state = itemBlock.getBlock().getStateFromMeta(itemBlock.getMetadata(injectableItemStack));
BlockPos pos = new BlockPos(8, y, 8);
dimWorld.setBlockState(pos, state, 2);
Block block = dimWorld.getBlockState(pos).getBlock();
// @todo @@@@@@@@@@@@@@ check if right?
block.onBlockActivated(dimWorld, pos, state, FakePlayerFactory.getMinecraft((WorldServer) dimWorld), EnumHand.MAIN_HAND, EnumFacing.DOWN, 0.0F, 0.0F, 0.0F);
// block.onBlockPlaced(dimWorld, pos, EnumFacing.DOWN, 0, 0, 0, 0, null);
block.onBlockPlacedBy(dimWorld, pos, state, null, injectableItemStack);
dimWorld.setBlockToAir(pos.up());
dimWorld.setBlockToAir(pos.up(2));
}
} else if (isTNT(injectableItemStack)) {
safeDeleteDimension(id, dimensionItemStack);
} else {
DimletKey key = KnownDimletConfiguration.getDimletKey(injectableItemStack);
DimensionInformation information = dimensionManager.getDimensionInformation(id);
information.injectDimlet(key);
dimensionManager.save(getWorld());
}
inventoryHelper.decrStackSize(DimensionEditorContainer.SLOT_INJECTINPUT, 1);
stopInjecting();
}
}
}
markDirty();
setState();
}
use of mcjty.rftoolsdim.config.Settings in project RFToolsDimensions by McJty.
the class EssencePainterTileEntity method convertToDimensionDescriptor.
/**
* Convert the dimlets in the inventory to a dimension descriptor.
*/
private DimensionDescriptor convertToDimensionDescriptor() {
List<DimletKey> descriptors = new ArrayList<>();
long forcedSeed = 0;
for (int i = 0; i < EssencePainterContainer.SIZE_DIMLETS; i++) {
ItemStack stack = inventoryHelper.getStackInSlot(i + EssencePainterContainer.SLOT_DIMLETS);
if (!stack.isEmpty()) {
DimletKey key = KnownDimletConfiguration.getDimletKey(stack);
Settings settings = KnownDimletConfiguration.getSettings(key);
if (settings != null) {
// Make sure the dimlet is not blacklisted.
descriptors.add(key);
NBTTagCompound tagCompound = stack.getTagCompound();
if (tagCompound != null && tagCompound.getLong("forcedSeed") != 0) {
forcedSeed = tagCompound.getLong("forcedSeed");
}
}
}
inventoryHelper.setStackInSlot(i + EssencePainterContainer.SLOT_DIMLETS, ItemStack.EMPTY);
}
return new DimensionDescriptor(descriptors, forcedSeed);
}
use of mcjty.rftoolsdim.config.Settings in project RFToolsDimensions by McJty.
the class KnownDimletConfiguration method dumpMob.
private static void dumpMob(String id) {
EntityEntry entry = ForgeRegistries.ENTITIES.getValue(new ResourceLocation(id));
Class<? extends Entity> entityClass = entry == null ? null : entry.getEntityClass();
if (entry != null) {
DimletKey key = new DimletKey(DimletType.DIMLET_MOB, id);
String mod = entry.getRegistryName().getResourceDomain();
Settings settings = DimletRules.getSettings(key, mod);
String resourceName = EntityTools.findEntityIdByClass(entityClass);
String readableName = EntityTools.findEntityLocNameByClass(entityClass);
Logging.log(resourceName + " (" + resourceName + ", " + readableName + "): " + settings.toString());
}
}
use of mcjty.rftoolsdim.config.Settings in project RFToolsDimensions by McJty.
the class DimletConfigurationManager method addRule.
@Override
public void addRule(IFilterBuilder filterBuilder, ISettingsBuilder settingsBuilder) {
Filter filter = ((Filter.Builder) filterBuilder).build();
Settings settings = ((Settings.Builder) settingsBuilder).build();
rules.add(Pair.of(filter, settings));
}
Aggregations