Skip to content

Commit 0964481

Browse files
authored
Merge pull request #6 from Magic-team-jvav/neoforge-dev/1.21.1
Neoforge dev/1.21.1
2 parents 8ffa61a + 79f1ff1 commit 0964481

57 files changed

Lines changed: 1830 additions & 294 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

build.gradle

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,6 @@ sourceSets.main.resources { srcDir 'src/generated/resources' }
9999

100100

101101
dependencies {
102-
compileOnly 'org.projectlombok:lombok:1.18.38'
103-
annotationProcessor 'org.projectlombok:lombok:1.18.38'
104102
// Example mod dependency with JEI
105103
// The JEI API is declared for compile time use, while the full JEI artifact is used at runtime
106104
// compileOnly "mezz.jei:jei-${mc_version}-common-api:${jei_version}"

gradle.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ mod_name=Confluence Magic Lib
2929
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
3030
mod_license=MIT
3131
# The mod version. See https://semver.org/
32-
mod_version=0.0.2-SNAPSHOT
32+
###### remove '-SNAPSHOT' when merge to main branch ######
33+
mod_version=0.0.2d-SNAPSHOT
3334
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
3435
# This should match the base package used for the mod sources.
3536
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html

src/main/java/org/confluence/lib/ConfluenceMagicLib.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.confluence.lib.common.recipe.AmountIngredient;
2525
import org.confluence.lib.common.worldgen.structure.GridPiece;
2626
import org.confluence.lib.common.worldgen.structure.SimpleTemplatePiece;
27+
import org.jetbrains.annotations.ApiStatus;
2728
import org.jetbrains.annotations.NotNull;
2829
import org.slf4j.Logger;
2930
import org.slf4j.LoggerFactory;
@@ -35,21 +36,21 @@ public class ConfluenceMagicLib {
3536
public static final String LIB_ID = "confluence_magic_lib";
3637
public static final String CONFLUENCE_ID = "confluence";
3738
public static final Logger LOGGER = LoggerFactory.getLogger("Confluence Magic Lib");
38-
public static final com.google.common.base.Supplier<Boolean> IS_CONFLUENCE_LOADED = Suppliers.memoize(() -> ModList.get().isLoaded(CONFLUENCE_ID));
39+
public static final Supplier<Boolean> IS_CONFLUENCE_LOADED = Suppliers.memoize(() -> ModList.get().isLoaded(CONFLUENCE_ID));
3940

40-
public static final DeferredRegister<IngredientType<?>> INGREDIENT_TYPES = DeferredRegister.create(NeoForgeRegistries.Keys.INGREDIENT_TYPES, LIB_ID);
41+
private static final DeferredRegister<IngredientType<?>> INGREDIENT_TYPES = DeferredRegister.create(NeoForgeRegistries.Keys.INGREDIENT_TYPES, LIB_ID);
4142
public static final Supplier<IngredientType<AmountIngredient>> AMOUNT_INGREDIENT_TYPE = INGREDIENT_TYPES.register("amount_ingredient", () -> new IngredientType<>(AmountIngredient.CODEC, AmountIngredient.STREAM_CODEC));
4243

43-
public static final DeferredRegister<StructurePieceType> PIECE_TYPES = DeferredRegister.create(BuiltInRegistries.STRUCTURE_PIECE, LIB_ID);
44+
private static final DeferredRegister<StructurePieceType> PIECE_TYPES = DeferredRegister.create(BuiltInRegistries.STRUCTURE_PIECE, LIB_ID);
4445
public static final Supplier<StructurePieceType.StructureTemplateType> SIMPLE_TEMPLATE_PIECE = PIECE_TYPES.register("simple_template_piece", () -> SimpleTemplatePiece::new);
4546
public static final Supplier<StructurePieceType.ContextlessType> GRID_PIECE = PIECE_TYPES.register("grid_piece", () -> GridPiece::new);
4647

47-
public static final DeferredRegister.DataComponents DATA_COMPONENT_TYPES = DeferredRegister.createDataComponents(Registries.DATA_COMPONENT_TYPE, LIB_ID);
48+
private static final DeferredRegister.DataComponents DATA_COMPONENT_TYPES = DeferredRegister.createDataComponents(Registries.DATA_COMPONENT_TYPE, LIB_ID);
4849
public static final Supplier<DataComponentType<ModRarity>> MOD_RARITY = DATA_COMPONENT_TYPES.registerComponentType("mod_rarity", builder -> builder.persistent(ModRarity.CODEC).networkSynchronized(ModRarity.STREAM_CODEC));
4950
public static final Supplier<DataComponentType<ToolMode>> TOOL_MODE = DATA_COMPONENT_TYPES.registerComponentType("tool_mode", builder -> builder.persistent(ToolMode.CODEC).networkSynchronized(ToolMode.STREAM_CODEC));
5051
public static final Supplier<DataComponentType<NbtComponent>> NBT = DATA_COMPONENT_TYPES.registerComponentType("nbt", builder -> builder.persistent(NbtComponent.CODEC).networkSynchronized(NbtComponent.STREAM_CODEC));
5152

52-
public static final DeferredRegister<ParticleType<?>> PARTICLES = DeferredRegister.create(BuiltInRegistries.PARTICLE_TYPE, LIB_ID);
53+
private static final DeferredRegister<ParticleType<?>> PARTICLES = DeferredRegister.create(BuiltInRegistries.PARTICLE_TYPE, LIB_ID);
5354
public static final Supplier<ParticleType<CrossDustParticleOptions>> CROSS_DUST_PARTICLE = PARTICLES.register("cross_dust", () -> new ParticleType<>(false) {
5455
@Override
5556
@NotNull
@@ -74,4 +75,10 @@ public ConfluenceMagicLib(IEventBus modEventBus, ModContainer modContainer) {
7475
public static ResourceLocation asResource(String path) {
7576
return ResourceLocation.fromNamespaceAndPath(LIB_ID, path);
7677
}
78+
79+
@Deprecated(since = "1.2.0", forRemoval = true)
80+
@ApiStatus.ScheduledForRemoval(inVersion = "1.3.0")
81+
public static boolean isConfluenceLoaded() {
82+
return IS_CONFLUENCE_LOADED.get();
83+
}
7784
}
Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,33 @@
11
package org.confluence.lib.client;
22

33
import com.mojang.blaze3d.vertex.PoseStack;
4+
import org.confluence.lib.mixed.IPoseStack;
45

5-
public class AntiPushPoseStack extends PoseStack {
6+
public class AntiPushPoseStack extends PoseStack implements IPoseStack {
67
@Override
7-
public void popPose(){
8+
public void popPose() {
89
popPose(false);
910
}
1011

1112
@Override
12-
public void pushPose(){
13+
public void pushPose() {
1314
pushPose(false);
1415
}
1516

16-
public void popPose(boolean real){
17-
if(real){
17+
public void popPose(boolean real) {
18+
if (real) {
1819
super.popPose();
1920
}
2021
}
21-
public void pushPose(boolean real){
22-
if(real){
22+
23+
public void pushPose(boolean real) {
24+
if (real) {
2325
super.pushPose();
2426
}
2527
}
28+
29+
@Override
30+
public boolean confluence$isAntiPush() {
31+
return true;
32+
}
2633
}

src/main/java/org/confluence/lib/client/event/LibGameEvents.java

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,49 @@
33
import com.mojang.datafixers.util.Either;
44
import net.minecraft.ChatFormatting;
55
import net.minecraft.network.chat.Component;
6+
import net.minecraft.network.chat.FormattedText;
7+
import net.minecraft.world.inventory.tooltip.TooltipComponent;
8+
import net.minecraft.world.item.ItemStack;
69
import net.neoforged.api.distmarker.Dist;
10+
import net.neoforged.bus.api.EventPriority;
711
import net.neoforged.bus.api.SubscribeEvent;
812
import net.neoforged.fml.common.EventBusSubscriber;
13+
import net.neoforged.neoforge.client.event.ClientTickEvent;
914
import net.neoforged.neoforge.client.event.RenderTooltipEvent;
1015
import org.confluence.lib.ConfluenceMagicLib;
16+
import org.confluence.lib.client.animate.ExpertColorAnimation;
17+
import org.confluence.lib.client.animate.MasterColorAnimation;
1118
import org.confluence.lib.common.LibTags;
19+
import org.confluence.lib.common.component.ModRarity;
20+
21+
import java.util.List;
22+
import java.util.Optional;
1223

1324
@EventBusSubscriber(modid = ConfluenceMagicLib.LIB_ID, bus = EventBusSubscriber.Bus.GAME, value = Dist.CLIENT)
1425
public final class LibGameEvents {
1526
@SubscribeEvent
27+
public static void clientTick$Post(ClientTickEvent.Pre event) {
28+
ExpertColorAnimation.INSTANCE.updateColor();
29+
MasterColorAnimation.INSTANCE.updateColor();
30+
}
31+
32+
@SubscribeEvent(priority = EventPriority.HIGHEST)
1633
public static void renderTooltip$GatherComponents(RenderTooltipEvent.GatherComponents event) {
17-
if (event.getItemStack().isEmpty() || !event.getItemStack().is(LibTags.Items.WIP)) return;
18-
event.getTooltipElements().add(1, Either.left(Component.translatable("tooltip.confluence.work_in_progress").withStyle(ChatFormatting.RED)));
34+
ItemStack itemStack = event.getItemStack();
35+
if (itemStack.isEmpty()) return;
36+
37+
List<Either<FormattedText, TooltipComponent>> tooltipElements = event.getTooltipElements();
38+
if (tooltipElements.isEmpty()) return;
39+
Optional<FormattedText> displayName = tooltipElements.getFirst().left();
40+
if (displayName.isPresent() && displayName.get() instanceof Component component) {
41+
ModRarity rarity = ModRarity.getRarity(itemStack);
42+
if (rarity != null) {
43+
tooltipElements.set(0, Either.left(component.copy().withColor(rarity.color())));
44+
}
45+
}
46+
47+
if (itemStack.is(LibTags.Items.WIP)) {
48+
event.getTooltipElements().add(1, Either.left(Component.translatable("tooltip.confluence.work_in_progress").withStyle(ChatFormatting.RED)));
49+
}
1950
}
2051
}

src/main/java/org/confluence/lib/client/particle/CrossDustParticle.java

Lines changed: 42 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ public CrossDustParticle(ClientLevel level, double x, double y, double z, CrossD
2626
super(level, x, y, z);
2727
this.sprites = sprites;
2828
this.options = options;
29-
this.lifetime = options.getLifetime();
30-
this.gravity = options.isNoGravity() ? 0 : 0.7f;
31-
this.hasPhysics = !options.isNoPhysics();
32-
this.quadSize = 0.1f;
33-
setScale(options.isPulse() ? 0 : options.getScale());
34-
quadSizeOld = quadSize;
35-
xd = options.getVelocity().x;
36-
yd = options.getVelocity().y;
37-
zd = options.getVelocity().z;
38-
age = 1;
29+
this.lifetime = options.lifetime;
30+
this.gravity = options.noGravity ? 0 : 0.7F;
31+
this.hasPhysics = !options.noPhysics;
32+
this.quadSize = 0.1F;
33+
setScale(options.pulse ? 0 : options.scale);
34+
this.quadSizeOld = quadSize;
35+
this.xd = options.velocity.x;
36+
this.yd = options.velocity.y;
37+
this.zd = options.velocity.z;
38+
this.age = 1;
3939
}
4040

4141
@Override
@@ -50,37 +50,38 @@ public void render(VertexConsumer buffer, Camera renderInfo, float partialTicks)
5050
public void tick() {
5151
float lastProgress = ((float) age - 1) / lifetime;
5252
float progress = (float) age / lifetime;
53-
if (options.isNoGravity()) {
54-
accelOld = accel;
55-
accel = LibUtils.cubicBezier(progress, options.getSpeedCurve().x, options.getSpeedCurve().y, options.getSpeedCurve().z, options.getSpeedCurve().w);
53+
if (options.noGravity) {
54+
this.accelOld = accel;
55+
this.accel = LibUtils.cubicBezier(progress, options.speedCurve.x, options.speedCurve.y, options.speedCurve.z, options.speedCurve.w);
5656
float k = (accel - accelOld) / (progress - lastProgress);
57-
xd = options.getVelocity().x * k;
58-
yd = options.getVelocity().y * k;
59-
zd = options.getVelocity().z * k;
57+
this.xd = options.velocity.x * k;
58+
this.yd = options.velocity.y * k;
59+
this.zd = options.velocity.z * k;
6060
}
61-
oRoll = roll;
62-
rollDeltaOld = rollDelta;
63-
rollDelta = LibUtils.cubicBezier(progress, options.getRollCurve().x, options.getRollCurve().y, options.getRollCurve().z, options.getRollCurve().w);
61+
this.oRoll = roll;
62+
this.rollDeltaOld = rollDelta;
63+
this.rollDelta = LibUtils.cubicBezier(progress, options.rollCurve.x, options.rollCurve.y, options.rollCurve.z, options.rollCurve.w);
6464
float k = (rollDelta - rollDeltaOld) / (progress - lastProgress);
65-
roll += options.getRoll() * k * Mth.DEG_TO_RAD;
65+
this.roll += options.roll * k * Mth.DEG_TO_RAD;
6666

67-
quadSizeOld = quadSize;
68-
if (options.isPulse()) {
67+
this.quadSizeOld = quadSize;
68+
if (options.pulse) {
6969
if (progress < 0.5f) {
70-
setScale(options.getScale() * progress * 2);
71-
}else{
72-
setScale(options.getScale() * (1 - progress) * 2);
70+
setScale(options.scale * progress * 2);
71+
} else {
72+
setScale(options.scale * (1 - progress) * 2);
7373
}
74-
}else{
75-
setScale(options.getScale() * (1 - progress));
74+
} else {
75+
setScale(options.scale * (1 - progress));
7676
}
7777

7878
super.tick();
7979
}
8080

8181
public void setScale(float scale) {
82-
quadSize = scale * 0.1f;
83-
setSize(scale * 0.2f, scale * 0.2f);
82+
this.quadSize = scale * 0.1F;
83+
scale = quadSize + quadSize;
84+
setSize(scale, scale);
8485
}
8586

8687
@Override
@@ -89,33 +90,25 @@ public float getQuadSize(float partialTicks) {
8990
}
9091

9192
protected void useCenterSprite() {
92-
setSprite(sprites.get(options.isLarge() ? 3 : 1, 4));
93-
float a = (options.getCenterColor() >>> 24 & 0xff) / 255f;
94-
float r = (options.getCenterColor() >>> 16 & 0xff) / 255f;
95-
float g = (options.getCenterColor() >>> 8 & 0xff) / 255f;
96-
float b = (options.getCenterColor() & 0xff) / 255f;
97-
this.alpha = a;
98-
this.rCol = r;
99-
this.gCol = g;
100-
this.bCol = b;
93+
setSprite(sprites.get(options.large ? 3 : 1, 4));
94+
this.alpha = (options.centerColor >>> 24 & 0xFF) / 255F;
95+
this.rCol = (options.centerColor >>> 16 & 0xFF) / 255F;
96+
this.gCol = (options.centerColor >>> 8 & 0xFF) / 255F;
97+
this.bCol = (options.centerColor & 0xFF) / 255F;
10198
}
10299

103100
protected void useEdgeSprite() {
104-
setSprite(sprites.get(options.isLarge() ? 4 : 2, 4));
105-
float a = (options.getEdgeColor() >>> 24 & 0xff) / 255f;
106-
float r = (options.getEdgeColor() >>> 16 & 0xff) / 255f;
107-
float g = (options.getEdgeColor() >>> 8 & 0xff) / 255f;
108-
float b = (options.getEdgeColor() & 0xff) / 255f;
109-
this.alpha = a;
110-
this.rCol = r;
111-
this.gCol = g;
112-
this.bCol = b;
101+
setSprite(sprites.get(options.large ? 4 : 2, 4));
102+
this.alpha = (options.edgeColor >>> 24 & 0xFF) / 255F;
103+
this.rCol = (options.edgeColor >>> 16 & 0xFF) / 255F;
104+
this.gCol = (options.edgeColor >>> 8 & 0xFF) / 255F;
105+
this.bCol = (options.edgeColor & 0xFF) / 255F;
113106
}
114107

115108
@Override
116109
protected int getLightColor(float partialTick) {
117-
if (options.isFullBrightness()) {
118-
return 15 << 20 | 15 << 4;
110+
if (options.fullBrightness) {
111+
return 0xF000F0;
119112
}
120113
return super.getLightColor(partialTick);
121114
}

src/main/java/org/confluence/lib/color/FloatRGB.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
public record FloatRGB(float red, float green, float blue) {
99
public static final FloatRGB ZERO = new FloatRGB(0.0F, 0.0F, 0.0F);
10-
public static final FloatRGB DEMON_A = new FloatRGB(0.5F, 0.3F, 1.0F);
11-
public static final FloatRGB DEMON_B = new FloatRGB(1.0F, 0.3F, 0.0F);
1210

1311
public static FloatRGB fromVector(Vector3f vector3f) {
1412
return new FloatRGB(vector3f.x, vector3f.y, vector3f.z);

src/main/java/org/confluence/lib/color/GlobalColors.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package org.confluence.lib.color;
22

3-
public class GlobalColors {
3+
public final class GlobalColors {
44
public static final IntegerRGB NPC_ARRIVED = IntegerRGB.of(0x327dff);
55
public static final IntegerRGB NPC_SLAIN = IntegerRGB.of(0xff1919);
66
public static final IntegerRGB MESSAGE = IntegerRGB.of(0x32ff82);

src/main/java/org/confluence/lib/common/block/HorizontalDirectionalWaterloggedBlock.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.confluence.lib.common.block;
22

3+
import com.mojang.serialization.MapCodec;
34
import net.minecraft.core.BlockPos;
45
import net.minecraft.core.Direction;
56
import net.minecraft.world.item.context.BlockPlaceContext;
@@ -14,14 +15,20 @@
1415
import net.minecraft.world.level.material.FluidState;
1516
import net.minecraft.world.level.material.Fluids;
1617

17-
public abstract class HorizontalDirectionalWaterloggedBlock extends HorizontalDirectionalBlock implements SimpleWaterloggedBlock {
18+
public class HorizontalDirectionalWaterloggedBlock extends HorizontalDirectionalBlock implements SimpleWaterloggedBlock {
19+
public static final MapCodec<HorizontalDirectionalWaterloggedBlock> CODEC = simpleCodec(HorizontalDirectionalWaterloggedBlock::new);
1820
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
1921

2022
public HorizontalDirectionalWaterloggedBlock(Properties properties) {
2123
super(properties);
2224
registerDefaultState(stateDefinition.any().setValue(FACING, Direction.NORTH).setValue(WATERLOGGED, false));
2325
}
2426

27+
@Override
28+
protected MapCodec<? extends HorizontalDirectionalWaterloggedBlock> codec() {
29+
return CODEC;
30+
}
31+
2532
@Override
2633
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
2734
builder.add(FACING, WATERLOGGED);

src/main/java/org/confluence/lib/common/block/HorizontalDirectionalWithForwardTwoPartBlock.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.confluence.lib.common.block;
22

3+
import com.mojang.serialization.MapCodec;
34
import net.minecraft.core.BlockPos;
45
import net.minecraft.core.Direction;
56
import net.minecraft.world.entity.LivingEntity;
@@ -14,14 +15,20 @@
1415
import net.minecraft.world.level.material.PushReaction;
1516
import org.jetbrains.annotations.Nullable;
1617

17-
public abstract class HorizontalDirectionalWithForwardTwoPartBlock extends HorizontalDirectionalBlock {
18+
public class HorizontalDirectionalWithForwardTwoPartBlock extends HorizontalDirectionalBlock {
19+
public static final MapCodec<HorizontalDirectionalWithForwardTwoPartBlock> CODEC = simpleCodec(HorizontalDirectionalWithForwardTwoPartBlock::new);
1820
public static final EnumProperty<StateProperties.ForwardTwoPart> PART = StateProperties.FORWARD_TWO_PART;
1921

2022
public HorizontalDirectionalWithForwardTwoPartBlock(Properties properties) {
2123
super(properties);
2224
registerDefaultState(stateDefinition.any().setValue(PART, StateProperties.ForwardTwoPart.BASE).setValue(FACING, Direction.NORTH));
2325
}
2426

27+
@Override
28+
protected MapCodec<? extends HorizontalDirectionalWithForwardTwoPartBlock> codec() {
29+
return CODEC;
30+
}
31+
2532
@Override
2633
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
2734
builder.add(StateProperties.FORWARD_TWO_PART, FACING);

0 commit comments

Comments
 (0)