Skip to content

Commit

Permalink
bug: Fixed autocannon seats not displaying properly when rendered usi…
Browse files Browse the repository at this point in the history
…ng instancing
  • Loading branch information
rbasamoyai committed Jan 13, 2025
1 parent bdcab0a commit d335482
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

**Create Big Cannons 5.8.3. More fixes.**

Fixed:
- Fixed autocannon seats not displaying properly when rendered using instancing

## [5.8.2] - 2025-01-07

**Create Big Cannons 5.8.2. Comes with a few fixes, mainly for missing functionality.**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package rbasamoyai.createbigcannons.cannons.autocannon.breech;

import org.joml.Quaternionf;
import org.joml.Vector3f;

import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.api.instance.DynamicInstance;
import com.jozufozu.flywheel.backend.instancing.blockentity.BlockEntityInstance;
Expand All @@ -9,10 +12,8 @@
import com.jozufozu.flywheel.util.AnimationTickHolder;
import com.mojang.math.Axis;

import org.joml.Quaternionf;
import org.joml.Vector3f;

import net.minecraft.core.Direction;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Blocks;
Expand All @@ -28,6 +29,7 @@ public class AutocannonBreechInstance extends BlockEntityInstance<AbstractAutoca
private OrientedData ejector;
private OrientedData seat;
private OrientedData ammoContainer;
private DyeColor seatColor;
//private final OrientedData shell;

private Direction facing;
Expand All @@ -51,9 +53,11 @@ public void init() {
.createInstance();
this.ejector.setRotation(q);

this.seatColor = this.blockEntity.getSeatColor();

this.seat = this.materialManager.defaultCutout()
.material(Materials.ORIENTED)
.getModel(CBCBlockPartials.autocannonSeatFor(this.blockEntity.getSeatColor()), this.blockState, this.facing)
.getModel(CBCBlockPartials.autocannonSeatFor(this.seatColor), this.blockState, this.facing)
.createInstance();
this.seat.setRotation(q).setPosition(this.getInstancePosition());

Expand Down Expand Up @@ -87,7 +91,7 @@ public void init() {
private void updateTransforms() {
if (this.blockState.getValue(AutocannonBreechBlock.HANDLE)) {
this.ejector.setColor((byte) 255, (byte) 255, (byte) 255, (byte) 0);
this.seat.setColor((byte) 255, (byte) 255, (byte) 255, (byte) (this.blockEntity.getSeatColor() == null ? 0 : 255));
this.seat.setColor((byte) 255, (byte) 255, (byte) 255, (byte) (this.seatColor == null ? 0 : 255));
} else {
this.seat.setColor((byte) 255, (byte) 255, (byte) 255, (byte) 0);

Expand All @@ -99,7 +103,7 @@ private void updateTransforms() {

ItemStack container = this.blockEntity.getMagazine();
this.ammoContainer.setColor((byte) 255, (byte) 255, (byte) 255, (byte)(container.getItem() instanceof AutocannonAmmoContainerItem ? 255 : 0));
if (this.isFilled != this.isFilled() || this.magazineItem != this.getMagazineItem()) {
if (this.isFilled != this.isFilled() || this.magazineItem != this.getMagazineItem() || this.seatColor != this.blockEntity.getSeatColor()) {
this.remove();
this.init();
this.updateLight();
Expand Down

0 comments on commit d335482

Please sign in to comment.