Skip to content

Commit

Permalink
Don't use deprecated stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Irgendwer01 committed Dec 17, 2023
1 parent ec3c4ab commit 5cbe01c
Show file tree
Hide file tree
Showing 10 changed files with 204 additions and 137 deletions.
4 changes: 2 additions & 2 deletions src/main/java/gregtech/api/GTValues.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,11 @@ public class GTValues {
MODID_GENETICS = "genetics",
MODID_BOP = "biomesoplenty",
MODID_TCON = "tconstruct",
MODID_EN = "exnihilocreatio";
MODID_EN = "exnihilocreatio",
MODID_PROJRED_CORE = "projectred-core",
MODID_RC = "railcraft",
MODID_CHISEL = "chisel";

private static Boolean isClient;

public static boolean isClientSide() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package gregtech.integration.exnihilo;

import gregtech.api.GTValues;

import net.minecraftforge.common.config.Config;

import static net.minecraftforge.common.config.Config.Comment;
import static net.minecraftforge.common.config.Config.RequiresMcRestart;
import static net.minecraftforge.common.config.Config.LangKey;
import static net.minecraftforge.common.config.Config.RequiresMcRestart;

@LangKey("gregtech.config.ex_nihilo")
@Config(modid = GTValues.MODID, name = GTValues.MODID + "/ex_nihilo", category = "Ex Nihilo")
Expand Down
88 changes: 55 additions & 33 deletions src/main/java/gregtech/integration/exnihilo/ExNihiloModule.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package gregtech.integration.exnihilo;

import gregtech.api.GTValues;
import gregtech.api.gui.GuiTextures;
import gregtech.api.gui.resources.SteamTexture;
import gregtech.api.gui.widgets.ProgressWidget;
import gregtech.api.modules.GregTechModule;
import gregtech.api.recipes.RecipeMap;
import gregtech.api.recipes.RecipeMapBuilder;
import gregtech.api.recipes.builders.SimpleRecipeBuilder;
import gregtech.api.unification.material.event.MaterialEvent;
import gregtech.api.unification.material.info.MaterialIconType;
Expand All @@ -21,8 +20,9 @@
import gregtech.integration.exnihilo.recipes.ExNihiloRecipes;
import gregtech.integration.exnihilo.recipes.MeshRecipes;
import gregtech.integration.exnihilo.recipes.SieveDrops;
import gregtech.integration.exnihilo.recipes.recipemaps.SieveRecipeMap;
import gregtech.integration.exnihilo.recipes.ui.SieveUI;
import gregtech.modules.GregTechModules;

import net.minecraft.init.SoundEvents;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.util.ResourceLocation;
Expand All @@ -33,7 +33,8 @@
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

import javax.annotation.Nonnull;
import org.jetbrains.annotations.NotNull;

import java.io.File;
import java.util.Collections;
import java.util.List;
Expand All @@ -43,28 +44,33 @@
import static gregtech.common.metatileentities.MetaTileEntities.*;

@GregTechModule(
moduleID = GregTechModules.MODULE_EN,
containerID = GTValues.MODID,
modDependencies = GTValues.MODID_EN,
name = "GregTech Ex Nihilo Creatio Integration",
description = "Ex Nihilo Integration Module")
moduleID = GregTechModules.MODULE_EN,
containerID = GTValues.MODID,
modDependencies = GTValues.MODID_EN,
name = "GregTech Ex Nihilo Creatio Integration",
description = "Ex Nihilo Integration Module")
public class ExNihiloModule extends IntegrationSubmodule {

// Items
public static ExNihiloPebble GTPebbles;

// Recipe maps
public static final RecipeMap<SimpleRecipeBuilder> SIEVE_RECIPES = new SieveRecipeMap("electric_sieve", 2, false, 36, true, 0, false, 0, false, new SimpleRecipeBuilder().duration(100).EUt(4), false)
.setProgressBar(GuiTextures.PROGRESS_BAR_SIFT, ProgressWidget.MoveType.VERTICAL_INVERTED)
.setSound(SoundEvents.BLOCK_SAND_PLACE);
public static final RecipeMap<SimpleRecipeBuilder> SIEVE_RECIPES = new RecipeMapBuilder<>("electric_sieve",
new SimpleRecipeBuilder().duration(100).EUt(4))
.itemInputs(2)
.itemOutputs(36)
.ui(SieveUI::new)
.sound(SoundEvents.BLOCK_SAND_PLACE)
.build();

// Machines
public static MetaTileEntitySteamSieve STEAM_SIEVE_BRONZE;
public static MetaTileEntitySteamSieve STEAM_SIEVE_STEEL;
public static MetaTileEntitySieve[] SIEVES = new MetaTileEntitySieve[GTValues.V.length - 1];

// Textures
public static final SteamTexture PROGRESS_BAR_SIFTER_STEAM = SteamTexture.fullImage("textures/gui/progress_bar/progress_bar_sift_%s.png");
public static final SteamTexture PROGRESS_BAR_SIFTER_STEAM = SteamTexture
.fullImage("textures/gui/progress_bar/progress_bar_sift_%s.png");

// Ore prefixes
public static OrePrefix oreChunk;
Expand All @@ -76,7 +82,7 @@ public class ExNihiloModule extends IntegrationSubmodule {
public static MaterialIconType oreEnderChunkIcon;
public static MaterialIconType oreNetherChunkIcon;

@Nonnull
@NotNull
@Override
public List<Class<?>> getEventBusSubscribers() {
return Collections.singletonList(ExNihiloModule.class);
Expand All @@ -87,7 +93,8 @@ public void preInit(FMLPreInitializationEvent event) {
getLogger().info("Registering Ex Nihilo Compat Items, Blocks, and Machines");
GTPebbles = new ExNihiloPebble();
registerMetaTileEntities();
FileUtility.extractJarFiles(String.format("/assets/%s/%s", GTValues.MODID, "exnihilo"), new File(Loader.instance().getConfigDir(), "gregtech"), false);
FileUtility.extractJarFiles(String.format("/assets/%s/%s", GTValues.MODID, "exnihilo"),
new File(Loader.instance().getConfigDir(), "gregtech"), false);
}

@Override
Expand All @@ -110,10 +117,10 @@ public static void registerMaterials(MaterialEvent event) {
oreEnderChunkIcon = new MaterialIconType("oreEnderChunk");
oreNetherChunkIcon = new MaterialIconType("oreNetherChunk");


oreChunk = new OrePrefix("oreChunk", -1, null, oreChunkIcon, ENABLE_UNIFICATION, hasOreProperty);
oreEnderChunk = new OrePrefix("oreEnderChunk", -1, null, oreEnderChunkIcon, ENABLE_UNIFICATION, hasOreProperty);
oreNetherChunk = new OrePrefix("oreNetherChunk", -1, null, oreNetherChunkIcon, ENABLE_UNIFICATION, hasOreProperty);
oreNetherChunk = new OrePrefix("oreNetherChunk", -1, null, oreNetherChunkIcon, ENABLE_UNIFICATION,
hasOreProperty);

oreChunk.setAlternativeOreName(OrePrefix.ore.name());
oreEnderChunk.setAlternativeOreName(OrePrefix.oreEndstone.name());
Expand All @@ -123,25 +130,40 @@ public static void registerMaterials(MaterialEvent event) {
}

private void registerMetaTileEntities() {
STEAM_SIEVE_BRONZE = MetaTileEntities.registerMetaTileEntity(4000, new MetaTileEntitySteamSieve(new ResourceLocation(GTValues.MODID ,"sieve.steam"), false));
STEAM_SIEVE_STEEL = MetaTileEntities.registerMetaTileEntity(4001, new MetaTileEntitySteamSieve(new ResourceLocation(GTValues.MODID, "steam_sieve_steel"), true));

SIEVES[0] = MetaTileEntities.registerMetaTileEntity(4002, new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.lv"), 1));
SIEVES[1] = MetaTileEntities.registerMetaTileEntity(4003, new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.mv"), 2));
SIEVES[2] = MetaTileEntities.registerMetaTileEntity(4004, new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.hv"), 3));
SIEVES[3] = MetaTileEntities.registerMetaTileEntity(4005, new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.ev"), 4));
SIEVES[4] = MetaTileEntities.registerMetaTileEntity(4006, new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.iv"), 5));
STEAM_SIEVE_BRONZE = MetaTileEntities.registerMetaTileEntity(4000,
new MetaTileEntitySteamSieve(new ResourceLocation(GTValues.MODID, "sieve.steam"), false));
STEAM_SIEVE_STEEL = MetaTileEntities.registerMetaTileEntity(4001,
new MetaTileEntitySteamSieve(new ResourceLocation(GTValues.MODID, "steam_sieve_steel"), true));

SIEVES[0] = MetaTileEntities.registerMetaTileEntity(4002,
new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.lv"), 1));
SIEVES[1] = MetaTileEntities.registerMetaTileEntity(4003,
new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.mv"), 2));
SIEVES[2] = MetaTileEntities.registerMetaTileEntity(4004,
new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.hv"), 3));
SIEVES[3] = MetaTileEntities.registerMetaTileEntity(4005,
new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.ev"), 4));
SIEVES[4] = MetaTileEntities.registerMetaTileEntity(4006,
new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.iv"), 5));
if (getMidTier("sieve")) {
SIEVES[5] = MetaTileEntities.registerMetaTileEntity(4007, new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.luv"), 6));
SIEVES[6] = MetaTileEntities.registerMetaTileEntity(4008, new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.zpm"), 7));
SIEVES[7] = MetaTileEntities.registerMetaTileEntity(4009, new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.uv"), 8));
SIEVES[5] = MetaTileEntities.registerMetaTileEntity(4007,
new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.luv"), 6));
SIEVES[6] = MetaTileEntities.registerMetaTileEntity(4008,
new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.zpm"), 7));
SIEVES[7] = MetaTileEntities.registerMetaTileEntity(4009,
new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.uv"), 8));
}
if (getHighTier("sieve")) {
SIEVES[8] = MetaTileEntities.registerMetaTileEntity(4010, new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.uhv"), 9));
SIEVES[9] = MetaTileEntities.registerMetaTileEntity(4011, new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.uev"), 10));
SIEVES[10] = MetaTileEntities.registerMetaTileEntity(4012, new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.uiv"), 11));
SIEVES[11] = MetaTileEntities.registerMetaTileEntity(4013, new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.uxv"), 12));
SIEVES[12] = MetaTileEntities.registerMetaTileEntity(4014, new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.opv"), 13));
SIEVES[8] = MetaTileEntities.registerMetaTileEntity(4010,
new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.uhv"), 9));
SIEVES[9] = MetaTileEntities.registerMetaTileEntity(4011,
new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.uev"), 10));
SIEVES[10] = MetaTileEntities.registerMetaTileEntity(4012,
new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.uiv"), 11));
SIEVES[11] = MetaTileEntities.registerMetaTileEntity(4013,
new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.uxv"), 12));
SIEVES[12] = MetaTileEntities.registerMetaTileEntity(4014,
new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.opv"), 13));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package gregtech.integration.exnihilo.items;

import exnihilocreatio.ExNihiloCreatio;
import exnihilocreatio.entities.ProjectileStone;
import exnihilocreatio.util.Data;
import exnihilocreatio.util.IHasModel;
import gregtech.integration.exnihilo.ExNihiloModule;

import net.minecraft.client.renderer.block.model.ModelBakery;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
Expand All @@ -18,11 +15,16 @@
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.jetbrains.annotations.Nullable;

import javax.annotation.Nonnull;
import exnihilocreatio.ExNihiloCreatio;
import exnihilocreatio.entities.ProjectileStone;
import exnihilocreatio.util.Data;
import exnihilocreatio.util.IHasModel;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class ExNihiloPebble extends Item implements IHasModel {

public ExNihiloPebble() {
setTranslationKey("gtPebble");
setRegistryName("gtPebble");
Expand All @@ -32,14 +34,14 @@ public ExNihiloPebble() {
}

@Override
@Nonnull
public String getTranslationKey(@Nonnull ItemStack stack) {
@NotNull
public String getTranslationKey(@NotNull ItemStack stack) {
return String.format("%s.%s", getTranslationKey(), GTPebbles.VALUES[stack.getItemDamage()].getName());
}

@Override
@SideOnly(Side.CLIENT)
public void getSubItems(@Nullable CreativeTabs tab, @Nonnull NonNullList<ItemStack> list) {
public void getSubItems(@Nullable CreativeTabs tab, @NotNull NonNullList<ItemStack> list) {
if (tab != null && isInCreativeTab(tab)) {
for (GTPebbles pebble : GTPebbles.VALUES) {
list.add(new ItemStack(ExNihiloModule.GTPebbles, 1, pebble.ordinal()));
Expand All @@ -48,13 +50,15 @@ public void getSubItems(@Nullable CreativeTabs tab, @Nonnull NonNullList<ItemSta
}

@Override
@Nonnull
public ActionResult<ItemStack> onItemRightClick(@Nonnull World world, @Nonnull EntityPlayer player, @Nonnull EnumHand hand) {
@NotNull
public ActionResult<ItemStack> onItemRightClick(@NotNull World world, @NotNull EntityPlayer player,
@NotNull EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);

if (!stack.isEmpty()) {
world.playSound(player, player.posX, player.posY, player.posZ,
SoundEvents.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
SoundEvents.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F,
0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

if (!world.isRemote) {
ItemStack thrown = stack.copy();
Expand All @@ -79,14 +83,16 @@ public ActionResult<ItemStack> onItemRightClick(@Nonnull World world, @Nonnull E
public void initModel(ModelRegistryEvent e) {
ModelResourceLocation[] locations = new ModelResourceLocation[GTPebbles.VALUES.length];
for (GTPebbles pebble : GTPebbles.VALUES) {
locations[pebble.ordinal()] = new ModelResourceLocation(getRegistryName(), String.format("type=%s", pebble.getName()));
locations[pebble.ordinal()] = new ModelResourceLocation(getRegistryName(),
String.format("type=%s", pebble.getName()));
}

ModelBakery.registerItemVariants(this, locations);
ModelLoader.setCustomMeshDefinition(this, stack -> locations[stack.getMetadata()]);
}

private enum GTPebbles implements IStringSerializable {

BASALT("basalt"),
BLACK_GRANITE("black_granite"),
MARBLE("marble"),
Expand All @@ -100,7 +106,7 @@ private enum GTPebbles implements IStringSerializable {
}

@Override
@Nonnull
@NotNull
public String getName() {
return this.name;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
import gregtech.api.metatileentity.interfaces.IGregTechTileEntity;
import gregtech.client.renderer.texture.Textures;
import gregtech.integration.exnihilo.ExNihiloModule;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;

import javax.annotation.Nonnull;
import org.jetbrains.annotations.NotNull;

public class MetaTileEntitySieve extends SimpleMachineMetaTileEntity {

Expand All @@ -28,13 +29,14 @@ public MetaTileEntity createMetaTileEntity(IGregTechTileEntity holder) {
}

@Override
protected ModularUI.Builder createGuiTemplate(@Nonnull EntityPlayer player) {
protected ModularUI.Builder createGuiTemplate(@NotNull EntityPlayer player) {
ModularUI.Builder builder = new ModularUI.Builder(GuiTextures.BACKGROUND, 176, 192)
.label(5, 5, this.getMetaFullName())
.slot(this.importItems, 0, 17, 25, GuiTextures.SLOT)
.slot(this.importItems, 1, 35, 25, GuiTextures.SLOT)
.progressBar(workable::getProgressPercent, 25, 50, 20, 20,
GuiTextures.PROGRESS_BAR_SIFT, ProgressWidget.MoveType.VERTICAL_INVERTED, workable.getRecipeMap())
GuiTextures.PROGRESS_BAR_SIFT, ProgressWidget.MoveType.VERTICAL_INVERTED,
workable.getRecipeMap())
.widget(new ImageWidget(25, 69, 18, 18, GuiTextures.INDICATOR_NO_ENERGY).setIgnoreColor(true)
.setPredicate(workable::isHasNotEnoughEnergy))
.bindPlayerInventory(player.inventory, GuiTextures.SLOT, 7, 109);
Expand All @@ -47,13 +49,13 @@ protected ModularUI.Builder createGuiTemplate(@Nonnull EntityPlayer player) {

builder.widget(new ToggleButtonWidget(7, 87, 18, 18,
GuiTextures.BUTTON_ITEM_OUTPUT, this::isAutoOutputItems, this::setAutoOutputItems)
.setTooltipText("gregtech.gui.item_auto_output.tooltip")
.shouldUseBaseBackground());
.setTooltipText("gregtech.gui.item_auto_output.tooltip")
.shouldUseBaseBackground());

builder.widget(new CycleButtonWidget(25, 87, 18, 18,
workable.getAvailableOverclockingTiers(), workable::getOverclockTier, workable::setOverclockTier)
.setTooltipHoverString("gregtech.gui.overclock.description")
.setButtonTexture(GuiTextures.BUTTON_OVERCLOCK));
.setTooltipHoverString("gregtech.gui.overclock.description")
.setButtonTexture(GuiTextures.BUTTON_OVERCLOCK));

return builder;
}
Expand Down
Loading

0 comments on commit 5cbe01c

Please sign in to comment.