Skip to content

Commit

Permalink
Merge pull request #635 from rbasamoyai/1.20/dev
Browse files Browse the repository at this point in the history
1.19.2/dev 5.5.1 fixes => 1.20/dev
  • Loading branch information
rbasamoyai authored Aug 1, 2024
2 parents 60445bf + 959a7d1 commit 86d9a49
Show file tree
Hide file tree
Showing 34 changed files with 322 additions and 242 deletions.
6 changes: 6 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ Changelog
Create Big Cannons 5.5.1. A few critical fixes for 5.5.0 as well as some code changes.

Added:
- Added version checks for compat mods on 1.18.2
[Development] - Added ability to get big cannon projectile from all big cannon projectile item stacks
Changed:
- Optimized entity bounds for big cannons and autocannons to optimize lighting
- Changed impact explosion queueing to better allow compatibility with Valkyrien Skies
- All Autocannon Recoil Springs on an autocannon now play the firing animation
- Format for storing Autocannon Recoil Spring positions has changed, reassemble autocannons to fix any issues
- Registered custom shaders properly so that Create Big Cannons shaders don't cause logspam on crash
Fixed:
- Fixed Trinkets compat crashing
- Fixed gas mask overlay rendering as solid color when holding Just Enough Guns firearm
Expand All @@ -21,6 +23,10 @@ Fixed:
- Fixed autocannon assembly shooting projectiles the wrong way
- Added assembly failure message
- Fixed Fluid Shell item filling
- Fixed tracer not rendering for Drop Mortar Shell
- Fixed initial projectile chunkloading breaking Valkyrien Skies Quick-Firing Breeches
- Fixed illegal autocannon connections on creative block placement
- Fixed cannon casting connecting blocks that shouldn't connect

===

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,8 @@ public void fireShot(ServerLevel level, PitchOrientedContraptionEntity entity) {
SoundSource.BLOCKS, 12, 1, 5f);
}

if (CBCConfigs.SERVER.munitions.projectilesCanChunkload.get()) {
ChunkPos cpos1 = new ChunkPos(BlockPos.containing(spawnPos));
if (projectile != null && CBCConfigs.SERVER.munitions.projectilesCanChunkload.get()) {
ChunkPos cpos1 = new ChunkPos(BlockPos.containing(projectile.position()));
RitchiesProjectileLib.queueForceLoad(level, cpos1.x, cpos1.z);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,8 @@ public void fireShot(ServerLevel level, PitchOrientedContraptionEntity entity) {
player.connection.send(blastWavePacket);
}

if (CBCConfigs.SERVER.munitions.projectilesCanChunkload.get()) {
ChunkPos cpos1 = new ChunkPos(BlockPos.containing(spawnPos));
if (projectile != null && CBCConfigs.SERVER.munitions.projectilesCanChunkload.get()) {
ChunkPos cpos1 = new ChunkPos(BlockPos.containing(projectile.position()));
RitchiesProjectileLib.queueForceLoad(level, cpos1.x, cpos1.z);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,9 @@ public void setWelded(Direction face, boolean welded) {
public boolean isWelded() { return !this.weldedTowards.isEmpty(); }
public boolean isWeldedOn(Direction dir) { return this.weldedTowards.contains(dir); }

public boolean canConnectToSide(Direction face) {
BlockState state = this.blockEntity.getBlockState();
return state.getBlock() instanceof CannonContraptionProviderBlock cBlock && cBlock.canConnectToSide(state, face);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,23 @@

import javax.annotation.Nonnull;

import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.state.BlockState;
import rbasamoyai.createbigcannons.cannon_control.contraption.AbstractMountedCannonContraption;
import rbasamoyai.createbigcannons.crafting.casting.CannonCastShape;

public interface CannonContraptionProviderBlock {

@Nonnull AbstractMountedCannonContraption getCannonContraption();
Direction getFacing(BlockState state);

default boolean canConnectToSide(BlockState state, Direction face) { return this.getFacing(state).getAxis() == face.getAxis(); }

CannonCastShape getCannonShape();
default CannonCastShape getCannonShapeInLevel(LevelAccessor level, BlockState state, BlockPos pos) { return this.getCannonShape(); }

boolean isComplete(BlockState state);

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,14 @@
import rbasamoyai.createbigcannons.cannons.InteractableCannonBlock;
import rbasamoyai.createbigcannons.cannons.ItemCannonBehavior;
import rbasamoyai.createbigcannons.cannons.autocannon.material.AutocannonMaterial;
import rbasamoyai.createbigcannons.crafting.casting.CannonCastShape;
import rbasamoyai.createbigcannons.crafting.welding.WeldableBlock;

public interface AutocannonBlock extends WeldableBlock, CannonContraptionProviderBlock, InteractableCannonBlock {

AutocannonMaterial getAutocannonMaterial();
default AutocannonMaterial getAutocannonMaterialInLevel(LevelAccessor level, BlockState state, BlockPos pos) { return this.getAutocannonMaterial(); }

CannonCastShape getCannonShape();
default CannonCastShape getCannonShapeInLevel(LevelAccessor level, BlockState state, BlockPos pos) { return this.getCannonShape(); }

Direction getFacing(BlockState state);

default boolean canConnectToSide(BlockState state, Direction face) { return this.getFacing(state).getAxis() == face.getAxis(); }

boolean isBreechMechanism(BlockState state);
boolean isComplete(BlockState state);

default void onRemoveCannon(BlockState state, Level level, BlockPos pos, BlockState newState, boolean isMoving) {
if (!(state.getBlock() instanceof AutocannonBlock cBlock) || state.is(newState.getBlock())) return;
Expand All @@ -55,7 +46,7 @@ default void onRemoveCannon(BlockState state, Level level, BlockPos pos, BlockSt
}
}

if (cBlock.canConnectToSide(state, facing)) {
if (this.canConnectToSide(state, facing)) {
BlockPos pos1 = pos.relative(facing);
BlockState state1 = level.getBlockState(pos1);
BlockEntity be1 = level.getBlockEntity(pos1);
Expand All @@ -69,7 +60,7 @@ default void onRemoveCannon(BlockState state, Level level, BlockPos pos, BlockSt
}
}

if (cBlock.canConnectToSide(state, opposite)) {
if (this.canConnectToSide(state, opposite)) {
BlockPos pos2 = pos.relative(opposite);
BlockState state2 = level.getBlockState(pos2);
BlockEntity be2 = level.getBlockEntity(pos2);
Expand Down Expand Up @@ -103,7 +94,8 @@ static void onPlace(Level level, BlockPos pos) {
BlockState state1 = level.getBlockState(pos1);
BlockEntity be1 = level.getBlockEntity(pos1);

if (state1.getBlock() instanceof AutocannonBlock cBlock1
if (cBlock.canConnectToSide(state, facing)
&& state1.getBlock() instanceof AutocannonBlock cBlock1
&& cBlock1.getAutocannonMaterialInLevel(level, state1, pos1) == material
&& cBlock1.canConnectToSide(state1, opposite)) {
if (state1.hasProperty(AutocannonBarrelBlock.BARREL_END)) {
Expand All @@ -122,7 +114,8 @@ static void onPlace(Level level, BlockPos pos) {
BlockState state2 = level.getBlockState(pos2);
BlockEntity be2 = level.getBlockEntity(pos2);

if (state2.getBlock() instanceof AutocannonBlock cBlock2
if (cBlock.canConnectToSide(state, opposite)
&& state2.getBlock() instanceof AutocannonBlock cBlock2
&& cBlock2.getAutocannonMaterialInLevel(level, state2, pos2) == material
&& cBlock2.canConnectToSide(state2, facing)) {
if (state2.hasProperty(AutocannonBarrelBlock.BARREL_END)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ public interface BigCannonBlock extends WeldableBlock, CannonContraptionProvider

BigCannonMaterial getCannonMaterial();

CannonCastShape getCannonShape();

Direction getFacing(BlockState state);

default BigCannonEnd getOpeningType(@Nullable Level level, BlockState state, BlockPos pos) {
Expand All @@ -62,19 +60,11 @@ default BigCannonEnd getOpeningType(MountedBigCannonContraption contraption, Blo

BigCannonEnd getDefaultOpeningType();

boolean isComplete(BlockState state);

default BigCannonMaterial getCannonMaterialInLevel(LevelAccessor level, BlockState state, BlockPos pos) {
return this.getCannonMaterial();
}

default CannonCastShape getShapeInLevel(LevelAccessor level, BlockState state, BlockPos pos) {
return this.getCannonShape();
}

default boolean canConnectToSide(BlockState state, Direction dir) { return this.getFacing(state).getAxis() == dir.getAxis(); }

default boolean isImmovable(BlockState state) {
default boolean isImmovable(BlockState state) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ protected boolean addToInitialFrontier(Level level, BlockPos pos, Direction forc
}
fullShape = null;
} else {
CannonCastShape shape = cBlock.getShapeInLevel(level, state, currentPos);
CannonCastShape shape = cBlock.getCannonShapeInLevel(level, state, currentPos);
if (fullShape == null && !isConnected(connectedShapes, shape)) {
if (firstBlock) {
connectedShapes.add(shape);
Expand Down Expand Up @@ -281,7 +281,7 @@ private static boolean isNonLayerConnectedTo(Level level, CannonCastShape shape,
BlockPos pos, Direction dir, Direction forcedMovement) {
boolean pushing = dir == forcedMovement;
if (cBlock.getFacing(state).getAxis() != dir.getAxis()
|| cBlock.getShapeInLevel(level, state, pos) != shape
|| cBlock.getCannonShapeInLevel(level, state, pos) != shape
|| !(level.getBlockEntity(pos) instanceof ICannonBlockEntity<?> cbe)
|| !cbe.cannonBehavior().isConnectedTo(dir) && !pushing) return false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,11 @@ protected void finishCasting() {
}
recipe.assembleInWorld(this.getLevel(), pos);

if (y > 0 && this.getLevel().getBlockEntity(pos) instanceof ICannonBlockEntity<?> cbe && this.getLevel().getBlockEntity(pos.below()) instanceof ICannonBlockEntity<?> cbe1) {
if (y > 0
&& this.getLevel().getBlockEntity(pos) instanceof ICannonBlockEntity<?> cbe
&& cbe.cannonBehavior().canConnectToSide(Direction.DOWN)
&& this.getLevel().getBlockEntity(pos.below()) instanceof ICannonBlockEntity<?> cbe1
&& cbe1.cannonBehavior().canConnectToSide(Direction.UP)) {
cbe.cannonBehavior().setConnectedFace(Direction.DOWN, true);
cbe1.cannonBehavior().setConnectedFace(Direction.UP, true);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package rbasamoyai.createbigcannons.index;

import java.io.IOException;
import java.util.Locale;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;

import javax.annotation.Nullable;
Expand All @@ -11,14 +14,16 @@

import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.ShaderInstance;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.ResourceProvider;
import rbasamoyai.createbigcannons.CreateBigCannons;

public enum CBCRenderTypes {
CANNON_SMOKE_PARTICLE(CBCRenderingParts.CANNON_SMOKE_PARTICLE_INPUT, VertexFormat.Mode.QUADS, CBCRenderingParts.CANNON_SMOKE_PARTICLE_STATE),
SPLINTER_PARTICLE(type -> RenderType.create(type.id, CBCRenderingParts.SPLINTER_PARTICLE_INPUT, VertexFormat.Mode.QUADS,
SPLINTER_PARTICLE(type -> RenderType.create(type.id.toString(), CBCRenderingParts.SPLINTER_PARTICLE_INPUT, VertexFormat.Mode.QUADS,
512, false, false, CBCRenderingParts.SPLINTER_PARTICLE_STATE.apply(type)));

private final String id = CreateBigCannons.MOD_ID + "_" + this.name().toLowerCase(Locale.ROOT);
private final ResourceLocation id = CreateBigCannons.resource(this.name().toLowerCase(Locale.ROOT));
private final RenderType renderType;
@Nullable private ShaderInstance shaderInstance;

Expand All @@ -27,10 +32,10 @@ public enum CBCRenderTypes {
}

CBCRenderTypes(VertexFormat format, VertexFormat.Mode mode, Function<CBCRenderTypes, RenderType.CompositeState> state) {
this(type -> RenderType.create(type.id, format, mode, 256, false, false, state.apply(type)));
this(type -> RenderType.create(type.id.toString(), format, mode, 256, false, false, state.apply(type)));
}

public String id() { return this.id; }
public ResourceLocation id() { return this.id; }
public RenderType renderType() { return this.renderType; }
@Nullable public ShaderInstance getShaderInstance() { return this.shaderInstance; }
public void setShaderInstance(ShaderInstance shaderInstance) { this.shaderInstance = shaderInstance; }
Expand All @@ -40,4 +45,14 @@ public void setRenderTypeForBuilder(BufferBuilder builder) {
builder.begin(this.renderType.mode(), this.renderType.format());
}

public static void registerAllShaders(BiConsumer<ShaderInstance, Consumer<ShaderInstance>> cons,
CreateShaderInstance shaderCreator, ResourceProvider resourceManager) throws IOException {
for (CBCRenderTypes renderType : values())
cons.accept(shaderCreator.create(resourceManager, renderType.id, renderType.renderType().format()), renderType::setShaderInstance);
}

public interface CreateShaderInstance {
ShaderInstance create(ResourceProvider manager, ResourceLocation location, VertexFormat format) throws IOException;
}

}
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
package rbasamoyai.createbigcannons.mixin.client;

import com.mojang.blaze3d.vertex.PoseStack;

import net.minecraft.client.renderer.MultiBufferSource;

import net.minecraft.util.Mth;

import org.joml.AxisAngle4f;
import org.joml.Quaternionf;
import org.joml.Vector3f;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.mojang.blaze3d.vertex.PoseStack;

import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity;

import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import rbasamoyai.createbigcannons.cannon_control.contraption.PitchOrientedContraptionEntity;

@Mixin(EntityRenderDispatcher.class)
public class EntityRenderDispatcherMixin {

@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;isInvisible()Z", ordinal = 0))
private boolean createbigcannons$render$isInvisible(Entity instance) {
return instance.isInvisible() || instance.getVehicle() instanceof PitchOrientedContraptionEntity poce && poce.getSeatPos(instance) != null;
@WrapOperation(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;isInvisible()Z", ordinal = 0))
private boolean createbigcannons$render$isInvisible(Entity instance, Operation<Boolean> original) {
return original.call(instance) || instance.getVehicle() instanceof PitchOrientedContraptionEntity poce && poce.getSeatPos(instance) != null;
}

@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/EntityRenderDispatcher;renderHitbox(Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/mojang/blaze3d/vertex/VertexConsumer;Lnet/minecraft/world/entity/Entity;F)V"))
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
package rbasamoyai.createbigcannons.mixin.client;

import com.simibubi.create.foundation.ponder.PonderRegistry;
import com.simibubi.create.foundation.ponder.PonderScene;
import com.simibubi.create.foundation.ponder.PonderStoryBoardEntry;

import net.minecraft.resources.ResourceLocation;
import java.util.ArrayList;
import java.util.List;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;

import rbasamoyai.createbigcannons.CreateBigCannons;
import com.llamalad7.mixinextras.sugar.Local;
import com.simibubi.create.foundation.ponder.PonderRegistry;
import com.simibubi.create.foundation.ponder.PonderScene;
import com.simibubi.create.foundation.ponder.PonderStoryBoardEntry;

import java.util.ArrayList;
import java.util.List;
import net.minecraft.resources.ResourceLocation;
import rbasamoyai.createbigcannons.CreateBigCannons;

@Mixin(PonderRegistry.class)
public class PonderRegistryMixin {

@Inject(method = "compile(Lnet/minecraft/resources/ResourceLocation;)Ljava/util/List;",
at = @At(value = "INVOKE", target = "Lcom/simibubi/create/foundation/ponder/PonderRegistry;compile(Ljava/util/List;)Ljava/util/List;"), locals = LocalCapture.CAPTURE_FAILHARD)
private static void createbigcannons$compile(ResourceLocation id, CallbackInfoReturnable<List<PonderScene>> cir, List<PonderStoryBoardEntry> list) {
at = @At(value = "INVOKE", target = "Lcom/simibubi/create/foundation/ponder/PonderRegistry;compile(Ljava/util/List;)Ljava/util/List;"))
private static void createbigcannons$compile(ResourceLocation id, CallbackInfoReturnable<List<PonderScene>> cir,
@Local List<PonderStoryBoardEntry> list) {
if (id.getNamespace().equals(CreateBigCannons.MOD_ID)) return;
List<PonderStoryBoardEntry> modified = new ArrayList<>();
for (PonderStoryBoardEntry ponder : list) {
Expand Down
Loading

0 comments on commit 86d9a49

Please sign in to comment.