Skip to content

Commit

Permalink
custom patreon banner patterns (ldtteam#9233)
Browse files Browse the repository at this point in the history
Introduces custom banner patterns for Patreons
Some small fix for the clipboard
Rerun datagen
  • Loading branch information
Raycoms committed Jul 8, 2023
1 parent 2c836f3 commit 38fb74c
Show file tree
Hide file tree
Showing 19 changed files with 60 additions and 21 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ mappingsVersion=1.20.1
dataGeneratorsVersion=1.19.3-0.1.54-ALPHA
blockUI_version=1.20-0.0.84-ALPHA
structurize_version=1.20-1.0.506-ALPHA
domumOrnamentumVersion=1.20-1.0.100-ALPHA
multiPistonVersion=1.20-1.2.29-ALPHA
domumOrnamentumVersion=1.20-1.0.104-ALPHA
multiPistonVersion=1.20-1.2.30-ALPHA

jei_mcversion=1.20.1
jei_version=15.1.0.19
Expand Down
40 changes: 40 additions & 0 deletions src/api/java/com/minecolonies/api/items/ModBannerPatterns.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.minecolonies.api.items;

import com.minecolonies.api.util.constant.Constants;
import net.minecraft.core.registries.Registries;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.level.block.entity.BannerPattern;
import net.minecraftforge.registries.DeferredRegister;

/**
* Registering of sound events for our colony.
*/
public final class ModBannerPatterns
{
public static final DeferredRegister<BannerPattern> BANNER_PATTERNS = DeferredRegister.create(Registries.BANNER_PATTERN, Constants.MOD_ID);

/**
* Private constructor to hide the implicit public one.
*/
private ModBannerPatterns()
{
/*
* Intentionally left empty.
*/
}

/**
* Register the {@link SoundEvent}s.
*
* @param registry the registry to register at.
*/
static
{
BANNER_PATTERNS.register("horse", () -> new BannerPattern("hsy"));
BANNER_PATTERNS.register("eagle", () -> new BannerPattern("egl"));
BANNER_PATTERNS.register("lion", () -> new BannerPattern("lin"));
BANNER_PATTERNS.register("tower", () -> new BannerPattern("twr"));
BANNER_PATTERNS.register("bear", () -> new BannerPattern("ber"));
BANNER_PATTERNS.register("fleur", () -> new BannerPattern("flr"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
}
}
],
"triggerOrder": "((1 && 4) || (2 && 4 && 1) || (1 && 3 && 4)) && 5 && 6",
"triggerOrder": "6 && ((1 && 4) || (2 && 4 && 1) || (1 && 3 && 4)) && 5",
"triggers": [
{
"type": "minecolonies:random",
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/minecolonies/coremod/MineColonies.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.minecolonies.api.entity.citizen.AbstractEntityCitizen;
import com.minecolonies.api.entity.mobs.AbstractEntityMinecoloniesMob;
import com.minecolonies.api.entity.mobs.RaiderMobUtils;
import com.minecolonies.api.items.ModBannerPatterns;
import com.minecolonies.api.items.ModTags;
import com.minecolonies.api.loot.ModLootConditions;
import com.minecolonies.api.sounds.ModSoundEvents;
Expand Down Expand Up @@ -90,6 +91,7 @@ public MineColonies()
ModResearchEffectInitializer.DEFERRED_REGISTER.register(FMLJavaModLoadingContext.get().getModEventBus());
ModLootConditions.DEFERRED_REGISTER.register(FMLJavaModLoadingContext.get().getModEventBus());
SupplyLoot.GLM.register(FMLJavaModLoadingContext.get().getModEventBus());
ModBannerPatterns.BANNER_PATTERNS.register(FMLJavaModLoadingContext.get().getModEventBus());

ModQuestInitializer.DEFERRED_REGISTER_OBJECTIVE.register(FMLJavaModLoadingContext.get().getModEventBus());
ModQuestInitializer.DEFERRED_REGISTER_TRIGGER.register(FMLJavaModLoadingContext.get().getModEventBus());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.minecolonies.api.colony.IColonyView;
import com.minecolonies.api.util.Log;
import com.minecolonies.api.util.constant.Constants;
import com.minecolonies.coremod.client.gui.townhall.AbstractWindowTownHall;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.datafixers.util.Pair;
Expand All @@ -17,9 +18,7 @@
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.client.renderer.blockentity.BannerRenderer;
import net.minecraft.core.Holder;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.level.block.entity.BannerPattern;
Expand All @@ -30,12 +29,12 @@
import net.minecraft.world.level.block.entity.BannerPatterns;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.registries.ForgeRegistries;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;

import static com.minecolonies.api.util.constant.translation.BaseGameTranslationConstants.BASE_GUI_DONE;
Expand Down Expand Up @@ -122,10 +121,11 @@ public class WindowBannerPicker extends Screen
private int scrollRow = 0;

/**
* @param colony the colony to make the flag for
* @param hallWindow the calling town hall window to return to
* @param colony the colony to make the flag for
* @param hallWindow the calling town hall window to return to
* @param isFeatureUnlocked
*/
public WindowBannerPicker(IColonyView colony, AbstractWindowTownHall hallWindow)
public WindowBannerPicker(IColonyView colony, AbstractWindowTownHall hallWindow, final AtomicBoolean isFeatureUnlocked)
{
super(Component.literal("Flag"));

Expand All @@ -142,8 +142,13 @@ public WindowBannerPicker(IColonyView colony, AbstractWindowTownHall hallWindow)
exclusion.add((Holder<BannerPattern>) BuiltInRegistries.BANNER_PATTERN.getHolder(key).get());
}
}
this.patterns = new LinkedList<>(BuiltInRegistries.BANNER_PATTERN.holders().collect(Collectors.toList()));

this.patterns = BuiltInRegistries.BANNER_PATTERN.holders().collect(Collectors.toCollection(LinkedList::new));
this.patterns.removeAll(exclusion);
if (!isFeatureUnlocked.get())
{
this.patterns.removeIf(key -> key.unwrapKey().get().location().getNamespace().equals(Constants.MOD_ID));
}

// Fetch the patterns as a List and not ListNBT
this.layers = BannerBlockEntity.createPatterns(DyeColor.WHITE, colony.getColonyFlag());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ private void togglePrintProgress(@NotNull final Button button)
*/
private void openBannerPicker(@NotNull final Button button)
{
Screen window = new WindowBannerPicker(building.getColony(), this);
Screen window = new WindowBannerPicker(building.getColony(), this, isFeatureUnlocked);
Minecraft.getInstance().execute(() -> Minecraft.getInstance().setScreen(window));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import com.minecolonies.api.colony.requestsystem.resolver.player.IPlayerRequestResolver;
import com.minecolonies.api.colony.requestsystem.resolver.retrying.IRetryingRequestResolver;
import com.minecolonies.api.colony.requestsystem.token.IToken;
import com.minecolonies.api.util.Log;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
Expand All @@ -18,10 +16,7 @@
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.client.IItemDecorator;


import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import static com.minecolonies.coremod.items.ItemClipboard.TAG_COLONY;
Expand Down Expand Up @@ -49,10 +44,7 @@ public boolean render(GuiGraphics graphics, Font font, ItemStack stack, int xOff
if (compoundTag != null)
{
final int colonyId = compoundTag.getInt(TAG_COLONY);
if (colonyView == null || colonyId != colonyView.getID())
{
colonyView = IColonyManager.getInstance().getColonyView(colonyId, Minecraft.getInstance().level.dimension());
}
colonyView = IColonyManager.getInstance().getColonyView(colonyId, Minecraft.getInstance().level.dimension());

if (colonyView != null)
{
Expand Down Expand Up @@ -90,7 +82,7 @@ public boolean render(GuiGraphics graphics, Font font, ItemStack stack, int xOff
ps.pushPose();
ps.translate(0, 0, 500);
graphics.drawCenteredString(font,
Component.literal(count+ ""),
Component.literal(count + ""),
xOffset + 15,
yOffset - 2,
0xFF4500 | (255 << 24));
Expand Down
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.
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.
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.
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.
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.
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.

0 comments on commit 38fb74c

Please sign in to comment.