diff --git a/common/src/main/java/io/github/foundationgames/automobility/AutomobilityClient.java b/common/src/main/java/io/github/foundationgames/automobility/AutomobilityClient.java index 22c19f2c..f01c86c7 100644 --- a/common/src/main/java/io/github/foundationgames/automobility/AutomobilityClient.java +++ b/common/src/main/java/io/github/foundationgames/automobility/AutomobilityClient.java @@ -28,15 +28,23 @@ import net.minecraft.client.color.block.BlockColor; import net.minecraft.client.color.item.ItemColor; import net.minecraft.client.model.Model; +import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.renderer.BiomeColors; import net.minecraft.client.renderer.entity.NoopRenderer; +import net.minecraft.client.renderer.item.ItemProperties; import net.minecraft.commands.SharedSuggestionProvider; import net.minecraft.core.HolderLookup; +import net.minecraft.core.component.DataComponents; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.component.BlockItemStateProperties; import net.minecraft.world.level.GrassColor; +import net.minecraft.world.level.block.LightBlock; import java.io.IOException; +import java.util.HashSet; +import java.util.Set; import java.util.function.Function; public class AutomobilityClient { @@ -68,6 +76,15 @@ public static void init() { ) ) ); + + ClientLevel.MARKER_PARTICLE_ITEMS = new HashSet<>(ClientLevel.MARKER_PARTICLE_ITEMS); + ClientLevel.MARKER_PARTICLE_ITEMS.add(AutomobilityBlocks.OFF_ROAD_AREA.require().asItem()); + + //ItemProperties.register(Items.LIGHT, ResourceLocation.withDefaultNamespace("level"), (p_329788_, p_329789_, p_329790_, p_329791_) -> { + // BlockItemStateProperties blockitemstateproperties = p_329788_.getOrDefault(DataComponents.BLOCK_STATE, BlockItemStateProperties.EMPTY); + // Integer integer = blockitemstateproperties.get(LightBlock.LEVEL); + // return integer != null ? (float)integer.intValue() / 16.0F : 1.0F; + //}); } public static void initBlocks() { diff --git a/common/src/main/java/io/github/foundationgames/automobility/block/AutomobilityBlocks.java b/common/src/main/java/io/github/foundationgames/automobility/block/AutomobilityBlocks.java index 5f5db7c2..9a3035a9 100644 --- a/common/src/main/java/io/github/foundationgames/automobility/block/AutomobilityBlocks.java +++ b/common/src/main/java/io/github/foundationgames/automobility/block/AutomobilityBlocks.java @@ -18,11 +18,17 @@ import net.minecraft.network.chat.Component; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.LightBlock; import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockBehaviour; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.material.MapColor; import java.util.function.Function; import java.util.function.Supplier; @@ -45,13 +51,12 @@ public enum AutomobilityBlocks {; public static final Eventual DASH_PANEL = register("dash_panel", () -> new DashPanelBlock(BlockBehaviour.Properties.ofFullCopy(Blocks.IRON_BLOCK) .lightLevel(s -> s.getValue(DashPanelBlock.POWERED) ? 0 : 1).emissiveRendering((s, l, p) -> !s.getValue(DashPanelBlock.POWERED)).noCollission()), b -> new DashPanelItem(b, new Item.Properties()), Automobility.TAB); - public static final Eventual GRASS_OFF_ROAD = register("grass_off_road", () -> new OffRoadBlock(BlockBehaviour.Properties.ofFullCopy(Blocks.GRASS_BLOCK).noCollission(), AUtils.colorFromInt(0x406918)), Automobility.TAB); - public static final Eventual DIRT_OFF_ROAD = register("dirt_off_road", () -> new OffRoadBlock(BlockBehaviour.Properties.ofFullCopy(Blocks.DIRT).noCollission(), AUtils.colorFromInt(0x594227)), Automobility.TAB); - public static final Eventual SAND_OFF_ROAD = register("sand_off_road", () -> new OffRoadBlock(BlockBehaviour.Properties.ofFullCopy(Blocks.SAND).noCollission(), AUtils.colorFromInt(0xC2B185)), Automobility.TAB); - public static final Eventual SNOW_OFF_ROAD = register("snow_off_road", () -> new OffRoadBlock(BlockBehaviour.Properties.ofFullCopy(Blocks.SNOW_BLOCK).noCollission(), AUtils.colorFromInt(0xD0E7ED)), Automobility.TAB); - + public static final Eventual GRASS_OFF_ROAD = register("grass_off_road", () -> new LayeredOffroadBlock(BlockBehaviour.Properties.ofFullCopy(Blocks.GRASS_BLOCK).noCollission(), AUtils.colorFromInt(0x406918)), Automobility.TAB); + public static final Eventual DIRT_OFF_ROAD = register("dirt_off_road", () -> new LayeredOffroadBlock(BlockBehaviour.Properties.ofFullCopy(Blocks.DIRT).noCollission(), AUtils.colorFromInt(0x594227)), Automobility.TAB); + public static final Eventual SAND_OFF_ROAD = register("sand_off_road", () -> new LayeredOffroadBlock(BlockBehaviour.Properties.ofFullCopy(Blocks.SAND).noCollission(), AUtils.colorFromInt(0xC2B185)), Automobility.TAB); + public static final Eventual SNOW_OFF_ROAD = register("snow_off_road", () -> new LayeredOffroadBlock(BlockBehaviour.Properties.ofFullCopy(Blocks.SNOW_BLOCK).noCollission(), AUtils.colorFromInt(0xD0E7ED)), Automobility.TAB); public static final Eventual LAUNCH_GEL = register("launch_gel", () -> new LaunchGelBlock(BlockBehaviour.Properties.ofFullCopy(Blocks.CLAY).strength(0.1f).sound(SoundType.HONEY_BLOCK).noCollission()), Automobility.TAB); - + public static final Eventual OFF_ROAD_AREA = register("off_road_area", () -> new OffroadAreaBlock(BlockBehaviour.Properties.of().replaceable().strength(-1.0F, 3600000.8F).mapColor(waterloggedMapColor(MapColor.NONE)).noLootTable().noOcclusion()), (CreativeTabQueue) null); public static final Eventual ALLOW = register("allow", () -> new Block(BlockBehaviour.Properties.ofFullCopy(Blocks.BEDROCK).sound(SoundType.METAL)), b -> new TooltipBlockItem(b, Component.translatable("tooltip.block.automobility.allow").withStyle(ChatFormatting.AQUA), new Item.Properties())); @@ -61,6 +66,10 @@ public enum AutomobilityBlocks {; Automobility.rl("autopilot_sign"), () -> Platform.get().blockEntity(AutopilotSignBlockEntity::new, AUTOPILOT_SIGN.require())); public static void init() { + for (int i = 1; i < 9; i++) { + int finalI = i; + Automobility.TAB.queueStack(() -> OffroadAreaBlock.setStrengthOnStack(new ItemStack(OFF_ROAD_AREA.require().asItem()), finalI)); + } } public static Eventual register(String name, Supplier block) { @@ -85,4 +94,8 @@ public static Eventual register(String name, Supplier block, Funct public static Eventual register(String name, Supplier block, Function item) { return register(name, block, item, null); } + + private static Function waterloggedMapColor(MapColor unwaterloggedMapColor) { + return (blockState) -> (Boolean)blockState.getValue(BlockStateProperties.WATERLOGGED) ? MapColor.WATER : unwaterloggedMapColor; + } } diff --git a/common/src/main/java/io/github/foundationgames/automobility/block/DashPanelBlock.java b/common/src/main/java/io/github/foundationgames/automobility/block/DashPanelBlock.java index 195074aa..47a9f00c 100644 --- a/common/src/main/java/io/github/foundationgames/automobility/block/DashPanelBlock.java +++ b/common/src/main/java/io/github/foundationgames/automobility/block/DashPanelBlock.java @@ -116,7 +116,7 @@ public static void onCollideWithDashPanel(@Nullable BlockState panelState, Entit } if (entity instanceof AutomobileEntity auto) { - auto.boost(0.45f, 50); + auto.boost(0.35f, 50); } else if (entity.getType().is(AutomobilityEntities.DASH_PANEL_BOOSTABLES)) { if (entity instanceof LivingEntity living) { living.addEffect(new MobEffectInstance(MobEffects.MOVEMENT_SPEED, 40, 6, true, false, false)); diff --git a/common/src/main/java/io/github/foundationgames/automobility/block/LaunchGelBlock.java b/common/src/main/java/io/github/foundationgames/automobility/block/LaunchGelBlock.java index eda77e71..901a44e5 100644 --- a/common/src/main/java/io/github/foundationgames/automobility/block/LaunchGelBlock.java +++ b/common/src/main/java/io/github/foundationgames/automobility/block/LaunchGelBlock.java @@ -28,7 +28,7 @@ public void entityInside(BlockState state, Level world, BlockPos pos, Entity ent super.entityInside(state, world, pos, entity); if (entity instanceof AutomobileEntity automobile && automobile.automobileOnGround()) { - automobile.boost(0.14f, 7); + automobile.boost(0.13f, 7); } } diff --git a/common/src/main/java/io/github/foundationgames/automobility/block/OffRoadBlock.java b/common/src/main/java/io/github/foundationgames/automobility/block/LayeredOffroadBlock.java similarity index 62% rename from common/src/main/java/io/github/foundationgames/automobility/block/OffRoadBlock.java rename to common/src/main/java/io/github/foundationgames/automobility/block/LayeredOffroadBlock.java index e5c1bc92..03d4156b 100644 --- a/common/src/main/java/io/github/foundationgames/automobility/block/OffRoadBlock.java +++ b/common/src/main/java/io/github/foundationgames/automobility/block/LayeredOffroadBlock.java @@ -16,16 +16,21 @@ import org.jetbrains.annotations.Nullable; import org.joml.Vector3f; -public class OffRoadBlock extends Block { - public static final VoxelShape ONE_LAYER_SHAPE = box(0, 0, 0, 16, 2, 16); - public static final VoxelShape TWO_LAYER_SHAPE = box(0, 0, 0, 16, 4, 16); - public static final VoxelShape THREE_LAYER_SHAPE = box(0, 0, 0, 16, 6, 16); - - public static final IntegerProperty LAYERS = IntegerProperty.create("layers", 1, 3); +public class LayeredOffroadBlock extends Block implements OffroadBlock { + public static final int MAX_LAYERS = 8; + public static final IntegerProperty LAYERS = IntegerProperty.create("layers", 1, MAX_LAYERS); public final Vector3f color; + private static final VoxelShape[] SHAPES_BY_LAYER; + + static { + SHAPES_BY_LAYER = new VoxelShape[MAX_LAYERS]; + for (int i = 0; i < SHAPES_BY_LAYER.length; i++) { + SHAPES_BY_LAYER[i] = getShapeForLayerCount(i + 1); + } + } - public OffRoadBlock(Properties settings, Vector3f color) { + public LayeredOffroadBlock(Properties settings, Vector3f color) { super(settings.pushReaction(PushReaction.DESTROY)); registerDefaultState(defaultBlockState().setValue(LAYERS, 1)); this.color = color; @@ -35,7 +40,7 @@ public OffRoadBlock(Properties settings, Vector3f color) { @Override public BlockState getStateForPlacement(BlockPlaceContext ctx) { var state = ctx.getLevel().getBlockState(ctx.getClickedPos()); - if (state.is(this) && state.getValue(LAYERS) < 3) { + if (state.is(this) && state.getValue(LAYERS) < MAX_LAYERS) { return state.setValue(LAYERS, state.getValue(LAYERS) + 1); } return super.getStateForPlacement(ctx); @@ -43,7 +48,7 @@ public BlockState getStateForPlacement(BlockPlaceContext ctx) { @Override public boolean canBeReplaced(BlockState state, BlockPlaceContext context) { - return state.getValue(LAYERS) < 3 && context.getItemInHand().is(this.asItem()); + return state.getValue(LAYERS) < MAX_LAYERS && context.getItemInHand().is(this.asItem()); } @Override @@ -61,11 +66,12 @@ public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { @Override public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) { - return switch (state.getValue(LAYERS)) { - case 2 -> TWO_LAYER_SHAPE; - case 3 -> THREE_LAYER_SHAPE; - default -> ONE_LAYER_SHAPE; - }; + int shapeIndex = state.getValue(LAYERS) - 1; + if(shapeIndex >= 0 && shapeIndex < SHAPES_BY_LAYER.length) { + return SHAPES_BY_LAYER[shapeIndex]; + } else { + return SHAPES_BY_LAYER[0]; + } } @Override @@ -73,4 +79,19 @@ protected void createBlockStateDefinition(StateDefinition.Builder CODEC = Block.simpleCodec(OffroadAreaBlock::new); + public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; + public static final IntegerProperty STRENGTH = IntegerProperty.create("strength", 1, MAX_STRENGTH); + public MapCodec codec() { + return CODEC; + } + + public OffroadAreaBlock(BlockBehaviour.Properties properties) { + super(properties); + this.registerDefaultState(this.stateDefinition.any().setValue(WATERLOGGED, false).setValue(STRENGTH, 4)); + } + + protected void createBlockStateDefinition(StateDefinition.Builder builder) { + builder.add(WATERLOGGED); + builder.add(STRENGTH); + } + + protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) { + if (!level.isClientSide && player.canUseGameMasterBlocks()) { + return InteractionResult.SUCCESS; + } else { + return InteractionResult.CONSUME; + } + } + + protected VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) { + return context.isHoldingItem(asItem()) ? Shapes.block() : Shapes.empty(); + } + + protected boolean propagatesSkylightDown(BlockState state, BlockGetter level, BlockPos pos) { + return state.getFluidState().isEmpty(); + } + + protected RenderShape getRenderShape(BlockState state) { + return RenderShape.INVISIBLE; + } + + protected float getShadeBrightness(BlockState state, BlockGetter level, BlockPos pos) { + return 1.0F; + } + + protected BlockState updateShape(BlockState state, Direction direction, BlockState neighborState, LevelAccessor level, BlockPos pos, BlockPos neighborPos) { + if (state.getValue(WATERLOGGED)) { + level.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(level)); + } + + return super.updateShape(state, direction, neighborState, level, pos, neighborPos); + } + + protected FluidState getFluidState(BlockState state) { + return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state); + } + + public ItemStack getCloneItemStack(LevelReader level, BlockPos pos, BlockState state) { + return setStrengthOnStack(super.getCloneItemStack(level, pos, state), (Integer)state.getValue(STRENGTH)); + } + + public static ItemStack setStrengthOnStack(ItemStack stack, int strength) { + stack.set(DataComponents.BLOCK_STATE, BlockItemStateProperties.EMPTY.with(STRENGTH, strength)); + return stack; + } + + @Override + public float getSpeedMultiplier(BlockState blockState) { + int strength = blockState.getValue(OffroadAreaBlock.STRENGTH); + return (float) ((-40 * strength) + 333) / ((50 * strength) + 365); + } + + @Override + public Vector3f getDebrisColor(BlockState blockState, BlockPos position, BlockGetter level) { + return AUtils.colorFromInt(level.getBlockState(position.below()).getMapColor(level, position).col); + } +} \ No newline at end of file diff --git a/common/src/main/java/io/github/foundationgames/automobility/block/OffroadBlock.java b/common/src/main/java/io/github/foundationgames/automobility/block/OffroadBlock.java new file mode 100644 index 00000000..95ecd154 --- /dev/null +++ b/common/src/main/java/io/github/foundationgames/automobility/block/OffroadBlock.java @@ -0,0 +1,11 @@ +package io.github.foundationgames.automobility.block; + +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.block.state.BlockState; +import org.joml.Vector3f; + +public interface OffroadBlock { + float getSpeedMultiplier(BlockState blockState); + Vector3f getDebrisColor(BlockState blockState, BlockPos position, BlockGetter level); +} diff --git a/common/src/main/java/io/github/foundationgames/automobility/entity/AutomobileEntity.java b/common/src/main/java/io/github/foundationgames/automobility/entity/AutomobileEntity.java index 150cb34f..27e28e60 100644 --- a/common/src/main/java/io/github/foundationgames/automobility/entity/AutomobileEntity.java +++ b/common/src/main/java/io/github/foundationgames/automobility/entity/AutomobileEntity.java @@ -15,13 +15,11 @@ import io.github.foundationgames.automobility.automobile.attachment.rear.DeployableRearAttachment; import io.github.foundationgames.automobility.automobile.attachment.rear.RearAttachment; import io.github.foundationgames.automobility.automobile.render.RenderableAutomobile; -import io.github.foundationgames.automobility.block.AutomobileAssemblerBlock; -import io.github.foundationgames.automobility.block.LaunchGelBlock; -import io.github.foundationgames.automobility.block.OffRoadBlock; -import io.github.foundationgames.automobility.block.SpecialAutomobileColliderBlock; +import io.github.foundationgames.automobility.block.*; import io.github.foundationgames.automobility.controller.AutomobileController; import io.github.foundationgames.automobility.item.AutomobileInteractable; import io.github.foundationgames.automobility.item.AutomobilityItems; +import io.github.foundationgames.automobility.mixin.BlockBehaviorAccess; import io.github.foundationgames.automobility.particle.AutomobilityParticles; import io.github.foundationgames.automobility.platform.Platform; import io.github.foundationgames.automobility.screen.AutomobileContainerLevelAccess; @@ -36,6 +34,8 @@ import net.minecraft.core.Cursor3D; import net.minecraft.core.Direction; import net.minecraft.core.Holder; +import net.minecraft.core.particles.BlockParticleOption; +import net.minecraft.core.particles.ParticleTypes; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.protocol.Packet; @@ -71,6 +71,10 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.RenderShape; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.entity.EntityTypeTest; import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.phys.AABB; @@ -117,11 +121,14 @@ public class AutomobileEntity extends Entity implements RenderableAutomobile, En public static final int SMALL_TURBO_TIME = 35; public static final int MEDIUM_TURBO_TIME = 70; - public static final int LARGE_TURBO_TIME = 115; + public static final int LARGE_TURBO_TIME = 125; public static final float TERMINAL_VELOCITY = -1.2f; + public static final float TRICK_MIN_VELOCITY = 0.4f; public final Input input = new Input(); private boolean prevHoldDrift = input.holdingDrift; + private boolean prevPrevHoldDrift = input.holdingDrift; + private boolean prevPrevPrevHoldDrift = input.holdingDrift; private long clientTime; @@ -181,6 +188,7 @@ public class AutomobileEntity extends Entity implements RenderableAutomobile, En private boolean automobileOnGround = true; private boolean wasOnGround = automobileOnGround; private boolean isFloorDirectlyBelow = true; + private boolean isFloorWithinOneBlockBelow = true; private boolean touchingWall = false; private int hadVehicleCollision = 0; @@ -205,17 +213,21 @@ public class AutomobileEntity extends Entity implements RenderableAutomobile, En private Vector3f debrisColor = new Vector3f(); private int fallTicks = 0; + private int airTime = 0; private int despawnTime = -1; private int despawnCountdown = 0; private boolean decorative = false; + private boolean trickBuffered = false; private boolean wasEngineRunning = false; private float standStillTime = -1.3f; + private float stepSoundMovementDistance; public void writeSyncStateData(FriendlyByteBuf buf) { buf.writeInt(boostTimer); + buf.writeInt(airTime); buf.writeFloat(steering); buf.writeFloat(wheelAngle); buf.writeInt(turboCharge); @@ -224,11 +236,13 @@ public void writeSyncStateData(FriendlyByteBuf buf) { input.writePacket(buf); buf.writeBoolean(drifting); + buf.writeBoolean(trickBuffered); buf.writeBoolean(burningOut); } public void readSyncStateData(FriendlyByteBuf buf) { boostTimer = buf.readInt(); + airTime = buf.readInt(); steering = buf.readFloat(); wheelAngle = buf.readFloat(); turboCharge = buf.readInt(); @@ -237,6 +251,7 @@ public void readSyncStateData(FriendlyByteBuf buf) { input.readPacket(buf); setDrifting(buf.readBoolean()); + setTrickBuffered(buf.readBoolean()); setBurningOut(buf.readBoolean()); this.dataLerpTicks = CLIENT_SYNC_INTERVAL; @@ -285,9 +300,11 @@ public void readAdditionalSaveData(CompoundTag nbt) { input.holdingDrift = nbt.getBoolean("holdingDrift"); input.holdingHorn = nbt.getBoolean("holdingHorn"); fallTicks = nbt.getInt("fallTicks"); + airTime = nbt.getInt("airTime"); despawnTime = nbt.getInt("despawnTime"); despawnCountdown = nbt.getInt("despawnCountdown"); decorative = nbt.getBoolean("decorative"); + trickBuffered = nbt.getBoolean("trickBuffered"); } @Override @@ -320,9 +337,11 @@ public void addAdditionalSaveData(CompoundTag nbt) { nbt.putBoolean("holdingDrift", input.holdingDrift); nbt.putBoolean("holdingHorn", input.holdingHorn); nbt.putInt("fallTicks", fallTicks); + nbt.putInt("airTime", airTime); nbt.putInt("despawnTime", despawnTime); nbt.putInt("despawnCountdown", despawnCountdown); nbt.putBoolean("decorative", decorative); + nbt.putBoolean("trickBuffered", trickBuffered); } public AutomobileEntity(EntityType type, Level world) { @@ -492,6 +511,10 @@ private void setDrifting(boolean drifting) { this.drifting = drifting; } + private void setTrickBuffered(boolean trickBuffered) { + this.trickBuffered = trickBuffered; + } + private void setBurningOut(boolean burningOut) { if (this.level().isClientSide() && !this.drifting && !this.burningOut && burningOut) { skidSound.accept(this); @@ -516,6 +539,10 @@ public boolean isDrifting() { return this.drifting; } + public boolean isTrickBuffered() { + return this.trickBuffered; + } + public boolean isBike() { return this.getFrame().model().wheelBase().wheelCount() == 2; } @@ -714,6 +741,7 @@ public void tick() { positionTrackingTick(); collisionStateTick(); steeringTick(); + rampTrickTick(); driftingTick(); burnoutTick(); @@ -831,6 +859,10 @@ public void updateEngineSpeed(float speed) { return; } + if(engineSpeed > stats.getComfortableSpeed() * 1.25f) { + speed = stats.getComfortableSpeed() * 1.25f; + } + this.engineSpeed = speed; } @@ -870,6 +902,7 @@ public void movementTick() { this.setSpeed(Math.max(this.getHSpeed(), 0.1f), Math.max(this.getVSpeed(), 0.9f)); this.jumpCooldown = 5; this.automobileOnGround = false; + level().playLocalSound(getX(), getY(), getZ(), SoundEvents.SLIME_JUMP, SoundSource.AMBIENT, 0.8f * getUnderwaterVolumeMultiplier(), getUnderwaterPitchMultiplier(), true); } // Track the last position of the automobile @@ -934,11 +967,11 @@ public void movementTick() { boolean wasOffRoad = this.offRoad && this.hSpeed > 0.01; // Handle being in off-road - if (boostSpeed < 0.4f && level().getBlockState(blockPosition()).getBlock() instanceof OffRoadBlock block) { - int layers = level().getBlockState(blockPosition()).getValue(OffRoadBlock.LAYERS); - float cap = stats.getComfortableSpeed() * (1 - ((float)layers / 3.5f)); + if (boostSpeed < 0.4f && level().getBlockState(blockPosition()).getBlock() instanceof OffroadBlock block) { + BlockState blockState = level().getBlockState(blockPosition()); + float cap = stats.getComfortableSpeed() * block.getSpeedMultiplier(blockState); this.updateEngineSpeed(Math.min(cap, engineSpeed)); - this.debrisColor = block.color; + this.debrisColor = block.getDebrisColor(blockState, blockPosition(), level()); this.offRoad = true; } else this.offRoad = false; @@ -1053,7 +1086,7 @@ public void receiveVehicleCollisions() { .multiply(1, 0, 1)); if (hadVehicleCollision <= 0) { - level().playLocalSound(this.getX(), this.getY(), this.getZ(), AutomobilitySounds.COLLISION.require(), SoundSource.AMBIENT, 0.22f, 0.7f + (0.06f * (this.level().random.nextFloat() - 0.5f)), false); + level().playLocalSound(this.getX(), this.getY(), this.getZ(), AutomobilitySounds.COLLISION.require(), SoundSource.AMBIENT, 0.22f * getUnderwaterVolumeMultiplier(), 0.7f + (0.06f * (this.level().random.nextFloat() - 0.5f)) * getUnderwaterPitchMultiplier(), false); this.engineSpeed *= 0.6f; hadVehicleCollision = 12; } @@ -1080,7 +1113,7 @@ public void postMovementTick() { double knockSpeed = ((-0.2 * hSpeed) - 0.5); addedVelocity = addedVelocity.add(Math.sin(angle) * knockSpeed, 0, Math.cos(angle) * knockSpeed); - level().playLocalSound(this.getX(), this.getY(), this.getZ(), AutomobilitySounds.COLLISION.require(), SoundSource.AMBIENT, 0.76f, 0.65f + (0.06f * (this.level().random.nextFloat() - 0.5f)), true); + level().playLocalSound(this.getX(), this.getY(), this.getZ(), AutomobilitySounds.COLLISION.require(), SoundSource.AMBIENT, 0.76f * getUnderwaterVolumeMultiplier(), 0.65f + (0.06f * (this.level().random.nextFloat() - 0.5f)) * getUnderwaterPitchMultiplier(), true); if (isVehicle() && level().isClientSide()) { if (getPassengers().stream().anyMatch(p -> p instanceof LocalPlayer)) { @@ -1100,6 +1133,13 @@ public void postMovementTick() { fallTicks = 0; } + // Increment air time timer + if (!automobileOnGround) { + airTime += 1; + } else { + airTime = 0; + } + // Handle launching off slopes double highestPrevYDisp = 0; for (double d : prevYDisplacements) { @@ -1164,6 +1204,76 @@ public void postMovementTick() { if (this.automobileOnGround()) { this.smoothAngVel = Mth.lerp(0.34f, this.smoothAngVel, this.measuredAngVel); } + + // Add step sounds and particles + if(automobileOnGround() && Math.abs(getHSpeed()) > 0.05f && !(level().getBlockState(blockPosition()).getBlock() instanceof OffroadBlock block)) { + stepSoundMovementDistance += Math.abs(getHSpeed()); + + if(stepSoundMovementDistance > 0.5f) { + if(isUnderWater()) { + this.playSound(this.getSwimSound(), 0.035f, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.3F); + + if(Math.abs(getHSpeed()) > 0.2f && !isReversing()) { + spawnBubbleParticle(); + } + } else { + BlockPos stepSoundPosition = getPrimaryStepSoundBlockPos(blockPosition().below()); + BlockState stepSoundBlockState = level().getBlockState(stepSoundPosition); + SoundType soundType = stepSoundBlockState.getSoundType(); + this.playSound(soundType.getStepSound(), soundType.getVolume() * 0.07f * getUnderwaterVolumeMultiplier(), soundType.getPitch() * 0.8f * getUnderwaterPitchMultiplier()); + + if(Math.abs(getHSpeed()) > 0.2f && !isReversing()) { + spawnGroundParticle(); + } + } + + stepSoundMovementDistance = 0; + } + } + } + + private void spawnGroundParticle() { + BlockPos blockPos = this.getOnPos(); + BlockState blockState = this.level().getBlockState(blockPos); + BlockBehaviorAccess blockProperties = (BlockBehaviorAccess)blockState.getBlock().properties(); + if(!blockProperties.getSpawnTerrainParticles()) return; + + if (blockState.getRenderShape() != RenderShape.INVISIBLE) { + Vec3 deltaMovement = this.getDeltaMovement(); + for (var wheel : this.getFrame().model().wheelBase().wheels()) { + float particleResistance = Math.clamp(blockProperties.getExplosionResistance(), 2, 9) * 0.11f; + particleResistance -= ((Math.clamp(Math.abs(getHSpeed()), 0.3f, 1f)) - 0.3f) * 0.25f; + if(isDrifting()) particleResistance *= 0.75f; + if(random.nextFloat() < particleResistance) continue; + + if (wheel.end() == WheelBase.WheelEnd.BACK) { + Vector3d pos = new Vector3d(wheel.right() + ((wheel.right() > 0 ? 1 : -1) * this.getWheels().model().width() * wheel.scale()), 0, wheel.forward()).mul(0.0625); + localPosToWorldSpace(pos); + pos.add(-deltaMovement.x * 0.9f, -0.025f, -deltaMovement.z * 0.9f); + + level().addParticle(new BlockParticleOption(ParticleTypes.BLOCK, blockState), pos.x(), pos.y(), pos.z(), deltaMovement.x * (double)-1.5f + (random.nextFloat() - 0.5f) * 2.5f, (double)1.5f, deltaMovement.z * (double)-1.5f + (random.nextFloat() - 0.5f) * 2.5f); + } + } + } + } + + private void spawnBubbleParticle() { + BlockPos blockPos = this.getOnPos(); + BlockState blockState = this.level().getBlockState(blockPos); + if (blockState.getRenderShape() != RenderShape.INVISIBLE) { + Vec3 deltaMovement = this.getDeltaMovement(); + for (var wheel : this.getFrame().model().wheelBase().wheels()) { + if(random.nextFloat() < 0.2f) continue; + + if (wheel.end() == WheelBase.WheelEnd.BACK) { + Vector3d pos = new Vector3d(wheel.right() + ((wheel.right() > 0 ? 1 : -1) * this.getWheels().model().width() * wheel.scale()), 0, wheel.forward()).mul(0.0625); + localPosToWorldSpace(pos); + pos.add(-deltaMovement.x * 0.9f, 0, -deltaMovement.z * 0.9f); + + level().addParticle(ParticleTypes.BUBBLE, pos.x(), pos.y(), pos.z(), deltaMovement.x * (double)-1.5f + (random.nextFloat() - 0.5f) * 1.5f, 0.5f, deltaMovement.z * (double)-1.5f + (random.nextFloat() - 0.5f) * 1.5f); + } + } + } } public void whenRotated(float dYaw, Entity e) { @@ -1171,6 +1281,18 @@ public void whenRotated(float dYaw, Entity e) { e.setYBodyRot(Mth.wrapDegrees(e.getYRot() + dYaw)); } + public float getUnderwaterVolumeMultiplier() { + return isUnderWater() ? 0.8f : 1.0f; + } + + public float getUnderwaterPitchMultiplier() { + return isUnderWater() ? 0.8f : 1.0f; + } + + public boolean isReversing() { + return engineSpeed < 0; + } + private void whenRotatedSmooth(Entity passenger) { double lockStrength = 0.36; @@ -1246,15 +1368,19 @@ public void collisionStateTick() { wasOnGround = automobileOnGround; automobileOnGround = false; isFloorDirectlyBelow = false; + isFloorWithinOneBlockBelow = false; + var b = getBoundingBox(); var groundBox = new AABB(b.minX, b.minY - 0.04, b.minZ, b.maxX, b.minY, b.maxZ); var wid = (b.getXsize() + b.getZsize()) * 0.5f; var floorBox = new AABB(b.minX + (wid * 0.94), b.minY - 0.05, b.minZ + (wid * 0.94), b.maxX - (wid * 0.94), b.minY, b.maxZ - (wid * 0.94)); + var floorOneBlockBelowBox = new AABB(b.minX, b.minY - 1, b.minZ, b.maxX, b.minY, b.maxZ); var wallBox = b.deflate(0.05).move(this.lastVelocity.normalize().scale(0.12)); - var start = new BlockPos((int) Math.floor(b.minX - 0.1), (int) Math.floor(b.minY - 0.2), (int) Math.floor(b.minZ - 0.1)); + var start = new BlockPos((int) Math.floor(b.minX - 0.1), (int) Math.floor(b.minY - 1), (int) Math.floor(b.minZ - 0.1)); var end = new BlockPos((int) Math.floor(b.maxX + 0.1), (int) Math.floor(b.maxY + 0.2 + this.maxUpStep()), (int) Math.floor(b.maxZ + 0.1)); var groundCuboid = Shapes.create(groundBox); var floorCuboid = Shapes.create(floorBox); + var floorOneBlockBelowCuboid = Shapes.create(floorOneBlockBelowBox); var wallCuboid = Shapes.create(wallBox); var stepWallCuboid = wallCuboid.move(0, this.maxUpStep() - 0.05, 0); boolean wallHit = false; @@ -1270,6 +1396,7 @@ public void collisionStateTick() { var blockShape = state.getCollisionShape(this.level(), pos, shapeCtx).move(pos.getX(), pos.getY(), pos.getZ()); this.automobileOnGround |= Shapes.joinIsNotEmpty(blockShape, groundCuboid, BooleanOp.AND); this.isFloorDirectlyBelow |= Shapes.joinIsNotEmpty(blockShape, floorCuboid, BooleanOp.AND); + this.isFloorWithinOneBlockBelow |= Shapes.joinIsNotEmpty(blockShape, floorOneBlockBelowCuboid, BooleanOp.AND); wallHit |= Shapes.joinIsNotEmpty(blockShape, wallCuboid, BooleanOp.AND); stepWallHit |= Shapes.joinIsNotEmpty(blockShape, stepWallCuboid, BooleanOp.AND); } @@ -1318,6 +1445,10 @@ public void boost(float power, int time) { } controllerAction(c -> c.updateBoostingRumbleState(true, power)); + + float boostSoundPitch = 1.6f - (Math.clamp(power - 0.15f, 0f, 0.25f) * 3); + float boostSoundVolume = 0.5f; + level().playLocalSound(getX(), getY(), getZ(), SoundEvents.BLAZE_SHOOT, SoundSource.AMBIENT, boostSoundVolume * getUnderwaterVolumeMultiplier(), boostSoundPitch * getUnderwaterPitchMultiplier(), true); } private void steeringTick() { @@ -1328,11 +1459,11 @@ private void steeringTick() { private void consumeTurboCharge() { if (turboCharge > LARGE_TURBO_TIME) { - boost(0.38f, 38); + boost(0.25f, 38); } else if (turboCharge > MEDIUM_TURBO_TIME) { - boost(0.3f, 21); + boost(0.25f, 21); } else if (turboCharge > SMALL_TURBO_TIME) { - boost(0.23f, 9); + boost(0.25f, 9); } turboCharge = 0; } @@ -1341,7 +1472,7 @@ private void driftingTick() { int prevTurboCharge = turboCharge; // Handles starting a drift - if (!prevHoldDrift && input.holdingDrift) { + if ((!prevHoldDrift && input.holdingDrift) || (!prevPrevHoldDrift && prevHoldDrift) || (!prevPrevPrevHoldDrift && prevPrevHoldDrift)) { if (steering != 0 && !drifting && hSpeed > 0.4f && automobileOnGround) { setDrifting(true); controllerAction(AutomobileController::driftChargeRumble); @@ -1381,9 +1512,66 @@ private void driftingTick() { controllerAction(c -> c.updateMaxChargeRumbleState(false)); } + if (turboCharge >= SMALL_TURBO_TIME && prevTurboCharge < SMALL_TURBO_TIME) { + level().playLocalSound(getX(), getY(), getZ(), SoundEvents.WITHER_SHOOT, SoundSource.AMBIENT, 0.08f * getUnderwaterVolumeMultiplier(), 1.5f * getUnderwaterPitchMultiplier(), true); + } else if (turboCharge >= MEDIUM_TURBO_TIME && prevTurboCharge < MEDIUM_TURBO_TIME) { + level().playLocalSound(getX(), getY(), getZ(), SoundEvents.WITHER_SHOOT, SoundSource.AMBIENT, 0.09f * getUnderwaterVolumeMultiplier(), 1.75f * getUnderwaterPitchMultiplier(), true); + } else if (turboCharge >= LARGE_TURBO_TIME && prevTurboCharge < LARGE_TURBO_TIME) { + level().playLocalSound(getX(), getY(), getZ(), SoundEvents.WITHER_SHOOT, SoundSource.AMBIENT, 0.1f * getUnderwaterVolumeMultiplier(), 2.0f * getUnderwaterPitchMultiplier(), true); + } + + this.prevPrevPrevHoldDrift = this.prevPrevHoldDrift; + this.prevPrevHoldDrift = this.prevHoldDrift; this.prevHoldDrift = input.holdingDrift; } + private void rampTrickTick() { + boolean trickCommandEarly = wasOnGround && + !automobileOnGround && + !isFloorDirectlyBelow && + hSpeed > TRICK_MIN_VELOCITY && + ((!prevHoldDrift && input.holdingDrift) || (!prevPrevHoldDrift && prevHoldDrift) || (!prevPrevPrevHoldDrift && prevPrevHoldDrift)); + + boolean trickCommandLate = !wasOnGround && + !automobileOnGround && + !isFloorDirectlyBelow && + hSpeed > TRICK_MIN_VELOCITY && + airTime < 2 && + (!prevHoldDrift && input.holdingDrift); + + if (trickCommandEarly || trickCommandLate) { + setDrifting(false); + spawnTrickEffect(); + level().playLocalSound(getX(), getY(), getZ(), SoundEvents.EXPERIENCE_ORB_PICKUP, SoundSource.AMBIENT, 0.25f * getUnderwaterVolumeMultiplier(), 1.5f * getUnderwaterPitchMultiplier(), true); + trickBuffered = true; + } + + if ((isFloorWithinOneBlockBelow || isFloorDirectlyBelow || automobileOnGround) && trickBuffered) { + boost(0.25f, 9); + trickBuffered = false; + } + } + + private void spawnTrickEffect() { + + for (int i = 0; i < 6; i++) { + for (int j = 0; j < 6; j++) { + double xVel = Math.sin(i) * Math.cos(j) * 2; + double yVel = Math.sin(i) * Math.sin(j) * 2; + double zVel = Math.cos(i) * 2; + + level().addParticle( + ParticleTypes.CRIT, + getX(), + getY() + 0.5, + getZ(), + xVel, + yVel, + zVel); + } + } + } + private void endBurnout() { setBurningOut(false); this.updateEngineSpeed(0); @@ -1395,7 +1583,13 @@ private void burnoutTick() { if (this.addedVelocity.length() > 0.05 || Math.abs(this.angularSpeed) > 0.05) { createDriftParticles(); } + + int prevTurboCharge = turboCharge; if (hSpeed < 0.08 && turboCharge <= SMALL_TURBO_TIME) turboCharge += 1; + + if (turboCharge >= SMALL_TURBO_TIME && prevTurboCharge < SMALL_TURBO_TIME) { + level().playLocalSound(getX(), getY(), getZ(), SoundEvents.WITHER_SHOOT, SoundSource.AMBIENT, 0.08f * getUnderwaterVolumeMultiplier(), 1.5f * getUnderwaterPitchMultiplier(), true); + } } if (!input.braking) { endBurnout(); @@ -1502,7 +1696,7 @@ public float getStandStillTime() { public void playHitSound(Vec3 pos) { level().gameEvent(this, GameEvent.ENTITY_DAMAGE, pos); - level().playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.COPPER_BREAK, SoundSource.AMBIENT, 1, 0.9f + (this.level().random.nextFloat() * 0.2f)); + level().playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.COPPER_BREAK, SoundSource.AMBIENT, 1 * getUnderwaterVolumeMultiplier(), 0.9f + (this.level().random.nextFloat() * 0.2f) * getUnderwaterPitchMultiplier()); } private void dropParts(Vec3 pos) { @@ -1800,7 +1994,7 @@ public float getTrackedFrontAttachmentAnimation() { public void bounce() { suspensionBounceTimer = 3; - level().playLocalSound(this.getX(), this.getY(), this.getZ(), AutomobilitySounds.LANDING.require(), SoundSource.AMBIENT, 1, 1.5f + (0.15f * (this.level().random.nextFloat() - 0.5f)), true); + level().playLocalSound(this.getX(), this.getY(), this.getZ(), AutomobilitySounds.LANDING.require(), SoundSource.AMBIENT, 1 * getUnderwaterVolumeMultiplier(), 1.5f + (0.15f * (this.level().random.nextFloat() - 0.5f)) * getUnderwaterPitchMultiplier(), true); controllerAction(AutomobileController::groundThudRumble); } diff --git a/common/src/main/java/io/github/foundationgames/automobility/item/CreativeTabQueue.java b/common/src/main/java/io/github/foundationgames/automobility/item/CreativeTabQueue.java index 20e9ae7f..861627bb 100644 --- a/common/src/main/java/io/github/foundationgames/automobility/item/CreativeTabQueue.java +++ b/common/src/main/java/io/github/foundationgames/automobility/item/CreativeTabQueue.java @@ -4,13 +4,16 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; import java.util.ArrayList; import java.util.List; +import java.util.function.Supplier; public class CreativeTabQueue implements CreativeModeTab.DisplayItemsGenerator { public final ResourceLocation location; private final List> items = new ArrayList<>(); + private final List> itemStacks = new ArrayList<>(); public CreativeTabQueue(ResourceLocation location) { this.location = location; @@ -20,6 +23,10 @@ public void queue(Eventual item) { this.items.add(item); } + public void queueStack(Supplier itemStack) { + this.itemStacks.add(itemStack); + } + @Override public void accept(CreativeModeTab.ItemDisplayParameters params, CreativeModeTab.Output output) { items.forEach(i -> { @@ -29,5 +36,9 @@ public void accept(CreativeModeTab.ItemDisplayParameters params, CreativeModeTab output.accept(i.require()); } }); + + itemStacks.forEach(i -> { + output.accept(i.get()); + }); } } diff --git a/common/src/main/java/io/github/foundationgames/automobility/mixin/BlockBehaviorAccess.java b/common/src/main/java/io/github/foundationgames/automobility/mixin/BlockBehaviorAccess.java new file mode 100644 index 00000000..8759c299 --- /dev/null +++ b/common/src/main/java/io/github/foundationgames/automobility/mixin/BlockBehaviorAccess.java @@ -0,0 +1,14 @@ +package io.github.foundationgames.automobility.mixin; + +import net.minecraft.world.level.block.state.BlockBehaviour; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(BlockBehaviour.Properties.class) +public interface BlockBehaviorAccess { + @Accessor + boolean getSpawnTerrainParticles(); + + @Accessor + float getExplosionResistance(); +} diff --git a/common/src/main/java/io/github/foundationgames/automobility/mixin/EntityMixin.java b/common/src/main/java/io/github/foundationgames/automobility/mixin/EntityMixin.java index 0441d24d..e79fc7fa 100644 --- a/common/src/main/java/io/github/foundationgames/automobility/mixin/EntityMixin.java +++ b/common/src/main/java/io/github/foundationgames/automobility/mixin/EntityMixin.java @@ -1,15 +1,42 @@ package io.github.foundationgames.automobility.mixin; import io.github.foundationgames.automobility.entity.AutomobileEntity; +import net.minecraft.client.player.LocalPlayer; +import net.minecraft.util.Mth; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(Entity.class) public class EntityMixin { + @Shadow + private float yRot; + @Shadow + public float yRotO; + @Unique + private float automobility$lastYRot = 0f; + + // Rotation smoothing bug fix taken from https://github.com/FoundationGames/Automobility/pull/129 + @Inject(method = "setYRot", at = @At("HEAD"), cancellable = true) + public void automobility$smoothYRotOnAutomobile(float yRot, CallbackInfo ci) { + Entity self = (Entity)(Object)this; + if (self instanceof LocalPlayer player && player.isLocalPlayer() && self.getVehicle() instanceof AutomobileEntity) { + float smoothedYRot = Mth.rotLerp(1.0f, this.automobility$lastYRot, yRot); + this.automobility$lastYRot = smoothedYRot; + + ci.cancel(); + this.yRotO = this.yRot; + this.yRot = smoothedYRot; + } else { + this.automobility$lastYRot = yRot; + } + } + @Inject(method = "stopRiding", at = @At("HEAD")) private void automobility$clientFinalSyncBeforeDismountAutomobile(CallbackInfo ci) { var self = (Entity) (Object) this; diff --git a/common/src/main/java/io/github/foundationgames/automobility/sound/AutomobileSoundInstance.java b/common/src/main/java/io/github/foundationgames/automobility/sound/AutomobileSoundInstance.java index 264ef39f..802198fe 100644 --- a/common/src/main/java/io/github/foundationgames/automobility/sound/AutomobileSoundInstance.java +++ b/common/src/main/java/io/github/foundationgames/automobility/sound/AutomobileSoundInstance.java @@ -105,12 +105,12 @@ protected boolean canPlay(AutomobileEntity automobile) { @Override protected float getPitch(AutomobileEntity automobile) { - return (float) (Math.pow(4, (automobile.getEffectiveSpeed() - 0.9)) + 0.32); + return ((float) (Math.pow(4, (automobile.getEffectiveSpeed() - 0.9)) + 0.32)) * automobile.getUnderwaterPitchMultiplier(); } @Override protected float getVolume(AutomobileEntity automobile) { - return 1; + return 0.7f * automobile.getUnderwaterVolumeMultiplier(); } @Override @@ -134,13 +134,13 @@ protected boolean canPlay(AutomobileEntity automobile) { @Override protected float getPitch(AutomobileEntity automobile) { - return automobile.burningOut() ? 0.75f : - 1 + 0.056f * ((float)Math.min(automobile.getTurboCharge(), AutomobileEntity.LARGE_TURBO_TIME) / AutomobileEntity.LARGE_TURBO_TIME); + return (automobile.burningOut() ? 0.75f : 1 + 0.056f * ((float)Math.min(automobile.getTurboCharge(), AutomobileEntity.LARGE_TURBO_TIME) / AutomobileEntity.LARGE_TURBO_TIME)) * automobile.getUnderwaterPitchMultiplier(); } @Override protected float getVolume(AutomobileEntity automobile) { - return automobile.automobileOnGround() ? 1 : 0; + float volumeBoost = ((Math.clamp(automobile.getHSpeed(), 0.2f, 1.4f) - 0.2f) / 1.2f) * 3; + return (automobile.automobileOnGround() ? 0.75f + volumeBoost : 0) * automobile.getUnderwaterVolumeMultiplier(); } @Override diff --git a/common/src/main/java/io/github/foundationgames/automobility/sound/SlicedLoopingAutomobileSoundInstance.java b/common/src/main/java/io/github/foundationgames/automobility/sound/SlicedLoopingAutomobileSoundInstance.java index 95fba379..4fac9657 100644 --- a/common/src/main/java/io/github/foundationgames/automobility/sound/SlicedLoopingAutomobileSoundInstance.java +++ b/common/src/main/java/io/github/foundationgames/automobility/sound/SlicedLoopingAutomobileSoundInstance.java @@ -96,7 +96,7 @@ protected float getPitch(AutomobileEntity automobile) { @Override protected float getVolume(AutomobileEntity automobile) { - return 2; + return 2 * automobile.getUnderwaterVolumeMultiplier(); } @Override diff --git a/common/src/main/resources/assets/automobility/blockstates/allow.json b/common/src/main/resources/assets/automobility/blockstates/allow.json deleted file mode 100644 index 109a5f4c..00000000 --- a/common/src/main/resources/assets/automobility/blockstates/allow.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "variants": { - "": { - "model": "automobility:block/allow" - } - } -} \ No newline at end of file diff --git a/common/src/main/resources/assets/automobility/blockstates/dirt_off_road.json b/common/src/main/resources/assets/automobility/blockstates/dirt_off_road.json index 04154b78..3a58b686 100644 --- a/common/src/main/resources/assets/automobility/blockstates/dirt_off_road.json +++ b/common/src/main/resources/assets/automobility/blockstates/dirt_off_road.json @@ -1,13 +1,28 @@ { "variants": { - "layers=3": { - "model": "automobility:block/dirt_off_road_2" - }, "layers=1": { "model": "automobility:block/dirt_off_road_0" }, "layers=2": { "model": "automobility:block/dirt_off_road_1" + }, + "layers=3": { + "model": "automobility:block/dirt_off_road_2" + }, + "layers=4": { + "model": "automobility:block/dirt_off_road_3" + }, + "layers=5": { + "model": "automobility:block/dirt_off_road_4" + }, + "layers=6": { + "model": "automobility:block/dirt_off_road_5" + }, + "layers=7": { + "model": "automobility:block/dirt_off_road_6" + }, + "layers=8": { + "model": "automobility:block/dirt_off_road_7" } } } \ No newline at end of file diff --git a/common/src/main/resources/assets/automobility/blockstates/grass_off_road.json b/common/src/main/resources/assets/automobility/blockstates/grass_off_road.json index ff44ed4f..400f0aae 100644 --- a/common/src/main/resources/assets/automobility/blockstates/grass_off_road.json +++ b/common/src/main/resources/assets/automobility/blockstates/grass_off_road.json @@ -1,13 +1,28 @@ { "variants": { - "layers=3": { - "model": "automobility:block/grass_off_road_2" - }, "layers=1": { "model": "automobility:block/grass_off_road_0" }, "layers=2": { "model": "automobility:block/grass_off_road_1" + }, + "layers=3": { + "model": "automobility:block/grass_off_road_2" + }, + "layers=4": { + "model": "automobility:block/grass_off_road_3" + }, + "layers=5": { + "model": "automobility:block/grass_off_road_4" + }, + "layers=6": { + "model": "automobility:block/grass_off_road_5" + }, + "layers=7": { + "model": "automobility:block/grass_off_road_6" + }, + "layers=8": { + "model": "automobility:block/grass_off_road_7" } } } \ No newline at end of file diff --git a/common/src/main/resources/assets/automobility/blockstates/off_road_area.json b/common/src/main/resources/assets/automobility/blockstates/off_road_area.json new file mode 100644 index 00000000..e26261d3 --- /dev/null +++ b/common/src/main/resources/assets/automobility/blockstates/off_road_area.json @@ -0,0 +1,28 @@ +{ + "variants": { + "strength=1": { + "model": "automobility:block/off_road_area_0" + }, + "strength=2": { + "model": "automobility:block/off_road_area_1" + }, + "strength=3": { + "model": "automobility:block/off_road_area_2" + }, + "strength=4": { + "model": "automobility:block/off_road_area_3" + }, + "strength=5": { + "model": "automobility:block/off_road_area_4" + }, + "strength=6": { + "model": "automobility:block/off_road_area_5" + }, + "strength=7": { + "model": "automobility:block/off_road_area_6" + }, + "strength=8": { + "model": "automobility:block/off_road_area_7" + } + } +} \ No newline at end of file diff --git a/common/src/main/resources/assets/automobility/blockstates/sand_off_road.json b/common/src/main/resources/assets/automobility/blockstates/sand_off_road.json index 54127118..6d762162 100644 --- a/common/src/main/resources/assets/automobility/blockstates/sand_off_road.json +++ b/common/src/main/resources/assets/automobility/blockstates/sand_off_road.json @@ -1,13 +1,28 @@ { "variants": { - "layers=3": { - "model": "automobility:block/sand_off_road_2" - }, "layers=1": { "model": "automobility:block/sand_off_road_0" }, "layers=2": { "model": "automobility:block/sand_off_road_1" + }, + "layers=3": { + "model": "automobility:block/sand_off_road_2" + }, + "layers=4": { + "model": "automobility:block/sand_off_road_3" + }, + "layers=5": { + "model": "automobility:block/sand_off_road_4" + }, + "layers=6": { + "model": "automobility:block/sand_off_road_5" + }, + "layers=7": { + "model": "automobility:block/sand_off_road_6" + }, + "layers=8": { + "model": "automobility:block/sand_off_road_7" } } } \ No newline at end of file diff --git a/common/src/main/resources/assets/automobility/blockstates/snow_off_road.json b/common/src/main/resources/assets/automobility/blockstates/snow_off_road.json index 71072915..fbd052c9 100644 --- a/common/src/main/resources/assets/automobility/blockstates/snow_off_road.json +++ b/common/src/main/resources/assets/automobility/blockstates/snow_off_road.json @@ -1,13 +1,28 @@ { "variants": { - "layers=3": { - "model": "automobility:block/snow_off_road_2" - }, "layers=1": { "model": "automobility:block/snow_off_road_0" }, "layers=2": { "model": "automobility:block/snow_off_road_1" + }, + "layers=3": { + "model": "automobility:block/snow_off_road_2" + }, + "layers=4": { + "model": "automobility:block/snow_off_road_3" + }, + "layers=5": { + "model": "automobility:block/snow_off_road_4" + }, + "layers=6": { + "model": "automobility:block/snow_off_road_5" + }, + "layers=7": { + "model": "automobility:block/snow_off_road_6" + }, + "layers=8": { + "model": "automobility:block/snow_off_road_7" } } } \ No newline at end of file diff --git a/common/src/main/resources/assets/automobility/lang/en_us.json b/common/src/main/resources/assets/automobility/lang/en_us.json index 298699a2..8c3deb9a 100644 --- a/common/src/main/resources/assets/automobility/lang/en_us.json +++ b/common/src/main/resources/assets/automobility/lang/en_us.json @@ -36,6 +36,8 @@ "block.automobility.dirt_off_road": "Dirt Off Road", "block.automobility.sand_off_road": "Sand Off Road", "block.automobility.snow_off_road": "Snow Off Road", + "block.automobility.off_road_area": "Off Road Area", + "block.automobility.launch_gel": "Launch Gel", "block.automobility.dash_panel": "Dash Panel", "block.automobility.sloped_dash_panel": "Sloped Dash Panel", diff --git a/common/src/main/resources/assets/automobility/models/block/dirt_off_road_3.json b/common/src/main/resources/assets/automobility/models/block/dirt_off_road_3.json new file mode 100644 index 00000000..589d926e --- /dev/null +++ b/common/src/main/resources/assets/automobility/models/block/dirt_off_road_3.json @@ -0,0 +1,7 @@ +{ + "parent": "automobility:block/template_off_road_3", + "textures": { + "off_road": "automobility:block/dirt_off_road" + }, + "elements": [] +} \ No newline at end of file diff --git a/common/src/main/resources/assets/automobility/models/block/dirt_off_road_4.json b/common/src/main/resources/assets/automobility/models/block/dirt_off_road_4.json new file mode 100644 index 00000000..f0482a5b --- /dev/null +++ b/common/src/main/resources/assets/automobility/models/block/dirt_off_road_4.json @@ -0,0 +1,7 @@ +{ + "parent": "automobility:block/template_off_road_4", + "textures": { + "off_road": "automobility:block/dirt_off_road" + }, + "elements": [] +} \ No newline at end of file diff --git a/common/src/main/resources/assets/automobility/models/block/dirt_off_road_5.json b/common/src/main/resources/assets/automobility/models/block/dirt_off_road_5.json new file mode 100644 index 00000000..6bda6bb4 --- /dev/null +++ b/common/src/main/resources/assets/automobility/models/block/dirt_off_road_5.json @@ -0,0 +1,7 @@ +{ + "parent": "automobility:block/template_off_road_5", + "textures": { + "off_road": "automobility:block/dirt_off_road" + }, + "elements": [] +} \ No newline at end of file diff --git a/common/src/main/resources/assets/automobility/models/block/dirt_off_road_6.json b/common/src/main/resources/assets/automobility/models/block/dirt_off_road_6.json new file mode 100644 index 00000000..a0f6516c --- /dev/null +++ b/common/src/main/resources/assets/automobility/models/block/dirt_off_road_6.json @@ -0,0 +1,7 @@ +{ + "parent": "automobility:block/template_off_road_6", + "textures": { + "off_road": "automobility:block/dirt_off_road" + }, + "elements": [] +} \ No newline at end of file diff --git a/common/src/main/resources/assets/automobility/models/block/dirt_off_road_7.json b/common/src/main/resources/assets/automobility/models/block/dirt_off_road_7.json new file mode 100644 index 00000000..6394c81a --- /dev/null +++ b/common/src/main/resources/assets/automobility/models/block/dirt_off_road_7.json @@ -0,0 +1,7 @@ +{ + "parent": "automobility:block/template_off_road_7", + "textures": { + "off_road": "automobility:block/dirt_off_road" + }, + "elements": [] +} \ No newline at end of file diff --git a/common/src/main/resources/assets/automobility/models/block/grass_off_road_3.json b/common/src/main/resources/assets/automobility/models/block/grass_off_road_3.json new file mode 100644 index 00000000..64bc97aa --- /dev/null +++ b/common/src/main/resources/assets/automobility/models/block/grass_off_road_3.json @@ -0,0 +1,7 @@ +{ + "parent": "automobility:block/template_off_road_3", + "textures": { + "off_road": "automobility:block/grass_off_road" + }, + "elements": [] +} \ No newline at end of file diff --git a/common/src/main/resources/assets/automobility/models/block/grass_off_road_4.json b/common/src/main/resources/assets/automobility/models/block/grass_off_road_4.json new file mode 100644 index 00000000..a95965c1 --- /dev/null +++ b/common/src/main/resources/assets/automobility/models/block/grass_off_road_4.json @@ -0,0 +1,7 @@ +{ + "parent": "automobility:block/template_off_road_4", + "textures": { + "off_road": "automobility:block/grass_off_road" + }, + "elements": [] +} \ No newline at end of file diff --git a/common/src/main/resources/assets/automobility/models/block/grass_off_road_5.json b/common/src/main/resources/assets/automobility/models/block/grass_off_road_5.json new file mode 100644 index 00000000..5e3f1770 --- /dev/null +++ b/common/src/main/resources/assets/automobility/models/block/grass_off_road_5.json @@ -0,0 +1,7 @@ +{ + "parent": "automobility:block/template_off_road_5", + "textures": { + "off_road": "automobility:block/grass_off_road" + }, + "elements": [] +} \ No newline at end of file diff --git a/common/src/main/resources/assets/automobility/models/block/grass_off_road_6.json b/common/src/main/resources/assets/automobility/models/block/grass_off_road_6.json new file mode 100644 index 00000000..dc3948fc --- /dev/null +++ b/common/src/main/resources/assets/automobility/models/block/grass_off_road_6.json @@ -0,0 +1,7 @@ +{ + "parent": "automobility:block/template_off_road_6", + "textures": { + "off_road": "automobility:block/grass_off_road" + }, + "elements": [] +} \ No newline at end of file diff --git a/common/src/main/resources/assets/automobility/models/block/grass_off_road_7.json b/common/src/main/resources/assets/automobility/models/block/grass_off_road_7.json new file mode 100644 index 00000000..8f728b64 --- /dev/null +++ b/common/src/main/resources/assets/automobility/models/block/grass_off_road_7.json @@ -0,0 +1,7 @@ +{ + "parent": "automobility:block/template_off_road_7", + "textures": { + "off_road": "automobility:block/grass_off_road" + }, + "elements": [] +} \ No newline at end of file diff --git a/common/src/main/resources/assets/automobility/models/block/off_road_area_0.json b/common/src/main/resources/assets/automobility/models/block/off_road_area_0.json new file mode 100644 index 00000000..cc6b73fa --- /dev/null +++ b/common/src/main/resources/assets/automobility/models/block/off_road_area_0.json @@ -0,0 +1,5 @@ +{ + "textures": { + "particle": "automobility:item/off_road_area_0" + } +} \ No newline at end of file diff --git a/common/src/main/resources/assets/automobility/models/block/off_road_area_1.json b/common/src/main/resources/assets/automobility/models/block/off_road_area_1.json new file mode 100644 index 00000000..45301794 --- /dev/null +++ b/common/src/main/resources/assets/automobility/models/block/off_road_area_1.json @@ -0,0 +1,5 @@ +{ + "textures": { + "particle": "automobility:item/off_road_area_1" + } +} \ No newline at end of file diff --git a/common/src/main/resources/assets/automobility/models/block/off_road_area_2.json b/common/src/main/resources/assets/automobility/models/block/off_road_area_2.json new file mode 100644 index 00000000..0070ad35 --- /dev/null +++ b/common/src/main/resources/assets/automobility/models/block/off_road_area_2.json @@ -0,0 +1,5 @@ +{ + "textures": { + "particle": "automobility:item/off_road_area_2" + } +} \ No newline at end of file diff --git a/common/src/main/resources/assets/automobility/models/block/off_road_area_3.json b/common/src/main/resources/assets/automobility/models/block/off_road_area_3.json new file mode 100644 index 00000000..e08d92c2 --- /dev/null +++ b/common/src/main/resources/assets/automobility/models/block/off_road_area_3.json @@ -0,0 +1,5 @@ +{ + "textures": { + "particle": "automobility:item/off_road_area_3" + } +} \ No newline at end of file diff --git a/common/src/main/resources/assets/automobility/models/block/off_road_area_4.json b/common/src/main/resources/assets/automobility/models/block/off_road_area_4.json new file mode 100644 index 00000000..1f1c1918 --- /dev/null +++ b/common/src/main/resources/assets/automobility/models/block/off_road_area_4.json @@ -0,0 +1,5 @@ +{ + "textures": { + "particle": "automobility:item/off_road_area_4" + } +} \ No newline at end of file diff --git a/common/src/main/resources/assets/automobility/models/block/off_road_area_5.json b/common/src/main/resources/assets/automobility/models/block/off_road_area_5.json new file mode 100644 index 00000000..89d3ebeb --- /dev/null +++ b/common/src/main/resources/assets/automobility/models/block/off_road_area_5.json @@ -0,0 +1,5 @@ +{ + "textures": { + "particle": "automobility:item/off_road_area_5" + } +} \ No newline at end of file diff --git a/common/src/main/resources/assets/automobility/models/block/off_road_area_6.json b/common/src/main/resources/assets/automobility/models/block/off_road_area_6.json new file mode 100644 index 00000000..b32c2a8b --- /dev/null +++ b/common/src/main/resources/assets/automobility/models/block/off_road_area_6.json @@ -0,0 +1,5 @@ +{ + "textures": { + "particle": "automobility:item/off_road_area_6" + } +} \ No newline at end of file diff --git a/common/src/main/resources/assets/automobility/models/block/off_road_area_7.json b/common/src/main/resources/assets/automobility/models/block/off_road_area_7.json new file mode 100644 index 00000000..092db330 --- /dev/null +++ b/common/src/main/resources/assets/automobility/models/block/off_road_area_7.json @@ -0,0 +1,5 @@ +{ + "textures": { + "particle": "automobility:item/off_road_area_7" + } +} \ No newline at end of file diff --git a/common/src/main/resources/assets/automobility/models/block/sand_off_road_3.json b/common/src/main/resources/assets/automobility/models/block/sand_off_road_3.json new file mode 100644 index 00000000..77bd78ea --- /dev/null +++ b/common/src/main/resources/assets/automobility/models/block/sand_off_road_3.json @@ -0,0 +1,7 @@ +{ + "parent": "automobility:block/template_off_road_3", + "textures": { + "off_road": "automobility:block/sand_off_road" + }, + "elements": [] +} \ No newline at end of file diff --git a/common/src/main/resources/assets/automobility/models/block/sand_off_road_4.json b/common/src/main/resources/assets/automobility/models/block/sand_off_road_4.json new file mode 100644 index 00000000..019f9e98 --- /dev/null +++ b/common/src/main/resources/assets/automobility/models/block/sand_off_road_4.json @@ -0,0 +1,7 @@ +{ + "parent": "automobility:block/template_off_road_4", + "textures": { + "off_road": "automobility:block/sand_off_road" + }, + "elements": [] +} \ No newline at end of file diff --git a/common/src/main/resources/assets/automobility/models/block/sand_off_road_5.json b/common/src/main/resources/assets/automobility/models/block/sand_off_road_5.json new file mode 100644 index 00000000..1e01eac3 --- /dev/null +++ b/common/src/main/resources/assets/automobility/models/block/sand_off_road_5.json @@ -0,0 +1,7 @@ +{ + "parent": "automobility:block/template_off_road_5", + "textures": { + "off_road": "automobility:block/sand_off_road" + }, + "elements": [] +} \ No newline at end of file diff --git a/common/src/main/resources/assets/automobility/models/block/sand_off_road_6.json b/common/src/main/resources/assets/automobility/models/block/sand_off_road_6.json new file mode 100644 index 00000000..4816a152 --- /dev/null +++ b/common/src/main/resources/assets/automobility/models/block/sand_off_road_6.json @@ -0,0 +1,7 @@ +{ + "parent": "automobility:block/template_off_road_6", + "textures": { + "off_road": "automobility:block/sand_off_road" + }, + "elements": [] +} \ No newline at end of file diff --git a/common/src/main/resources/assets/automobility/models/block/sand_off_road_7.json b/common/src/main/resources/assets/automobility/models/block/sand_off_road_7.json new file mode 100644 index 00000000..046dd819 --- /dev/null +++ b/common/src/main/resources/assets/automobility/models/block/sand_off_road_7.json @@ -0,0 +1,7 @@ +{ + "parent": "automobility:block/template_off_road_7", + "textures": { + "off_road": "automobility:block/sand_off_road" + }, + "elements": [] +} \ No newline at end of file diff --git a/common/src/main/resources/assets/automobility/models/block/snow_off_road_3.json b/common/src/main/resources/assets/automobility/models/block/snow_off_road_3.json new file mode 100644 index 00000000..55a65da0 --- /dev/null +++ b/common/src/main/resources/assets/automobility/models/block/snow_off_road_3.json @@ -0,0 +1,7 @@ +{ + "parent": "automobility:block/template_off_road_3", + "textures": { + "off_road": "automobility:block/snow_off_road" + }, + "elements": [] +} \ No newline at end of file diff --git a/common/src/main/resources/assets/automobility/models/block/snow_off_road_4.json b/common/src/main/resources/assets/automobility/models/block/snow_off_road_4.json new file mode 100644 index 00000000..787dd24d --- /dev/null +++ b/common/src/main/resources/assets/automobility/models/block/snow_off_road_4.json @@ -0,0 +1,7 @@ +{ + "parent": "automobility:block/template_off_road_4", + "textures": { + "off_road": "automobility:block/snow_off_road" + }, + "elements": [] +} \ No newline at end of file diff --git a/common/src/main/resources/assets/automobility/models/block/snow_off_road_5.json b/common/src/main/resources/assets/automobility/models/block/snow_off_road_5.json new file mode 100644 index 00000000..6ae4d0c2 --- /dev/null +++ b/common/src/main/resources/assets/automobility/models/block/snow_off_road_5.json @@ -0,0 +1,7 @@ +{ + "parent": "automobility:block/template_off_road_5", + "textures": { + "off_road": "automobility:block/snow_off_road" + }, + "elements": [] +} \ No newline at end of file diff --git a/common/src/main/resources/assets/automobility/models/block/snow_off_road_6.json b/common/src/main/resources/assets/automobility/models/block/snow_off_road_6.json new file mode 100644 index 00000000..cfe3d67b --- /dev/null +++ b/common/src/main/resources/assets/automobility/models/block/snow_off_road_6.json @@ -0,0 +1,7 @@ +{ + "parent": "automobility:block/template_off_road_6", + "textures": { + "off_road": "automobility:block/snow_off_road" + }, + "elements": [] +} \ No newline at end of file diff --git a/common/src/main/resources/assets/automobility/models/block/snow_off_road_7.json b/common/src/main/resources/assets/automobility/models/block/snow_off_road_7.json new file mode 100644 index 00000000..3eff23ca --- /dev/null +++ b/common/src/main/resources/assets/automobility/models/block/snow_off_road_7.json @@ -0,0 +1,7 @@ +{ + "parent": "automobility:block/template_off_road_7", + "textures": { + "off_road": "automobility:block/snow_off_road" + }, + "elements": [] +} \ No newline at end of file diff --git a/common/src/main/resources/assets/automobility/models/block/template_off_road_3.json b/common/src/main/resources/assets/automobility/models/block/template_off_road_3.json new file mode 100644 index 00000000..8c55c693 --- /dev/null +++ b/common/src/main/resources/assets/automobility/models/block/template_off_road_3.json @@ -0,0 +1,20 @@ +{ + "parent": "minecraft:block/thin_block", + "textures": { + "particle": "#off_road" + }, + "elements": [ + { + "from": [0, 0, 0], + "to": [16, 8, 16], + "faces": { + "north": {"uv": [0, 8, 16, 16], "texture": "#off_road", "tintindex": 0}, + "east": {"uv": [0, 8, 16, 16], "texture": "#off_road", "tintindex": 0}, + "south": {"uv": [0, 8, 16, 16], "texture": "#off_road", "tintindex": 0}, + "west": {"uv": [0, 8, 16, 16], "texture": "#off_road", "tintindex": 0}, + "up": {"uv": [0, 0, 16, 16], "texture": "#off_road", "tintindex": 0}, + "down": {"uv": [0, 0, 16, 16], "texture": "#off_road", "tintindex": 0} + } + } + ] +} \ No newline at end of file diff --git a/common/src/main/resources/assets/automobility/models/block/template_off_road_4.json b/common/src/main/resources/assets/automobility/models/block/template_off_road_4.json new file mode 100644 index 00000000..524898c3 --- /dev/null +++ b/common/src/main/resources/assets/automobility/models/block/template_off_road_4.json @@ -0,0 +1,20 @@ +{ + "parent": "minecraft:block/thin_block", + "textures": { + "particle": "#off_road" + }, + "elements": [ + { + "from": [0, 0, 0], + "to": [16, 10, 16], + "faces": { + "north": {"uv": [0, 6, 16, 16], "texture": "#off_road", "tintindex": 0}, + "east": {"uv": [0, 6, 16, 16], "texture": "#off_road", "tintindex": 0}, + "south": {"uv": [0, 6, 16, 16], "texture": "#off_road", "tintindex": 0}, + "west": {"uv": [0, 6, 16, 16], "texture": "#off_road", "tintindex": 0}, + "up": {"uv": [0, 0, 16, 16], "texture": "#off_road", "tintindex": 0}, + "down": {"uv": [0, 0, 16, 16], "texture": "#off_road", "tintindex": 0} + } + } + ] +} \ No newline at end of file diff --git a/common/src/main/resources/assets/automobility/models/block/template_off_road_5.json b/common/src/main/resources/assets/automobility/models/block/template_off_road_5.json new file mode 100644 index 00000000..0d7023c4 --- /dev/null +++ b/common/src/main/resources/assets/automobility/models/block/template_off_road_5.json @@ -0,0 +1,20 @@ +{ + "parent": "minecraft:block/thin_block", + "textures": { + "particle": "#off_road" + }, + "elements": [ + { + "from": [0, 0, 0], + "to": [16, 12, 16], + "faces": { + "north": {"uv": [0, 4, 16, 16], "texture": "#off_road", "tintindex": 0}, + "east": {"uv": [0, 4, 16, 16], "texture": "#off_road", "tintindex": 0}, + "south": {"uv": [0, 4, 16, 16], "texture": "#off_road", "tintindex": 0}, + "west": {"uv": [0, 4, 16, 16], "texture": "#off_road", "tintindex": 0}, + "up": {"uv": [0, 0, 16, 16], "texture": "#off_road", "tintindex": 0}, + "down": {"uv": [0, 0, 16, 16], "texture": "#off_road", "tintindex": 0} + } + } + ] +} \ No newline at end of file diff --git a/common/src/main/resources/assets/automobility/models/block/template_off_road_6.json b/common/src/main/resources/assets/automobility/models/block/template_off_road_6.json new file mode 100644 index 00000000..1466fd51 --- /dev/null +++ b/common/src/main/resources/assets/automobility/models/block/template_off_road_6.json @@ -0,0 +1,20 @@ +{ + "parent": "minecraft:block/thin_block", + "textures": { + "particle": "#off_road" + }, + "elements": [ + { + "from": [0, 0, 0], + "to": [16, 14, 16], + "faces": { + "north": {"uv": [0, 2, 16, 16], "texture": "#off_road", "tintindex": 0}, + "east": {"uv": [0, 2, 16, 16], "texture": "#off_road", "tintindex": 0}, + "south": {"uv": [0, 2, 16, 16], "texture": "#off_road", "tintindex": 0}, + "west": {"uv": [0, 2, 16, 16], "texture": "#off_road", "tintindex": 0}, + "up": {"uv": [0, 0, 16, 16], "texture": "#off_road", "tintindex": 0}, + "down": {"uv": [0, 0, 16, 16], "texture": "#off_road", "tintindex": 0} + } + } + ] +} \ No newline at end of file diff --git a/common/src/main/resources/assets/automobility/models/block/template_off_road_7.json b/common/src/main/resources/assets/automobility/models/block/template_off_road_7.json new file mode 100644 index 00000000..9c9b7356 --- /dev/null +++ b/common/src/main/resources/assets/automobility/models/block/template_off_road_7.json @@ -0,0 +1,20 @@ +{ + "parent": "minecraft:block/thin_block", + "textures": { + "particle": "#off_road" + }, + "elements": [ + { + "from": [0, 0, 0], + "to": [16, 16, 16], + "faces": { + "north": {"uv": [0, 0, 16, 16], "texture": "#off_road", "tintindex": 0}, + "east": {"uv": [0, 0, 16, 16], "texture": "#off_road", "tintindex": 0}, + "south": {"uv": [0, 0, 16, 16], "texture": "#off_road", "tintindex": 0}, + "west": {"uv": [0, 0, 16, 16], "texture": "#off_road", "tintindex": 0}, + "up": {"uv": [0, 0, 16, 16], "texture": "#off_road", "tintindex": 0}, + "down": {"uv": [0, 0, 16, 16], "texture": "#off_road", "tintindex": 0} + } + } + ] +} \ No newline at end of file diff --git a/common/src/main/resources/assets/automobility/models/item/off_road_area.json b/common/src/main/resources/assets/automobility/models/item/off_road_area.json new file mode 100644 index 00000000..55951068 --- /dev/null +++ b/common/src/main/resources/assets/automobility/models/item/off_road_area.json @@ -0,0 +1,16 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "automobility:item/off_road_area" + }, + "overrides": [ + { "predicate": { "automobility:strength": 0.125 }, "model": "automobility:item/off_road_area_0" }, + { "predicate": { "automobility:strength": 0.25 }, "model": "automobility:item/off_road_area_1" }, + { "predicate": { "automobility:strength": 0.375 }, "model": "automobility:item/off_road_area_2" }, + { "predicate": { "automobility:strength": 0.5 }, "model": "automobility:item/off_road_area_3" }, + { "predicate": { "automobility:strength": 0.625 }, "model": "automobility:item/off_road_area_4" }, + { "predicate": { "automobility:strength": 0.75 }, "model": "automobility:item/off_road_area_5" }, + { "predicate": { "automobility:strength": 0.875 }, "model": "automobility:item/off_road_area_6" }, + { "predicate": { "automobility:strength": 1.0 }, "model": "automobility:item/off_road_area_7" } + ] +} diff --git a/common/src/main/resources/assets/automobility/models/item/off_road_area_0.json b/common/src/main/resources/assets/automobility/models/item/off_road_area_0.json new file mode 100644 index 00000000..71bf9cd8 --- /dev/null +++ b/common/src/main/resources/assets/automobility/models/item/off_road_area_0.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "automobility:item/off_road_area_0" + } +} \ No newline at end of file diff --git a/common/src/main/resources/assets/automobility/models/item/off_road_area_1.json b/common/src/main/resources/assets/automobility/models/item/off_road_area_1.json new file mode 100644 index 00000000..1819c72f --- /dev/null +++ b/common/src/main/resources/assets/automobility/models/item/off_road_area_1.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "automobility:item/off_road_area_1" + } +} \ No newline at end of file diff --git a/common/src/main/resources/assets/automobility/models/item/off_road_area_2.json b/common/src/main/resources/assets/automobility/models/item/off_road_area_2.json new file mode 100644 index 00000000..498129ce --- /dev/null +++ b/common/src/main/resources/assets/automobility/models/item/off_road_area_2.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "automobility:item/off_road_area_2" + } +} \ No newline at end of file diff --git a/common/src/main/resources/assets/automobility/models/item/off_road_area_3.json b/common/src/main/resources/assets/automobility/models/item/off_road_area_3.json new file mode 100644 index 00000000..9dba3c15 --- /dev/null +++ b/common/src/main/resources/assets/automobility/models/item/off_road_area_3.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "automobility:item/off_road_area_3" + } +} \ No newline at end of file diff --git a/common/src/main/resources/assets/automobility/models/item/off_road_area_4.json b/common/src/main/resources/assets/automobility/models/item/off_road_area_4.json new file mode 100644 index 00000000..94eb1553 --- /dev/null +++ b/common/src/main/resources/assets/automobility/models/item/off_road_area_4.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "automobility:item/off_road_area_4" + } +} \ No newline at end of file diff --git a/common/src/main/resources/assets/automobility/models/item/off_road_area_5.json b/common/src/main/resources/assets/automobility/models/item/off_road_area_5.json new file mode 100644 index 00000000..ac9211c9 --- /dev/null +++ b/common/src/main/resources/assets/automobility/models/item/off_road_area_5.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "automobility:item/off_road_area_5" + } +} \ No newline at end of file diff --git a/common/src/main/resources/assets/automobility/models/item/off_road_area_6.json b/common/src/main/resources/assets/automobility/models/item/off_road_area_6.json new file mode 100644 index 00000000..bb1421e4 --- /dev/null +++ b/common/src/main/resources/assets/automobility/models/item/off_road_area_6.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "automobility:item/off_road_area_6" + } +} \ No newline at end of file diff --git a/common/src/main/resources/assets/automobility/models/item/off_road_area_7.json b/common/src/main/resources/assets/automobility/models/item/off_road_area_7.json new file mode 100644 index 00000000..b8fd56d1 --- /dev/null +++ b/common/src/main/resources/assets/automobility/models/item/off_road_area_7.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "automobility:item/off_road_area_7" + } +} \ No newline at end of file diff --git a/common/src/main/resources/assets/automobility/textures/item/off_road_area.png b/common/src/main/resources/assets/automobility/textures/item/off_road_area.png new file mode 100644 index 00000000..b963ce7b Binary files /dev/null and b/common/src/main/resources/assets/automobility/textures/item/off_road_area.png differ diff --git a/common/src/main/resources/assets/automobility/textures/item/off_road_area_0.png b/common/src/main/resources/assets/automobility/textures/item/off_road_area_0.png new file mode 100644 index 00000000..6d9367fa Binary files /dev/null and b/common/src/main/resources/assets/automobility/textures/item/off_road_area_0.png differ diff --git a/common/src/main/resources/assets/automobility/textures/item/off_road_area_1.png b/common/src/main/resources/assets/automobility/textures/item/off_road_area_1.png new file mode 100644 index 00000000..f9f2edf2 Binary files /dev/null and b/common/src/main/resources/assets/automobility/textures/item/off_road_area_1.png differ diff --git a/common/src/main/resources/assets/automobility/textures/item/off_road_area_2.png b/common/src/main/resources/assets/automobility/textures/item/off_road_area_2.png new file mode 100644 index 00000000..5f1ee6fd Binary files /dev/null and b/common/src/main/resources/assets/automobility/textures/item/off_road_area_2.png differ diff --git a/common/src/main/resources/assets/automobility/textures/item/off_road_area_3.png b/common/src/main/resources/assets/automobility/textures/item/off_road_area_3.png new file mode 100644 index 00000000..a7a47f89 Binary files /dev/null and b/common/src/main/resources/assets/automobility/textures/item/off_road_area_3.png differ diff --git a/common/src/main/resources/assets/automobility/textures/item/off_road_area_4.png b/common/src/main/resources/assets/automobility/textures/item/off_road_area_4.png new file mode 100644 index 00000000..559d78e6 Binary files /dev/null and b/common/src/main/resources/assets/automobility/textures/item/off_road_area_4.png differ diff --git a/common/src/main/resources/assets/automobility/textures/item/off_road_area_5.png b/common/src/main/resources/assets/automobility/textures/item/off_road_area_5.png new file mode 100644 index 00000000..d40fb194 Binary files /dev/null and b/common/src/main/resources/assets/automobility/textures/item/off_road_area_5.png differ diff --git a/common/src/main/resources/assets/automobility/textures/item/off_road_area_6.png b/common/src/main/resources/assets/automobility/textures/item/off_road_area_6.png new file mode 100644 index 00000000..22fed4c5 Binary files /dev/null and b/common/src/main/resources/assets/automobility/textures/item/off_road_area_6.png differ diff --git a/common/src/main/resources/assets/automobility/textures/item/off_road_area_7.png b/common/src/main/resources/assets/automobility/textures/item/off_road_area_7.png new file mode 100644 index 00000000..2797f2ac Binary files /dev/null and b/common/src/main/resources/assets/automobility/textures/item/off_road_area_7.png differ diff --git a/common/src/main/resources/automobility.accesswidener b/common/src/main/resources/automobility.accesswidener index f985db3f..5a1a6b9b 100644 --- a/common/src/main/resources/automobility.accesswidener +++ b/common/src/main/resources/automobility.accesswidener @@ -5,3 +5,5 @@ accessible method net/minecraft/world/entity/Entity collectColliders (Lnet/minec accessible method net/minecraft/world/entity/Entity collectCandidateStepUpHeights (Lnet/minecraft/world/phys/AABB;Ljava/util/List;FF)[F accessible method net/minecraft/world/entity/Entity collideWithShapes (Lnet/minecraft/world/phys/Vec3;Lnet/minecraft/world/phys/AABB;Ljava/util/List;)Lnet/minecraft/world/phys/Vec3; accessible field net/minecraft/world/entity/Entity passengers Lcom/google/common/collect/ImmutableList; +accessible field net/minecraft/client/multiplayer/ClientLevel MARKER_PARTICLE_ITEMS Ljava/util/Set; +mutable field net/minecraft/client/multiplayer/ClientLevel MARKER_PARTICLE_ITEMS Ljava/util/Set; \ No newline at end of file diff --git a/common/src/main/resources/automobility.mixins.json b/common/src/main/resources/automobility.mixins.json index 1d0c50df..180e35ae 100644 --- a/common/src/main/resources/automobility.mixins.json +++ b/common/src/main/resources/automobility.mixins.json @@ -7,13 +7,14 @@ "mixins": [ "AABBMixin", "AbstractContainerMenuMixin", - "EntityMixin", + "BlockBehaviorAccess", "ItemCombinerMenuMixin", "PlayerEnderChestContainerMixin", "ServerGamePacketListenerImplMixin", "ShovelItemAccess" ], "client": [ + "EntityMixin", "EntityRenderDispatcherMixin", "EntityRenderersMixin", "KeyMappingAccess", diff --git a/fabric/build.gradle.kts b/fabric/build.gradle.kts index 256ddfb0..2694f16a 100644 --- a/fabric/build.gradle.kts +++ b/fabric/build.gradle.kts @@ -13,6 +13,8 @@ repositories { maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots") } maven { url = uri("https://jitpack.io") } maven { url = uri("https://maven.isxander.dev/releases") } + + maven { url = uri("https://maven.quiltmc.org/repository/release") } } dependencies { diff --git a/fabric/src/main/java/io/github/foundationgames/automobility/fabric/AutomobilityClientFabric.java b/fabric/src/main/java/io/github/foundationgames/automobility/fabric/AutomobilityClientFabric.java index 054ed1bd..219e5370 100644 --- a/fabric/src/main/java/io/github/foundationgames/automobility/fabric/AutomobilityClientFabric.java +++ b/fabric/src/main/java/io/github/foundationgames/automobility/fabric/AutomobilityClientFabric.java @@ -1,7 +1,9 @@ package io.github.foundationgames.automobility.fabric; +import io.github.foundationgames.automobility.Automobility; import io.github.foundationgames.automobility.AutomobilityClient; import io.github.foundationgames.automobility.block.AutomobilityBlocks; +import io.github.foundationgames.automobility.block.OffroadAreaBlock; import io.github.foundationgames.automobility.block.model.SlopeBakedModel; import io.github.foundationgames.automobility.block.model.SlopeUnbakedModel; import io.github.foundationgames.automobility.entity.AutomobileEntity; @@ -31,11 +33,16 @@ import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.inventory.MenuAccess; import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.item.ItemProperties; +import net.minecraft.core.component.DataComponents; import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; import net.minecraft.server.packs.PackType; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.component.BlockItemStateProperties; public class AutomobilityClientFabric implements ClientModInitializer { private static boolean wasRidingAutomobile = false; @@ -99,5 +106,12 @@ public > void ResourceManagerHelper.get(PackType.CLIENT_RESOURCES).registerReloadListener(FabricAutomobileModels.INSTANCE); ResourceManagerHelper.get(PackType.CLIENT_RESOURCES).registerReloadListener(FabricObjLoader.INSTANCE); + + ItemProperties.register(AutomobilityBlocks.OFF_ROAD_AREA.require().asItem(), + ResourceLocation.fromNamespaceAndPath(Automobility.MOD_ID, "strength"), (stack, level, living, id) -> { + BlockItemStateProperties blockitemstateproperties = stack.getOrDefault(DataComponents.BLOCK_STATE, BlockItemStateProperties.EMPTY); + Integer integer = blockitemstateproperties.get(OffroadAreaBlock.STRENGTH); + return integer != null ? (float)integer/OffroadAreaBlock.MAX_STRENGTH : 1; + }); } } diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 86113d98..6d80894c 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -5,7 +5,7 @@ "name": "Automobility", "description": "Vehicles and whatnot", "authors": [ - "FoundationGames" + "FoundationGames", "Toastworth" ], "contact": { "homepage": "", diff --git a/gradle.properties b/gradle.properties index 1c30bf67..a452791e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,6 +10,6 @@ fabric_api_version=0.115.1+1.21.1 jsonem_version=0.3+1.21 controlify_version=2.0.1+1.21 -mod_version = 0.5.0.h +mod_version = 0.5.1 maven_group = io.github.foundationgames archives_base_name = automobility diff --git a/neoforge/src/main/java/io/github/foundationgames/automobility/neoforge/AutomobilityClientNeoForge.java b/neoforge/src/main/java/io/github/foundationgames/automobility/neoforge/AutomobilityClientNeoForge.java index 650c5048..b91d0ec3 100644 --- a/neoforge/src/main/java/io/github/foundationgames/automobility/neoforge/AutomobilityClientNeoForge.java +++ b/neoforge/src/main/java/io/github/foundationgames/automobility/neoforge/AutomobilityClientNeoForge.java @@ -1,9 +1,11 @@ package io.github.foundationgames.automobility.neoforge; +import io.github.foundationgames.automobility.Automobility; import io.github.foundationgames.automobility.AutomobilityClient; import io.github.foundationgames.automobility.automobile.render.AutomobileModels; import io.github.foundationgames.automobility.automobile.render.obj.ObjLoader; import io.github.foundationgames.automobility.block.AutomobilityBlocks; +import io.github.foundationgames.automobility.block.OffroadAreaBlock; import io.github.foundationgames.automobility.block.model.SlopeBakedModel; import io.github.foundationgames.automobility.entity.AutomobileEntity; import io.github.foundationgames.automobility.neoforge.block.render.NeoForgeSlopeBakedModel; @@ -19,10 +21,15 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.inventory.MenuAccess; +import net.minecraft.client.renderer.item.ItemProperties; +import net.minecraft.core.component.DataComponents; import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.item.component.BlockItemStateProperties; +import net.minecraft.world.level.block.LightBlock; import net.neoforged.api.distmarker.Dist; import net.neoforged.bus.api.SubscribeEvent; import net.neoforged.fml.common.EventBusSubscriber; @@ -60,6 +67,17 @@ public static void initClient(FMLClientSetupEvent setup) { evt.setFOV(AutomobilityClient.modifyBoostFov(Minecraft.getInstance(), evt.getFOV(), (float) evt.getPartialTick()))); } + @SubscribeEvent + public static void registerItemProperties(FMLClientSetupEvent evt) { + evt.enqueueWork(() -> + ItemProperties.register(AutomobilityBlocks.OFF_ROAD_AREA.require().asItem(), + ResourceLocation.fromNamespaceAndPath(Automobility.MOD_ID, "strength"), (stack, level, living, id) -> { + BlockItemStateProperties blockitemstateproperties = stack.getOrDefault(DataComponents.BLOCK_STATE, BlockItemStateProperties.EMPTY); + Integer integer = blockitemstateproperties.get(OffroadAreaBlock.STRENGTH); + return integer != null ? (float)integer/OffroadAreaBlock.MAX_STRENGTH : 1; + })); + } + @SubscribeEvent public static void registerParticleProviders(RegisterParticleProvidersEvent evt) { evt.registerSpriteSet(AutomobilityParticles.DRIFT_SMOKE.require(), DriftSmokeParticle.Factory::new); diff --git a/neoforge/src/main/resources/META-INF/accesstransformer.cfg b/neoforge/src/main/resources/META-INF/accesstransformer.cfg index d0917316..c2f75685 100644 --- a/neoforge/src/main/resources/META-INF/accesstransformer.cfg +++ b/neoforge/src/main/resources/META-INF/accesstransformer.cfg @@ -3,3 +3,4 @@ public net.minecraft.world.entity.Entity collectColliders(Lnet/minecraft/world/e public net.minecraft.world.entity.Entity collectCandidateStepUpHeights(Lnet/minecraft/world/phys/AABB;Ljava/util/List;FF)[F public net.minecraft.world.entity.Entity collideWithShapes(Lnet/minecraft/world/phys/Vec3;Lnet/minecraft/world/phys/AABB;Ljava/util/List;)Lnet/minecraft/world/phys/Vec3; public net.minecraft.world.entity.Entity passengers +public-f net.minecraft.client.multiplayer.ClientLevel MARKER_PARTICLE_ITEMS \ No newline at end of file diff --git a/neoforge/src/main/resources/META-INF/neoforge.mods.toml b/neoforge/src/main/resources/META-INF/neoforge.mods.toml index 9f5cd011..007779b5 100644 --- a/neoforge/src/main/resources/META-INF/neoforge.mods.toml +++ b/neoforge/src/main/resources/META-INF/neoforge.mods.toml @@ -7,7 +7,7 @@ modId="automobility" version="${version}" displayName="Automobility" logoFile="automobility.png" -authors="FoundationGames" #optional +authors="FoundationGames, Toastworth" #optional description=''' Vehicles and whatnot '''