Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 26 additions & 17 deletions src/main/java/com/daniking/backtools/BackToolFeatureRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import net.minecraft.util.math.RotationAxis;

@Environment(EnvType.CLIENT)
public class BackToolFeatureRenderer <M extends PlayerEntityModel> extends PlayerHeldItemFeatureRenderer<PlayerEntityRenderState, M> {
public class BackToolFeatureRenderer<M extends PlayerEntityModel> extends PlayerHeldItemFeatureRenderer<PlayerEntityRenderState, M> {
public ItemStack mainStack = ItemStack.EMPTY;
public ItemStack offStack = ItemStack.EMPTY;
public Arm mainArm = Arm.RIGHT;
Expand All @@ -42,36 +42,38 @@ public void render(MatrixStack matrixStack, VertexConsumerProvider vertexConsume
matrixStack.push();
this.getContextModel().body.rotate(matrixStack);
boolean isHelicopterMode = ConfigHandler.isHelicopterModeOn() && (playerRenderState.isSwimming || playerRenderState.isGliding);
this.renderItem(!playerRenderState.equippedChestStack.isEmpty() ? 1.0F : playerRenderState.jacketVisible ? 0.5F : 0F, matrixStack, vertexConsumerProvider, light, isHelicopterMode ? playerRenderState.age : 0);
this.renderItem(!playerRenderState.equippedChestStack.isEmpty() ? 1.0F : playerRenderState.jacketVisible ? 0.5F : 0F,
matrixStack, vertexConsumerProvider, light, isHelicopterMode ? playerRenderState.age : 0);
matrixStack.pop();
}
}

private void renderItem(float offset, MatrixStack matrices, VertexConsumerProvider provider, int light, final float age) {
matrices.translate(0F, 4F/16F, 1.91F/16F + (offset / 16F));
matrices.translate(0F, 4F / 16F, 1.91F / 16F + (offset / 16F));
matrices.translate(0F, 0F, 0.025F);

if (!this.mainStack.isEmpty()) {
if (this.mainArm == Arm.RIGHT) {
matrices.scale(-1F, 1F, -1F);
}
boolean bl = this.mainStack.getItem() instanceof ShieldItem;
if (bl) {
if (this.mainStack.getItem() instanceof ShieldItem) {
float scale = 1.5F;
matrices.scale(scale, scale, scale);
if (this.mainArm == Arm.LEFT) {
matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(180F));
matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(-25F));
matrices.translate(-2.5F/16F, 2F/16F, 1.25F/16F);
matrices.translate(-2.5F / 16F, 2F / 16F, 1.25F / 16F);
} else {
matrices.translate(-1F / 16F, 0.25F / 16F, 1.0F / 16F);
matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(25F));
}
} else {
TransformationSetting config = ConfigHandler.getToolOrientation(this.mainStack);
matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(config.getX()));
matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(config.getY()));
matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(config.getZ()));
}
if (!bl) {
final float i = ConfigHandler.getToolOrientation(this.mainStack.getItem());
matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(i));
}

if (ConfigHandler.isBeltTool(this.mainStack.getItem())) {
float swordScale = 0.8F;
matrices.scale(swordScale, swordScale, swordScale);
Expand All @@ -83,7 +85,13 @@ private void renderItem(float offset, MatrixStack matrices, VertexConsumerProvid
matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(270F));
matrices.translate(0.19F, 0.6F, 0.33F);
}
TransformationSetting config = ConfigHandler.getToolOffset(this.mainStack);
matrices.translate(config.getX(), config.getY(), config.getZ());
} else {
TransformationSetting config = ConfigHandler.getToolOffset(this.mainStack);
matrices.translate(config.getX(), config.getY(), -config.getZ());
}

if (age > 0) {
matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(age * 40F));
}
Expand All @@ -93,23 +101,24 @@ private void renderItem(float offset, MatrixStack matrices, VertexConsumerProvid
if (this.mainArm == Arm.LEFT) {
matrices.scale(-1F, 1F, -1F);
}
boolean isShield = this.offStack.getItem() instanceof ShieldItem;
if (isShield) {
if (this.offStack.getItem() instanceof ShieldItem) {
float scale = 1.5F;
matrices.scale(scale, scale, scale);
if (this.mainArm == Arm.RIGHT) {
matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(180F));
matrices.translate(-2.5F/16F, 2F/16F, 1.25F/16F);
matrices.translate(-2.5F / 16F, 2F / 16F, 1.25F / 16F);
matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(-25F));
} else {
matrices.translate(-1F / 16F, 0.25F / 16F, 1.0F / 16F);
matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(25F));
}
} else {
TransformationSetting config = ConfigHandler.getToolOrientation(this.mainStack);
matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(config.getX()));
matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(config.getY()));
matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(config.getZ()));
}
if (!isShield) {
final float i = ConfigHandler.getToolOrientation(this.mainStack.getItem());
matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(i));
}

if (age > 0) {
matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(age * 40F));
}
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/com/daniking/backtools/BackToolsConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,24 @@
public class BackToolsConfig implements ConfigData {
@Comment(value = "\nThese options affect only the client that loads the mod.\nIt is not possible to override the environment of the mod.")
public final String environment = EnvType.CLIENT.name();
@Comment(value = "What items should render on your belt.")
@Comment(value = "What items should render on your belt by their resource name. Eg: minecraft:diamond_hoe")
public List<String> beltTools = new ArrayList<>();
@Comment(value = "Enabled tools, by their resource name. Eg: minecraft:diamond_hoe. Putting any entry in here converts BackTools to a whitelist-only mod. Disabled Tools will be ignored.")
public List<String> enabledTools = new ArrayList<>();
@Comment(value = "Disabled tools, by their resource name. Eg: minecraft:diamond_hoe")
public List<String> disabledTools = new ArrayList<>();
@Comment(value = "Tool orientation, by class file and degrees. Separate with \":\" . See defaults for examples.")
@Comment(value = "Tool orientation, by class file, component data and degrees. Separate with \":\" . See defaults for examples.")
public List<String> toolOrientation = Arrays.asList(
"net.minecraft.item.MiningToolItem" + ":0",
"net.minecraft.item.HoeItem" + ":0",
"net.minecraft.item.FishingRodItem" + ":0",
"net.minecraft.item.TridentItem" + ":0",
"net.minecraft.item.MaceItem" + ":-22.5",
"net.minecraft.item.RangedWeaponItem" + ":90");
@Comment(value = "Tool translation; by class file, component data and degrees. Separate with \":\" . See defaults for examples.")
public List<String> toolOffset = Arrays.asList(
"net.minecraft.item.HoeItem" + "{\"minecraft:custom_name\":'\"translation test1\"'}}" + ":0.3:0:0.3",
"net.minecraft.item.HoeItem" + "{\"minecraft:custom_name\":'\"translation test2\"'}}" + ":0.3");
@Comment(value = "Get in swimming position and your tools go \"Weeee\"")
public boolean helicopterMode = false;
@Comment(value = "If true, tools render with capes")
Expand Down
Loading