Search in sources :

Example 6 with Settings

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();
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) WorldServer(net.minecraft.world.WorldServer) DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey) World(net.minecraft.world.World) ItemBlock(net.minecraft.item.ItemBlock) RfToolsDimensionManager(mcjty.rftoolsdim.dimensions.RfToolsDimensionManager) Item(net.minecraft.item.Item) Block(net.minecraft.block.Block) ItemBlock(net.minecraft.item.ItemBlock) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) DimensionInformation(mcjty.rftoolsdim.dimensions.DimensionInformation) Settings(mcjty.rftoolsdim.config.Settings)

Example 7 with Settings

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);
}
Also used : DimensionDescriptor(mcjty.rftoolsdim.dimensions.description.DimensionDescriptor) ArrayList(java.util.ArrayList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey) ItemStack(net.minecraft.item.ItemStack) Settings(mcjty.rftoolsdim.config.Settings)

Example 8 with Settings

use of mcjty.rftoolsdim.config.Settings in project RFToolsDimensions by McJty.

the class DimletWorkbenchTileEntity method doExtract.

private boolean doExtract() {
    int rf = MachineConfiguration.workbenchRfPerDimlet;
    if (getEnergyStored() < rf) {
        // Not enough energy.
        return false;
    }
    consumeEnergy(rf);
    float factor = getInfusedFactor();
    Settings entry = KnownDimletConfiguration.getSettings(idToExtract);
    if (extractSuccess(factor)) {
        mergeItemOrThrowInWorld(new ItemStack(ModItems.dimletBaseItem));
    }
    int rarity = entry.getRarity();
    if (extractSuccess(factor)) {
        mergeItemOrThrowInWorld(new ItemStack(ModItems.dimletTypeControllerItem, 1, idToExtract.getType().ordinal()));
    }
    int level = DimletCraftingTools.calculateItemLevelFromRarity(rarity);
    if (extractSuccess(factor)) {
        mergeItemOrThrowInWorld(new ItemStack(ModItems.dimletMemoryUnitItem, 1, level));
    } else {
        // If this failed we increase our chances a bit
        factor += 0.1f;
    }
    if (extractSuccess(factor)) {
        mergeItemOrThrowInWorld(new ItemStack(ModItems.dimletEnergyModuleItem, 1, level));
    } else {
        // If this failed we increase our chances a bit
        factor += 0.1f;
    }
    if (extractSuccess(factor)) {
        mergeItemOrThrowInWorld(new ItemStack(ModItems.dimletControlCircuitItem, 1, rarity));
    }
    idToExtract = null;
    markDirty();
    return true;
}
Also used : ItemStack(net.minecraft.item.ItemStack) Settings(mcjty.rftoolsdim.config.Settings)

Example 9 with Settings

use of mcjty.rftoolsdim.config.Settings in project RFToolsDimensions by McJty.

the class DimletWorkbenchTileEntity method suggestParts.

private void suggestParts(EntityPlayerMP playerMP, DimletKey key) {
    // First try to remove all items currently in the slots
    setAsideIfPossible(playerMP, DimletWorkbenchContainer.SLOT_BASE);
    setAsideIfPossible(playerMP, DimletWorkbenchContainer.SLOT_CONTROLLER);
    setAsideIfPossible(playerMP, DimletWorkbenchContainer.SLOT_ENERGY);
    setAsideIfPossible(playerMP, DimletWorkbenchContainer.SLOT_MEMORY);
    setAsideIfPossible(playerMP, DimletWorkbenchContainer.SLOT_TYPE_CONTROLLER);
    setAsideIfPossible(playerMP, DimletWorkbenchContainer.SLOT_ESSENCE);
    // Place the correct ones back;
    Settings entry = KnownDimletConfiguration.getSettings(key);
    int rarity = entry.getRarity();
    int level = DimletCraftingTools.calculateItemLevelFromRarity(rarity);
    tryPlaceIfPossible(playerMP, DimletWorkbenchContainer.SLOT_BASE, new ItemStack(ModItems.dimletBaseItem, 1));
    tryPlaceIfPossible(playerMP, DimletWorkbenchContainer.SLOT_TYPE_CONTROLLER, new ItemStack(ModItems.dimletTypeControllerItem, 1, key.getType().ordinal()));
    tryPlaceIfPossible(playerMP, DimletWorkbenchContainer.SLOT_MEMORY, new ItemStack(ModItems.dimletMemoryUnitItem, 1, level));
    tryPlaceIfPossible(playerMP, DimletWorkbenchContainer.SLOT_ENERGY, new ItemStack(ModItems.dimletEnergyModuleItem, 1, level));
    tryPlaceIfPossible(playerMP, DimletWorkbenchContainer.SLOT_CONTROLLER, new ItemStack(ModItems.dimletControlCircuitItem, 1, rarity));
    tryPlaceEssenceIfPossible(playerMP, DimletWorkbenchContainer.SLOT_ESSENCE, key, key.getType().dimletType);
    markDirtyClient();
    checkCrafting();
}
Also used : ItemStack(net.minecraft.item.ItemStack) Settings(mcjty.rftoolsdim.config.Settings)

Example 10 with Settings

use of mcjty.rftoolsdim.config.Settings in project RFToolsDimensions by McJty.

the class GuiDimletWorkbench method setDimletTooltip.

private void setDimletTooltip() {
    itemList.setTooltips("All known dimlets");
    int x = Mouse.getEventX() * this.width / this.mc.displayWidth;
    int y = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1;
    Widget widget = window.getToplevel().getWidgetAtPosition(x, y);
    if (widget != null && !(widget instanceof BlockRender)) {
        Object userObject = widget.getUserObject();
        if (userObject instanceof DimletKey) {
            DimletKey key = (DimletKey) userObject;
            Settings settings = KnownDimletConfiguration.getSettings(key);
            int rarity = settings.getRarity();
            int level = DimletCraftingTools.calculateItemLevelFromRarity(rarity);
            ItemStack base = new ItemStack(ModItems.dimletBaseItem, 1);
            ItemStack ctrl = new ItemStack(ModItems.dimletControlCircuitItem, 1, rarity);
            ItemStack energy = new ItemStack(ModItems.dimletEnergyModuleItem, 1, level);
            ItemStack memory = new ItemStack(ModItems.dimletMemoryUnitItem, 1, level);
            ItemStack typectrl = new ItemStack(ModItems.dimletTypeControllerItem, 1, key.getType().ordinal());
            ItemStack essence = key.getType().dimletType.getDefaultEssence(key);
            List<String> tooltips = new ArrayList<>();
            if (Minecraft.getMinecraft().player.isCreative()) {
                tooltips.add(TextFormatting.RED + "Shift-Double-Click to cheat");
            }
            tooltips.add("Type: " + key.getType().dimletType.getName());
            tooltips.add("Name: " + escapeString(KnownDimletConfiguration.getDisplayName(key)));
            tooltips.add("Key: " + escapeString(key.getId()));
            tooltips.add("Rarity: " + settings.getRarity());
            tooltips.add("@0@1@2");
            tooltips.add("@3@4@5");
            if (essence.isEmpty()) {
                tooltips.add(TextFormatting.RED + "(currently not craftable)");
            }
            widget.setTooltips(tooltips.toArray(new String[tooltips.size()]));
            widget.setTooltipItems(base, ctrl, energy, memory, typectrl, essence);
        // itemList.setTooltips("Type: " + key.getType().dimletType.getName(), "Rarity: " + settings.getRarity(), "Y: @0 @1 @2 @3 @4 @5");
        // itemList.setTooltipItems(base, ctrl, energy, memory, typectrl, essence);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey) ItemStack(net.minecraft.item.ItemStack) Settings(mcjty.rftoolsdim.config.Settings)

Aggregations

Settings (mcjty.rftoolsdim.config.Settings)33 DimletKey (mcjty.rftoolsdim.dimensions.dimlets.DimletKey)16 ItemStack (net.minecraft.item.ItemStack)9 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)6 ArrayList (java.util.ArrayList)5 Block (net.minecraft.block.Block)5 ResourceLocation (net.minecraft.util.ResourceLocation)5 Filter (mcjty.rftoolsdim.config.Filter)3 DimensionDescriptor (mcjty.rftoolsdim.dimensions.description.DimensionDescriptor)3 IBlockState (net.minecraft.block.state.IBlockState)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 DimletType (mcjty.rftoolsdim.dimensions.dimlets.types.DimletType)2 BlockLiquid (net.minecraft.block.BlockLiquid)2 IProperty (net.minecraft.block.properties.IProperty)2 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 SortedMap (java.util.SortedMap)1 IFilterBuilder (mcjty.rftoolsdim.api.dimlet.IFilterBuilder)1 ISettingsBuilder (mcjty.rftoolsdim.api.dimlet.ISettingsBuilder)1