Search in sources :

Example 1 with GearCrossbowItem

use of net.silentchaos512.gear.item.gear.GearCrossbowItem 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 GearCrossbowItem

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

the class GearModelOverrideList method getOverrideModel.

private BakedModel getOverrideModel(CacheKey key, ItemStack stack, @Nullable ClientLevel worldIn, @Nullable LivingEntity entityIn, int animationFrame) {
    boolean broken = GearHelper.isBroken(stack);
    if (isDebugLoggingEnabled()) {
        SilentGear.LOGGER.info("getOverrideModel for {} ({})", stack.getHoverName().getString(), broken ? "broken" : "normal");
        SilentGear.LOGGER.info("- model key {}", key.data);
    }
    List<MaterialLayer> layers = new ArrayList<>();
    for (PartData part : getPartsInRenderOrder(stack)) {
        if (((ICoreItem) stack.getItem()).hasTexturesFor(part.getType())) {
            addSimplePartLayers(layers, part, stack);
            if (part.get() instanceof CompoundPart) {
                MaterialInstance mat = CompoundPart.getPrimaryMaterial(part);
                if (mat != null) {
                    addWithBlendedColor(layers, part, mat, stack);
                }
            }
        }
    }
    // TODO: Make this not a special case...
    if (stack.getItem() instanceof GearCrossbowItem) {
        getCrossbowCharge(stack, worldIn, entityIn).ifPresent(layers::add);
    }
    return model.bake(stack, layers, animationFrame, "test", owner, bakery, spriteGetter, modelTransform, this, modelLocation);
}
Also used : MaterialLayer(net.silentchaos512.gear.api.material.MaterialLayer) ArrayList(java.util.ArrayList) PartData(net.silentchaos512.gear.gear.part.PartData) ICoreItem(net.silentchaos512.gear.api.item.ICoreItem) CompoundPart(net.silentchaos512.gear.gear.part.CompoundPart) GearCrossbowItem(net.silentchaos512.gear.item.gear.GearCrossbowItem) MaterialInstance(net.silentchaos512.gear.gear.material.MaterialInstance)

Aggregations

ArrayList (java.util.ArrayList)2 GearCrossbowItem (net.silentchaos512.gear.item.gear.GearCrossbowItem)2 Nonnull (javax.annotation.Nonnull)1 Minecraft (net.minecraft.client.Minecraft)1 LocalPlayer (net.minecraft.client.player.LocalPlayer)1 BlockPos (net.minecraft.core.BlockPos)1 ResourceLocation (net.minecraft.resources.ResourceLocation)1 Entity (net.minecraft.world.entity.Entity)1 LivingEntity (net.minecraft.world.entity.LivingEntity)1 Item (net.minecraft.world.item.Item)1 ItemStack (net.minecraft.world.item.ItemStack)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 ICoreItem (net.silentchaos512.gear.api.item.ICoreItem)1 MaterialLayer (net.silentchaos512.gear.api.material.MaterialLayer)1 MaterialInstance (net.silentchaos512.gear.gear.material.MaterialInstance)1 CompoundPart (net.silentchaos512.gear.gear.part.CompoundPart)1 PartData (net.silentchaos512.gear.gear.part.PartData)1