Search in sources :

Example 1 with ICoreTool

use of net.silentchaos512.gear.api.item.ICoreTool in project Silent-Gear by SilentChaos512.

the class DebugOverlay method getDebugText.

@Nonnull
@Override
public List<String> getDebugText() {
    List<String> list = new ArrayList<>();
    Minecraft mc = Minecraft.getInstance();
    LocalPlayer player = mc.player;
    if (player == null)
        return list;
    // addAttributeInfo(list, player, SharedMonsterAttributes.LUCK);
    ItemStack heldItem = player.getItemInHand(InteractionHand.MAIN_HAND);
    if (heldItem.isEmpty())
        return list;
    Item item = heldItem.getItem();
    // Crossbow debugging
    if (item instanceof GearCrossbowItem) {
        float pull = ModelPropertiesHelper.getValue(heldItem, new ResourceLocation("pull"), mc.level, player);
        float pulling = ModelPropertiesHelper.getValue(heldItem, new ResourceLocation("pulling"), mc.level, player);
        float charged = ModelPropertiesHelper.getValue(heldItem, new ResourceLocation("charged"), mc.level, player);
        float firework = ModelPropertiesHelper.getValue(heldItem, new ResourceLocation("firework"), mc.level, player);
        list.add(String.format("pull=%.1f", pull));
        list.add(String.format("pulling=%.1f", pulling));
        list.add(String.format("charged=%.1f", charged));
        list.add(String.format("firework=%.1f", firework));
        list.add(String.format("chargeTime=%d", GearCrossbowItem.getChargeTime(heldItem)));
        return list;
    }
    // Harvest level checks
    HitResult rt = mc.hitResult;
    if (rt != null && rt.getType() == HitResult.Type.BLOCK) {
        BlockHitResult brt = (BlockHitResult) rt;
        Entity renderViewEntity = mc.getCameraEntity();
        if (renderViewEntity != null) {
            BlockPos pos = brt.getBlockPos();
            BlockState state = renderViewEntity.level.getBlockState(pos);
        /*if (item instanceof ICoreTool) {
                    ToolType toolClass = state.getBlock().getHarvestTool(state);
                    final int blockLevel = state.getBlock().getHarvestLevel(state);
                    final int toolLevel = item.getHarvestLevel(heldItem, toolClass, player, state);

                    final boolean canHarvest = toolLevel >= blockLevel;
                    ChatFormatting format = canHarvest ? ChatFormatting.GREEN : ChatFormatting.RED;
                    String name = toolClass == null ? "null" : toolClass.getName();
                    list.add(format + String.format("%s=%d (%d)", name, blockLevel, toolLevel));

                    final float destroySpeed = heldItem.getDestroySpeed(state);
                    if (canHarvest) {
                        int level = TraitHelper.getTraitLevel(heldItem, Const.Traits.LUSTROUS);
                        int light = GearEvents.getLightForLustrousTrait(player.level, player.blockPosition());
                        final float newSpeed = destroySpeed + GearEvents.getLustrousSpeedBonus(level, light);
                        list.add(String.format("speed = %.1f", newSpeed));
                    } else {
                        list.add(String.format("speed = %.1f", destroySpeed));
                    }
                }*/
        }
    } else if (rt != null && rt.getType() == HitResult.Type.ENTITY) {
        EntityHitResult ert = (EntityHitResult) rt;
        Entity entity = ert.getEntity();
        if (entity instanceof LivingEntity) {
            list.add(String.format("%s", entity.getScoreboardName()));
            list.add(String.format("health = %.3f", ((LivingEntity) entity).getHealth()));
        }
    }
    return list;
}
Also used : LivingEntity(net.minecraft.world.entity.LivingEntity) Entity(net.minecraft.world.entity.Entity) LocalPlayer(net.minecraft.client.player.LocalPlayer) ArrayList(java.util.ArrayList) Minecraft(net.minecraft.client.Minecraft) EntityHitResult(net.minecraft.world.phys.EntityHitResult) BlockHitResult(net.minecraft.world.phys.BlockHitResult) EntityHitResult(net.minecraft.world.phys.EntityHitResult) HitResult(net.minecraft.world.phys.HitResult) LivingEntity(net.minecraft.world.entity.LivingEntity) Item(net.minecraft.world.item.Item) GearCrossbowItem(net.silentchaos512.gear.item.gear.GearCrossbowItem) BlockState(net.minecraft.world.level.block.state.BlockState) ResourceLocation(net.minecraft.resources.ResourceLocation) BlockPos(net.minecraft.core.BlockPos) GearCrossbowItem(net.silentchaos512.gear.item.gear.GearCrossbowItem) ItemStack(net.minecraft.world.item.ItemStack) BlockHitResult(net.minecraft.world.phys.BlockHitResult) Nonnull(javax.annotation.Nonnull)

Example 2 with ICoreTool

use of net.silentchaos512.gear.api.item.ICoreTool in project Silent-Gear by SilentChaos512.

the class GearGenerator method randomizeParts.

public static ItemStack randomizeParts(ItemStack stack, int tier) {
    if (!(stack.getItem() instanceof ICoreItem)) {
        throw new RuntimeException("Called GearGenerator.randomizeParts on non-gear");
    }
    ICoreItem item = (ICoreItem) stack.getItem();
    GearType gearType = item.getGearType();
    PartDataList parts = PartDataList.of();
    for (PartType partType : item.getRequiredParts()) {
        getRandomPart(gearType, partType, tier).ifPresent(parts::add);
    }
    if (parts.isEmpty()) {
        return ItemStack.EMPTY;
    }
    ItemStack result = stack.copy();
    parts.forEach(p -> p.onAddToGear(result));
    GearData.writeConstructionParts(result, parts);
    // Apply some random upgrades?
    if (item instanceof ICoreTool && tier > 1 && SilentGear.RANDOM.nextFloat() < 0.2f * tier + 0.1f) {
        getRandomPart(gearType, PartType.TIP, tier).ifPresent(part -> GearData.addUpgradePart(result, part));
    }
    GearData.recalculateStats(result, null);
    return result;
}
Also used : PartDataList(net.silentchaos512.gear.api.part.PartDataList) PartType(net.silentchaos512.gear.api.part.PartType) GearType(net.silentchaos512.gear.api.item.GearType) ICoreTool(net.silentchaos512.gear.api.item.ICoreTool) ICoreItem(net.silentchaos512.gear.api.item.ICoreItem) ItemStack(net.minecraft.world.item.ItemStack)

Example 3 with ICoreTool

use of net.silentchaos512.gear.api.item.ICoreTool in project Silent-Gear by SilentChaos512.

the class GearHelper method getDisplayName.

public static Component getDisplayName(ItemStack gear) {
    PartData part = GearData.getPrimaryPart(gear);
    if (part == null)
        return new TranslatableComponent(gear.getDescriptionId());
    Component partName = part.getMaterialName(gear);
    if (TimedEvents.isAprilFools()) {
        partName = partName.copy().append(new TextComponent(" & Knuckles"));
    }
    Component gearName = new TranslatableComponent(gear.getDescriptionId() + ".nameProper", partName);
    Component result = gearName;
    if (gear.getItem() instanceof ICoreTool) {
        ICoreItem item = (ICoreItem) gear.getItem();
        if (item.requiresPartOfType(PartType.ROD) && GearData.getPartOfType(gear, PartType.ROD) == null) {
            result = new TranslatableComponent(gear.getDescriptionId() + ".noRod", gearName);
        } else if (item.requiresPartOfType(PartType.CORD) && GearData.getPartOfType(gear, PartType.CORD) == null) {
            result = new TranslatableComponent(gear.getDescriptionId() + ".unstrung", gearName);
        }
    }
    // Prefixes
    for (Component t : getNamePrefixes(gear, GearData.getConstructionParts(gear))) {
        result = t.copy().append(new TextComponent(" ")).append(result);
    }
    return result;
}
Also used : TextComponent(net.minecraft.network.chat.TextComponent) TranslatableComponent(net.minecraft.network.chat.TranslatableComponent) ICoreTool(net.silentchaos512.gear.api.item.ICoreTool) PartData(net.silentchaos512.gear.gear.part.PartData) IPartData(net.silentchaos512.gear.api.part.IPartData) ICoreItem(net.silentchaos512.gear.api.item.ICoreItem) TranslatableComponent(net.minecraft.network.chat.TranslatableComponent) TextComponent(net.minecraft.network.chat.TextComponent) Component(net.minecraft.network.chat.Component)

Example 4 with ICoreTool

use of net.silentchaos512.gear.api.item.ICoreTool in project Silent-Gear by SilentChaos512.

the class SGearJeiPlugin method registerRecipes.

@Override
public void registerRecipes(IRecipeRegistration reg) {
    assert Minecraft.getInstance().level != null;
    RecipeManager recipeManager = Minecraft.getInstance().level.getRecipeManager();
    // Repair kit hints
    for (RepairKitItem item : Registration.getItems(RepairKitItem.class)) {
        String itemName = NameUtils.fromItem(item).getPath();
        reg.addRecipes(Collections.singleton(new ShapelessRecipe(SilentGear.getId(itemName + "_fill_hint"), "", new ItemStack(item), NonNullList.of(Ingredient.EMPTY, Ingredient.of(item), PartMaterialIngredient.of(PartType.MAIN), PartMaterialIngredient.of(PartType.MAIN), PartMaterialIngredient.of(PartType.MAIN)))), VanillaRecipeCategoryUid.CRAFTING);
        reg.addRecipes(Collections.singleton(new ShapelessRecipe(SilentGear.getId(itemName + "_fill_hint_frag"), "", new ItemStack(item), NonNullList.of(Ingredient.EMPTY, Ingredient.of(item), Ingredient.of(ModItems.FRAGMENT), Ingredient.of(ModItems.FRAGMENT), Ingredient.of(ModItems.FRAGMENT)))), VanillaRecipeCategoryUid.CRAFTING);
    }
    reg.addRecipes(recipeManager.getRecipes().stream().filter(SGearJeiPlugin::isGearCraftingRecipe).collect(Collectors.toList()), GEAR_CRAFTING);
    // Compounders
    reg.addRecipes(recipeManager.getRecipes().stream().filter(r -> r.getType() == CompoundingRecipe.COMPOUNDING_FABRIC_TYPE).collect(Collectors.toList()), Const.COMPOUNDING_FABRIC);
    reg.addRecipes(recipeManager.getRecipes().stream().filter(r -> r.getType() == CompoundingRecipe.COMPOUNDING_GEM_TYPE).collect(Collectors.toList()), Const.COMPOUNDING_GEM);
    reg.addRecipes(recipeManager.getRecipes().stream().filter(r -> r.getType() == CompoundingRecipe.COMPOUNDING_METAL_TYPE).collect(Collectors.toList()), Const.COMPOUNDING_METAL);
    for (int i = 2; i <= 4; ++i) {
        reg.addRecipes(Collections.singleton(CompoundingRecipe.makeExample(Const.FABRIC_COMPOUNDER_INFO, i, new FabricCompoundingRecipe(SilentGear.getId("fabric_example_" + i)))), Const.COMPOUNDING_FABRIC);
        reg.addRecipes(Collections.singleton(CompoundingRecipe.makeExample(Const.GEM_COMPOUNDER_INFO, i, new GemCompoundingRecipe(SilentGear.getId("gem_example_" + i)))), Const.COMPOUNDING_GEM);
        reg.addRecipes(Collections.singleton(CompoundingRecipe.makeExample(Const.METAL_COMPOUNDER_INFO, i, new MetalCompoundingRecipe(SilentGear.getId("metal_example_" + i)))), Const.COMPOUNDING_METAL);
    }
    // Grading
    reg.addRecipes(Collections.singleton(new MaterialGraderRecipeCategory.GraderRecipe()), Const.GRADING);
    // Salvaging
    reg.addRecipes(recipeManager.getRecipes().stream().filter(r -> r.getType() == SalvagingRecipe.SALVAGING_TYPE).collect(Collectors.toList()), Const.SALVAGING);
    addInfoPage(reg, CraftingItems.RED_CARD_UPGRADE);
    addInfoPage(reg, CraftingItems.SPOON_UPGRADE);
    for (Item item : Registration.getItems(item -> item instanceof ICoreTool)) {
        addInfoPage(reg, item);
    }
}
Also used : GemCompoundingRecipe(net.silentchaos512.gear.crafting.recipe.compounder.GemCompoundingRecipe) MetalCompoundingRecipe(net.silentchaos512.gear.crafting.recipe.compounder.MetalCompoundingRecipe) FabricCompoundingRecipe(net.silentchaos512.gear.crafting.recipe.compounder.FabricCompoundingRecipe) ICoreTool(net.silentchaos512.gear.api.item.ICoreTool) RepairKitItem(net.silentchaos512.gear.item.RepairKitItem) RepairKitItem(net.silentchaos512.gear.item.RepairKitItem) Item(net.minecraft.world.item.Item) FragmentItem(net.silentchaos512.gear.item.FragmentItem) CustomMaterialItem(net.silentchaos512.gear.item.CustomMaterialItem) ItemStack(net.minecraft.world.item.ItemStack)

Aggregations

ItemStack (net.minecraft.world.item.ItemStack)3 ICoreTool (net.silentchaos512.gear.api.item.ICoreTool)3 Item (net.minecraft.world.item.Item)2 ICoreItem (net.silentchaos512.gear.api.item.ICoreItem)2 ArrayList (java.util.ArrayList)1 Nonnull (javax.annotation.Nonnull)1 Minecraft (net.minecraft.client.Minecraft)1 LocalPlayer (net.minecraft.client.player.LocalPlayer)1 BlockPos (net.minecraft.core.BlockPos)1 Component (net.minecraft.network.chat.Component)1 TextComponent (net.minecraft.network.chat.TextComponent)1 TranslatableComponent (net.minecraft.network.chat.TranslatableComponent)1 ResourceLocation (net.minecraft.resources.ResourceLocation)1 Entity (net.minecraft.world.entity.Entity)1 LivingEntity (net.minecraft.world.entity.LivingEntity)1 BlockState (net.minecraft.world.level.block.state.BlockState)1 BlockHitResult (net.minecraft.world.phys.BlockHitResult)1 EntityHitResult (net.minecraft.world.phys.EntityHitResult)1 HitResult (net.minecraft.world.phys.HitResult)1 GearType (net.silentchaos512.gear.api.item.GearType)1