Skip to content

Commit

Permalink
Update to 1.20.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ramidzkh committed Jul 8, 2023
1 parent 3a627d2 commit 22e3887
Show file tree
Hide file tree
Showing 22 changed files with 184 additions and 122 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
.idea/
.vscode/
build/
libs/
run/
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ repositories {
}

maven {
name = "Progwml6 maven"
url = uri("https://dvs1.progwml6.com/files/maven/")
name = "Jared maven"
url = uri("https://maven.blamejared.com/")

content {
includeGroup("mezz.jei")
Expand Down
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
minecraft_version=1.19.2
forge_version=43.2.4
ae2_version=12.9.2
mekanism_version=10.3.7.476
jei_version=11.4.0.287
jade_id=4096513
minecraft_version=1.20.1
forge_version=47.1.0
ae2_version=15.0.4-beta
mekanism_version=10.3.9.homebaked
jei_version=15.2.0.22
jade_id=4614153

org.gradle.daemon=false

Expand Down
45 changes: 27 additions & 18 deletions src/main/java/me/ramidzkh/mekae2/AMItems.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package me.ramidzkh.mekae2;

import net.minecraft.Util;
import net.minecraft.core.registries.Registries;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
Expand All @@ -23,28 +24,35 @@

public class AMItems {

private static final DeferredRegister<CreativeModeTab> TABS = DeferredRegister.create(Registries.CREATIVE_MODE_TAB,
AppliedMekanistics.ID);
private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS,
AppliedMekanistics.ID);

public static void initialize(IEventBus bus) {
TABS.register(bus);
ITEMS.register(bus);
}

private static Item basic() {
return new MaterialItem(properties());
}

public static final CreativeModeTab CREATIVE_TAB = new CreativeModeTab(AppliedMekanistics.ID) {
@Override
public ItemStack makeIcon() {
return new ItemStack(AMItems.CHEMICAL_CELL_64K.get());
}
};

private static Item.Properties properties() {
return new Item.Properties().tab(CREATIVE_TAB);
return new Item.Properties();
}

public static final RegistryObject<CreativeModeTab> CREATIVE_TAB = TABS.register("main",
() -> CreativeModeTab.builder()
.title(AMText.CREATIVE_TAB.formatted())
.icon(() -> new ItemStack(AMItems.CHEMICAL_CELL_64K.get()))
.displayItems((params, output) -> {
for (var entry : ITEMS.getEntries()) {
output.accept(entry.get());
}
})
.build());

public static final RegistryObject<Item> CHEMICAL_CELL_HOUSING = ITEMS.register("chemical_cell_housing",
AMItems::basic);

Expand All @@ -64,23 +72,24 @@ private static Item.Properties properties() {
CHEMICAL_CELL_HOUSING.get()));

public static final RegistryObject<Item> PORTABLE_CHEMICAL_CELL_1K = ITEMS.register(
"portable_chemical_storage_cell_1k", () -> new ChemicalPortableCellItem(AMMenus.PORTABLE_CHEMICAL_CELL_TYPE,
StorageTier.SIZE_1K, properties().stacksTo(1)));
"portable_chemical_storage_cell_1k",
() -> new ChemicalPortableCellItem(18, AMMenus.PORTABLE_CHEMICAL_CELL_TYPE,
StorageTier.SIZE_1K, properties().stacksTo(1), 0));
public static final RegistryObject<Item> PORTABLE_CHEMICAL_CELL_4K = ITEMS.register(
"portable_chemical_storage_cell_4k", () -> new ChemicalPortableCellItem(AMMenus.PORTABLE_CHEMICAL_CELL_TYPE,
StorageTier.SIZE_4K, properties().stacksTo(1)));
"portable_chemical_storage_cell_4k", () -> new ChemicalPortableCellItem(18,
AMMenus.PORTABLE_CHEMICAL_CELL_TYPE, StorageTier.SIZE_4K, properties().stacksTo(1), 0));
public static final RegistryObject<Item> PORTABLE_CHEMICAL_CELL_16K = ITEMS.register(
"portable_chemical_storage_cell_16k",
() -> new ChemicalPortableCellItem(AMMenus.PORTABLE_CHEMICAL_CELL_TYPE, StorageTier.SIZE_16K,
properties().stacksTo(1)));
() -> new ChemicalPortableCellItem(18, AMMenus.PORTABLE_CHEMICAL_CELL_TYPE, StorageTier.SIZE_16K,
properties().stacksTo(1), 0));
public static final RegistryObject<Item> PORTABLE_CHEMICAL_CELL_64K = ITEMS.register(
"portable_chemical_storage_cell_64k",
() -> new ChemicalPortableCellItem(AMMenus.PORTABLE_CHEMICAL_CELL_TYPE, StorageTier.SIZE_64K,
properties().stacksTo(1)));
() -> new ChemicalPortableCellItem(18, AMMenus.PORTABLE_CHEMICAL_CELL_TYPE, StorageTier.SIZE_64K,
properties().stacksTo(1), 0));
public static final RegistryObject<Item> PORTABLE_CHEMICAL_CELL_256K = ITEMS.register(
"portable_chemical_storage_cell_256k",
() -> new ChemicalPortableCellItem(AMMenus.PORTABLE_CHEMICAL_CELL_TYPE, StorageTier.SIZE_256K,
properties().stacksTo(1)));
() -> new ChemicalPortableCellItem(18, AMMenus.PORTABLE_CHEMICAL_CELL_TYPE, StorageTier.SIZE_256K,
properties().stacksTo(1), 0));

public static final RegistryObject<PartItem<ChemicalP2PTunnelPart>> CHEMICAL_P2P_TUNNEL = Util.make(() -> {
PartModels.registerModels(PartModelsHelper.createModels(ChemicalP2PTunnelPart.class));
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/me/ramidzkh/mekae2/AMText.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import net.minecraft.network.chat.Component;

public enum AMText {
CHEMICAL("chemical"),
CREATIVE_TAB("creative_tab"),
QIO_FREQUENCY("qio_frequency"),
;

Expand Down
5 changes: 2 additions & 3 deletions src/main/java/me/ramidzkh/mekae2/AppliedMekanistics.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import org.jetbrains.annotations.Nullable;

import net.minecraft.core.Direction;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
Expand Down Expand Up @@ -67,7 +67,7 @@ public AppliedMekanistics() {
bus.addListener(MekAE2DataGenerators::onGatherData);

bus.addListener((RegisterEvent event) -> {
if (!event.getRegistryKey().equals(Registry.BLOCK_REGISTRY)) {
if (!event.getRegistryKey().equals(Registries.BLOCK)) {
return;
}

Expand Down Expand Up @@ -134,7 +134,6 @@ public boolean isSpecializedFor(ItemStack cell) {

@Override
public void openChestGui(Player player, IChestOrDrive chest, ICellHandler cellHandler, ItemStack cell) {
chest.getUp();
MenuOpener.open(MEStorageMenu.TYPE, player,
MenuLocators.forBlockEntity((BlockEntity) chest));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,31 @@
import com.mojang.blaze3d.vertex.PoseStack;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.client.renderer.texture.TextureAtlas;
import net.minecraft.network.chat.Component;
import net.minecraft.world.level.Level;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;

import appeng.api.client.AEStackRendering;
import appeng.api.client.IAEStackRenderHandler;
import appeng.api.client.AEKeyRenderHandler;
import appeng.api.client.AEKeyRendering;
import appeng.client.gui.style.Blitter;
import appeng.util.Platform;

public class AMChemicalStackRenderer implements IAEStackRenderHandler<MekanismKey> {
public class AMChemicalStackRenderer implements AEKeyRenderHandler<MekanismKey> {

public static void initialize(IEventBus bus) {
bus.addListener((FMLClientSetupEvent event) -> event.enqueueWork(() -> {
AEStackRendering.register(MekanismKeyType.TYPE, MekanismKey.class, new AMChemicalStackRenderer());
AEKeyRendering.register(MekanismKeyType.TYPE, MekanismKey.class, new AMChemicalStackRenderer());
}));
}

@Override
public void drawInGui(Minecraft minecraft, PoseStack poseStack, int x, int y, int zIndex, MekanismKey what) {
public void drawInGui(Minecraft minecraft, GuiGraphics guiGraphics, int x, int y, MekanismKey what) {
var stack = what.getStack();

Blitter.sprite(
Expand All @@ -37,12 +39,12 @@ public void drawInGui(Minecraft minecraft, PoseStack poseStack, int x, int y, in
// Most fluid texture have transparency, but we want an opaque slot
.blending(false)
.dest(x, y, 16, 16)
.blit(poseStack, 100 + zIndex);
.blit(guiGraphics);
}

@Override
public void drawOnBlockFace(PoseStack poseStack, MultiBufferSource buffers, MekanismKey what, float scale,
int combinedLight) {
int combinedLight, Level level) {
var stack = what.getStack();
var sprite = Minecraft.getInstance().getTextureAtlas(TextureAtlas.LOCATION_BLOCKS)
.apply(stack.getType().getIcon());
Expand Down
30 changes: 22 additions & 8 deletions src/main/java/me/ramidzkh/mekae2/ae2/MekanismKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,21 @@
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;

import me.ramidzkh.mekae2.util.ChemicalBridge;
import mekanism.api.Coord4D;
import mekanism.api.MekanismAPI;
import mekanism.api.chemical.ChemicalStack;
import mekanism.api.chemical.gas.Gas;
import mekanism.api.chemical.gas.GasStack;
import mekanism.api.chemical.infuse.InfuseType;
import mekanism.api.chemical.infuse.InfusionStack;
import mekanism.api.chemical.pigment.Pigment;
import mekanism.api.chemical.pigment.PigmentStack;
import mekanism.api.chemical.slurry.Slurry;
import mekanism.api.chemical.slurry.SlurryStack;

import appeng.api.stacks.AEKey;
Expand All @@ -35,7 +40,6 @@ public class MekanismKey extends AEKey {
private final ChemicalStack<?> stack;

private MekanismKey(ChemicalStack<?> stack) {
super(stack.getTextComponent());
this.stack = stack;
}

Expand Down Expand Up @@ -88,11 +92,6 @@ public Object getPrimaryKey() {
return stack.getType();
}

@Override
public String getModId() {
return stack.getTypeRegistryName().getNamespace();
}

@Override
public ResourceLocation getId() {
return stack.getTypeRegistryName();
Expand All @@ -105,18 +104,33 @@ public void writeToPacket(FriendlyByteBuf data) {
}

@Override
public Component getDisplayName() {
protected Component computeDisplayName() {
return stack.getType().getTextComponent();
}

@Override
public void addDrops(long amount, List<ItemStack> drops, Level level, BlockPos pos) {
if (getStack()instanceof GasStack gasStack) {
if (stack instanceof GasStack gasStack) {
MekanismAPI.getRadiationManager().dumpRadiation(new Coord4D(pos, level),
ChemicalBridge.withAmount(gasStack, amount));
}
}

@Override
public boolean isTagged(TagKey<?> tag) {
if (stack.getType()instanceof Gas gas) {
return tag.registry().equals(MekanismAPI.gasRegistryName()) && gas.is((TagKey<Gas>) tag);
} else if (stack.getType()instanceof InfuseType infuse) {
return tag.registry().equals(MekanismAPI.infuseTypeRegistryName()) && infuse.is((TagKey<InfuseType>) tag);
} else if (stack.getType()instanceof Pigment pigment) {
return tag.registry().equals(MekanismAPI.pigmentRegistryName()) && pigment.is((TagKey<Pigment>) tag);
} else if (stack.getType()instanceof Slurry slurry) {
return tag.registry().equals(MekanismAPI.slurryRegistryName()) && slurry.is((TagKey<Slurry>) tag);
} else {
throw new UnsupportedOperationException();
}
}

@Override
public boolean equals(Object o) {
if (this == o)
Expand Down
20 changes: 17 additions & 3 deletions src/main/java/me/ramidzkh/mekae2/ae2/MekanismKeyType.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
package me.ramidzkh.mekae2.ae2;

import java.util.stream.Stream;

import javax.annotation.Nullable;

import com.google.common.collect.Streams;

import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.chat.Component;
import net.minecraft.tags.TagKey;

import me.ramidzkh.mekae2.AMText;
import me.ramidzkh.mekae2.AppliedMekanistics;
import mekanism.api.MekanismAPI;
import mekanism.api.chemical.gas.GasStack;
import mekanism.api.chemical.infuse.InfusionStack;
import mekanism.api.chemical.pigment.PigmentStack;
Expand All @@ -21,8 +27,7 @@ public class MekanismKeyType extends AEKeyType {
public static final AEKeyType TYPE = new MekanismKeyType();

private MekanismKeyType() {
super(AppliedMekanistics.id("chemical"), MekanismKey.class,
Component.translatable("gui." + AppliedMekanistics.ID + ".chemical"));
super(AppliedMekanistics.id("chemical"), MekanismKey.class, AMText.CHEMICAL.formatted());
}

@Nullable
Expand All @@ -49,6 +54,15 @@ public AEKey loadKeyFromTag(CompoundTag tag) {
};
}

@Override
public Stream<TagKey<?>> getTagNames() {
return Streams.concat(
MekanismAPI.gasRegistry().tags().getTagNames(),
MekanismAPI.infuseTypeRegistry().tags().getTagNames(),
MekanismAPI.pigmentRegistry().tags().getTagNames(),
MekanismAPI.slurryRegistry().tags().getTagNames());
}

// Copied from AEFluidKeys
@Override
public int getAmountPerOperation() {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/me/ramidzkh/mekae2/data/BlockModelProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.util.Locale;

import net.minecraft.data.DataGenerator;
import net.minecraft.data.PackOutput;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.common.data.ExistingFileHelper;

Expand All @@ -15,8 +15,8 @@ public class BlockModelProvider extends net.minecraftforge.client.model.generato

private static final ResourceLocation DRIVE_CELL = AppEng.makeId("block/drive/drive_cell");

public BlockModelProvider(DataGenerator generator, ExistingFileHelper existingFileHelper) {
super(generator, AppliedMekanistics.ID, existingFileHelper);
public BlockModelProvider(PackOutput output, ExistingFileHelper existingFileHelper) {
super(output, AppliedMekanistics.ID, existingFileHelper);

existingFileHelper.trackGenerated(DRIVE_CELL, MODEL);
}
Expand Down
14 changes: 9 additions & 5 deletions src/main/java/me/ramidzkh/mekae2/data/BlockTagsProvider.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
package me.ramidzkh.mekae2.data;

import java.util.concurrent.CompletableFuture;

import org.jetbrains.annotations.Nullable;

import net.minecraft.data.DataGenerator;
import net.minecraft.core.HolderLookup;
import net.minecraft.data.PackOutput;
import net.minecraftforge.common.data.ExistingFileHelper;

import me.ramidzkh.mekae2.AppliedMekanistics;

public class BlockTagsProvider extends net.minecraft.data.tags.BlockTagsProvider {
public class BlockTagsProvider extends net.minecraftforge.common.data.BlockTagsProvider {

public BlockTagsProvider(DataGenerator generator, @Nullable ExistingFileHelper existingFileHelper) {
super(generator, AppliedMekanistics.ID, existingFileHelper);
public BlockTagsProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> lookupProvider,
@Nullable ExistingFileHelper existingFileHelper) {
super(output, lookupProvider, AppliedMekanistics.ID, existingFileHelper);
}

@Override
protected void addTags() {
protected void addTags(HolderLookup.Provider provider) {
}
}
6 changes: 3 additions & 3 deletions src/main/java/me/ramidzkh/mekae2/data/ItemModelProvider.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package me.ramidzkh.mekae2.data;

import net.minecraft.data.DataGenerator;
import net.minecraft.data.PackOutput;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import net.minecraftforge.common.data.ExistingFileHelper;
Expand All @@ -19,8 +19,8 @@ public class ItemModelProvider extends net.minecraftforge.client.model.generator
private static final ResourceLocation PORTABLE_CELL_LED = AppEng.makeId("item/portable_cell_led");
private static final ResourceLocation OSMIUM_BLOCK = new ResourceLocation("mekanism", "block/block_osmium");

public ItemModelProvider(DataGenerator generator, ExistingFileHelper existingFileHelper) {
super(generator, AppliedMekanistics.ID, existingFileHelper);
public ItemModelProvider(PackOutput output, ExistingFileHelper existingFileHelper) {
super(output, AppliedMekanistics.ID, existingFileHelper);

existingFileHelper.trackGenerated(P2P_TUNNEL_BASE_ITEM, MODEL);
existingFileHelper.trackGenerated(P2P_TUNNEL_BASE_PART, MODEL);
Expand Down
Loading

0 comments on commit 22e3887

Please sign in to comment.