Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

basic 1.20 port #30

Open
wants to merge 7 commits into
base: 1.19
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common/src/main/java/com/lodestar/aileron/Aileron.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static void boostPlayer(Player player) {
}

public static void playerDashedServer(ServerPlayer player) {
ServerLevel serverLevel = (ServerLevel) player.level;
ServerLevel serverLevel = (ServerLevel) player.level();
int stocks = player.getEntityData().get(AileronEntityData.SMOKE_STACK_CHARGES);

if (stocks > 0) {
Expand Down
54 changes: 54 additions & 0 deletions common/src/main/java/com/lodestar/aileron/AileronGuiRender.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package com.lodestar.aileron;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.HumanoidArm;
import net.minecraft.world.item.enchantment.EnchantmentHelper;

public class AileronGuiRender {

private static final ResourceLocation TEXTURE_EMPTY = new ResourceLocation("aileron:textures/gui/sprites/hud/smokestack_empty.png");
private static final ResourceLocation TEXTURE_FULL = new ResourceLocation("aileron:textures/gui/sprites/hud/smokestack_full.png");

public static int moveAttackIndicator(int spriteX) {
LocalPlayer player = Minecraft.getInstance().player;
if (player == null) return spriteX;
if (!Aileron.canChargeSmokeStack(player)) return spriteX;

if (player.getMainArm() == HumanoidArm.LEFT) spriteX -= 9;
else spriteX += 5;

return spriteX;
}

public static void renderSmokeStackBar(GuiGraphics graphics, int screenHeight, int screenWidth) {
LocalPlayer player = Minecraft.getInstance().player;
if (player == null) return;
if (!Aileron.canChargeSmokeStack(player)) return;

int smokeStockLevel = EnchantmentHelper.getItemEnchantmentLevel(
BuiltInRegistries.ENCHANTMENT.get(new ResourceLocation(Aileron.MOD_ID, "smokestack")),
player.getInventory().getArmor(2)
);

int screenX = (screenWidth / 2);
if (player.getMainArm() == HumanoidArm.LEFT) screenX -= 102;
else screenX += 92;

int screenY = screenHeight - 10;

int smokeStackCharges = player.getEntityData().get(AileronEntityData.SMOKE_STACK_CHARGES);
for (int spriteIndex = 0; spriteIndex < smokeStockLevel; spriteIndex++) {
ResourceLocation texture;
if (smokeStackCharges > spriteIndex) texture = TEXTURE_FULL;
else texture = TEXTURE_EMPTY;
int spriteY = screenY - (spriteIndex * 9);
graphics.blit(texture, screenX, spriteY, 0, 0, 9, 9, 9, 9);
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static void localPlayerTick(Player self) {
if (stocks > 0) {
self.setDeltaMovement(self.getDeltaMovement().add(self.getLookAngle().scale(1.5)));
self.getEntityData().set(AileronEntityData.SMOKE_STACK_CHARGES, stocks - 1);
self.level.playSound(null, self.blockPosition(), SoundEvents.FIRECHARGE_USE, SoundSource.PLAYERS, 0.8f, 0.4f);
self.level().playSound(null, self.blockPosition(), SoundEvents.FIRECHARGE_USE, SoundSource.PLAYERS, 0.8f, 0.4f);
AileronClientNetworking.sendSmokeStackDash();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import com.lodestar.aileron.Aileron;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Registry;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.core.particles.SimpleParticleType;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.Level;
Expand Down Expand Up @@ -38,7 +38,7 @@ private static void makeParticles(Level level, BlockPos blockPos, boolean bl, bo

if (neighbors > 0) {
RandomSource random = level.getRandom();
SimpleParticleType particleType = (SimpleParticleType) Registry.PARTICLE_TYPE.get(new ResourceLocation(Aileron.MOD_ID, "custom_campfire_smoke"));
SimpleParticleType particleType = (SimpleParticleType) BuiltInRegistries.PARTICLE_TYPE.get(new ResourceLocation(Aileron.MOD_ID, "custom_campfire_smoke"));
level.addAlwaysVisibleParticle(particleType, true, (double) blockPos.getX() + 0.5D + random.nextDouble() / 3.0D * (double) (random.nextBoolean() ? 1 : -1), (double) blockPos.getY() + random.nextDouble() + random.nextDouble(), (double) blockPos.getZ() + 0.5D + random.nextDouble() / 3.0D * (double) (random.nextBoolean() ? 1 : -1), neighbors * 40 + (bl ? 280 : 80), 0.07D, 0.0D);
if (bl2) {
level.addParticle(ParticleTypes.SMOKE, (double) blockPos.getX() + 0.5D + random.nextDouble() / 4.0D * (double) (random.nextBoolean() ? 1 : -1), (double) blockPos.getY() + 0.4D, (double) blockPos.getZ() + 0.5D + random.nextDouble() / 4.0D * (double) (random.nextBoolean() ? 1 : -1), 0.0D, 0.005D, 0.0D);
Expand Down
69 changes: 26 additions & 43 deletions common/src/main/java/com/lodestar/aileron/mixin/GuiMixin.java
Original file line number Diff line number Diff line change
@@ -1,61 +1,44 @@
package com.lodestar.aileron.mixin;

import com.lodestar.aileron.Aileron;
import com.lodestar.aileron.AileronEntityData;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Minecraft;
import com.lodestar.aileron.AileronGuiRender;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiComponent;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.client.gui.GuiGraphics;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyArg;
import org.spongepowered.asm.mixin.injection.*;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(Gui.class)
public class GuiMixin {

private static final ResourceLocation smokeStock = new ResourceLocation("aileron:textures/gui/smokestack.png");
@Shadow private int screenWidth;
@Shadow private int screenHeight;

@ModifyArg(method = "renderExperienceBar", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/Font;draw(Lcom/mojang/blaze3d/vertex/PoseStack;Ljava/lang/String;FFI)I"), index = 3)
public float shiftUpwards(float g) {
LocalPlayer player = Minecraft.getInstance().player;
if (Aileron.canChargeSmokeStack(player)) {
return g + 4;
} else {
return g;
}
@ModifyArg(
method = "renderHotbar",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/gui/GuiGraphics;blit(Lnet/minecraft/resources/ResourceLocation;IIIIII)V"
),
slice = @Slice(
from = @At(
value = "INVOKE",
target = "Lcom/mojang/blaze3d/systems/RenderSystem;enableBlend()V"
),
to = @At(
value = "INVOKE",
target = "Lcom/mojang/blaze3d/systems/RenderSystem;disableBlend()V"
)
),
index = 1
)
private int renderAttackIndicator(int x) {
return AileronGuiRender.moveAttackIndicator(x);
}

@Inject(method = "renderExperienceBar", at = @At(value = "TAIL"))
public void renderExperienceBar(PoseStack poseStack, int i, CallbackInfo ci) {
final Gui self = (Gui) (Object) this;

LocalPlayer player = Minecraft.getInstance().player;
if (Aileron.canChargeSmokeStack(player)) {
int y = this.screenHeight - 40;
int smokeStockMaxLevel = EnchantmentHelper.getItemEnchantmentLevel(Registry.ENCHANTMENT.get(new ResourceLocation(Aileron.MOD_ID, "smokestack")), player.getInventory().getArmor(2));

RenderSystem.setShaderTexture(0, smokeStock);
int x = screenWidth / 2 - 10 + ((3 - smokeStockMaxLevel) * 3);

for (int j = 0; j < smokeStockMaxLevel; j++) {
if (player.getEntityData().get(AileronEntityData.SMOKE_STACK_CHARGES) > j) {
RenderSystem.setShaderColor(1f, 1f, 1f, 1f);
} else {
RenderSystem.setShaderColor(0f, 0f, 0f, 0.5f);
}
GuiComponent.blit(poseStack, x + (j * 6), y, self.getBlitOffset(), 0, 0, 8, 8, 8, 8);
}
}

public void renderSmokeStackBar(GuiGraphics g, int i, CallbackInfo ci) {
AileronGuiRender.renderSmokeStackBar(g, screenHeight, screenWidth);
}

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.lodestar.aileron.mixin;

import com.lodestar.aileron.Aileron;
import net.minecraft.core.Registry;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
Expand All @@ -29,7 +29,7 @@ public LivingEntityMixin(EntityType<?> entityType, Level level) {
private void modifyVelocity(LivingEntity instance, Vec3 vec3) {
Vec3 negator = new Vec3(1.0 / 0.9900000095367432D, 1.0, 1.0 / 0.9900000095367432D);

int cloudSkipper = instance instanceof Player ? EnchantmentHelper.getItemEnchantmentLevel(Registry.ENCHANTMENT.get(new ResourceLocation(Aileron.MOD_ID, "cloudskipper")), ((Player) instance).getInventory().getArmor(2)) : 0;
int cloudSkipper = instance instanceof Player ? EnchantmentHelper.getItemEnchantmentLevel(BuiltInRegistries.ENCHANTMENT.get(new ResourceLocation(Aileron.MOD_ID, "cloudskipper")), ((Player) instance).getInventory().getArmor(2)) : 0;

double fac = 0;
double y = instance.position().y;
Expand All @@ -43,8 +43,8 @@ else if (y < 230)
fac *= 0.6;
fac *= cloudSkipper / 3.0;

if (fac > 0.1 && !level.isClientSide && tickCount % ((int) (1.0 - fac) * 2 + 1) == 0) {
ServerLevel serverLevel = ((ServerLevel) level);
if (fac > 0.1 && !level().isClientSide && tickCount % ((int) (1.0 - fac) * 2 + 1) == 0) {
ServerLevel serverLevel = ((ServerLevel) level());

for (ServerPlayer player : serverLevel.players()) {
Vec3 pos = instance.position().add(instance.getLookAngle().scale(-1.0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,17 @@
public class MixinFireworkRocketItem {

@Inject(method = "use", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/projectile/FireworkRocketEntity;<init>(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/entity/LivingEntity;)V"), cancellable = true)
public void use(Level level, Player player, InteractionHand interactionHand, CallbackInfoReturnable<InteractionResultHolder<ItemStack>> cir) {
if (!AileronConfig.fireworkChanges()) {
ItemStack itemStack = player.getItemInHand(interactionHand);
public void use(Level level, Player player, InteractionHand hand, CallbackInfoReturnable<InteractionResultHolder<ItemStack>> cir) {
if (!AileronConfig.fireworkChanges()) return;

if (!player.getAbilities().instabuild) {
itemStack.shrink(1);
}
ItemStack stack = player.getItemInHand(hand);
if (!player.getAbilities().instabuild) stack.shrink(1);

((AileronPlayer) player).setSmokeTrailTicks(100);
player.getCooldowns().addCooldown((FireworkRocketItem) (Object) this, 100);
player.awardStat(Stats.ITEM_USED.get((FireworkRocketItem) (Object) this));
cir.setReturnValue(InteractionResultHolder.pass(player.getItemInHand(interactionHand)));
}
((AileronPlayer) player).setSmokeTrailTicks(100);
FireworkRocketItem item = (FireworkRocketItem) (Object) this;
player.getCooldowns().addCooldown(item, 100);
player.awardStat(Stats.ITEM_USED.get(item));
cir.setReturnValue(InteractionResultHolder.pass(stack));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.lodestar.aileron.AileronConfig;
import com.lodestar.aileron.accessor.AileronCamera;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Vector3f;
import com.mojang.math.Axis;
import net.minecraft.client.Camera;
import net.minecraft.client.Minecraft;
import net.minecraft.client.player.LocalPlayer;
Expand All @@ -30,7 +30,7 @@ public void renderLevel(float partial, long l, PoseStack poseStack, CallbackInfo
float deltaMovementSpeed = (float) player.getDeltaMovement().length();

if (AileronConfig.doCameraRoll())
poseStack.mulPose(Vector3f.ZP.rotationDegrees((float) (roll * deltaMovementSpeed * AileronConfig.cameraRollScale())));
poseStack.mulPose(Axis.ZP.rotationDegrees((float) (roll * deltaMovementSpeed * AileronConfig.cameraRollScale())));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import com.lodestar.aileron.accessor.AileronPlayer;
import com.lodestar.aileron.client.AileronClient;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Registry;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.core.particles.SimpleParticleType;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
Expand Down Expand Up @@ -45,7 +45,7 @@ public abstract class PlayerEntityMixin implements AileronPlayer {
@Inject(method = "tick", at = @At("TAIL"))
public void postTick(CallbackInfo ci) {
Player self = ((Player) (Object) this);
Level level = self.level;
Level level = self.level();

if (boostTicks > 0) boostTicks--;
if (!self.isFallFlying()) boostTicks = 0;
Expand Down Expand Up @@ -84,7 +84,7 @@ public void postTick(CallbackInfo ci) {
// smoke trail
if (smokeTrailTicks > 0) {

if (self.tickCount == 0) {
if (self.tickCount % 3 == 0) {
final ServerLevel serverLevel = ((ServerLevel) level);

for (ServerPlayer player : serverLevel.players()) {
Expand Down Expand Up @@ -115,7 +115,7 @@ public void postTick(CallbackInfo ci) {
if (chargeTime % AileronConfig.smokeStackChargeTicks() == 0 && chargeTime > 0) {
int stocks = self.getEntityData().get(AileronEntityData.SMOKE_STACK_CHARGES);

int smokeStockMaxLevel = EnchantmentHelper.getItemEnchantmentLevel(Registry.ENCHANTMENT.get(new ResourceLocation(Aileron.MOD_ID, "smokestack")), self.getInventory().getArmor(2));
int smokeStockMaxLevel = EnchantmentHelper.getItemEnchantmentLevel(BuiltInRegistries.ENCHANTMENT.get(new ResourceLocation(Aileron.MOD_ID, "smokestack")), self.getInventory().getArmor(2));

if (stocks < smokeStockMaxLevel || !charged) {
charged = true;
Expand Down Expand Up @@ -163,7 +163,7 @@ public void postTick(CallbackInfo ci) {
startFlyingTimer = 5;
}

if (self.isFallFlying() && self.level.isClientSide && self.isLocalPlayer()) {
if (self.isFallFlying() && self.level().isClientSide && self.isLocalPlayer()) {
int maxRange = 38;
int depth = 0;

Expand Down Expand Up @@ -216,7 +216,7 @@ public void postTick(CallbackInfo ci) {
}

}
if (self.level.isClientSide && self.isLocalPlayer())
if (self.level().isClientSide && self.isLocalPlayer())
AileronClient.localPlayerTick(self);
}

Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.lodestar.aileron.enchantment.CloudSkipperEnchantment;
import com.lodestar.aileron.enchantment.SmokeStackEnchantment;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.enchantment.Enchantment;

Expand All @@ -12,7 +13,7 @@ public class AileronEnchantmentsImpl {
public static Enchantment CLOUDSKIPPER = new CloudSkipperEnchantment(Enchantment.Rarity.UNCOMMON);

public static void register() {
Registry.register(Registry.ENCHANTMENT, new ResourceLocation(Aileron.MOD_ID, "smokestack"), SMOKESTACK);
Registry.register(Registry.ENCHANTMENT, new ResourceLocation(Aileron.MOD_ID, "cloudskipper"), CLOUDSKIPPER);
Registry.register(BuiltInRegistries.ENCHANTMENT, new ResourceLocation(Aileron.MOD_ID, "smokestack"), SMOKESTACK);
Registry.register(BuiltInRegistries.ENCHANTMENT, new ResourceLocation(Aileron.MOD_ID, "cloudskipper"), CLOUDSKIPPER);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
import net.fabricmc.fabric.api.particle.v1.FabricParticleTypes;
import net.minecraft.core.Registry;
import net.minecraft.core.particles.SimpleParticleType;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;

public class AileronParticlesImpl {
public static final SimpleParticleType CUSTOM_CAMPFIRE_SMOKE = FabricParticleTypes.simple();

public static void register() {
Registry.register(Registry.PARTICLE_TYPE, new ResourceLocation(Aileron.MOD_ID, "custom_campfire_smoke"), CUSTOM_CAMPFIRE_SMOKE);
Registry.register(BuiltInRegistries.PARTICLE_TYPE, new ResourceLocation(Aileron.MOD_ID, "custom_campfire_smoke"), CUSTOM_CAMPFIRE_SMOKE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
public class AileronClientParticlesImpl {
@SubscribeEvent
public static void registerParticleFactories(RegisterParticleProvidersEvent event) {
event.register(CUSTOM_CAMPFIRE_SMOKE.get(), CustomCampfireParticle.CustomCampfireParticleProvider::new);
event.registerSpriteSet(CUSTOM_CAMPFIRE_SMOKE.get(), CustomCampfireParticle.CustomCampfireParticleProvider::new);
}

public static void register() {
Expand Down
16 changes: 8 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx2G
# Fabric Properties
minecraft_version=1.19.2
yarn_mappings=1.19.2+build.28
fabric_loader_version=0.14.19
forge_version=1.19.2-43.2.0
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.10
fabric_loader_version=0.14.22
forge_version=1.20.1-47.1.0
enabled_platforms=fabric,forge
# Dependencies
architectury_version=6.5.82
midnightlib_version=1.0.0
fabric_api_version=0.76.0+1.19.2
mod_menu_version=4.2.0-beta.2
architectury_version=9.1.12
midnightlib_version=1.4.1
fabric_api_version=0.87.0+1.20.1
mod_menu_version=7.2.2
# Mod Properties
mod_version=1.0.4
maven_group=com.lodestar
Expand Down