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;
}
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;
}
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;
}
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);
}
}
Aggregations