mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 07:13:28 +01:00
Compare commits
5 commits
268cf651d0
...
43a23883e3
Author | SHA1 | Date | |
---|---|---|---|
|
43a23883e3 | ||
|
d644baa4cc | ||
|
f45bcb2f30 | ||
|
7d5876a7ad | ||
|
53b721f824 |
9 changed files with 105 additions and 208 deletions
|
@ -0,0 +1 @@
|
|||
// 1.21.1 2024-10-22T19:46:05.5548254 Update structure files in /structure
|
|
@ -1,5 +1,6 @@
|
|||
package de.ellpeck.actuallyadditions.data;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||
import de.ellpeck.actuallyadditions.data.patchouli.PatchouliGenerator;
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.gen.ActuallyBiomeModifiers;
|
||||
|
@ -72,6 +73,7 @@ public class ActuallyAdditionsData {
|
|||
|
||||
generator.addProvider(event.includeServer(), new DatapackBuiltinEntriesProvider(
|
||||
packOutput, patchedProvider, Set.of(ActuallyAdditions.MODID)));
|
||||
generator.addProvider(true, new StructureUpdater("structure", ActuallyAdditionsAPI.MOD_ID, helper, packOutput));
|
||||
|
||||
generator.addProvider(true, new Curios(packOutput, helper, lookupProvider));
|
||||
}
|
||||
|
|
|
@ -0,0 +1,102 @@
|
|||
package de.ellpeck.actuallyadditions.data;
|
||||
|
||||
/*
|
||||
* BluSunrize
|
||||
* Copyright (c) 2021
|
||||
*
|
||||
* This code is licensed under "Blu's License of Common Sense".
|
||||
* Class written by malte0811 and BluSunrize, and used with malte's permission.
|
||||
*/
|
||||
|
||||
import com.google.common.hash.Hashing;
|
||||
import com.mojang.datafixers.DataFixer;
|
||||
import com.mojang.datafixers.DataFixerUpper;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.data.CachedOutput;
|
||||
import net.minecraft.data.DataProvider;
|
||||
import net.minecraft.data.PackOutput;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtAccounter;
|
||||
import net.minecraft.nbt.NbtIo;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.resources.MultiPackResourceManager;
|
||||
import net.minecraft.server.packs.resources.Resource;
|
||||
import net.minecraft.util.datafix.DataFixTypes;
|
||||
import net.minecraft.util.datafix.DataFixers;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
|
||||
import net.neoforged.neoforge.common.data.ExistingFileHelper;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.nio.file.Path;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class StructureUpdater implements DataProvider {
|
||||
private final String basePath;
|
||||
private final String modid;
|
||||
private final PackOutput output;
|
||||
private final MultiPackResourceManager resources;
|
||||
|
||||
public StructureUpdater(
|
||||
String basePath, String modid, ExistingFileHelper helper, PackOutput output
|
||||
) {
|
||||
this.basePath = basePath;
|
||||
this.modid = modid;
|
||||
this.output = output;
|
||||
try {
|
||||
Field serverData = ExistingFileHelper.class.getDeclaredField("serverData");
|
||||
serverData.setAccessible(true);
|
||||
resources = (MultiPackResourceManager) serverData.get(helper);
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<?> run(@Nonnull CachedOutput cache) {
|
||||
try {
|
||||
for (var entry : resources.listResources(basePath, $ -> true).entrySet())
|
||||
if (entry.getKey().getNamespace().equals(modid))
|
||||
process(entry.getKey(), entry.getValue(), cache);
|
||||
return CompletableFuture.completedFuture(null);
|
||||
} catch (IOException x) {
|
||||
return CompletableFuture.failedFuture(x);
|
||||
}
|
||||
}
|
||||
|
||||
private void process(ResourceLocation loc, Resource resource, CachedOutput cache) throws IOException {
|
||||
CompoundTag inputNBT = NbtIo.readCompressed(resource.open(), NbtAccounter.unlimitedHeap());
|
||||
CompoundTag converted = updateNBT(inputNBT);
|
||||
if (!converted.equals(inputNBT)) {
|
||||
Class<? extends DataFixer> fixerClass = DataFixers.getDataFixer().getClass();
|
||||
if (!fixerClass.equals(DataFixerUpper.class))
|
||||
throw new RuntimeException("Structures are not up to date, but unknown data fixer is in use: " + fixerClass.getName());
|
||||
writeNBTTo(loc, converted, cache);
|
||||
}
|
||||
}
|
||||
|
||||
private void writeNBTTo(ResourceLocation loc, CompoundTag data, CachedOutput cache) throws IOException {
|
||||
ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream();
|
||||
NbtIo.writeCompressed(data, bytearrayoutputstream);
|
||||
byte[] bytes = bytearrayoutputstream.toByteArray();
|
||||
Path outputPath = output.getOutputFolder().resolve("data/" + loc.getNamespace() + "/" + loc.getPath());
|
||||
cache.writeIfNeeded(outputPath, bytes, Hashing.sha1().hashBytes(bytes));
|
||||
}
|
||||
|
||||
private static CompoundTag updateNBT(CompoundTag nbt) {
|
||||
final CompoundTag updatedNBT = DataFixTypes.STRUCTURE.updateToCurrentVersion(
|
||||
DataFixers.getDataFixer(), nbt, nbt.getInt("DataVersion")
|
||||
);
|
||||
StructureTemplate template = new StructureTemplate();
|
||||
template.load(BuiltInRegistries.BLOCK.asLookup(), updatedNBT);
|
||||
return template.save(new CompoundTag());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Update structure files in /" + basePath + "/";
|
||||
}
|
||||
}
|
|
@ -67,8 +67,6 @@ public class ActuallyAdditions {
|
|||
public static final String NAME = "Actually Additions";
|
||||
@Deprecated
|
||||
public static final String VERSION = "@VERSION@";
|
||||
@Deprecated
|
||||
public static final String GUIFACTORY = "de.ellpeck.actuallyadditions.mod.config.GuiFactory";
|
||||
public static final String DEPS = "required:forge@[14.23.5.2836,);before:craftingtweaks;after:fastbench@[1.3.2,)";
|
||||
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger(MODID);
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
// TODO: [port][note] forge does not support this atm
|
||||
///*
|
||||
// * This file ("GuiFactory.java") is part of the Actually Additions mod for Minecraft.
|
||||
// * It is created and owned by Ellpeck and distributed
|
||||
// * under the Actually Additions License to be found at
|
||||
// * http://ellpeck.de/actaddlicense
|
||||
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
// *
|
||||
// * © 2015-2017 Ellpeck
|
||||
// */
|
||||
//
|
||||
//package de.ellpeck.actuallyadditions.mod.config;
|
||||
//
|
||||
//import java.util.Set;
|
||||
//
|
||||
//import net.minecraft.client.Minecraft;
|
||||
//import net.minecraft.client.gui.GuiScreen;
|
||||
//import net.minecraftforge.fml.client.IModGuiFactory;
|
||||
//
|
||||
//public class GuiFactory implements IModGuiFactory {
|
||||
//
|
||||
// @Override
|
||||
// public void initialize(Minecraft minecraftInstance) {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean hasConfigGui() {
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public GuiScreen createConfigGui(GuiScreen parentScreen) {
|
||||
// return new GuiConfiguration(parentScreen);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Set<RuntimeOptionCategoryElement> runtimeGuiCategories() {
|
||||
// return null;
|
||||
// }
|
||||
//}
|
|
@ -1,84 +0,0 @@
|
|||
package de.ellpeck.actuallyadditions.mod.inventory.gui;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@Deprecated(forRemoval = true) //Unused because vanilla's Button class can render small just fine and even allows text scrolling
|
||||
public class Buttons {
|
||||
|
||||
@Deprecated(forRemoval = true) //Vanilla's Button class can render small just fine and even allows text scrolling
|
||||
public static class SmallerButton extends Button {
|
||||
|
||||
public final ResourceLocation resLoc = AssetUtil.getGuiLocation("gui_inputter");
|
||||
private final boolean smaller;
|
||||
|
||||
public SmallerButton(int x, int y, Component display, OnPress pressable) {
|
||||
this(x, y, display, false, pressable);
|
||||
}
|
||||
|
||||
public SmallerButton(int x, int y, Component display, boolean smaller, OnPress pressable) {
|
||||
super(x, y, 16, smaller
|
||||
? 12
|
||||
: 16, display, pressable, DEFAULT_NARRATION);
|
||||
this.smaller = smaller;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderWidget(@Nonnull GuiGraphics guiGraphics, int mouseX, int mouseY, float f) {
|
||||
if (this.visible) {
|
||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
int k = !this.active ? 0 : (this.isHoveredOrFocused() ? 2 : 1);
|
||||
GlStateManager._enableBlend();
|
||||
GlStateManager.glBlendFuncSeparate(770, 771, 1, 0);
|
||||
GlStateManager._blendFunc(770, 771);
|
||||
guiGraphics.blit(this.resLoc, this.getX(), this.getY(), this.smaller
|
||||
? 200
|
||||
: 176, k * this.height, this.width, this.height);
|
||||
//this.mouseDragged(mc, x, y); // The heck was this doing here?
|
||||
|
||||
int color = 14737632;
|
||||
if (this.packedFGColor != 0) {
|
||||
color = this.packedFGColor;
|
||||
} else if (!this.active) {
|
||||
color = 10526880;
|
||||
} else if (this.isHovered) {
|
||||
color = 16777120;
|
||||
}
|
||||
|
||||
guiGraphics.drawCenteredString(Minecraft.getInstance().font, this.getMessage(), this.getX() + this.width / 2, this.getY() + (this.height - 8) / 2, this.getMessage().getStyle().getColor().getValue());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class TinyButton extends Button {
|
||||
|
||||
public final ResourceLocation resLoc = AssetUtil.getGuiLocation("gui_inputter");
|
||||
|
||||
public TinyButton(int id, int x, int y) {
|
||||
super(x, y, 8, 8, Component.literal(""), Button::onPress, DEFAULT_NARRATION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float f) {
|
||||
if (this.visible) {
|
||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
int k = !this.active ? 0 : (this.isHoveredOrFocused() ? 2 : 1);
|
||||
GlStateManager._enableBlend();
|
||||
GlStateManager.glBlendFuncSeparate(770, 771, 1, 0);
|
||||
GlStateManager._blendFunc(770, 771);
|
||||
guiGraphics.blit(this.resLoc, this.getX(), this.getY(), 192, k * 8, 8, 8);
|
||||
//this.mouseDragged(mc, x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,75 +0,0 @@
|
|||
/*
|
||||
* This file ("InitOreDict.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2017 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.ore;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
// TODO: [port][change] migrate to TAGS
|
||||
@Deprecated
|
||||
public final class InitOreDict {
|
||||
|
||||
public static void init() {
|
||||
ActuallyAdditions.LOGGER.info("Initializing OreDictionary Entries...");
|
||||
|
||||
//Vanilla Ores
|
||||
addOre(Items.COAL, "coal");
|
||||
|
||||
//Ores for Pulverizers etc.
|
||||
// addOre(InitItems.itemDust.get(), TheDusts.IRON.ordinal(), "dustIron");
|
||||
// addOre(InitItems.itemDust.get(), TheDusts.GOLD.ordinal(), "dustGold");
|
||||
// addOre(InitItems.itemDust.get(), TheDusts.DIAMOND.ordinal(), "dustDiamond");
|
||||
// addOre(InitItems.itemDust.get(), TheDusts.EMERALD.ordinal(), "dustEmerald");
|
||||
// addOre(InitItems.itemDust.get(), TheDusts.LAPIS.ordinal(), "dustLapis");
|
||||
// addOre(InitItems.itemDust.get(), TheDusts.QUARTZ.ordinal(), "dustQuartz");
|
||||
// addOre(InitItems.itemDust.get(), TheDusts.QUARTZ.ordinal(), "dustNetherQuartz");
|
||||
// addOre(InitItems.itemDust.get(), TheDusts.COAL.ordinal(), "dustCoal");
|
||||
// addOre(InitItems.itemDust.get(), TheDusts.QUARTZ_BLACK.ordinal(), "dustQuartzBlack");
|
||||
// addOre(ActuallyBlocks.blockMisc.get(), TheMiscBlocks.ORE_QUARTZ.ordinal(), "oreQuartzBlack");
|
||||
// addOre(InitItems.itemMisc.get(), TheMiscItems.QUARTZ.ordinal(), "gemQuartzBlack");
|
||||
//
|
||||
// //For Thermal Expansion Machine that "grows crops"
|
||||
// addOre(InitItems.itemCanolaSeed.get(), "seedCanola");
|
||||
// addOre(InitItems.itemMisc.get(), TheMiscItems.CANOLA.ordinal(), "cropCanola");
|
||||
// addOre(InitItems.itemRiceSeed.get(), "seedRice");
|
||||
// addOre(InitItems.itemFoods.get(), TheFoods.RICE.ordinal(), "cropRice");
|
||||
// addOre(InitItems.itemFlaxSeed.get(), "seedFlax");
|
||||
// addOre(Items.STRING, "cropFlax");
|
||||
// addOre(InitItems.itemCoffeeSeed.get(), "seedCoffee");
|
||||
// addOre(InitItems.itemCoffeeBean.get(), "cropCoffee");
|
||||
//
|
||||
// //For Crafting
|
||||
// addOre(InitItems.itemMisc.get(), TheMiscItems.RICE_SLIME.ordinal(), "slimeball");
|
||||
// addOre(ActuallyBlocks.blockMisc.get(), TheMiscBlocks.CHARCOAL_BLOCK.ordinal(), "blockCharcoal");
|
||||
// addOre(ActuallyBlocks.blockMisc.get(), TheMiscBlocks.QUARTZ.ordinal(), "blockQuartzBlack");
|
||||
// addOre(InitItems.itemMisc.get(), TheMiscItems.BLACK_DYE.ordinal(), "dyeBlack");
|
||||
// addOre(InitItems.itemMisc.get(), TheMiscItems.BLACK_DYE.ordinal(), "dye");
|
||||
}
|
||||
|
||||
private static void addOre(Item item, int meta, String name) {
|
||||
// addOre(new ItemStack(item, 1, meta), name);
|
||||
}
|
||||
|
||||
private static void addOre(Item item, String name) {
|
||||
// addOre(item, 0, name);
|
||||
}
|
||||
|
||||
private static void addOre(Block block, int meta, String name) {
|
||||
// addOre(new ItemStack(block, 1, meta), name);
|
||||
}
|
||||
|
||||
private static void addOre(ItemStack stack, String name) {
|
||||
// OreDictionary.registerOre(name, stack);
|
||||
}
|
||||
}
|
|
@ -18,12 +18,6 @@ import net.neoforged.fml.loading.FMLLoader;
|
|||
|
||||
public final class Util {
|
||||
|
||||
@Deprecated
|
||||
public static final int WILDCARD = Short.MAX_VALUE;//OreDictionary.WILDCARD_VALUE;
|
||||
|
||||
@Deprecated
|
||||
public static final int BUCKET = 1000;
|
||||
|
||||
public static boolean isDevVersion() {
|
||||
return ActuallyAdditions.VERSION.equals("@VERSION@");
|
||||
}
|
||||
|
|
Binary file not shown.
Loading…
Reference in a new issue