Skip to content

Commit 614dcdf

Browse files
committed
gravitite items fall upwards with tag, cleanup
1 parent dcf595b commit 614dcdf

File tree

11 files changed

+101
-30
lines changed

11 files changed

+101
-30
lines changed

src/main/java/teamport/aether/AetherClient.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,10 @@ public void afterClientStart() {
105105
skyroot = add(new Colorizer("skyroot"));
106106
oakGolden = add(new Colorizer("oakGolden"));
107107

108-
WorldTypeFXDispatcher.getInstance().addDispatch(new WorldTypeFXAether(AetherWorldTypes.AETHER_EXTENDED)
109-
.setHasGround(false));
110-
WorldTypeFXDispatcher.getInstance().addDispatch(new WorldTypeFXAether(AetherWorldTypes.AETHER_DEFAULT)
111-
.setHasGround(false));
112-
WorldTypeFXDispatcher.getInstance().addDispatch(new WorldTypeFXAether(AetherWorldTypes.AETHER_SKYBLOCK)
113-
.setHasGround(false));
114-
WorldTypeFXDispatcher.getInstance().addDispatch(new WorldTypeFXAether(AetherWorldTypes.AETHER_RETRO)
115-
.setHasGround(false));
108+
WorldTypeFXDispatcher.getInstance().addDispatch(new WorldTypeFXAether(AetherWorldTypes.AETHER_EXTENDED));
109+
WorldTypeFXDispatcher.getInstance().addDispatch(new WorldTypeFXAether(AetherWorldTypes.AETHER_DEFAULT));
110+
WorldTypeFXDispatcher.getInstance().addDispatch(new WorldTypeFXAether(AetherWorldTypes.AETHER_SKYBLOCK));
111+
WorldTypeFXDispatcher.getInstance().addDispatch(new WorldTypeFXAether(AetherWorldTypes.AETHER_RETRO));
116112
}
117113

118114
public void setupCustomBlockLight() {

src/main/java/teamport/aether/AetherMod.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import teamport.aether.effect.AetherEffects;
2323
import teamport.aether.entity.AetherEntities;
2424
import teamport.aether.entity.monster.mimic.MimicRegistry;
25+
import teamport.aether.item.AetherItemTags;
2526
import teamport.aether.item.AetherItems;
2627
import teamport.aether.item.accessory.ItemTrinket;
2728
import teamport.aether.lookup.LookupFuelEnchanter;
@@ -142,6 +143,8 @@ public static void registerNewTagForItems() {
142143
ItemTrinket.setIcon(Items.MAP, "aether:item/trinket/armor_map_outline");
143144
ItemTrinket.setIcon(AetherItems.TOOL_DUNGEON_COMPASS, "aether:item/trinket/armor_compass_outline");
144145

146+
AetherBlocks.ORE_GRAVITITE_HOLYSTONE.asItem().withTags(AetherItemTags.FALLS_UPWARDS);
147+
145148
Blocks.WORKBENCH.withTags(AetherBlockTags.MINEABLE_BY_AETHER_AXE);
146149
Blocks.LADDER_OAK.withTags(AetherBlockTags.MINEABLE_BY_AETHER_AXE);
147150

src/main/java/teamport/aether/entity/monster/fireminion/MobFireMinion.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@
99
import org.jspecify.annotations.NonNull;
1010
import org.jspecify.annotations.Nullable;
1111
import teamport.aether.entity.AetherDeathMessage;
12-
import teamport.aether.entity.AetherMobOtherImmunities;
1312
import teamport.aether.entity.MobUtil;
1413
import teamport.aether.entity.monster.MobMonsterAether;
1514
import teamport.aether.helper.ParticleMaker;
1615

1716
import static teamport.aether.entity.DamageInstance.inst;
1817

19-
public class MobFireMinion extends MobMonsterAether implements Enemy, AetherDeathMessage, AetherMobOtherImmunities {
18+
public class MobFireMinion extends MobMonsterAether implements Enemy, AetherDeathMessage {
2019

2120
public MobFireMinion(@Nullable World world) {
2221
super(world);
@@ -128,9 +127,4 @@ public boolean canSpawnHere() {
128127
&& this.world.checkIfAABBIsClear(this.bb)
129128
&& this.world.getCubes(this, this.bb).isEmpty();
130129
}
131-
132-
@Override
133-
public boolean canTakeDamageFromCactus() {
134-
return true;
135-
}
136130
}

src/main/java/teamport/aether/item/AetherItemTags.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ private AetherItemTags(){}
2222
public static final Tag<Item> IMMUNE_TO_BLAST_DAMAGE = Tag.of("immune_to_blast_damage");
2323
private static final Map<DamageType, Tag<Item>> DAMAGE_IMMUNITIES = new HashMap<>();
2424

25+
public static final Tag<Item> FALLS_UPWARDS = Tag.of("falls_upwards");
26+
2527
static {
2628
DAMAGE_IMMUNITIES.put(DamageType.FIRE, AetherItemTags.IMMUNE_TO_FIRE_DAMAGE);
2729
DAMAGE_IMMUNITIES.put(DamageType.BLAST, AetherItemTags.IMMUNE_TO_BLAST_DAMAGE);

src/main/java/teamport/aether/item/AetherItems.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ public static void registerOther() {
312312
.build(new Item("zanite", itemKey("zanite"), itemID("ZANITE")));
313313

314314
ORE_RAW_GRAVITITE = new ItemBuilder(MOD_ID)
315+
.setTags(AetherItemTags.FALLS_UPWARDS)
315316
.build(new Item("ore.raw.gravitite", itemKey("ore_raw_gravitite"), itemID("ORE_RAW_GRAVITITE")));
316317

317318

src/main/java/teamport/aether/mixin/dimension/ParachuteMixin.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,23 @@ public abstract class ParachuteMixin extends Mob {
3030
@Shadow
3131
public Gamemode gamemode;
3232

33-
public ParachuteMixin(@Nullable World world) {
33+
protected ParachuteMixin(@Nullable World world) {
3434
super(world);
3535
}
3636

3737
@WrapMethod(method = "tick")
3838
public void grantChute(Operation<Void> original) {
3939

40-
if (
41-
this.world != null
40+
if (this.world != null
4241
&& this.world.dimension.id == AetherDimension.getAether().id
4342
&& !EnvironmentHelper.isClientWorld()
44-
) {
45-
if (AetherDimension.canGetParachute(uuid)) {
46-
if (!this.gamemode.isPlayerInvulnerable()) {
47-
EntityItem chute = new EntityItem(world, x, y, z, new ItemStack(AetherItems.PARACHUTE_CLOUD, 1));
48-
world.entityJoinedWorld(chute);
49-
}
50-
51-
AetherDimension.setParachuteReceived(uuid);
43+
&& AetherDimension.canGetParachute(uuid)) {
44+
if (!this.gamemode.isPlayerInvulnerable()) {
45+
EntityItem chute = new EntityItem(world, x, y, z, new ItemStack(AetherItems.PARACHUTE_CLOUD, 1));
46+
world.entityJoinedWorld(chute);
5247
}
48+
49+
AetherDimension.setParachuteReceived(uuid);
5350
}
5451

5552
original.call();
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package teamport.aether.mixin.entity;
2+
3+
import net.minecraft.core.block.Blocks;
4+
import net.minecraft.core.entity.Entity;
5+
import net.minecraft.core.entity.EntityItem;
6+
import net.minecraft.core.item.ItemStack;
7+
import net.minecraft.core.util.helper.MathHelper;
8+
import net.minecraft.core.world.World;
9+
import org.jspecify.annotations.Nullable;
10+
import org.spongepowered.asm.mixin.Mixin;
11+
import org.spongepowered.asm.mixin.Shadow;
12+
import org.spongepowered.asm.mixin.injection.At;
13+
import org.spongepowered.asm.mixin.injection.Inject;
14+
import org.spongepowered.asm.mixin.injection.ModifyVariable;
15+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
16+
import teamport.aether.item.AetherItemTags;
17+
18+
@Mixin(value = EntityItem.class, remap = false)
19+
public abstract class EntityItemFallUpwardsMixin extends Entity {
20+
@Shadow
21+
public ItemStack item;
22+
23+
protected EntityItemFallUpwardsMixin(@Nullable World world) {
24+
super(world);
25+
}
26+
27+
@Inject(method = "tick", at = @At("TAIL"))
28+
private void makeGravititeFloat(CallbackInfo ci) {
29+
if (item != null && item.getItem().hasTag(AetherItemTags.FALLS_UPWARDS)) {
30+
this.yd += 0.08;
31+
}
32+
}
33+
34+
@ModifyVariable(method = "tick", at = @At(value = "STORE"), ordinal = 0)
35+
private float flipFriction(float friction) {
36+
if (!item.getItem().hasTag(AetherItemTags.FALLS_UPWARDS)) {
37+
return friction;
38+
}
39+
40+
int blockAbove = this.world.getBlockId(MathHelper.floor(this.x), MathHelper.floor(this.bb.maxY) + 1, MathHelper.floor(this.z));
41+
if (blockAbove > 0) {
42+
return Blocks.blocksList[blockAbove].friction * 0.98F;
43+
}
44+
45+
if (this.y > (double) 320.0F) {
46+
this.outOfWorld();
47+
}
48+
49+
return friction;
50+
}
51+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package teamport.aether.mixin.entity;
2+
3+
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
4+
import net.fabricmc.api.EnvType;
5+
import net.fabricmc.api.Environment;
6+
import net.minecraft.client.render.entity.EntityRendererItem;
7+
import net.minecraft.client.render.tessellator.Tessellator;
8+
import net.minecraft.core.entity.EntityItem;
9+
import net.minecraft.core.item.ItemStack;
10+
import org.spongepowered.asm.mixin.Mixin;
11+
import org.spongepowered.asm.mixin.injection.At;
12+
import teamport.aether.item.AetherItemTags;
13+
14+
@Environment(EnvType.CLIENT)
15+
@Mixin(value = EntityRendererItem.class, remap = false)
16+
public abstract class EntityRendererBobDownMixin {
17+
18+
@ModifyExpressionValue(method = "render(Lnet/minecraft/client/render/tessellator/Tessellator;Lnet/minecraft/core/entity/EntityItem;DDDFF)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/core/util/helper/MathHelper;sin(F)F"))
19+
private float reverseBobbingSine(float original, Tessellator tessellator, EntityItem entity, double x, double y, double z, float yaw, float partialTick) {
20+
ItemStack stack = entity.item;
21+
if (stack != null && stack.getItem().hasTag(AetherItemTags.FALLS_UPWARDS)) {
22+
return original - 4.0f;
23+
} else return original;
24+
}
25+
}

src/main/java/teamport/aether/mixin/entity/LightningBoltSoundMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import net.minecraft.core.entity.Entity;
44
import net.minecraft.core.entity.EntityLightning;
55
import net.minecraft.core.world.World;
6-
import org.jetbrains.annotations.Nullable;
6+
import org.jspecify.annotations.Nullable;
77
import org.spongepowered.asm.mixin.Mixin;
88
import org.spongepowered.asm.mixin.injection.At;
99
import org.spongepowered.asm.mixin.injection.ModifyArg;

src/main/java/teamport/aether/particle/ParticleLightningKnife.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
import net.minecraft.client.render.texture.stitcher.TextureRegistry;
1010
import net.minecraft.core.util.helper.MathHelper;
1111
import net.minecraft.core.world.World;
12-
import org.jetbrains.annotations.NotNull;
12+
import org.jspecify.annotations.NonNull;
1313

1414
import static teamport.aether.AetherMod.MOD_ID;
1515

1616
@Environment(EnvType.CLIENT)
1717
public class ParticleLightningKnife extends Particle {
18-
public static final @NotNull IconCoordinate BOLT = TextureRegistry.getTexture(MOD_ID + ":particle/lightiningknife_flipped");
19-
public static final @NotNull IconCoordinate BOLT_FLIPPED = TextureRegistry.getTexture(MOD_ID + ":particle/lightiningknife");
18+
public static final @NonNull IconCoordinate BOLT = TextureRegistry.getTexture(MOD_ID + ":particle/lightiningknife_flipped");
19+
public static final @NonNull IconCoordinate BOLT_FLIPPED = TextureRegistry.getTexture(MOD_ID + ":particle/lightiningknife");
2020
private final float originalScale;
2121

2222
public ParticleLightningKnife(World world, double x, double y, double z, double xd, double yd, double zd) {

0 commit comments

Comments
 (0)