Skip to content

Commit 6908b69

Browse files
committed
debugging and arrow
1 parent 138a0df commit 6908b69

File tree

10 files changed

+56
-9
lines changed

10 files changed

+56
-9
lines changed

common/src/main/java/smartin/miapi/client/gui/crafting/statdisplay/StatDisplay.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ public class StatDisplay extends InteractAbleWidget {
8787
.Builder(AttributeRegistry.PROJECTILE_SPEED)
8888
.setTranslationKey("projectile_speed")
8989
.setFormat("##.#")
90+
.setDefault(0.0)
9091
.setMax(10).build());
9192
addStatDisplay(AttributeSingleDisplay
9293
.Builder(AttributeRegistry.PROJECTILE_ACCURACY)

common/src/main/java/smartin/miapi/client/modelrework/BakedMiapiModel.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public void render(MatrixStack matrices, ItemStack stack, ModelTransformationMod
4444

4545
for (BakedModel model : models) {
4646
for (Direction direction : Direction.values()) {
47+
MinecraftClient.getInstance().world.getProfiler().push("BakedModel");
4748
if (model.getOverrides() != null && !model.getOverrides().equals(ModelOverrideList.EMPTY)) {
4849
model = model.getOverrides().apply(model, stack, MinecraftClient.getInstance().world, entity, light);
4950
}
@@ -58,8 +59,10 @@ public void render(MatrixStack matrices, ItemStack stack, ModelTransformationMod
5859
consumer.quad(matrices.peek(), bakedQuad, 1, 1, 1, lightValue, overlay);
5960
});
6061
immediate.draw();
62+
MinecraftClient.getInstance().world.getProfiler().pop();
6163

6264
if (settings.shouldRender()) {
65+
MinecraftClient.getInstance().world.getProfiler().push("Glint");
6366
rootSettings.applySpeed();
6467
settings.applyAlpha();
6568
VertexConsumer glintConsumer = immediate.getBuffer(RegistryInventory.Client.modularItemGlint);
@@ -71,6 +74,7 @@ public void render(MatrixStack matrices, ItemStack stack, ModelTransformationMod
7174
glintConsumer.quad(matrices.peek(), bakedQuad, (float) glintColor.r() / 255, (float) glintColor.g() / 255, (float) glintColor.b() / 255, lightValue, overlay);
7275
});
7376
immediate.draw();
77+
MinecraftClient.getInstance().world.getProfiler().pop();
7478
}
7579
}
7680
}

common/src/main/java/smartin/miapi/client/modelrework/MiapiItemModel.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package smartin.miapi.client.modelrework;
22

3+
import net.minecraft.client.MinecraftClient;
34
import net.minecraft.client.render.VertexConsumerProvider;
45
import net.minecraft.client.render.model.json.ModelTransformationMode;
56
import net.minecraft.client.util.math.MatrixStack;
@@ -54,13 +55,15 @@ public void render(String modelType, MatrixStack matrices, ModelTransformationMo
5455
}
5556

5657
public void render(String modelType, ItemStack stack, MatrixStack matrices, ModelTransformationMode mode, float tickDelta, VertexConsumerProvider vertexConsumers, LivingEntity entity, int light, int overlay) {
58+
MinecraftClient.getInstance().world.getProfiler().push("modular_item");
5759
matrices.push();
5860
for (ModelTransformer transformer : modelTransformers) {
5961
matrices = transformer.transform(matrices, stack, mode, modelType, tickDelta);
6062
}
6163
RegistryInventory.Client.glintShader.getUniformOrDefault("ModelMat").set(new Matrix4f(matrices.peek().getPositionMatrix()));
6264
rootModel.render(modelType, stack, matrices, mode, tickDelta, vertexConsumers, entity, light, overlay);
6365
matrices.pop();
66+
MinecraftClient.getInstance().world.getProfiler().pop();
6467
}
6568

6669
@Override

common/src/main/java/smartin/miapi/item/modular/items/ExampleModularBowItem.java renamed to common/src/main/java/smartin/miapi/item/modular/items/ModularBow.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626

2727
import java.util.function.Predicate;
2828

29-
public class ExampleModularBowItem extends BowItem implements ModularItem {
29+
public class ModularBow extends BowItem implements ModularItem {
3030
public static boolean betterInfinity = true;
3131

32-
public ExampleModularBowItem() {
32+
public ModularBow() {
3333
super(new Item.Settings());
3434
if (smartin.miapi.Environment.isClient()) {
3535
registerAnimations();
@@ -44,7 +44,7 @@ public void onStoppedUsing(ItemStack bowStack, World world, LivingEntity user, i
4444
PlayerEntity playerEntity = (PlayerEntity) user;
4545
boolean consumeArrow = !playerEntity.getAbilities().creativeMode;
4646
ItemStack projectileStack = playerEntity.getProjectileType(bowStack);
47-
if(EnchantmentHelper.getLevel(Enchantments.INFINITY, bowStack) > 0 &&(projectileStack.isEmpty() || (projectileStack.getItem() instanceof ArrowItem && projectileStack.getOrCreateNbt().isEmpty()))){
47+
if (EnchantmentHelper.getLevel(Enchantments.INFINITY, bowStack) > 0 && (projectileStack.isEmpty() || (projectileStack.getItem() instanceof ArrowItem && projectileStack.getOrCreateNbt().isEmpty()))) {
4848
consumeArrow = false;
4949
projectileStack = new ItemStack(Items.ARROW);
5050
}
@@ -69,11 +69,12 @@ public void onStoppedUsing(ItemStack bowStack, World world, LivingEntity user, i
6969
itemProjectile.setPierceLevel((byte) ((byte) (int) AttributeProperty.getActualValue(projectileStack, EquipmentSlot.MAINHAND, AttributeRegistry.PROJECTILE_PIERCING) + piercingLevel));
7070

7171
float divergence = (float) AttributeProperty.getActualValue(projectileStack, EquipmentSlot.MAINHAND, AttributeRegistry.PROJECTILE_ACCURACY);
72-
float speed = (float) AttributeProperty.getActualValue(projectileStack, EquipmentSlot.MAINHAND, AttributeRegistry.PROJECTILE_SPEED);
72+
float speed = (float) AttributeProperty.getActualValue(projectileStack, EquipmentSlot.MAINHAND, AttributeRegistry.PROJECTILE_SPEED, 1.5f);
7373
float damage = (float) AttributeProperty.getActualValue(bowStack, EquipmentSlot.MAINHAND, AttributeRegistry.PROJECTILE_DAMAGE);
7474
divergence += (float) AttributeProperty.getActualValue(bowStack, EquipmentSlot.MAINHAND, AttributeRegistry.PROJECTILE_ACCURACY);
7575
speed += (float) AttributeProperty.getActualValue(bowStack, EquipmentSlot.MAINHAND, AttributeRegistry.PROJECTILE_SPEED);
7676
damage += (float) AttributeProperty.getActualValue(projectileStack, EquipmentSlot.MAINHAND, AttributeRegistry.PROJECTILE_DAMAGE);
77+
speed = speed * pullProgress;
7778
damage = damage / speed;
7879
itemProjectile.setDamage(damage);
7980
itemProjectile.setSpeedDamage(true);
@@ -123,7 +124,7 @@ public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand han
123124
}
124125

125126
public static float getPullProgress(int useTicks, ItemStack stack) {
126-
float f = (float) ((float) useTicks / AttributeProperty.getActualValue(stack, EquipmentSlot.MAINHAND, AttributeRegistry.BOW_DRAW_TIME));
127+
float f = (float) useTicks / 20.0f;
127128
if ((f = (f * f + f * 2.0f) / 3.0f) > 1.0f) {
128129
f = 1.0f;
129130
}

common/src/main/java/smartin/miapi/modules/abilities/util/ItemProjectile/ItemProjectile.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import net.minecraft.item.ItemStack;
1616
import net.minecraft.nbt.NbtCompound;
1717
import net.minecraft.server.network.ServerPlayerEntity;
18+
import net.minecraft.server.world.ServerWorld;
1819
import net.minecraft.sound.SoundEvent;
1920
import net.minecraft.sound.SoundEvents;
2021
import net.minecraft.util.hit.BlockHitResult;
@@ -101,6 +102,11 @@ public void tick() {
101102
this.dealtDamage = true;
102103
}
103104

105+
this.velocityDirty = true;
106+
if(this.getWorld() instanceof ServerWorld){
107+
this.setVelocity(this.getVelocity());
108+
}
109+
104110
Entity entity = this.getOwner();
105111
int loyaltyLevel = this.dataTracker.get(LOYALTY);
106112
if (loyaltyLevel > 0 && (this.dealtDamage || this.isNoClip()) && entity != null) {

common/src/main/java/smartin/miapi/modules/properties/AttributeProperty.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ public static double getActualValue(ItemStack stack, EquipmentSlot slot, EntityA
251251
AttributeContainer container1 = new AttributeContainer(container);
252252

253253
container1.addTemporaryModifiers(map);
254-
if (container1.hasAttribute(entityAttribute)) {
254+
if (map.containsKey(entityAttribute) && container1.hasAttribute(entityAttribute)) {
255255
return container1.getValue(entityAttribute);
256256
} else {
257257
return fallback;

common/src/main/java/smartin/miapi/registries/RegistryInventory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ public static void setup() {
242242
register(modularItems, "modular_hoe", ModularWeapon::new);
243243
register(modularItems, "modular_mattock", ModularWeapon::new);
244244

245-
register(modularItems, "modular_bow", ExampleModularBowItem::new);
245+
register(modularItems, "modular_bow", ModularBow::new);
246246
register(modularItems, "modular_arrow", ModularArrow::new);
247247

248248
register(modularItems, "modular_helmet", ModularHelmet::new);
@@ -302,7 +302,7 @@ public static void setup() {
302302
new ClampedEntityAttribute("miapi.attribute.name.projectile_damage", 2.0, 0.0, 1024.0).setTracked(true),
303303
att -> PROJECTILE_DAMAGE = att);
304304
registerAtt("generic.projectile_speed", true, () ->
305-
new ClampedEntityAttribute("miapi.attribute.name.projectile_speed", 1.0, 0.0, 1024.0).setTracked(true),
305+
new ClampedEntityAttribute("miapi.attribute.name.projectile_speed", 1.5, 0.0, 1024.0).setTracked(true),
306306
att -> PROJECTILE_SPEED = att);
307307
registerAtt("generic.projectile_accuracy", true, () ->
308308
new ClampedEntityAttribute("miapi.attribute.name.projectile_accuracy", 1.0, 0.0, 1024.0).setTracked(true),

common/src/main/resources/data/miapi/modules/bow/arm/normal_bow_arms.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,22 @@
4747
}
4848
}
4949
},
50+
"attributes": [
51+
{
52+
"attribute": "miapi:generic.projectile_speed",
53+
"value": "([material.hardness] + [material.flexibility] ) / 9",
54+
"operation": "+",
55+
"slot": "mainhand",
56+
"uuid": "AAAAAAAA-4180-4865-B01B-BCCE9785ACA3"
57+
},
58+
{
59+
"attribute": "miapi:generic.durability",
60+
"value": "[material.durability] / 2",
61+
"operation": "+",
62+
"slot": "mainhand",
63+
"uuid": "AAAAAAAA-4180-4865-B01B-BCCE9785ACA3"
64+
}
65+
],
5066
"allowedMaterial": {
5167
"allowedMaterials": [
5268
"wood",

common/src/main/resources/data/miapi/modules/bow/handle/normal_bow_handle.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@
2323
"allowedInSlots": [
2424
"bow","melee"
2525
],
26+
"attributes": [
27+
{
28+
"attribute": "miapi:generic.durability",
29+
"value": "[material.durability] / 2",
30+
"operation": "+",
31+
"slot": "mainhand",
32+
"uuid": "AAAAAAAA-4180-4865-B01B-BCCE9785ACA3"
33+
}
34+
],
2635
"slots": {
2736
"0": {
2837
"allowed": [

common/src/main/resources/data/miapi/modules/bow/string/normal_bow_string.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,14 @@
2626
"attributes": [
2727
{
2828
"attribute": "miapi:generic.projectile_speed",
29-
"value": "3.5",
29+
"value": "1.5",
30+
"operation": "+",
31+
"slot": "mainhand",
32+
"uuid": "AAAAAAAA-4180-4865-B01B-BCCE9785ACA3"
33+
},
34+
{
35+
"attribute": "miapi:generic.durability",
36+
"value": "[material.durability] / 2",
3037
"operation": "+",
3138
"slot": "mainhand",
3239
"uuid": "AAAAAAAA-4180-4865-B01B-BCCE9785ACA3"

0 commit comments

Comments
 (0)