generated from GreenhouseModding/greenhouse-multiloader-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bugfixes, implement vanilla rendering mode.
- Loading branch information
1 parent
07503a8
commit 597e4cf
Showing
68 changed files
with
789 additions
and
313 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
buildSrc/src/main/kotlin/net/modgarden/barricade/gradle/Versions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 6 additions & 22 deletions
28
common/src/main/java/net/modgarden/barricade/Barricade.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
common/src/main/java/net/modgarden/barricade/client/particle/AdvancedBarrierParticle.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
package net.modgarden.barricade.client.particle; | ||
|
||
import com.mojang.blaze3d.vertex.VertexConsumer; | ||
import net.minecraft.client.Camera; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.multiplayer.ClientLevel; | ||
import net.minecraft.client.particle.Particle; | ||
import net.minecraft.client.particle.ParticleProvider; | ||
import net.minecraft.client.particle.ParticleRenderType; | ||
import net.minecraft.client.particle.TextureSheetParticle; | ||
import net.minecraft.client.renderer.texture.TextureAtlas; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.core.Direction; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.util.Mth; | ||
import net.modgarden.barricade.Barricade; | ||
import net.modgarden.barricade.client.util.BarrierRenderUtils; | ||
import net.modgarden.barricade.component.BlockedDirectionsComponent; | ||
import net.modgarden.barricade.particle.AdvancedBarrierParticleOptions; | ||
import org.jetbrains.annotations.Nullable; | ||
import org.joml.Quaternionf; | ||
|
||
import java.util.Optional; | ||
|
||
public class AdvancedBarrierParticle extends TextureSheetParticle { | ||
private final BlockedDirectionsComponent blockedDirections; | ||
private final BlockedDirectionsComponent relative; | ||
private final ResourceLocation backTextureLocation; | ||
private final Optional<BlockPos> origin; | ||
private int removeTicks = 0; | ||
|
||
AdvancedBarrierParticle(BlockedDirectionsComponent blockedDirections, @Nullable ResourceLocation backTextureLocation, Optional<BlockPos> origin, ClientLevel level, double x, double y, double z) { | ||
super(level, x, y, z); | ||
this.gravity = 0.0F; | ||
this.lifetime = 80; | ||
this.hasPhysics = false; | ||
this.blockedDirections = blockedDirections; | ||
this.backTextureLocation = backTextureLocation; | ||
this.origin = origin; | ||
this.relative = origin.map(pos -> BarrierRenderUtils.relativeDirectionsComponent(blockedDirections, pos)).orElse(blockedDirections); | ||
} | ||
|
||
@Override | ||
public void render(VertexConsumer buffer, Camera renderInfo, float partialTicks) { | ||
if (blockedDirections != null && origin.isPresent() && !blockedDirections.blocksAll() && !blockedDirections.doesNotBlock() && !relative.equals(BarrierRenderUtils.relativeDirectionsComponent(blockedDirections, origin.get()))) { | ||
if (removeTicks > 4) { | ||
remove(); | ||
} | ||
removeTicks++; | ||
return; | ||
} | ||
removeTicks = 0; | ||
|
||
Quaternionf quaternionf = new Quaternionf(); | ||
this.getFacingCameraMode().setRotation(quaternionf, renderInfo, partialTicks); | ||
if (this.roll != 0.0F) { | ||
quaternionf.rotateZ(Mth.lerp(partialTicks, this.oRoll, this.roll)); | ||
} | ||
|
||
if (!relative.blocksAll()) { | ||
this.setSprite(Minecraft.getInstance().getModelManager().getAtlas(TextureAtlas.LOCATION_BLOCKS).getSprite(Barricade.asResource("item/barricade/no_barrier"))); | ||
this.renderRotatedQuad(buffer, renderInfo, quaternionf, partialTicks); | ||
} | ||
if (backTextureLocation != null) { | ||
try { | ||
this.setSprite(Minecraft.getInstance().getModelManager().getAtlas(TextureAtlas.LOCATION_BLOCKS).getSprite(backTextureLocation)); | ||
} catch (IllegalStateException ex) { | ||
this.setSprite(Minecraft.getInstance().getModelManager().getAtlas(TextureAtlas.LOCATION_BLOCKS).getSprite(ResourceLocation.withDefaultNamespace("missingno"))); | ||
} | ||
this.renderRotatedQuad(buffer, renderInfo, quaternionf, partialTicks); | ||
} | ||
if (!relative.blocksAll()) { | ||
for (Direction direction : relative.directions()) { | ||
this.setSprite(Minecraft.getInstance().getModelManager().getAtlas(TextureAtlas.LOCATION_BLOCKS).getSprite(Barricade.asResource("item/barricade/direction/" + direction.getName()))); | ||
this.renderRotatedQuad(buffer, renderInfo, quaternionf, partialTicks); | ||
} | ||
} | ||
|
||
if (relative.blocksAll()) { | ||
this.setSprite(Minecraft.getInstance().getModelManager().getAtlas(TextureAtlas.LOCATION_BLOCKS).getSprite(ResourceLocation.withDefaultNamespace("item/barrier"))); | ||
this.renderRotatedQuad(buffer, renderInfo, quaternionf, partialTicks); | ||
} | ||
} | ||
|
||
@Override | ||
public ParticleRenderType getRenderType() { | ||
return ParticleRenderType.TERRAIN_SHEET; | ||
} | ||
|
||
@Override | ||
public float getQuadSize(float scaleFactor) { | ||
return 0.5F; | ||
} | ||
|
||
public static class Provider implements ParticleProvider<AdvancedBarrierParticleOptions> { | ||
|
||
@Override | ||
public @Nullable Particle createParticle(AdvancedBarrierParticleOptions type, ClientLevel level, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) { | ||
|
||
return new AdvancedBarrierParticle(type.blockedDirections(), type.backTextureLocation(), type.origin(), level, x, y, z); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.