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