-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Balloons now change their appearance to reflect their type
- Loading branch information
Showing
15 changed files
with
95 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/main/java/com/minelittlepony/unicopia/item/GiantBalloonItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.minelittlepony.unicopia.item; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import com.minelittlepony.unicopia.entity.mob.AirBalloonEntity.BalloonDesign; | ||
import com.minelittlepony.unicopia.item.component.BalloonDesignComponent; | ||
import com.minelittlepony.unicopia.item.component.UDataComponentTypes; | ||
import com.minelittlepony.unicopia.item.group.MultiItem; | ||
|
||
import net.minecraft.item.Item; | ||
import net.minecraft.item.ItemStack; | ||
|
||
public class GiantBalloonItem extends Item implements MultiItem { | ||
public GiantBalloonItem(Settings settings) { | ||
super(settings); | ||
} | ||
|
||
@Override | ||
public List<ItemStack> getDefaultStacks() { | ||
return Arrays.stream(BalloonDesign.VALUES).map(design -> { | ||
ItemStack stack = getDefaultStack(); | ||
stack.set(UDataComponentTypes.BALLOON_DESIGN, new BalloonDesignComponent(design, true)); | ||
return stack; | ||
}).toList(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/main/java/com/minelittlepony/unicopia/item/component/BalloonDesignComponent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.minelittlepony.unicopia.item.component; | ||
|
||
import java.util.function.Consumer; | ||
|
||
import com.minelittlepony.unicopia.entity.mob.AirBalloonEntity; | ||
import com.mojang.serialization.Codec; | ||
import com.mojang.serialization.codecs.RecordCodecBuilder; | ||
|
||
import io.netty.buffer.ByteBuf; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.item.Item.TooltipContext; | ||
import net.minecraft.item.tooltip.TooltipAppender; | ||
import net.minecraft.item.tooltip.TooltipType; | ||
import net.minecraft.network.codec.PacketCodec; | ||
import net.minecraft.network.codec.PacketCodecs; | ||
import net.minecraft.text.Text; | ||
import net.minecraft.util.Formatting; | ||
|
||
public record BalloonDesignComponent(AirBalloonEntity.BalloonDesign design, boolean showInTooltip) implements TooltipAppender { | ||
public static final BalloonDesignComponent DEFAULT = new BalloonDesignComponent(AirBalloonEntity.BalloonDesign.NONE, false); | ||
public static final Codec<BalloonDesignComponent> CODEC = RecordCodecBuilder.create(instance -> instance.group( | ||
AirBalloonEntity.BalloonDesign.CODEC.fieldOf("design").forGetter(BalloonDesignComponent::design), | ||
Codec.BOOL.fieldOf("show_in_tooltip").forGetter(BalloonDesignComponent::showInTooltip) | ||
).apply(instance, BalloonDesignComponent::new)); | ||
public static final PacketCodec<ByteBuf, BalloonDesignComponent> PACKET_CODEC = PacketCodec.tuple( | ||
AirBalloonEntity.BalloonDesign.PACKET_CODEC, BalloonDesignComponent::design, | ||
PacketCodecs.BOOL, BalloonDesignComponent::showInTooltip, | ||
BalloonDesignComponent::new | ||
); | ||
|
||
public static BalloonDesignComponent get(ItemStack stack) { | ||
return stack.getOrDefault(UDataComponentTypes.BALLOON_DESIGN, DEFAULT); | ||
} | ||
|
||
public static ItemStack set(ItemStack stack, BalloonDesignComponent variant) { | ||
stack.set(UDataComponentTypes.BALLOON_DESIGN, variant); | ||
return stack; | ||
} | ||
|
||
@Override | ||
public void appendTooltip(TooltipContext context, Consumer<Text> tooltip, TooltipType type) { | ||
if (showInTooltip() && design != AirBalloonEntity.BalloonDesign.NONE) { | ||
tooltip.accept(Text.literal(design().name()).formatted(Formatting.LIGHT_PURPLE)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+6.6 KB
src/main/resources/assets/unicopia/textures/item/giant_balloon_dawn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.46 KB
src/main/resources/assets/unicopia/textures/item/giant_balloon_equality.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.51 KB
src/main/resources/assets/unicopia/textures/item/giant_balloon_luna.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.47 KB
src/main/resources/assets/unicopia/textures/item/giant_balloon_storm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.57 KB
src/main/resources/assets/unicopia/textures/item/giant_balloon_tale.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.