Port to 1.18.2
This commit is contained in:
parent
3ed3f43c59
commit
21e847676f
@ -10,6 +10,8 @@ val mod_version: String by project
|
|||||||
val mc_version: String by project
|
val mc_version: String by project
|
||||||
val forge_version: String by project
|
val forge_version: String by project
|
||||||
val mod_id: String by project
|
val mod_id: String by project
|
||||||
|
val handle_deps: String by project
|
||||||
|
val handleDeps = handle_deps == "true"
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
java
|
java
|
||||||
@ -98,13 +100,16 @@ dependencies {
|
|||||||
val jei_version: String by project
|
val jei_version: String by project
|
||||||
val mc_version_weak: String by project
|
val mc_version_weak: String by project
|
||||||
val the_one_probe_version: String by project
|
val the_one_probe_version: String by project
|
||||||
|
val mekanism_version: String by project
|
||||||
|
|
||||||
implementation("mezz.jei:jei-${mc_version}:${jei_version}:deobf")
|
if (handleDeps) {
|
||||||
implementation(fg.deobf(create("mcjty.theoneprobe:theoneprobe:${mc_version_weak}-${the_one_probe_version}", closureOf<Any> {
|
implementation(fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}"))
|
||||||
(this as ExternalModuleDependency).isTransitive = false
|
implementation(fg.deobf(create("mcjty.theoneprobe:theoneprobe:${mc_version_weak}-${the_one_probe_version}", closureOf<Any> {
|
||||||
} as Closure<Any>)))
|
(this as ExternalModuleDependency).isTransitive = false
|
||||||
|
} as Closure<Any>)))
|
||||||
|
|
||||||
implementation(fg.deobf("mekanism:Mekanism:1.18.1-10.1.2.homebaked:all"))
|
implementation(fg.deobf("mekanism:Mekanism:${mc_version}-${mekanism_version}:all"))
|
||||||
|
}
|
||||||
|
|
||||||
library(create("ru.dbotthepony:kvector:1.2.0", closureOf<Any> {
|
library(create("ru.dbotthepony:kvector:1.2.0", closureOf<Any> {
|
||||||
// avoid adding kotlin libraries as dependency twice
|
// avoid adding kotlin libraries as dependency twice
|
||||||
|
@ -7,17 +7,19 @@ kotlin.stdlib.default.dependency=false
|
|||||||
mod_id=overdrive_that_matters
|
mod_id=overdrive_that_matters
|
||||||
mod_version=1.0-SNAPSHOT
|
mod_version=1.0-SNAPSHOT
|
||||||
|
|
||||||
mc_version=1.18.1
|
mc_version=1.18.2
|
||||||
mc_version_weak=1.18
|
mc_version_weak=1.18
|
||||||
forge_gradle_version=5.1.27
|
forge_gradle_version=5.1.27
|
||||||
forge_version=39.0.85
|
forge_version=40.0.32
|
||||||
|
|
||||||
jei_version=9.4.1.106
|
jei_version=9.5.4.171
|
||||||
jupiter_version=5.8.2
|
jupiter_version=5.8.2
|
||||||
the_one_probe_version=5.0.1-5
|
the_one_probe_version=5.1.0
|
||||||
|
mekanism_version=10.1.2.homebaked
|
||||||
|
|
||||||
kotlin_for_forge_version=3.1.0
|
kotlin_for_forge_version=3.1.0
|
||||||
kotlin_version=1.6.10
|
kotlin_version=1.6.10
|
||||||
kotlin_coroutines_version=1.6.0
|
kotlin_coroutines_version=1.6.0
|
||||||
kotlin_serialization_version=1.3.2
|
kotlin_serialization_version=1.3.2
|
||||||
|
|
||||||
|
handle_deps=true
|
||||||
|
@ -32,7 +32,7 @@ import ru.dbotthepony.mc.otm.datagen.loot.TileNbtCopy
|
|||||||
import ru.dbotthepony.mc.otm.datagen.models.BlockMatteryModelProvider
|
import ru.dbotthepony.mc.otm.datagen.models.BlockMatteryModelProvider
|
||||||
import ru.dbotthepony.mc.otm.datagen.recipes.MatteryRecipeProvider
|
import ru.dbotthepony.mc.otm.datagen.recipes.MatteryRecipeProvider
|
||||||
import ru.dbotthepony.mc.otm.datagen.recipes.has
|
import ru.dbotthepony.mc.otm.datagen.recipes.has
|
||||||
import ru.dbotthepony.mc.otm.registry.MTags
|
import ru.dbotthepony.mc.otm.registry.MItemTags
|
||||||
|
|
||||||
@Mod.EventBusSubscriber(modid = DataGen.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
@Mod.EventBusSubscriber(modid = DataGen.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||||
object DataGen {
|
object DataGen {
|
||||||
@ -392,8 +392,8 @@ object DataGen {
|
|||||||
lambda { _, consumer ->
|
lambda { _, consumer ->
|
||||||
ShapelessRecipeBuilder(MItems.INDUSTRIAL_GLASS, 8)
|
ShapelessRecipeBuilder(MItems.INDUSTRIAL_GLASS, 8)
|
||||||
.requires(net.minecraft.world.item.Items.GLASS, 8)
|
.requires(net.minecraft.world.item.Items.GLASS, 8)
|
||||||
.requires(MTags.Items.PLATE_TRITANIUM)
|
.requires(MItemTags.PLATE_TRITANIUM)
|
||||||
.unlockedBy("has_plate", has(MTags.Items.PLATE_TRITANIUM))
|
.unlockedBy("has_plate", has(MItemTags.PLATE_TRITANIUM))
|
||||||
.unlockedBy("has_glass", has(net.minecraft.world.item.Items.GLASS))
|
.unlockedBy("has_glass", has(net.minecraft.world.item.Items.GLASS))
|
||||||
.save(consumer)
|
.save(consumer)
|
||||||
|
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
package ru.dbotthepony.mc.otm.datagen.items
|
|
||||||
|
|
||||||
import net.minecraft.resources.ResourceLocation
|
|
||||||
import net.minecraft.tags.Tag
|
|
||||||
import net.minecraft.world.item.Item
|
|
||||||
|
|
||||||
class DummyItemTag(private val name: ResourceLocation) : Tag.Named<Item> {
|
|
||||||
override fun contains(p_13287_: Item) = false
|
|
||||||
override fun getValues() = emptyList<Item>()
|
|
||||||
override fun getName() = name
|
|
||||||
}
|
|
@ -9,6 +9,7 @@ import net.minecraft.data.recipes.FinishedRecipe
|
|||||||
import net.minecraft.data.recipes.RecipeProvider
|
import net.minecraft.data.recipes.RecipeProvider
|
||||||
import net.minecraft.resources.ResourceLocation
|
import net.minecraft.resources.ResourceLocation
|
||||||
import net.minecraft.tags.Tag
|
import net.minecraft.tags.Tag
|
||||||
|
import net.minecraft.tags.TagKey
|
||||||
import net.minecraft.world.item.Item
|
import net.minecraft.world.item.Item
|
||||||
import net.minecraft.world.item.crafting.Ingredient
|
import net.minecraft.world.item.crafting.Ingredient
|
||||||
import net.minecraft.world.level.ItemLike
|
import net.minecraft.world.level.ItemLike
|
||||||
@ -26,7 +27,7 @@ fun has(p_125978_: ItemLike): InventoryChangeTrigger.TriggerInstance {
|
|||||||
return inventoryTrigger(ItemPredicate.Builder.item().of(p_125978_).build())
|
return inventoryTrigger(ItemPredicate.Builder.item().of(p_125978_).build())
|
||||||
}
|
}
|
||||||
|
|
||||||
fun has(p_125976_: Tag<Item>): InventoryChangeTrigger.TriggerInstance {
|
fun has(p_125976_: TagKey<Item>): InventoryChangeTrigger.TriggerInstance {
|
||||||
return inventoryTrigger(ItemPredicate.Builder.item().of(p_125976_).build())
|
return inventoryTrigger(ItemPredicate.Builder.item().of(p_125976_).build())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ import net.minecraft.world.item.CreativeModeTab;
|
|||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.fml.ModList;
|
import net.minecraftforge.fml.ModList;
|
||||||
import net.minecraftforge.fml.ModLoader;
|
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||||
|
@ -4,10 +4,9 @@ import net.minecraft.ChatFormatting;
|
|||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.chat.TranslatableComponent;
|
import net.minecraft.network.chat.TranslatableComponent;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.Items;
|
import net.minecraft.world.item.Items;
|
||||||
import net.minecraftforge.registries.RegistryManager;
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
import ru.dbotthepony.mc.otm.client.render.SkinElement;
|
import ru.dbotthepony.mc.otm.client.render.SkinElement;
|
||||||
import ru.dbotthepony.mc.otm.registry.MRegistry;
|
import ru.dbotthepony.mc.otm.registry.MRegistry;
|
||||||
|
|
||||||
@ -17,6 +16,7 @@ import java.util.List;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public class AndroidResearchBuilder {
|
public class AndroidResearchBuilder {
|
||||||
record DeferredItemStack(ResourceLocation id, int amount) {
|
record DeferredItemStack(ResourceLocation id, int amount) {
|
||||||
}
|
}
|
||||||
@ -171,7 +171,7 @@ public class AndroidResearchBuilder {
|
|||||||
resolved = true;
|
resolved = true;
|
||||||
|
|
||||||
for (var item : items) {
|
for (var item : items) {
|
||||||
var get_item = RegistryManager.ACTIVE.getRegistry(Item.class).getValue(item.id);
|
var get_item = ForgeRegistries.ITEMS.getValue(item.id);
|
||||||
|
|
||||||
if (get_item != null && get_item != Items.AIR) {
|
if (get_item != null && get_item != Items.AIR) {
|
||||||
resolved_stacks.add(new ItemStack(get_item, item.amount));
|
resolved_stacks.add(new ItemStack(get_item, item.amount));
|
||||||
|
@ -8,10 +8,10 @@ import net.minecraft.resources.ResourceLocation;
|
|||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.Items;
|
import net.minecraft.world.item.Items;
|
||||||
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
import net.minecraftforge.registries.ForgeRegistry;
|
import net.minecraftforge.registries.ForgeRegistry;
|
||||||
import net.minecraftforge.registries.RegistryManager;
|
import net.minecraftforge.registries.RegistryManager;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import javax.annotation.ParametersAreNonnullByDefault;
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@ -87,7 +87,7 @@ public record MatterTask(UUID id, @Nullable UUID pattern, Item item, int in_prog
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (nbt instanceof CompoundTag tag) {
|
if (nbt instanceof CompoundTag tag) {
|
||||||
Item get_item = RegistryManager.ACTIVE.getRegistry(Item.class).getValue(new ResourceLocation(tag.getString("item")));
|
Item get_item = ForgeRegistries.ITEMS.getValue(new ResourceLocation(tag.getString("item")));
|
||||||
|
|
||||||
if (get_item != null && get_item != Items.AIR) {
|
if (get_item != null && get_item != Items.AIR) {
|
||||||
long a = tag.getLong("pattern_u");
|
long a = tag.getLong("pattern_u");
|
||||||
@ -122,7 +122,7 @@ public record MatterTask(UUID id, @Nullable UUID pattern, Item item, int in_prog
|
|||||||
buffer.writeBoolean(false);
|
buffer.writeBoolean(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer.writeInt(((ForgeRegistry<Item>) RegistryManager.ACTIVE.getRegistry(Item.class)).getID(item));
|
buffer.writeInt(((ForgeRegistry<Item>) ForgeRegistries.ITEMS).getID(item));
|
||||||
buffer.writeInt(in_progress);
|
buffer.writeInt(in_progress);
|
||||||
buffer.writeInt(finished);
|
buffer.writeInt(finished);
|
||||||
buffer.writeInt(required);
|
buffer.writeInt(required);
|
||||||
@ -132,7 +132,7 @@ public record MatterTask(UUID id, @Nullable UUID pattern, Item item, int in_prog
|
|||||||
public static MatterTask read(FriendlyByteBuf buffer) {
|
public static MatterTask read(FriendlyByteBuf buffer) {
|
||||||
var id = new UUID(buffer.readLong(), buffer.readLong());
|
var id = new UUID(buffer.readLong(), buffer.readLong());
|
||||||
var pattern = buffer.readBoolean() ? new UUID(buffer.readLong(), buffer.readLong()) : null;
|
var pattern = buffer.readBoolean() ? new UUID(buffer.readLong(), buffer.readLong()) : null;
|
||||||
var item = ((ForgeRegistry<Item>) RegistryManager.ACTIVE.getRegistry(Item.class)).getValue(buffer.readInt());
|
var item = ((ForgeRegistry<Item>) ForgeRegistries.ITEMS).getValue(buffer.readInt());
|
||||||
|
|
||||||
if (item == null)
|
if (item == null)
|
||||||
return null;
|
return null;
|
||||||
|
@ -6,6 +6,7 @@ import net.minecraft.network.FriendlyByteBuf;
|
|||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
import net.minecraftforge.registries.ForgeRegistry;
|
import net.minecraftforge.registries.ForgeRegistry;
|
||||||
import net.minecraftforge.registries.RegistryManager;
|
import net.minecraftforge.registries.RegistryManager;
|
||||||
|
|
||||||
@ -52,7 +53,7 @@ public record PatternState(@Nonnull UUID id, @Nonnull Item item, double research
|
|||||||
@Nullable
|
@Nullable
|
||||||
public static PatternState deserializeNBT(Tag nbt) {
|
public static PatternState deserializeNBT(Tag nbt) {
|
||||||
if (nbt instanceof CompoundTag tag) {
|
if (nbt instanceof CompoundTag tag) {
|
||||||
var item = RegistryManager.ACTIVE.getRegistry(Item.class).getValue(new ResourceLocation(tag.getString("item")));
|
var item = ForgeRegistries.ITEMS.getValue(new ResourceLocation(tag.getString("item")));
|
||||||
|
|
||||||
if (item == null)
|
if (item == null)
|
||||||
return null;
|
return null;
|
||||||
@ -70,7 +71,7 @@ public record PatternState(@Nonnull UUID id, @Nonnull Item item, double research
|
|||||||
buffer.writeLong(id.getMostSignificantBits());
|
buffer.writeLong(id.getMostSignificantBits());
|
||||||
buffer.writeLong(id.getLeastSignificantBits());
|
buffer.writeLong(id.getLeastSignificantBits());
|
||||||
|
|
||||||
buffer.writeInt(((ForgeRegistry<Item>) RegistryManager.ACTIVE.getRegistry(Item.class)).getID(item));
|
buffer.writeInt(((ForgeRegistry<Item>) ForgeRegistries.ITEMS).getID(item));
|
||||||
|
|
||||||
buffer.writeDouble(research);
|
buffer.writeDouble(research);
|
||||||
}
|
}
|
||||||
@ -83,7 +84,7 @@ public record PatternState(@Nonnull UUID id, @Nonnull Item item, double research
|
|||||||
int item = buffer.readInt();
|
int item = buffer.readInt();
|
||||||
double percent = buffer.readDouble();
|
double percent = buffer.readDouble();
|
||||||
|
|
||||||
Item get_item = ((ForgeRegistry<Item>) RegistryManager.ACTIVE.getRegistry(Item.class)).getValue(item);
|
Item get_item = ((ForgeRegistry<Item>) ForgeRegistries.ITEMS).getValue(item);
|
||||||
|
|
||||||
if (get_item == null)
|
if (get_item == null)
|
||||||
return null;
|
return null;
|
||||||
|
@ -23,8 +23,6 @@ import ru.dbotthepony.mc.otm.OverdriveThatMatters;
|
|||||||
import ru.dbotthepony.mc.otm.capability.android.AndroidCapabilityPlayer;
|
import ru.dbotthepony.mc.otm.capability.android.AndroidCapabilityPlayer;
|
||||||
import ru.dbotthepony.mc.otm.capability.android.IAndroidCapability;
|
import ru.dbotthepony.mc.otm.capability.android.IAndroidCapability;
|
||||||
import ru.dbotthepony.mc.otm.capability.MatteryCapability;
|
import ru.dbotthepony.mc.otm.capability.MatteryCapability;
|
||||||
import ru.dbotthepony.mc.otm.core.Fraction;
|
|
||||||
import ru.dbotthepony.mc.otm.core.ImpreciseFraction;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
@ -7,15 +7,11 @@ package ru.dbotthepony.mc.otm.client.model;
|
|||||||
|
|
||||||
import net.minecraft.MethodsReturnNonnullByDefault;
|
import net.minecraft.MethodsReturnNonnullByDefault;
|
||||||
import net.minecraft.client.model.HumanoidModel;
|
import net.minecraft.client.model.HumanoidModel;
|
||||||
import net.minecraft.client.model.geom.LayerDefinitions;
|
|
||||||
import net.minecraft.client.model.geom.ModelLayerLocation;
|
import net.minecraft.client.model.geom.ModelLayerLocation;
|
||||||
import net.minecraft.client.model.geom.ModelLayers;
|
import net.minecraft.client.model.geom.ModelLayers;
|
||||||
import net.minecraft.client.model.geom.PartPose;
|
import net.minecraft.client.model.geom.PartPose;
|
||||||
import net.minecraft.client.model.geom.builders.*;
|
import net.minecraft.client.model.geom.builders.*;
|
||||||
import net.minecraft.client.player.AbstractClientPlayer;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraftforge.client.ForgeHooksClient;
|
import net.minecraftforge.client.ForgeHooksClient;
|
||||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters;
|
|
||||||
|
|
||||||
import javax.annotation.ParametersAreNonnullByDefault;
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
|
||||||
|
@ -109,8 +109,9 @@ public class MatterPanelScreen extends MatteryScreen<MatterPanelMenu> {
|
|||||||
return menu.patterns.get(slot1).stack();
|
return menu.patterns.get(slot1).stack();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
protected List<Component> getItemStackTooltip(ItemStack stack) {
|
protected List<Component> getItemStackTooltip(@Nonnull ItemStack stack) {
|
||||||
var slot1 = slot + scroll_panel.getScroll(menu.patterns.size() / GRID_WIDTH) * GRID_WIDTH;
|
var slot1 = slot + scroll_panel.getScroll(menu.patterns.size() / GRID_WIDTH) * GRID_WIDTH;
|
||||||
|
|
||||||
if (slot1 >= menu.patterns.size()) {
|
if (slot1 >= menu.patterns.size()) {
|
||||||
@ -151,8 +152,9 @@ public class MatterPanelScreen extends MatteryScreen<MatterPanelMenu> {
|
|||||||
return task.stack(Math.max(task.required(), 1));
|
return task.stack(Math.max(task.required(), 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
protected List<Component> getItemStackTooltip(ItemStack stack) {
|
protected List<Component> getItemStackTooltip(@Nonnull ItemStack stack) {
|
||||||
var slot1 = slot + scroll_panel.getScroll(menu.tasks.size() / GRID_WIDTH) * GRID_WIDTH;
|
var slot1 = slot + scroll_panel.getScroll(menu.tasks.size() / GRID_WIDTH) * GRID_WIDTH;
|
||||||
|
|
||||||
if (slot1 >= menu.tasks.size()) {
|
if (slot1 >= menu.tasks.size()) {
|
||||||
@ -228,8 +230,9 @@ public class MatterPanelScreen extends MatteryScreen<MatterPanelMenu> {
|
|||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
protected List<Component> getItemStackTooltip(ItemStack stack) {
|
protected List<Component> getItemStackTooltip(@Nonnull ItemStack stack) {
|
||||||
var task1_index = menu.tasks.indexOf(task);
|
var task1_index = menu.tasks.indexOf(task);
|
||||||
List<Component> get_list = super.getItemStackTooltip(stack);
|
List<Component> get_list = super.getItemStackTooltip(stack);
|
||||||
|
|
||||||
@ -299,15 +302,16 @@ public class MatterPanelScreen extends MatteryScreen<MatterPanelMenu> {
|
|||||||
return new ItemStack(state.item(), 1);
|
return new ItemStack(state.item(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
protected List<Component> getItemStackTooltip(ItemStack stack) {
|
protected List<Component> getItemStackTooltip(@Nonnull ItemStack stack) {
|
||||||
return getPatternTooltip(super.getItemStackTooltip(stack), state);
|
return getPatternTooltip(super.getItemStackTooltip(stack), state);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var input_amount = new EditBoxPanel(this, row_2, 0, 0, 10, 20, new TextComponent("Input amount")) {
|
var input_amount = new EditBoxPanel(this, row_2, 0, 0, 10, 20, new TextComponent("Input amount")) {
|
||||||
@Override
|
@Override
|
||||||
protected void configureNew(EditBox widget, boolean recreation) {
|
protected void configureNew(@Nonnull EditBox widget, boolean recreation) {
|
||||||
super.configureNew(widget, recreation);
|
super.configureNew(widget, recreation);
|
||||||
|
|
||||||
widget.setMaxLength(6);
|
widget.setMaxLength(6);
|
||||||
|
@ -58,7 +58,7 @@ public class SlotPanel<T extends MatterySlot> extends AbstractSlotPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void innerRender(PoseStack stack, float mouse_x, float mouse_y, float flag) {
|
protected void innerRender(@Nonnull PoseStack stack, float mouse_x, float mouse_y, float flag) {
|
||||||
renderSlotBackground(stack, mouse_x, mouse_y, flag);
|
renderSlotBackground(stack, mouse_x, mouse_y, flag);
|
||||||
|
|
||||||
var itemstack = slot.getItem();
|
var itemstack = slot.getItem();
|
||||||
@ -103,7 +103,7 @@ public class SlotPanel<T extends MatterySlot> extends AbstractSlotPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean innerRenderTooltips(PoseStack stack, float mouse_x, float mouse_y, float flag) {
|
protected boolean innerRenderTooltips(@Nonnull PoseStack stack, float mouse_x, float mouse_y, float flag) {
|
||||||
// no op, screen does it for us (completely)
|
// no op, screen does it for us (completely)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -2,16 +2,13 @@ package ru.dbotthepony.mc.otm.menu;
|
|||||||
|
|
||||||
import net.minecraft.MethodsReturnNonnullByDefault;
|
import net.minecraft.MethodsReturnNonnullByDefault;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.chat.FormattedText;
|
|
||||||
import net.minecraft.network.chat.TextComponent;
|
import net.minecraft.network.chat.TextComponent;
|
||||||
import net.minecraft.network.chat.TranslatableComponent;
|
import net.minecraft.network.chat.TranslatableComponent;
|
||||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters;
|
|
||||||
import ru.dbotthepony.mc.otm.core.Fraction;
|
import ru.dbotthepony.mc.otm.core.Fraction;
|
||||||
import ru.dbotthepony.mc.otm.core.ImpreciseFraction;
|
import ru.dbotthepony.mc.otm.core.ImpreciseFraction;
|
||||||
|
|
||||||
import javax.annotation.ParametersAreNonnullByDefault;
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.BigInteger;
|
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -6,11 +6,8 @@ import net.minecraftforge.api.distmarker.Dist;
|
|||||||
import net.minecraftforge.fml.DistExecutor;
|
import net.minecraftforge.fml.DistExecutor;
|
||||||
import net.minecraftforge.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
import ru.dbotthepony.mc.otm.capability.MatteryCapability;
|
import ru.dbotthepony.mc.otm.capability.MatteryCapability;
|
||||||
import ru.dbotthepony.mc.otm.core.Fraction;
|
|
||||||
import ru.dbotthepony.mc.otm.core.ImpreciseFraction;
|
import ru.dbotthepony.mc.otm.core.ImpreciseFraction;
|
||||||
import ru.dbotthepony.mc.otm.network.NetworkHelper;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public record AndroidEnergyPacket(boolean is_maximal, ImpreciseFraction energy) {
|
public record AndroidEnergyPacket(boolean is_maximal, ImpreciseFraction energy) {
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
package ru.dbotthepony.mc.otm.registry;
|
|
||||||
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.tags.ItemTags;
|
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
import net.minecraftforge.common.Tags;
|
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class MTags {
|
|
||||||
public static class Items {
|
|
||||||
public static final Tags.IOptionalNamedTag<Item> INGOT_TRITANIUM = ItemTags.createOptional(new ResourceLocation("forge", "ingots/tritanium"), Set.of(MItems.INSTANCE::getTRITANIUM_INGOT));
|
|
||||||
public static final Tags.IOptionalNamedTag<Item> PLATE_TRITANIUM = ItemTags.createOptional(new ResourceLocation("forge", "plates/tritanium"), Set.of(MItems.INSTANCE::getTRITANIUM_PLATE));
|
|
||||||
}
|
|
||||||
}
|
|
@ -164,7 +164,7 @@ inline fun <T> LazyOptional<T>.ifPresentK(lambda: (T) -> Unit) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val ItemStack.tagNotNull get() = orCreateTag
|
val ItemStack.tagNotNull: CompoundTag get() = orCreateTag
|
||||||
|
|
||||||
inline var Entity.position: Vec3
|
inline var Entity.position: Vec3
|
||||||
get() = position()
|
get() = position()
|
||||||
|
@ -8,9 +8,11 @@ import net.minecraftforge.event.TickEvent
|
|||||||
import net.minecraftforge.event.TickEvent.ServerTickEvent
|
import net.minecraftforge.event.TickEvent.ServerTickEvent
|
||||||
import net.minecraftforge.event.TickEvent.WorldTickEvent
|
import net.minecraftforge.event.TickEvent.WorldTickEvent
|
||||||
import net.minecraftforge.event.server.ServerAboutToStartEvent
|
import net.minecraftforge.event.server.ServerAboutToStartEvent
|
||||||
|
import net.minecraftforge.event.server.ServerStoppedEvent
|
||||||
import net.minecraftforge.event.server.ServerStoppingEvent
|
import net.minecraftforge.event.server.ServerStoppingEvent
|
||||||
import net.minecraftforge.eventbus.api.EventPriority
|
import net.minecraftforge.eventbus.api.EventPriority
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent
|
import net.minecraftforge.eventbus.api.SubscribeEvent
|
||||||
|
import org.apache.logging.log4j.LogManager
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.collections.ArrayList
|
import kotlin.collections.ArrayList
|
||||||
|
|
||||||
@ -24,6 +26,13 @@ private val postWorldTick = WeakHashMap<Level, ArrayList<IConditionalTickable>>(
|
|||||||
private val preWorldTickOnce = WeakHashMap<Level, ArrayList<ITickable>>()
|
private val preWorldTickOnce = WeakHashMap<Level, ArrayList<ITickable>>()
|
||||||
private val postWorldTickOnce = WeakHashMap<Level, ArrayList<ITickable>>()
|
private val postWorldTickOnce = WeakHashMap<Level, ArrayList<ITickable>>()
|
||||||
|
|
||||||
|
// Flag whenever is server alive
|
||||||
|
// To avoid baby deadlocks caused by minecraft engine design issues
|
||||||
|
var SERVER_IS_DYING = true
|
||||||
|
private set
|
||||||
|
|
||||||
|
private val LOGGER = LogManager.getLogger()
|
||||||
|
|
||||||
fun interface ITickable {
|
fun interface ITickable {
|
||||||
fun tick()
|
fun tick()
|
||||||
}
|
}
|
||||||
@ -73,18 +82,38 @@ fun onServerTick(event: ServerTickEvent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun addPreServerTicker(ticker: IConditionalTickable) {
|
fun addPreServerTicker(ticker: IConditionalTickable) {
|
||||||
|
if (SERVER_IS_DYING) {
|
||||||
|
LOGGER.error("Refusing to add ticker $ticker while server is dying", IllegalStateException("Server is stopping"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
preServerTick.add(ticker)
|
preServerTick.add(ticker)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addPostServerTicker(ticker: IConditionalTickable) {
|
fun addPostServerTicker(ticker: IConditionalTickable) {
|
||||||
|
if (SERVER_IS_DYING) {
|
||||||
|
LOGGER.error("Refusing to add ticker $ticker while server is dying", IllegalStateException("Server is stopping"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
postServerTick.add(ticker)
|
postServerTick.add(ticker)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addPreServerTickerOnce(ticker: ITickable) {
|
fun addPreServerTickerOnce(ticker: ITickable) {
|
||||||
|
if (SERVER_IS_DYING) {
|
||||||
|
LOGGER.error("Refusing to add ticker $ticker while server is dying", IllegalStateException("Server is stopping"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
preServerTickOnce.add(ticker)
|
preServerTickOnce.add(ticker)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addPostServerTickerOnce(ticker: ITickable) {
|
fun addPostServerTickerOnce(ticker: ITickable) {
|
||||||
|
if (SERVER_IS_DYING) {
|
||||||
|
LOGGER.error("Refusing to add ticker $ticker while server is dying", IllegalStateException("Server is stopping"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
postServerTickOnce.add(ticker)
|
postServerTickOnce.add(ticker)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,18 +169,38 @@ fun onWorldTick(event: WorldTickEvent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun addPreWorldTicker(level: Level, ticker: IConditionalTickable) {
|
fun addPreWorldTicker(level: Level, ticker: IConditionalTickable) {
|
||||||
|
if (SERVER_IS_DYING) {
|
||||||
|
LOGGER.error("Refusing to add ticker $ticker while server is dying", IllegalStateException("Server is stopping"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
preWorldTick.computeIfAbsent(level) { ArrayList() }.add(ticker)
|
preWorldTick.computeIfAbsent(level) { ArrayList() }.add(ticker)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addPostWorldTicker(level: Level, ticker: IConditionalTickable) {
|
fun addPostWorldTicker(level: Level, ticker: IConditionalTickable) {
|
||||||
|
if (SERVER_IS_DYING) {
|
||||||
|
LOGGER.error("Refusing to add ticker $ticker while server is dying", IllegalStateException("Server is stopping"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
postWorldTick.computeIfAbsent(level) { ArrayList() }.add(ticker)
|
postWorldTick.computeIfAbsent(level) { ArrayList() }.add(ticker)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addPreWorldTickerOnce(level: Level, ticker: ITickable) {
|
fun addPreWorldTickerOnce(level: Level, ticker: ITickable) {
|
||||||
|
if (SERVER_IS_DYING) {
|
||||||
|
LOGGER.error("Refusing to add ticker $ticker while server is dying", IllegalStateException("Server is stopping"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
preWorldTickOnce.computeIfAbsent(level) { ArrayList() }.add(ticker)
|
preWorldTickOnce.computeIfAbsent(level) { ArrayList() }.add(ticker)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addPostWorldTickerOnce(level: Level, ticker: ITickable) {
|
fun addPostWorldTickerOnce(level: Level, ticker: ITickable) {
|
||||||
|
if (SERVER_IS_DYING) {
|
||||||
|
LOGGER.error("Refusing to add ticker $ticker while server is dying", IllegalStateException("Server is stopping"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
postWorldTickOnce.computeIfAbsent(level) { ArrayList() }.add(ticker)
|
postWorldTickOnce.computeIfAbsent(level) { ArrayList() }.add(ticker)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,9 +218,21 @@ private fun clear() {
|
|||||||
@SubscribeEvent(priority = EventPriority.HIGHEST)
|
@SubscribeEvent(priority = EventPriority.HIGHEST)
|
||||||
fun onServerStarting(event: ServerAboutToStartEvent?) {
|
fun onServerStarting(event: ServerAboutToStartEvent?) {
|
||||||
clear()
|
clear()
|
||||||
|
SERVER_IS_DYING = false
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent(priority = EventPriority.HIGHEST)
|
@SubscribeEvent(priority = EventPriority.HIGHEST)
|
||||||
fun onServerStopping(event: ServerStoppingEvent?) {
|
fun onServerStopping(event: ServerStoppingEvent?) {
|
||||||
clear()
|
clear()
|
||||||
|
SERVER_IS_DYING = true
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent(priority = EventPriority.HIGHEST)
|
||||||
|
fun onServerStopped(event: ServerStoppedEvent?) {
|
||||||
|
if (!SERVER_IS_DYING) {
|
||||||
|
LOGGER.fatal("ServerStoppingEvent did not fire. If server has crashed this is normal. However, if server finished it's work 'gracefully' this is a bug.")
|
||||||
|
|
||||||
|
clear()
|
||||||
|
SERVER_IS_DYING = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,6 +57,6 @@ class CargoCrateBlock : RotatableMatteryBlock(), EntityBlock {
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@JvmField
|
@JvmField
|
||||||
val IS_OPEN = BooleanProperty.create("open")
|
val IS_OPEN: BooleanProperty = BooleanProperty.create("open")
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -42,6 +42,6 @@ class DriveViewerBlock : RotatableMatteryBlock(), EntityBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val DRIVE_PRESENT = BooleanProperty.create("drive")
|
val DRIVE_PRESENT: BooleanProperty = BooleanProperty.create("drive")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ import net.minecraft.world.level.block.state.StateDefinition
|
|||||||
import net.minecraft.world.level.block.state.properties.EnumProperty
|
import net.minecraft.world.level.block.state.properties.EnumProperty
|
||||||
import net.minecraft.world.phys.shapes.CollisionContext
|
import net.minecraft.world.phys.shapes.CollisionContext
|
||||||
import net.minecraft.world.phys.shapes.VoxelShape
|
import net.minecraft.world.phys.shapes.VoxelShape
|
||||||
|
import ru.dbotthepony.mc.otm.SERVER_IS_DYING
|
||||||
import ru.dbotthepony.mc.otm.block.entity.EnergyCounterBlockEntity
|
import ru.dbotthepony.mc.otm.block.entity.EnergyCounterBlockEntity
|
||||||
import ru.dbotthepony.mc.otm.registry.MBlockEntities
|
import ru.dbotthepony.mc.otm.registry.MBlockEntities
|
||||||
import ru.dbotthepony.mc.otm.shapes.BlockShapes
|
import ru.dbotthepony.mc.otm.shapes.BlockShapes
|
||||||
@ -70,8 +71,8 @@ class EnergyCounterBlock : MatteryBlock(), EntityBlock {
|
|||||||
) {
|
) {
|
||||||
super.neighborChanged(state, level, pos, sender, sender_pos, flag)
|
super.neighborChanged(state, level, pos, sender, sender_pos, flag)
|
||||||
|
|
||||||
if (!level.isClientSide) {
|
if (!level.isClientSide && !SERVER_IS_DYING) {
|
||||||
(level.getBlockEntity(pos) as? EnergyCounterBlockEntity)?.checkSurroundings(level)
|
(level.getBlockEntity(pos) as? EnergyCounterBlockEntity)?.checkSurroundings()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,6 +98,6 @@ class MatterPanelBlock : MatteryBlock(), EntityBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val FACING = EnumProperty.create("facing", Direction::class.java)
|
val FACING: EnumProperty<Direction> = EnumProperty.create("facing", Direction::class.java)
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -120,7 +120,7 @@ abstract class RotatableMatteryBlock @JvmOverloads constructor(properties: Prope
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@JvmField
|
@JvmField
|
||||||
val FACING = EnumProperty.create(
|
val FACING: EnumProperty<Direction> = EnumProperty.create(
|
||||||
"facing",
|
"facing",
|
||||||
Direction::class.java,
|
Direction::class.java,
|
||||||
Direction.SOUTH,
|
Direction.SOUTH,
|
||||||
@ -130,6 +130,6 @@ abstract class RotatableMatteryBlock @JvmOverloads constructor(properties: Prope
|
|||||||
)
|
)
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
val FACING_FULL = EnumProperty.create("facing", Direction::class.java)
|
val FACING_FULL: EnumProperty<Direction> = EnumProperty.create("facing", Direction::class.java)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,16 +19,14 @@ import net.minecraftforge.common.util.LazyOptional
|
|||||||
import net.minecraftforge.energy.CapabilityEnergy
|
import net.minecraftforge.energy.CapabilityEnergy
|
||||||
import net.minecraftforge.energy.IEnergyStorage
|
import net.minecraftforge.energy.IEnergyStorage
|
||||||
import net.minecraftforge.items.CapabilityItemHandler
|
import net.minecraftforge.items.CapabilityItemHandler
|
||||||
|
import ru.dbotthepony.mc.otm.*
|
||||||
import ru.dbotthepony.mc.otm.block.BatteryBankBlock
|
import ru.dbotthepony.mc.otm.block.BatteryBankBlock
|
||||||
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
||||||
import ru.dbotthepony.mc.otm.capability.*
|
import ru.dbotthepony.mc.otm.capability.*
|
||||||
import ru.dbotthepony.mc.otm.container.MatteryContainer
|
import ru.dbotthepony.mc.otm.container.MatteryContainer
|
||||||
import ru.dbotthepony.mc.otm.core.ImpreciseFraction
|
import ru.dbotthepony.mc.otm.core.ImpreciseFraction
|
||||||
import ru.dbotthepony.mc.otm.ifPresentK
|
|
||||||
import ru.dbotthepony.mc.otm.menu.BatteryBankMenu
|
import ru.dbotthepony.mc.otm.menu.BatteryBankMenu
|
||||||
import ru.dbotthepony.mc.otm.registry.MBlockEntities
|
import ru.dbotthepony.mc.otm.registry.MBlockEntities
|
||||||
import ru.dbotthepony.mc.otm.set
|
|
||||||
import ru.dbotthepony.mc.otm.unaryMinus
|
|
||||||
import javax.annotation.ParametersAreNonnullByDefault
|
import javax.annotation.ParametersAreNonnullByDefault
|
||||||
|
|
||||||
@MethodsReturnNonnullByDefault
|
@MethodsReturnNonnullByDefault
|
||||||
@ -282,7 +280,7 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte
|
|||||||
@Suppress("name_shadowing")
|
@Suppress("name_shadowing")
|
||||||
val level = this.level
|
val level = this.level
|
||||||
|
|
||||||
if (level is ServerLevel)
|
if (level is ServerLevel && !SERVER_IS_DYING)
|
||||||
checkSurroundings(level)
|
checkSurroundings(level)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,8 @@ class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryBl
|
|||||||
val ref = WeakReference(this)
|
val ref = WeakReference(this)
|
||||||
|
|
||||||
resolver.addListener {
|
resolver.addListener {
|
||||||
ref.get()?.checkSurroundings()
|
if (!SERVER_IS_DYING)
|
||||||
|
ref.get()?.checkSurroundings()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -379,8 +379,7 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat
|
|||||||
resolverOutputMekanism = LazyOptional.of { MatteryToMekanismEnergyWrapper(energyInput) }
|
resolverOutputMekanism = LazyOptional.of { MatteryToMekanismEnergyWrapper(energyInput) }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (level != null)
|
checkSurroundings()
|
||||||
checkSurroundings(level)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -396,11 +395,8 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat
|
|||||||
val weak = WeakReference(this)
|
val weak = WeakReference(this)
|
||||||
|
|
||||||
resolve.addListener {
|
resolve.addListener {
|
||||||
val get = weak.get()
|
if (!SERVER_IS_DYING)
|
||||||
|
weak.get()?.checkSurroundings()
|
||||||
if (get?.level != null) {
|
|
||||||
get.checkSurroundings(get.level)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return resolve
|
return resolve
|
||||||
@ -409,7 +405,8 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat
|
|||||||
return old
|
return old
|
||||||
}
|
}
|
||||||
|
|
||||||
fun checkSurroundings(level: Level?) {
|
fun checkSurroundings() {
|
||||||
|
val level = level
|
||||||
if (isRemoved || level !is ServerLevel) return
|
if (isRemoved || level !is ServerLevel) return
|
||||||
|
|
||||||
inputCapability = getAndBind(
|
inputCapability = getAndBind(
|
||||||
|
@ -19,16 +19,14 @@ import net.minecraftforge.common.capabilities.Capability
|
|||||||
import net.minecraftforge.common.util.LazyOptional
|
import net.minecraftforge.common.util.LazyOptional
|
||||||
import net.minecraftforge.items.CapabilityItemHandler
|
import net.minecraftforge.items.CapabilityItemHandler
|
||||||
import net.minecraftforge.items.IItemHandler
|
import net.minecraftforge.items.IItemHandler
|
||||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
import ru.dbotthepony.mc.otm.*
|
||||||
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
||||||
import ru.dbotthepony.mc.otm.capability.MatteryCapability
|
import ru.dbotthepony.mc.otm.capability.MatteryCapability
|
||||||
import ru.dbotthepony.mc.otm.capability.WorkerEnergyStorage
|
import ru.dbotthepony.mc.otm.capability.WorkerEnergyStorage
|
||||||
import ru.dbotthepony.mc.otm.core.ImpreciseFraction
|
import ru.dbotthepony.mc.otm.core.ImpreciseFraction
|
||||||
import ru.dbotthepony.mc.otm.core.plus
|
import ru.dbotthepony.mc.otm.core.plus
|
||||||
import ru.dbotthepony.mc.otm.get
|
|
||||||
import ru.dbotthepony.mc.otm.graph.storage.BasicStorageGraphNode
|
import ru.dbotthepony.mc.otm.graph.storage.BasicStorageGraphNode
|
||||||
import ru.dbotthepony.mc.otm.graph.storage.StorageNetworkGraph
|
import ru.dbotthepony.mc.otm.graph.storage.StorageNetworkGraph
|
||||||
import ru.dbotthepony.mc.otm.orThrow
|
|
||||||
import ru.dbotthepony.mc.otm.registry.MBlockEntities
|
import ru.dbotthepony.mc.otm.registry.MBlockEntities
|
||||||
import ru.dbotthepony.mc.otm.registry.MNames
|
import ru.dbotthepony.mc.otm.registry.MNames
|
||||||
import ru.dbotthepony.mc.otm.storage.*
|
import ru.dbotthepony.mc.otm.storage.*
|
||||||
@ -361,6 +359,9 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun checkSurroundings() {
|
fun checkSurroundings() {
|
||||||
|
if (isRemoved)
|
||||||
|
return
|
||||||
|
|
||||||
val front = blockPos + blockState.getValue(RotatableMatteryBlock.FACING_FULL)
|
val front = blockPos + blockState.getValue(RotatableMatteryBlock.FACING_FULL)
|
||||||
val storage = level?.getBlockEntity(front)?.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)?.let { if (it.isPresent) it else null }
|
val storage = level?.getBlockEntity(front)?.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)?.let { if (it.isPresent) it else null }
|
||||||
|
|
||||||
@ -373,8 +374,9 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter
|
|||||||
storage.addListener {
|
storage.addListener {
|
||||||
val self = ref.get() ?: return@addListener
|
val self = ref.get() ?: return@addListener
|
||||||
|
|
||||||
if (self.neighbour === it)
|
if (self.neighbour === it && !SERVER_IS_DYING) {
|
||||||
self.checkSurroundings()
|
self.checkSurroundings()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
component?.let(cell::removeStorageComponent)
|
component?.let(cell::removeStorageComponent)
|
||||||
|
@ -206,7 +206,7 @@ class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : BlockEn
|
|||||||
|
|
||||||
var affectedBounds = BoundingBox(0, 0, 0, 1, 1, 1)
|
var affectedBounds = BoundingBox(0, 0, 0, 1, 1, 1)
|
||||||
private set
|
private set
|
||||||
var affectedBoundsAABB = AABB.of(affectedBounds)
|
var affectedBoundsAABB: AABB = AABB.of(affectedBounds)
|
||||||
private set
|
private set
|
||||||
|
|
||||||
private fun setDeltaMovement(living: Entity, center: Vec3, distance: Double, weaker: Boolean) {
|
private fun setDeltaMovement(living: Entity, center: Vec3, distance: Double, weaker: Boolean) {
|
||||||
|
@ -10,9 +10,9 @@ import net.minecraft.network.chat.Component
|
|||||||
import net.minecraft.util.FormattedCharSequence
|
import net.minecraft.util.FormattedCharSequence
|
||||||
import ru.dbotthepony.mc.otm.core.*
|
import ru.dbotthepony.mc.otm.core.*
|
||||||
|
|
||||||
fun VertexConsumer.normal(vector: Vector) = normal(vector.x.toFloat(), vector.y.toFloat(), vector.z.toFloat())
|
fun VertexConsumer.normal(vector: Vector): VertexConsumer = normal(vector.x.toFloat(), vector.y.toFloat(), vector.z.toFloat())
|
||||||
fun VertexConsumer.vertex(matrix4f: Matrix4f, vector: Vector) = vertex(matrix4f, vector.x.toFloat(), vector.y.toFloat(), vector.z.toFloat())
|
fun VertexConsumer.vertex(matrix4f: Matrix4f, vector: Vector): VertexConsumer = vertex(matrix4f, vector.x.toFloat(), vector.y.toFloat(), vector.z.toFloat())
|
||||||
fun VertexConsumer.color(color: RGBAColor) = color(color.red, color.green, color.blue, color.alpha)
|
fun VertexConsumer.color(color: RGBAColor): VertexConsumer = color(color.red, color.green, color.blue, color.alpha)
|
||||||
|
|
||||||
fun PoseStack.translate(vector: Vector) = translate(vector.x, vector.y, vector.z)
|
fun PoseStack.translate(vector: Vector) = translate(vector.x, vector.y, vector.z)
|
||||||
fun PoseStack.translate(vector: Vec3i) = translate(vector.x.toDouble(), vector.y.toDouble(), vector.z.toDouble())
|
fun PoseStack.translate(vector: Vec3i) = translate(vector.x.toDouble(), vector.y.toDouble(), vector.z.toDouble())
|
||||||
|
@ -10,7 +10,7 @@ class GraphFlooder<T>(val startNode: Graph6Node<T>, @JvmField val seen: Int = ne
|
|||||||
private val _nodes = ArrayList<Graph6Node<T>>()
|
private val _nodes = ArrayList<Graph6Node<T>>()
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
val nodes = Collections.unmodifiableCollection(_nodes)
|
val nodes = Collections.unmodifiableCollection(_nodes)!!
|
||||||
|
|
||||||
fun size() = _nodes.size
|
fun size() = _nodes.size
|
||||||
|
|
||||||
|
@ -145,8 +145,8 @@ class PortableCondensationDriveItem(capacity: Int) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (matchTag) {
|
if (matchTag) {
|
||||||
val thisTags = item.item.tags
|
val thisTags = item.tags
|
||||||
val stackTatgs = stack.item.tags
|
val stackTatgs = stack.tags.toArray()
|
||||||
|
|
||||||
for (tag1 in thisTags) {
|
for (tag1 in thisTags) {
|
||||||
if (stackTatgs.contains(tag1)) {
|
if (stackTatgs.contains(tag1)) {
|
||||||
@ -166,8 +166,8 @@ class PortableCondensationDriveItem(capacity: Int) :
|
|||||||
var same = ItemStack.isSame(item, stack)
|
var same = ItemStack.isSame(item, stack)
|
||||||
|
|
||||||
if (!same && matchTag) {
|
if (!same && matchTag) {
|
||||||
val thisTags = item.item.tags
|
val thisTags = item.tags
|
||||||
val stackTatgs = stack.item.tags
|
val stackTatgs = stack.tags.toArray()
|
||||||
|
|
||||||
for (tag1 in thisTags) {
|
for (tag1 in thisTags) {
|
||||||
if (stackTatgs.contains(tag1)) {
|
if (stackTatgs.contains(tag1)) {
|
||||||
|
@ -14,10 +14,9 @@ import net.minecraft.world.item.crafting.Ingredient
|
|||||||
import net.minecraftforge.client.IItemRenderProperties
|
import net.minecraftforge.client.IItemRenderProperties
|
||||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||||
import ru.dbotthepony.mc.otm.client.model.TritaniumArmorModel
|
import ru.dbotthepony.mc.otm.client.model.TritaniumArmorModel
|
||||||
import ru.dbotthepony.mc.otm.registry.MTags
|
import ru.dbotthepony.mc.otm.registry.MItemTags
|
||||||
import java.util.function.Consumer
|
import java.util.function.Consumer
|
||||||
|
|
||||||
|
|
||||||
private object TritaniumArmorMaterial : ArmorMaterial {
|
private object TritaniumArmorMaterial : ArmorMaterial {
|
||||||
override fun getDurabilityForSlot(p_40410_: EquipmentSlot): Int {
|
override fun getDurabilityForSlot(p_40410_: EquipmentSlot): Int {
|
||||||
return when (p_40410_) {
|
return when (p_40410_) {
|
||||||
@ -43,7 +42,7 @@ private object TritaniumArmorMaterial : ArmorMaterial {
|
|||||||
|
|
||||||
override fun getEnchantmentValue() = 9
|
override fun getEnchantmentValue() = 9
|
||||||
override fun getEquipSound(): SoundEvent = SoundEvents.ARMOR_EQUIP_GENERIC
|
override fun getEquipSound(): SoundEvent = SoundEvents.ARMOR_EQUIP_GENERIC
|
||||||
override fun getRepairIngredient(): Ingredient = Ingredient.of(MTags.Items.INGOT_TRITANIUM)
|
override fun getRepairIngredient(): Ingredient = Ingredient.of(MItemTags.INGOT_TRITANIUM)
|
||||||
|
|
||||||
const val ID = "${OverdriveThatMatters.MOD_ID}:tritanium_armor"
|
const val ID = "${OverdriveThatMatters.MOD_ID}:tritanium_armor"
|
||||||
|
|
||||||
|
@ -2,12 +2,15 @@ package ru.dbotthepony.mc.otm.matter
|
|||||||
|
|
||||||
import net.minecraft.tags.ItemTags
|
import net.minecraft.tags.ItemTags
|
||||||
import net.minecraft.tags.Tag
|
import net.minecraft.tags.Tag
|
||||||
|
import net.minecraft.tags.TagKey
|
||||||
import net.minecraft.world.item.Item
|
import net.minecraft.world.item.Item
|
||||||
import net.minecraft.world.item.Items
|
import net.minecraft.world.item.Items
|
||||||
import net.minecraft.world.item.crafting.Recipe
|
import net.minecraft.world.item.crafting.Recipe
|
||||||
import net.minecraft.world.item.crafting.RecipeType
|
import net.minecraft.world.item.crafting.RecipeType
|
||||||
import net.minecraftforge.event.server.ServerStartedEvent
|
import net.minecraftforge.event.server.ServerStartedEvent
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent
|
import net.minecraftforge.eventbus.api.SubscribeEvent
|
||||||
|
import net.minecraftforge.registries.ForgeRegistries
|
||||||
|
import net.minecraftforge.registries.tags.ITag
|
||||||
import org.apache.logging.log4j.LogManager
|
import org.apache.logging.log4j.LogManager
|
||||||
import ru.dbotthepony.mc.otm.core.ImpreciseFraction
|
import ru.dbotthepony.mc.otm.core.ImpreciseFraction
|
||||||
import ru.dbotthepony.mc.otm.registry.MItems
|
import ru.dbotthepony.mc.otm.registry.MItems
|
||||||
@ -113,12 +116,26 @@ private fun deriveIfMissing(from: Item, to: Item, multValue: ImpreciseFraction =
|
|||||||
|
|
||||||
private fun deriveIfMissing(from: Item, to: Item, multValue: Double, multComplexity: Double = 1.0) = deriveIfMissing(from, to, ImpreciseFraction(multValue), multComplexity)
|
private fun deriveIfMissing(from: Item, to: Item, multValue: Double, multComplexity: Double = 1.0) = deriveIfMissing(from, to, ImpreciseFraction(multValue), multComplexity)
|
||||||
|
|
||||||
|
private fun make(tag: ITag<Item>, value: ImpreciseFraction, complexity: Double = defaultComplexity(value)) {
|
||||||
|
for (item in tag.stream().iterator()) {
|
||||||
|
make(item, value, complexity)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun make(tag: Tag<Item>, value: ImpreciseFraction, complexity: Double = defaultComplexity(value)) {
|
private fun make(tag: Tag<Item>, value: ImpreciseFraction, complexity: Double = defaultComplexity(value)) {
|
||||||
for (item in tag.values) {
|
for (item in tag.values) {
|
||||||
make(item, value, complexity)
|
make(item, value, complexity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun make(tag: TagKey<Item>, value: ImpreciseFraction, complexity: Double = defaultComplexity(value)) {
|
||||||
|
val resolved = ForgeRegistries.ITEMS.tags()?.getTag(tag)
|
||||||
|
|
||||||
|
if (resolved != null) {
|
||||||
|
make(resolved, value, complexity)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun logResolutionError(text: String) {
|
private fun logResolutionError(text: String) {
|
||||||
LOGGER.debug("... Item chain: " + seenItems.joinToString(" -> "))
|
LOGGER.debug("... Item chain: " + seenItems.joinToString(" -> "))
|
||||||
// LOGGER.error("Recipe chain: " + seenRecipes.joinToString(" -> "))
|
// LOGGER.error("Recipe chain: " + seenRecipes.joinToString(" -> "))
|
||||||
|
@ -34,7 +34,7 @@ open class MultiByteDataContainer(bytes: Int) {
|
|||||||
require(bytes >= 1) { "Buffer size of $bytes does not make any sense" }
|
require(bytes >= 1) { "Buffer size of $bytes does not make any sense" }
|
||||||
}
|
}
|
||||||
|
|
||||||
protected val buffer = ByteBuffer.allocate(bytes)
|
protected val buffer: ByteBuffer = ByteBuffer.allocate(bytes)
|
||||||
var slotID = 0
|
var slotID = 0
|
||||||
var dirty = false
|
var dirty = false
|
||||||
|
|
||||||
|
@ -11,13 +11,15 @@ import net.minecraft.world.level.block.state.BlockBehaviour
|
|||||||
import net.minecraft.world.level.block.state.BlockState
|
import net.minecraft.world.level.block.state.BlockState
|
||||||
import net.minecraft.world.level.material.Material
|
import net.minecraft.world.level.material.Material
|
||||||
import net.minecraft.world.level.material.MaterialColor
|
import net.minecraft.world.level.material.MaterialColor
|
||||||
import net.minecraftforge.event.RegistryEvent
|
|
||||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext
|
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext
|
||||||
import net.minecraftforge.registries.ForgeRegistry
|
import net.minecraftforge.registries.ForgeRegistry
|
||||||
|
import net.minecraftforge.registries.IForgeRegistry
|
||||||
|
import net.minecraftforge.registries.NewRegistryEvent
|
||||||
import net.minecraftforge.registries.RegistryBuilder
|
import net.minecraftforge.registries.RegistryBuilder
|
||||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||||
import ru.dbotthepony.mc.otm.android.AndroidFeatureType
|
import ru.dbotthepony.mc.otm.android.AndroidFeatureType
|
||||||
import ru.dbotthepony.mc.otm.android.AndroidResearchType
|
import ru.dbotthepony.mc.otm.android.AndroidResearchType
|
||||||
|
import java.util.function.Supplier
|
||||||
import kotlin.properties.ReadOnlyProperty
|
import kotlin.properties.ReadOnlyProperty
|
||||||
import kotlin.reflect.KProperty
|
import kotlin.reflect.KProperty
|
||||||
|
|
||||||
@ -66,16 +68,17 @@ class IndustrialGlassProperties(val color: DyeColor?, val name: String, val name
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class WriteOnceReadMany<T, V> : ReadOnlyProperty<T, V> {
|
private class RegistryDelegate<V>(private val name: String) {
|
||||||
private var value: V? = null
|
private var value: Supplier<V>? = null
|
||||||
|
|
||||||
override fun getValue(thisRef: T, property: KProperty<*>): V {
|
fun get(): V {
|
||||||
return value ?: throw IllegalStateException("Tried to access uninitialized property ${property.name}")
|
val supp = value ?: throw IllegalStateException("Tried to access uninitialized registry $name")
|
||||||
|
return supp.get() ?: throw IllegalStateException("Accessing registry $name too early")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun write(value: V) {
|
fun write(value: Supplier<V>) {
|
||||||
if (this.value != null) {
|
if (this.value != null) {
|
||||||
throw IllegalStateException("Already have value written")
|
throw IllegalStateException("Already have registry written")
|
||||||
}
|
}
|
||||||
|
|
||||||
this.value = value
|
this.value = value
|
||||||
@ -83,11 +86,11 @@ private class WriteOnceReadMany<T, V> : ReadOnlyProperty<T, V> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
object MRegistry {
|
object MRegistry {
|
||||||
private val features = WriteOnceReadMany<MRegistry, ForgeRegistry<AndroidFeatureType<*>>>()
|
private val features = RegistryDelegate<IForgeRegistry<AndroidFeatureType<*>>>("ANDROID_FEATURES")
|
||||||
private val research = WriteOnceReadMany<MRegistry, ForgeRegistry<AndroidResearchType<*>>>()
|
private val research = RegistryDelegate<IForgeRegistry<AndroidResearchType<*>>>("ANDROID_RESEARCH")
|
||||||
|
|
||||||
val ANDROID_FEATURES by features
|
val ANDROID_FEATURES get() = features.get() as ForgeRegistry<AndroidFeatureType<*>>
|
||||||
val ANDROID_RESEARCH by research
|
val ANDROID_RESEARCH get() = research.get() as ForgeRegistry<AndroidResearchType<*>>
|
||||||
|
|
||||||
fun initialize(context: FMLJavaModLoadingContext) {
|
fun initialize(context: FMLJavaModLoadingContext) {
|
||||||
context.modEventBus.addListener(this::register)
|
context.modEventBus.addListener(this::register)
|
||||||
@ -103,17 +106,17 @@ object MRegistry {
|
|||||||
AndroidResearch.register()
|
AndroidResearch.register()
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun register(event: RegistryEvent.NewRegistry) {
|
private fun register(event: NewRegistryEvent) {
|
||||||
features.write(RegistryBuilder<AndroidFeatureType<*>>().let {
|
features.write(RegistryBuilder<AndroidFeatureType<*>>().let {
|
||||||
it.setName(ResourceLocation(OverdriveThatMatters.MOD_ID, "android_features"))
|
it.setName(ResourceLocation(OverdriveThatMatters.MOD_ID, "android_features"))
|
||||||
it.type = AndroidFeatureType::class.java
|
it.type = AndroidFeatureType::class.java
|
||||||
it.create() as ForgeRegistry<AndroidFeatureType<*>>
|
event.create(it)
|
||||||
})
|
})
|
||||||
|
|
||||||
research.write(RegistryBuilder<AndroidResearchType<*>>().let {
|
research.write(RegistryBuilder<AndroidResearchType<*>>().let {
|
||||||
it.setName(ResourceLocation(OverdriveThatMatters.MOD_ID, "android_research"))
|
it.setName(ResourceLocation(OverdriveThatMatters.MOD_ID, "android_research"))
|
||||||
it.type = AndroidResearchType::class.java
|
it.type = AndroidResearchType::class.java
|
||||||
it.create() as ForgeRegistry<AndroidResearchType<*>>
|
event.create(it)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
11
src/main/kotlin/ru/dbotthepony/mc/otm/registry/Tags.kt
Normal file
11
src/main/kotlin/ru/dbotthepony/mc/otm/registry/Tags.kt
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package ru.dbotthepony.mc.otm.registry
|
||||||
|
|
||||||
|
import net.minecraft.resources.ResourceLocation
|
||||||
|
import net.minecraft.tags.ItemTags
|
||||||
|
import net.minecraft.tags.TagKey
|
||||||
|
import net.minecraft.world.item.Item
|
||||||
|
|
||||||
|
object MItemTags {
|
||||||
|
val INGOT_TRITANIUM: TagKey<Item> = ItemTags.create(ResourceLocation("forge", "ingots/tritanium"))
|
||||||
|
val PLATE_TRITANIUM: TagKey<Item> = ItemTags.create(ResourceLocation("forge", "plates/tritanium"))
|
||||||
|
}
|
@ -6,7 +6,7 @@
|
|||||||
# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
|
# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
|
||||||
modLoader="javafml" #mandatory
|
modLoader="javafml" #mandatory
|
||||||
# A version range to match for said mod loader - for regular FML @Mod it will be the forge version
|
# A version range to match for said mod loader - for regular FML @Mod it will be the forge version
|
||||||
loaderVersion="[38,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
|
loaderVersion="[40,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
|
||||||
# The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties.
|
# The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties.
|
||||||
# Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here.
|
# Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here.
|
||||||
license="MIT"
|
license="MIT"
|
||||||
@ -43,7 +43,7 @@ Matter. Energy. Combined.
|
|||||||
# Does this dependency have to exist - if not, ordering below must be specified
|
# Does this dependency have to exist - if not, ordering below must be specified
|
||||||
mandatory=true #mandatory
|
mandatory=true #mandatory
|
||||||
# The version range of the dependency
|
# The version range of the dependency
|
||||||
versionRange="[39,)" #mandatory
|
versionRange="[40,)" #mandatory
|
||||||
# An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
|
# An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
|
||||||
ordering="NONE"
|
ordering="NONE"
|
||||||
# Side this dependency is applied on - BOTH, CLIENT or SERVER
|
# Side this dependency is applied on - BOTH, CLIENT or SERVER
|
||||||
@ -53,6 +53,6 @@ Matter. Energy. Combined.
|
|||||||
modId="minecraft"
|
modId="minecraft"
|
||||||
mandatory=true
|
mandatory=true
|
||||||
# This version range declares a minimum of the current minecraft version up to but not including the next major version
|
# This version range declares a minimum of the current minecraft version up to but not including the next major version
|
||||||
versionRange="[1.18.1,1.19)"
|
versionRange="[1.18.2,1.19)"
|
||||||
ordering="NONE"
|
ordering="NONE"
|
||||||
side="BOTH"
|
side="BOTH"
|
||||||
|
Loading…
Reference in New Issue
Block a user