Backport to 1.18.2
This commit is contained in:
parent
1fbd10471f
commit
c344b5c0b6
67 changed files with 3335 additions and 3858 deletions
|
@ -1,20 +1,12 @@
|
|||
package dev.zontreck.otemod;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.mojang.logging.LogUtils;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.profiles.Profile;
|
||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.libzontreck.util.ServerUtilities;
|
||||
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||
import dev.zontreck.otemod.effects.ModEffects;
|
||||
import dev.zontreck.otemod.implementation.CreativeModeTabs;
|
||||
|
@ -24,22 +16,16 @@ import dev.zontreck.otemod.implementation.PlayerFirstJoinTag;
|
|||
import dev.zontreck.otemod.implementation.compressor.CompressionChamberScreen;
|
||||
import dev.zontreck.otemod.implementation.vault.*;
|
||||
import dev.zontreck.otemod.integrations.KeyBindings;
|
||||
import dev.zontreck.otemod.ore.OreGenerator;
|
||||
import dev.zontreck.otemod.recipe.ModRecipes;
|
||||
import net.minecraft.client.gui.screens.MenuScreens;
|
||||
import net.minecraft.client.renderer.entity.EntityRenderers;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.commands.GiveCommand;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.client.event.RegisterKeyMappingsEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
|
@ -55,6 +41,8 @@ import net.minecraftforge.event.server.ServerStoppingEvent;
|
|||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import dev.zontreck.otemod.blocks.ModBlocks;
|
||||
|
@ -64,13 +52,11 @@ import dev.zontreck.otemod.commands.CommandRegistry;
|
|||
import dev.zontreck.otemod.configs.OTEServerConfig;
|
||||
import dev.zontreck.otemod.enchantments.ModEnchantments;
|
||||
import dev.zontreck.otemod.entities.ModEntityTypes;
|
||||
import dev.zontreck.otemod.entities.monsters.client.PossumRenderer;
|
||||
import dev.zontreck.otemod.events.LoreHandlers;
|
||||
import dev.zontreck.otemod.implementation.inits.ModMenuTypes;
|
||||
import dev.zontreck.otemod.implementation.scrubber.ItemScrubberScreen;
|
||||
import dev.zontreck.otemod.implementation.scrubber.MagicalScrubberScreen;
|
||||
import dev.zontreck.otemod.items.ModItems;
|
||||
//import dev.zontreck.otemod.ore.Modifier.ModifierOfBiomes;
|
||||
import dev.zontreck.otemod.networking.ModMessages;
|
||||
|
||||
// The value here should match an entry in the META-INF/mods.toml file
|
||||
|
@ -110,13 +96,6 @@ public class OTEMod
|
|||
|
||||
|
||||
ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, OTEServerConfig.SPEC, "otemod-rss-server.toml");
|
||||
|
||||
|
||||
|
||||
// Register ourselves for server and other game events we are interested in
|
||||
//final DeferredRegister<Codec<? extends BiomeModifier>> serializers = DeferredRegister.create(ForgeRegistries.Keys.BIOME_MODIFIER_SERIALIZERS, OTEMod.MOD_ID);
|
||||
//serializers.register(bus);
|
||||
//serializers.register(MODIFY_BIOMES, ModifierOfBiomes::makeCodec);
|
||||
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
|
@ -125,10 +104,11 @@ public class OTEMod
|
|||
MinecraftForge.EVENT_BUS.register(new CommandRegistry());
|
||||
MinecraftForge.EVENT_BUS.register(new VaultWatcher());
|
||||
MinecraftForge.EVENT_BUS.register(new dev.zontreck.otemod.zschem.EventHandler());
|
||||
ModMenuTypes.CONTAINERS.register(bus);
|
||||
MinecraftForge.EVENT_BUS.register(OreGenerator.class);
|
||||
|
||||
|
||||
ModMenuTypes.CONTAINERS.register(bus);
|
||||
ModBlocks.register(bus);
|
||||
CreativeModeTabs.REGISTER.register(bus);
|
||||
ModItems.register(bus);
|
||||
ModEntities.register(bus);
|
||||
ModEnchantments.register(bus);
|
||||
|
@ -271,7 +251,7 @@ public class OTEMod
|
|||
@SubscribeEvent
|
||||
public void onItemExpire(final ItemExpireEvent ev)
|
||||
{
|
||||
if(ev.getEntity().level().isClientSide)return;
|
||||
if(ServerUtilities.isClient()) return;
|
||||
|
||||
if(OTEServerConfig.ITEM_DESPAWN_TIMER.get()<=0)return;
|
||||
|
||||
|
@ -325,13 +305,6 @@ public class OTEMod
|
|||
}
|
||||
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@SubscribeEvent
|
||||
public static void onRegisterKeybinds(RegisterKeyMappingsEvent ev)
|
||||
{
|
||||
ev.register(KeyBindings.OPEN_VAULT);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,9 +3,9 @@ package dev.zontreck.otemod.blocks;
|
|||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.DoorBlock;
|
||||
import net.minecraft.world.level.block.DoubleBlockCombiner;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.state.properties.BlockSetType;
|
||||
|
||||
public class AuroraDoorBlock extends DoorBlock
|
||||
{
|
||||
|
@ -16,7 +16,7 @@ public class AuroraDoorBlock extends DoorBlock
|
|||
}
|
||||
|
||||
public AuroraDoorBlock() {
|
||||
super(DOOR_PROPS, BlockSetType.IRON);
|
||||
super(DOOR_PROPS);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ public class CompressionChamberBlock extends HorizontalDirectionalBlock implemen
|
|||
if(be instanceof CompressionChamberBlockEntity)
|
||||
{
|
||||
CompressionChamberBlockEntity entity = (CompressionChamberBlockEntity) be;
|
||||
NetworkHooks.openScreen(((ServerPlayer)player), entity, pos);
|
||||
NetworkHooks.openGui(((ServerPlayer)player), entity, pos);
|
||||
|
||||
ModMessages.sendToPlayer(new EnergySyncS2CPacket(entity.getEnergyStorage().getEnergyStored(), entity.getBlockPos()), (ServerPlayer)player);
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ public class ItemScrubberBlock extends HorizontalDirectionalBlock implements Ent
|
|||
if(be instanceof ItemScrubberBlockEntity)
|
||||
{
|
||||
ItemScrubberBlockEntity entity = (ItemScrubberBlockEntity)be;
|
||||
NetworkHooks.openScreen(((ServerPlayer)player), entity, pos);
|
||||
NetworkHooks.openGui(((ServerPlayer)player), entity, pos);
|
||||
|
||||
ModMessages.sendToPlayer(new EnergySyncS2CPacket(entity.getEnergyStorage().getEnergyStored(), entity.getBlockPos()), (ServerPlayer)player);
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ public class MagicalScrubberBlock extends HorizontalDirectionalBlock implements
|
|||
if(be instanceof MagicalScrubberBlockEntity)
|
||||
{
|
||||
MagicalScrubberBlockEntity entity = (MagicalScrubberBlockEntity)be;
|
||||
NetworkHooks.openScreen(((ServerPlayer)player), entity, pos);
|
||||
NetworkHooks.openGui(((ServerPlayer)player), entity, pos);
|
||||
|
||||
ModMessages.sendToPlayer(new EnergySyncS2CPacket(entity.getEnergyStorage().getEnergyStored(), entity.getBlockPos()), (ServerPlayer)player);
|
||||
}else{
|
||||
|
|
|
@ -10,6 +10,7 @@ import net.minecraft.world.level.BlockGetter;
|
|||
import net.minecraft.world.level.block.*;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
@ -25,30 +26,30 @@ public class ModBlocks {
|
|||
OTEMod.LOGGER.info("Registering all blocks...");
|
||||
}
|
||||
|
||||
public static final RegistryObject<Block> ETERNIUM_ORE_BLOCK = BLOCKS.register("eternium_ore_block", () -> new Block(BlockBehaviour.Properties.of().requiresCorrectToolForDrops().strength(7F).explosionResistance(1200).destroyTime(6)));
|
||||
public static final RegistryObject<Block> ETERNIUM_ORE_BLOCK = BLOCKS.register("eternium_ore_block", () -> new Block(BlockBehaviour.Properties.of(Material.STONE).requiresCorrectToolForDrops().strength(7F).explosionResistance(1200).destroyTime(6)));
|
||||
|
||||
public static final RegistryObject<Item> ETERNIUM_ORE_BLOCK_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("eternium_ore_block", () -> new BlockItem(ETERNIUM_ORE_BLOCK.get(), new Item.Properties())));
|
||||
|
||||
public static final RegistryObject<Block> VAULT_STEEL_ORE_BLOCK = BLOCKS.register("vault_steel_ore_block", ()->new Block(BlockBehaviour.Properties.of().requiresCorrectToolForDrops().strength(8F).explosionResistance(1200).destroyTime(100)));
|
||||
public static final RegistryObject<Block> VAULT_STEEL_ORE_BLOCK = BLOCKS.register("vault_steel_ore_block", ()->new Block(BlockBehaviour.Properties.of(Material.STONE).requiresCorrectToolForDrops().strength(8F).explosionResistance(1200).destroyTime(100)));
|
||||
|
||||
public static final RegistryObject<Item> VAULT_STEEL_ORE_BLOCK_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("vault_steel_ore_block", ()->new BlockItem(VAULT_STEEL_ORE_BLOCK.get(), new Item.Properties())));
|
||||
|
||||
|
||||
public static final RegistryObject<Block> NETHER_VAULT_STEEL_ORE_BLOCK = BLOCKS.register("nether_vault_steel_ore_block", ()->new Block(BlockBehaviour.Properties.of().requiresCorrectToolForDrops().strength(8F).explosionResistance(1200).destroyTime(100)));
|
||||
public static final RegistryObject<Block> NETHER_VAULT_STEEL_ORE_BLOCK = BLOCKS.register("nether_vault_steel_ore_block", ()->new Block(BlockBehaviour.Properties.of(Material.STONE).requiresCorrectToolForDrops().strength(8F).explosionResistance(1200).destroyTime(100)));
|
||||
|
||||
public static final RegistryObject<Item> NETHER_VAULT_STEEL_ORE_BLOCK_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("nether_vault_steel_ore_block", ()->new BlockItem(NETHER_VAULT_STEEL_ORE_BLOCK.get(), new Item.Properties())));
|
||||
|
||||
|
||||
public static final RegistryObject<Block> ETERNIUM_BLOCK = BLOCKS.register("eternium_block", ()->new Block(BlockBehaviour.Properties.of().requiresCorrectToolForDrops().strength(8F).explosionResistance(1200).destroyTime(100)));
|
||||
public static final RegistryObject<Block> ETERNIUM_BLOCK = BLOCKS.register("eternium_block", ()->new Block(BlockBehaviour.Properties.of(Material.HEAVY_METAL).requiresCorrectToolForDrops().strength(8F).explosionResistance(1200).destroyTime(100)));
|
||||
|
||||
public static final RegistryObject<Item> ETERNIUM_BLOCK_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("eternium_block", ()->new FoiledBlockItem(ETERNIUM_BLOCK.get(), new Item.Properties())));
|
||||
|
||||
|
||||
public static final RegistryObject<Block> DEEPSLATE_ETERNIUM_ORE_BLOCK = BLOCKS.register("deepslate_eternium_ore_block", () -> new Block(BlockBehaviour.Properties.of().requiresCorrectToolForDrops().strength(5f).explosionResistance(1200).destroyTime(7)));
|
||||
public static final RegistryObject<Block> DEEPSLATE_ETERNIUM_ORE_BLOCK = BLOCKS.register("deepslate_eternium_ore_block", () -> new Block(BlockBehaviour.Properties.of(Material.STONE).requiresCorrectToolForDrops().strength(5f).explosionResistance(1200).destroyTime(7)));
|
||||
|
||||
public static final RegistryObject<Item> DEEPSLATE_ETERNIUM_ORE_BLOCK_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("deepslate_eternium_ore_block", () -> new BlockItem(DEEPSLATE_ETERNIUM_ORE_BLOCK.get(), new Item.Properties())));
|
||||
|
||||
public static final RegistryObject<Block> AURORA_BLOCK = BLOCKS.register("aurora_block", () -> new Block(BlockBehaviour.Properties.of().requiresCorrectToolForDrops().strength(9f).explosionResistance(100000f).destroyTime(10).sound(SoundType.NETHERITE_BLOCK)));
|
||||
public static final RegistryObject<Block> AURORA_BLOCK = BLOCKS.register("aurora_block", () -> new Block(BlockBehaviour.Properties.of(Material.HEAVY_METAL).requiresCorrectToolForDrops().strength(9f).explosionResistance(100000f).destroyTime(10).sound(SoundType.NETHERITE_BLOCK)));
|
||||
|
||||
public static final RegistryObject<Item> AURORA_BLOCK_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("aurora_block", () -> new BlockItem(AURORA_BLOCK.get(), new Item.Properties())));
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package dev.zontreck.otemod.blocks.entity;
|
||||
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.otemod.implementation.OutputItemStackHandler;
|
||||
import dev.zontreck.otemod.implementation.compressor.CompressionChamberMenu;
|
||||
import dev.zontreck.otemod.implementation.energy.OTEEnergy;
|
||||
|
@ -25,10 +26,11 @@ import net.minecraft.world.level.block.entity.BlockEntity;
|
|||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.energy.EnergyStorage;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
|
||||
|
@ -109,7 +111,7 @@ public class CompressionChamberBlockEntity extends BlockEntity implements MenuPr
|
|||
|
||||
@Override
|
||||
public Component getDisplayName() {
|
||||
return Component.literal("Compression Chamber");
|
||||
return ChatHelpers.macro("Compression Chamber");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -122,16 +124,16 @@ public class CompressionChamberBlockEntity extends BlockEntity implements MenuPr
|
|||
@Override
|
||||
public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side)
|
||||
{
|
||||
if(cap == ForgeCapabilities.ENERGY)
|
||||
if(cap == CapabilityEnergy.ENERGY)
|
||||
{
|
||||
return lazyEnergyHandler.cast();
|
||||
}
|
||||
if(side == Direction.DOWN && cap == ForgeCapabilities.ITEM_HANDLER)
|
||||
if(side == Direction.DOWN && cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
|
||||
{
|
||||
// Return the output slot only
|
||||
return lazyOutputItems.cast();
|
||||
}
|
||||
if(cap == ForgeCapabilities.ITEM_HANDLER)
|
||||
if(cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
|
||||
{
|
||||
return lazyItemHandler.cast();
|
||||
}
|
||||
|
@ -249,9 +251,9 @@ public class CompressionChamberBlockEntity extends BlockEntity implements MenuPr
|
|||
|
||||
if(existing.is(Items.AIR))
|
||||
{
|
||||
existing = recipe.get().getResultItem(entity.level.registryAccess());
|
||||
existing = recipe.get().getResultItem();
|
||||
}else
|
||||
existing.setCount(recipe.get().getResultItem(entity.level.registryAccess()).getCount() + existing.getCount());
|
||||
existing.setCount(recipe.get().getResultItem().getCount() + existing.getCount());
|
||||
|
||||
entity.outputItems.setStackInSlot(0, existing);
|
||||
entity.itemsHandler.extractItem(0,1,false);
|
||||
|
@ -275,7 +277,7 @@ public class CompressionChamberBlockEntity extends BlockEntity implements MenuPr
|
|||
|
||||
Optional<CompressionChamberRecipe> recipe = entity.level.getRecipeManager().getRecipeFor(CompressionChamberRecipe.Type.INSTANCE, inventory, entity.level);
|
||||
|
||||
boolean ret = recipe.isPresent() && canInsertIntoOutput(output, recipe.get().getResultItem(entity.level.registryAccess()));
|
||||
boolean ret = recipe.isPresent() && canInsertIntoOutput(output, recipe.get().getResultItem());
|
||||
|
||||
if(ret)
|
||||
{
|
||||
|
|
|
@ -9,6 +9,7 @@ import net.minecraft.core.BlockPos;
|
|||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.world.Containers;
|
||||
import net.minecraft.world.MenuProvider;
|
||||
import net.minecraft.world.SimpleContainer;
|
||||
|
@ -22,9 +23,10 @@ import net.minecraft.world.level.Level;
|
|||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
|
||||
|
@ -111,22 +113,22 @@ public class ItemScrubberBlockEntity extends BlockEntity implements MenuProvider
|
|||
|
||||
@Override
|
||||
public Component getDisplayName() {
|
||||
return Component.translatable("block.otemod.item_scrubber");
|
||||
return new TranslatableComponent("block.otemod.item_scrubber");
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side)
|
||||
{
|
||||
if(cap == ForgeCapabilities.ENERGY)
|
||||
if(cap == CapabilityEnergy.ENERGY)
|
||||
{
|
||||
return lazyEnergyHandler.cast();
|
||||
}
|
||||
if(side == Direction.DOWN && cap == ForgeCapabilities.ITEM_HANDLER)
|
||||
if(side == Direction.DOWN && cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
|
||||
{
|
||||
// Return the output slot only
|
||||
return lazyOutputItems.cast();
|
||||
}
|
||||
if(cap == ForgeCapabilities.ITEM_HANDLER)
|
||||
if(cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
|
||||
{
|
||||
return lazyItemHandler.cast();
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import net.minecraft.core.BlockPos;
|
|||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.world.Containers;
|
||||
import net.minecraft.world.MenuProvider;
|
||||
import net.minecraft.world.SimpleContainer;
|
||||
|
@ -26,9 +27,10 @@ import net.minecraft.world.level.Level;
|
|||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
|
||||
|
@ -117,22 +119,22 @@ public class MagicalScrubberBlockEntity extends BlockEntity implements MenuProvi
|
|||
|
||||
@Override
|
||||
public Component getDisplayName() {
|
||||
return Component.translatable("block.otemod.magical_scrubber");
|
||||
return new TranslatableComponent("block.otemod.magical_scrubber");
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side)
|
||||
{
|
||||
if(cap == ForgeCapabilities.ENERGY)
|
||||
if(cap == CapabilityEnergy.ENERGY)
|
||||
{
|
||||
return lazyEnergyHandler.cast();
|
||||
}
|
||||
if(side == Direction.DOWN && cap == ForgeCapabilities.ITEM_HANDLER)
|
||||
if(side == Direction.DOWN && cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
|
||||
{
|
||||
// Return the output slot only
|
||||
return lazyOutputItems.cast();
|
||||
}
|
||||
if(cap == ForgeCapabilities.ITEM_HANDLER)
|
||||
if(cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
|
||||
{
|
||||
return lazyItemHandler.cast();
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import net.minecraftforge.registries.RegistryObject;
|
|||
|
||||
public class ModEntities {
|
||||
|
||||
public static final DeferredRegister<BlockEntityType<?>> ENTITIES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, OTEMod.MOD_ID);
|
||||
public static final DeferredRegister<BlockEntityType<?>> ENTITIES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITIES, OTEMod.MOD_ID);
|
||||
|
||||
public static final RegistryObject <BlockEntityType <ItemScrubberBlockEntity>> ITEM_SCRUBBER = ENTITIES.register("item_scrubber", ()-> BlockEntityType.Builder.of(ItemScrubberBlockEntity::new, ModBlocks.ITEM_SCRUBBER.get()).build(null));
|
||||
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
package dev.zontreck.otemod.blocks.entity;
|
||||
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import org.joml.Matrix4f;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
|
|
|
@ -85,10 +85,10 @@ public class ChatServerOverride {
|
|||
@SubscribeEvent
|
||||
public void onClone(final PlayerEvent.Clone ev)
|
||||
{
|
||||
if(ev.getEntity().level().isClientSide)return;
|
||||
if(ev.getEntity().getLevel().isClientSide)return;
|
||||
// Fix for fly ability not copying to new instance on death or other circumstances
|
||||
Player old = ev.getOriginal();
|
||||
Player n = ev.getEntity();
|
||||
Player n = ev.getPlayer();
|
||||
|
||||
PlayerFlyCache c = PlayerFlyCache.cachePlayer((ServerPlayer)old);
|
||||
c.Assert((ServerPlayer)n);
|
||||
|
@ -96,7 +96,7 @@ public class ChatServerOverride {
|
|||
|
||||
@SubscribeEvent
|
||||
public void onChat(final ServerChatEvent ev){
|
||||
if(ev.getPlayer().level().isClientSide)return;
|
||||
if(ev.getPlayer().getLevel().isClientSide)return;
|
||||
// Player has chatted, apply override
|
||||
if(!OTEServerConfig.USE_CUSTOM_CHATREPLACER.get()) return;
|
||||
|
||||
|
@ -117,7 +117,7 @@ public class ChatServerOverride {
|
|||
prefixStr = ChatColor.DARK_GRAY + "[" + ChatColor.BOLD + XD.prefix_color + XD.prefix + ChatColor.resetChat() + ChatColor.DARK_GRAY + "] ";
|
||||
}
|
||||
|
||||
String msg = ev.getRawText();
|
||||
String msg = ev.getMessage();
|
||||
msg= ChatColor.doColors(msg);
|
||||
|
||||
String nameStr = ChatColor.resetChat() + "< "+ XD.name_color + XD.nickname + ChatColor.resetChat() + " >";
|
||||
|
@ -126,7 +126,7 @@ public class ChatServerOverride {
|
|||
hover=hover.withFont(Style.DEFAULT_FONT).withHoverEvent(HoverTip.get(ChatColor.MINECOIN_GOLD+"User Name: "+XD.username));
|
||||
ev.setCanceled(true);
|
||||
|
||||
ChatHelpers.broadcast(Component.literal(prefixStr + nameStr + message).setStyle(hover), ev.getPlayer().server);
|
||||
ChatHelpers.broadcast(ChatHelpers.macro(prefixStr + nameStr + message).setStyle(hover), ev.getPlayer().server);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2,13 +2,12 @@ package dev.zontreck.otemod.client.renderer;
|
|||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import dev.zontreck.otemod.blocks.ParallaxWindow;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import dev.zontreck.otemod.blocks.entity.ParallaxWindowEntity;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
||||
import net.minecraft.core.Direction;
|
||||
import org.joml.Matrix4f;
|
||||
|
||||
public class ParallaxWindowEntityRenderer implements BlockEntityRenderer<ParallaxWindowEntity>
|
||||
{
|
||||
|
|
|
@ -3,6 +3,7 @@ package dev.zontreck.otemod.commands;
|
|||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
|
@ -38,12 +39,12 @@ public class FlyCommand {
|
|||
p.onUpdateAbilities();
|
||||
|
||||
|
||||
ctx.sendSystemMessage(Component.literal(OTEMod.OTEPrefix + ChatColor.DARK_PURPLE + " Your ability to fly has been disabled"));
|
||||
ChatHelpers.broadcastTo(p.getUUID(), ChatHelpers.macro(OTEMod.OTEPrefix + ChatColor.DARK_PURPLE + " Your ability to fly has been disabled"), p.server);
|
||||
}else {
|
||||
p.getAbilities().mayfly=true;
|
||||
p.onUpdateAbilities();
|
||||
|
||||
ctx.sendSystemMessage(Component.literal(OTEMod.OTEPrefix + ChatColor.DARK_PURPLE + " You can now fly"));
|
||||
ChatHelpers.broadcastTo(p.getUUID(), ChatHelpers.macro(OTEMod.OTEPrefix + ChatColor.DARK_PURPLE + " You can now fly"), p.server);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -2,6 +2,7 @@ package dev.zontreck.otemod.commands.vaults;
|
|||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import dev.zontreck.libzontreck.profiles.Profile;
|
||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
|
@ -55,14 +56,19 @@ public class StarterCommand
|
|||
|
||||
public static int openStarterMenu(CommandSourceStack ctx)
|
||||
{
|
||||
ServerPlayer player = ctx.getPlayer();
|
||||
ServerPlayer player = null;
|
||||
try {
|
||||
player = ctx.getPlayerOrException();
|
||||
} catch (CommandSyntaxException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if(player != null)
|
||||
{
|
||||
if(player.hasPermissions(ctx.getServer().getOperatorUserPermissionLevel()))
|
||||
{
|
||||
try {
|
||||
StarterContainer container = new StarterContainer(player);
|
||||
NetworkHooks.openScreen(player, new SimpleMenuProvider(container.serverMenu, Component.literal("Starter Gear")));
|
||||
NetworkHooks.openGui(player, new SimpleMenuProvider(container.serverMenu, ChatHelpers.macro("Starter Gear")));
|
||||
|
||||
|
||||
// Add to the master vault registry
|
||||
|
@ -93,7 +99,7 @@ public class StarterCommand
|
|||
return;
|
||||
}
|
||||
|
||||
NetworkHooks.openScreen(p, new SimpleMenuProvider(container.serverMenu, Component.literal("Starter Gear")));
|
||||
NetworkHooks.openGui(p, new SimpleMenuProvider(container.serverMenu, ChatHelpers.macro("Starter Gear")));
|
||||
|
||||
// Add to the master vault registry
|
||||
if(StarterContainer.VAULT_REGISTRY.containsKey(p.getUUID()))VaultContainer.VAULT_REGISTRY.remove(p.getUUID());
|
||||
|
|
|
@ -37,7 +37,7 @@ public class TrashCommand {
|
|||
return 0;
|
||||
}
|
||||
|
||||
NetworkHooks.openScreen(play, new SimpleMenuProvider(container.serverMenu, Component.literal("Trash")));
|
||||
NetworkHooks.openGui(play, new SimpleMenuProvider(container.serverMenu, ChatHelpers.macro("Trash")));
|
||||
|
||||
// Add to the master vault registry
|
||||
if(VaultContainer.VAULT_REGISTRY.containsKey(play.getUUID()))VaultContainer.VAULT_REGISTRY.remove(play.getUUID());
|
||||
|
|
|
@ -51,7 +51,7 @@ public class VaultCommand {
|
|||
return;
|
||||
}
|
||||
|
||||
NetworkHooks.openScreen(p, new SimpleMenuProvider(container.serverMenu, Component.literal("Vault " + i)));
|
||||
NetworkHooks.openGui(p, new SimpleMenuProvider(container.serverMenu, ChatHelpers.macro("Vault " + i)));
|
||||
|
||||
// Add to the master vault registry
|
||||
if(VaultContainer.VAULT_REGISTRY.containsKey(p.getUUID()))VaultContainer.VAULT_REGISTRY.remove(p.getUUID());
|
||||
|
|
|
@ -37,7 +37,7 @@ public class SetPos1 {
|
|||
MemoryHolder.setPos1(play, new Vector3(source.getPosition()));
|
||||
MemoryHolder.setLevel(play, source.getLevel());
|
||||
|
||||
ChatHelpers.broadcastTo(play.getUUID(), Component.literal(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Green!Position 1 set!")), OTEMod.THE_SERVER);
|
||||
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Green!Position 1 set!")), OTEMod.THE_SERVER);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ public class SetPos2 {
|
|||
MemoryHolder.setPos2(play, new Vector3(source.getPosition()));
|
||||
MemoryHolder.setLevel(play, source.getLevel());
|
||||
|
||||
ChatHelpers.broadcastTo(play.getUUID(), Component.literal(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Green!Position 2 set!")), OTEMod.THE_SERVER);
|
||||
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Green!Position 2 set!")), OTEMod.THE_SERVER);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ public class PlayerFlyCache
|
|||
}
|
||||
|
||||
public void Assert(ServerPlayer play){
|
||||
if(play.gameMode.isCreative()) return;
|
||||
Abilities playerAbilities = play.getAbilities();
|
||||
playerAbilities.flying=Flying;
|
||||
playerAbilities.mayfly=FlyEnabled;
|
||||
|
|
|
@ -61,7 +61,13 @@ public class FlightEffect extends MobEffect {
|
|||
|
||||
private static void recheck(ServerPlayer sp)
|
||||
{
|
||||
if(sp.gameMode.isCreative())return; // Don't mess with the creative mode attributes
|
||||
if(sp.gameMode.isCreative()){
|
||||
Abilities a = sp.getAbilities();
|
||||
a.mayfly=true;
|
||||
|
||||
sp.onUpdateAbilities();
|
||||
return;
|
||||
} // Don't mess with the creative mode attributes
|
||||
|
||||
|
||||
ItemStack feet = sp.getItemBySlot(EquipmentSlot.FEET);
|
||||
|
@ -79,7 +85,7 @@ public class FlightEffect extends MobEffect {
|
|||
Abilities playerAbilities = sp.getAbilities();
|
||||
if(hasFlight)
|
||||
{
|
||||
if(playerAbilities.mayfly == false)
|
||||
if(!playerAbilities.mayfly)
|
||||
{
|
||||
playerAbilities.mayfly=true;
|
||||
sp.onUpdateAbilities();
|
||||
|
|
|
@ -80,7 +80,7 @@ public class FlightEnchantment extends Enchantment
|
|||
{
|
||||
if(event.side == LogicalSide.CLIENT) return;
|
||||
|
||||
if(TICKS.getAndIncrement() >= (5*20))
|
||||
if(TICKS.getAndIncrement() >= (10*20))
|
||||
{
|
||||
TICKS.set(0);
|
||||
|
||||
|
@ -104,7 +104,7 @@ public class FlightEnchantment extends Enchantment
|
|||
|
||||
if(hasFlight)
|
||||
{
|
||||
MobEffectInstance inst = new MobEffectInstance(ModEffects.FLIGHT.get(), -1, 0, false, false, true);
|
||||
MobEffectInstance inst = new MobEffectInstance(ModEffects.FLIGHT.get(), 30*20, 0, false, false, true);
|
||||
|
||||
event.player.addEffect(inst);
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ public class NightVisionEnchantment extends Enchantment
|
|||
{
|
||||
if(event.side == LogicalSide.CLIENT) return;
|
||||
|
||||
if(TICKS.getAndIncrement() >= (2*20))
|
||||
if(TICKS.getAndIncrement() >= (5*20))
|
||||
{
|
||||
TICKS.set(0);
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ public class ClientEvents {
|
|||
static long lastPress;
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onKeyInput(InputEvent.Key event)
|
||||
public static void onKeyInput(InputEvent.KeyInputEvent event)
|
||||
{
|
||||
//OTEMod.LOGGER.info("KEY PRESS: "+event.getKey());
|
||||
if(KeyBindings.OPEN_VAULT.matches(event.getKey(), event.getScanCode()) && Minecraft.getInstance().screen == null && lastPress+10 < Instant.now().getEpochSecond())
|
||||
|
|
|
@ -93,7 +93,7 @@ public class EventHandler {
|
|||
}
|
||||
|
||||
try {
|
||||
ChatHelpers.broadcast(Component.literal(DeathMessages.getRandomDeathMessage(Profile.get_profile_of(event.getEntity().getStringUUID()), event.getSource())), event.getEntity().level().getServer());
|
||||
ChatHelpers.broadcast(ChatHelpers.macro(DeathMessages.getRandomDeathMessage(Profile.get_profile_of(event.getEntity().getStringUUID()), event.getSource())), event.getEntity().getLevel().getServer());
|
||||
} catch (UserProfileNotYetExistsException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
|
@ -102,14 +102,14 @@ public class EventHandler {
|
|||
|
||||
@SubscribeEvent
|
||||
public void onEntityKilled(LivingDropsEvent ev){
|
||||
if(ev.getEntity().level().isClientSide)return;
|
||||
if(ev.getEntity().getLevel().isClientSide)return;
|
||||
|
||||
Entity killedentity = ev.getEntity();
|
||||
Entity ent = ev.getSource().getEntity();
|
||||
if(ent instanceof Player)
|
||||
{
|
||||
ServerPlayer play = (ServerPlayer)ent;
|
||||
LivingEntity killed = ev.getEntity();
|
||||
LivingEntity killed = ev.getEntityLiving();
|
||||
|
||||
ItemStack stack = play.getMainHandItem();
|
||||
int levelOfEgging = ItemUtils.getEnchantmentLevel(ModEnchantments.MOB_EGGING_ENCHANTMENT.get(),stack);
|
||||
|
@ -128,7 +128,7 @@ public class EventHandler {
|
|||
int level = ItemUtils.getEnchantmentLevel (Enchantments.MOB_LOOTING,stack);
|
||||
if(level==3){
|
||||
ItemStack egg = new ItemStack(ForgeSpawnEggItem.fromEntityType(killed.getType()));
|
||||
ev.getDrops().add(new ItemEntity(killed.level(), killed.getX(), killed.getY(), killed.getZ(), egg));
|
||||
ev.getDrops().add(new ItemEntity(killed.getLevel(), killed.getX(), killed.getY(), killed.getZ(), egg));
|
||||
//LoreHandlers.updateItem(stack, ItemStatType.EGGING);
|
||||
}
|
||||
}else{
|
||||
|
|
|
@ -1,26 +1,6 @@
|
|||
package dev.zontreck.otemod.events;
|
||||
|
||||
import dev.zontreck.libzontreck.lore.LoreContainer;
|
||||
import dev.zontreck.libzontreck.lore.LoreEntry;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.items.tags.ItemStatTag;
|
||||
import dev.zontreck.otemod.items.tags.ItemStatType;
|
||||
import dev.zontreck.otemod.items.tags.ItemStatistics;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.minecraftforge.event.level.BlockEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
|
|
@ -1,38 +1,17 @@
|
|||
package dev.zontreck.otemod.implementation;
|
||||
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.items.ModItems;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = OTEMod.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public class CreativeModeTabs
|
||||
{
|
||||
public static final DeferredRegister<CreativeModeTab> REGISTER = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, OTEMod.MOD_ID);
|
||||
|
||||
public static final List<Supplier<? extends ItemLike>> OTEMOD_TAB_ITEMS = new ArrayList<>();
|
||||
|
||||
public static final RegistryObject<CreativeModeTab> OTE_TAB = REGISTER.register("otemod", () -> CreativeModeTab.builder()
|
||||
.title(Component.translatable("itemGroup.tabs.otemod"))
|
||||
.icon(ModItems.IHAN_CRYSTAL.get()::getDefaultInstance)
|
||||
.displayItems((display, output) -> OTEMOD_TAB_ITEMS.forEach(it->output.accept(it.get())))
|
||||
.build()
|
||||
);
|
||||
|
||||
public static <T extends Item> RegistryObject<T> addToOTEModTab(RegistryObject<T> itemLike)
|
||||
{
|
||||
OTEMOD_TAB_ITEMS.add(itemLike);
|
||||
return itemLike;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,8 +7,6 @@ import java.util.Random;
|
|||
import dev.zontreck.libzontreck.profiles.Profile;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.damagesource.DamageTypes;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
|
||||
public class DeathMessages {
|
||||
private static final List<String> messages;
|
||||
|
@ -40,7 +38,7 @@ public class DeathMessages {
|
|||
{
|
||||
sourceName = "A godlike player";
|
||||
}
|
||||
if(source.is(DamageTypes.FALL))
|
||||
if(source.isFall())
|
||||
{
|
||||
msg = rng.nextInt(0,messages_falling.size()-1);
|
||||
return ChatHelpers.macroize(messages_falling.get(msg), String.valueOf(playerWhoDied.deaths), playerWhoDied.name_color + playerWhoDied.nickname);
|
||||
|
|
|
@ -14,7 +14,7 @@ import net.minecraft.world.inventory.*;
|
|||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.SlotItemHandler;
|
||||
|
||||
public class CompressionChamberMenu extends AbstractContainerMenu
|
||||
|
@ -25,7 +25,7 @@ public class CompressionChamberMenu extends AbstractContainerMenu
|
|||
|
||||
public CompressionChamberMenu(int id, Inventory inv, FriendlyByteBuf buf)
|
||||
{
|
||||
this(id, inv, inv.player.level().getBlockEntity(buf.readBlockPos()), new SimpleContainerData(1));
|
||||
this(id, inv, inv.player.getLevel().getBlockEntity(buf.readBlockPos()), new SimpleContainerData(1));
|
||||
}
|
||||
|
||||
public CompressionChamberMenu(int id, Inventory inv, BlockEntity entity, ContainerData data)
|
||||
|
@ -42,11 +42,11 @@ public class CompressionChamberMenu extends AbstractContainerMenu
|
|||
addPlayerInventory(inv);
|
||||
addPlayerHotbar(inv);
|
||||
|
||||
this.entity.getCapability(ForgeCapabilities.ITEM_HANDLER, Direction.UP).ifPresent(handler->{
|
||||
this.entity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.UP).ifPresent(handler->{
|
||||
addSlot(new SlotItemHandler(handler, 0, 34,34));
|
||||
});
|
||||
|
||||
this.entity.getCapability(ForgeCapabilities.ITEM_HANDLER, Direction.DOWN).ifPresent(handler->{
|
||||
this.entity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.DOWN).ifPresent(handler->{
|
||||
addSlot(new SlotItemHandler(handler, 0, 113, 34));
|
||||
});
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package dev.zontreck.otemod.implementation.compressor;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.implementation.MouseHelpers;
|
||||
import dev.zontreck.otemod.implementation.energy.screenrenderer.EnergyInfoArea;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
@ -45,23 +45,23 @@ public class CompressionChamberScreen extends AbstractContainerScreen<Compressio
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void renderBg(GuiGraphics guiGraphics, float v, int i, int i1) {
|
||||
protected void renderBg(PoseStack guiGraphics, float v, int i, int i1) {
|
||||
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
RenderSystem.setShaderTexture(0, TEXTURE);
|
||||
|
||||
|
||||
guiGraphics.blit(TEXTURE, this.leftPos, this.topPos, 0,0, imageWidth, imageHeight);
|
||||
blit(guiGraphics, this.leftPos, this.topPos, 0,0, imageWidth, imageHeight);
|
||||
renderCraftingProgress(guiGraphics);
|
||||
EIA.draw(guiGraphics);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void renderLabels(GuiGraphics stack, int mouseX, int mouseY)
|
||||
protected void renderLabels(PoseStack stack, int mouseX, int mouseY)
|
||||
{
|
||||
stack.drawString(font, this.title.getString(), 32, 4, 0xFFFFFF);
|
||||
drawString(stack, font, this.title.getString(), 32, 4, 0xFFFFFF);
|
||||
|
||||
int x = (width - imageWidth )/2;
|
||||
int y = (height - imageHeight)/2;
|
||||
|
@ -69,23 +69,23 @@ public class CompressionChamberScreen extends AbstractContainerScreen<Compressio
|
|||
//this.font.draw(stack, this.playerInventoryTitle.getString(), this.leftPos + 17, this.topPos + 123, 0xFFFFFF);
|
||||
}
|
||||
|
||||
private void renderEnergy(GuiGraphics stack, int mouseX, int mouseY, int x, int y) {
|
||||
private void renderEnergy(PoseStack stack, int mouseX, int mouseY, int x, int y) {
|
||||
if(isMouseAbove(mouseX, mouseY, x, y, 63, 46, 39, 6)){
|
||||
stack.renderTooltip(font, EIA.getTooltips(), Optional.empty(), mouseX-x, mouseY-y);
|
||||
renderTooltip(stack, EIA.getTooltips(), Optional.empty(), mouseX-x, mouseY-y, font);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void renderCraftingProgress(GuiGraphics stack)
|
||||
private void renderCraftingProgress(PoseStack stack)
|
||||
{
|
||||
if(menu.isCrafting())
|
||||
{
|
||||
stack.blit(TEXTURE, leftPos+63, topPos+34, 179, 11, menu.getScaledProgress(),6);
|
||||
blit(stack, leftPos+63, topPos+34, 179, 11, menu.getScaledProgress(),6);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(GuiGraphics stack, int mouseX, int mouseY, float delta)
|
||||
public void render(PoseStack stack, int mouseX, int mouseY, float delta)
|
||||
{
|
||||
renderBackground(stack);
|
||||
super.render(stack, mouseX, mouseY, delta);
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
package dev.zontreck.otemod.implementation.energy.screenrenderer;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import net.minecraft.client.renderer.Rect2i;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
|
@ -33,18 +32,18 @@ public class EnergyInfoArea extends InfoArea {
|
|||
}
|
||||
|
||||
public List<Component> getTooltips() {
|
||||
return List.of(Component.literal(energy.getEnergyStored()+"/"+energy.getMaxEnergyStored()+" FE"));
|
||||
return List.of(ChatHelpers.macro(energy.getEnergyStored()+"/"+energy.getMaxEnergyStored()+" FE"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(GuiGraphics transform) {
|
||||
public void draw(PoseStack transform) {
|
||||
final int height = area.getHeight();
|
||||
final int width = area.getWidth();
|
||||
int stored = (int)(height*(energy.getEnergyStored()/(float)energy.getMaxEnergyStored()));
|
||||
|
||||
|
||||
if(area.getHeight() > area.getWidth())
|
||||
transform.fillGradient(area.getX(), area.getY() + (height + stored), area.getX() + area.getWidth(), area.getY() + area.getHeight(), 0xff0000, 0xff550000);
|
||||
else transform.fillGradient(area.getX() + (width + stored), area.getY(),area.getX() + area.getWidth(), area.getY() + area.getHeight(), 0xff0000, 0xff005500);
|
||||
fillGradient(transform, area.getX(), area.getY() + (height + stored), area.getX() + area.getWidth(), area.getY() + area.getHeight(), 0xff0000, 0xff550000);
|
||||
else fillGradient(transform, area.getX() + (width + stored), area.getY(),area.getX() + area.getWidth(), area.getY() + area.getHeight(), 0xff0000, 0xff005500);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,8 +2,7 @@ package dev.zontreck.otemod.implementation.energy.screenrenderer;
|
|||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.GuiComponent;
|
||||
import net.minecraft.client.renderer.Rect2i;
|
||||
|
||||
/*
|
||||
|
@ -13,13 +12,13 @@ import net.minecraft.client.renderer.Rect2i;
|
|||
* This code is licensed under "Blu's License of Common Sense"
|
||||
* Details can be found in the license file in the root folder of this project
|
||||
*/
|
||||
public abstract class InfoArea {
|
||||
public abstract class InfoArea extends GuiComponent {
|
||||
protected final Rect2i area;
|
||||
|
||||
protected InfoArea(Rect2i area) {
|
||||
this.area = area;
|
||||
}
|
||||
|
||||
public abstract void draw(GuiGraphics transform);
|
||||
public abstract void draw(PoseStack transform);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ import net.minecraftforge.registries.RegistryObject;
|
|||
|
||||
public final class ModMenuTypes
|
||||
{
|
||||
public static final DeferredRegister<MenuType<?>> CONTAINERS = DeferredRegister.create(ForgeRegistries.MENU_TYPES, OTEMod.MOD_ID);
|
||||
public static final DeferredRegister<MenuType<?>> CONTAINERS = DeferredRegister.create(ForgeRegistries.CONTAINERS, OTEMod.MOD_ID);
|
||||
|
||||
public static final RegistryObject<MenuType<VaultMenu>> VAULT = registerMenuType(VaultMenu::new, "vault");
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import net.minecraft.world.inventory.*;
|
|||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.SlotItemHandler;
|
||||
|
||||
public class ItemScrubberMenu extends AbstractContainerMenu
|
||||
|
@ -22,7 +22,7 @@ public class ItemScrubberMenu extends AbstractContainerMenu
|
|||
|
||||
public ItemScrubberMenu(int id, Inventory inv, FriendlyByteBuf buf)
|
||||
{
|
||||
this(id, inv, inv.player.level().getBlockEntity(buf.readBlockPos()), new SimpleContainerData(1));
|
||||
this(id, inv, inv.player.getLevel().getBlockEntity(buf.readBlockPos()), new SimpleContainerData(1));
|
||||
}
|
||||
|
||||
public ItemScrubberMenu(int id, Inventory inv, BlockEntity entity, ContainerData data){
|
||||
|
@ -31,15 +31,15 @@ public class ItemScrubberMenu extends AbstractContainerMenu
|
|||
checkContainerSize(inv, 1);
|
||||
this.entity = (ItemScrubberBlockEntity)entity;
|
||||
this.data=data;
|
||||
this.level = inv.player.level();
|
||||
this.level = inv.player.getLevel();
|
||||
|
||||
addPlayerInventory(inv);
|
||||
addPlayerHotbar(inv);
|
||||
|
||||
this.entity.getCapability(ForgeCapabilities.ITEM_HANDLER, Direction.UP).ifPresent(handler->{
|
||||
this.entity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.UP).ifPresent(handler->{
|
||||
addSlot(new SlotItemHandler(handler, 0, 16, 41));
|
||||
});
|
||||
this.entity.getCapability(ForgeCapabilities.ITEM_HANDLER, Direction.DOWN).ifPresent(handler->{
|
||||
this.entity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.DOWN).ifPresent(handler->{
|
||||
addSlot(new SlotItemHandler(handler, 0, 177, 41));
|
||||
});
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ import com.mojang.blaze3d.vertex.PoseStack;
|
|||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.implementation.MouseHelpers;
|
||||
import dev.zontreck.otemod.implementation.energy.screenrenderer.EnergyInfoArea;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
@ -47,22 +46,22 @@ public class ItemScrubberScreen extends AbstractContainerScreen<ItemScrubberMenu
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void renderBg(GuiGraphics poseStack, float partialTick, int mouseX, int mouseY) {
|
||||
protected void renderBg(PoseStack poseStack, float partialTick, int mouseX, int mouseY) {
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
RenderSystem.setShaderTexture(0, TEXTURE);
|
||||
|
||||
|
||||
poseStack.blit(TEXTURE, this.leftPos, this.topPos, 0,0, imageWidth, imageHeight);
|
||||
blit(poseStack, this.leftPos, this.topPos, 0,0, imageWidth, imageHeight);
|
||||
renderUncraftingProgress(poseStack);
|
||||
EIA.draw(poseStack);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void renderLabels(GuiGraphics stack, int mouseX, int mouseY)
|
||||
protected void renderLabels(PoseStack stack, int mouseX, int mouseY)
|
||||
{
|
||||
stack.drawString(font, this.title.getString(), 63, 12, 0xFFFFFF);
|
||||
drawString(stack, font, this.title.getString(), 63, 12, 0xFFFFFF);
|
||||
|
||||
int x = (width - imageWidth )/2;
|
||||
int y = (height - imageHeight)/2;
|
||||
|
@ -70,22 +69,22 @@ public class ItemScrubberScreen extends AbstractContainerScreen<ItemScrubberMenu
|
|||
//this.font.draw(stack, this.playerInventoryTitle.getString(), this.leftPos + 17, this.topPos + 123, 0xFFFFFF);
|
||||
}
|
||||
|
||||
private void renderEnergy(GuiGraphics stack, int mouseX, int mouseY, int x, int y) {
|
||||
private void renderEnergy(PoseStack stack, int mouseX, int mouseY, int x, int y) {
|
||||
if(isMouseAbove(mouseX, mouseY, x, y, 188, 69, 7, 72)){
|
||||
stack.renderTooltip(font, EIA.getTooltips(), Optional.empty(), mouseX-x, mouseY-y);
|
||||
renderTooltip(stack, EIA.getTooltips(), Optional.empty(), mouseX-x, mouseY-y, font);
|
||||
}
|
||||
}
|
||||
|
||||
private void renderUncraftingProgress(GuiGraphics stack)
|
||||
private void renderUncraftingProgress(PoseStack stack)
|
||||
{
|
||||
if(menu.isCrafting())
|
||||
{
|
||||
stack.blit(TEXTURE, leftPos+42, topPos+45, 1, 168, menu.getScaledProgress(),6);
|
||||
blit(stack, leftPos+42, topPos+45, 1, 168, menu.getScaledProgress(),6);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(GuiGraphics stack, int mouseX, int mouseY, float delta)
|
||||
public void render(PoseStack stack, int mouseX, int mouseY, float delta)
|
||||
{
|
||||
renderBackground(stack);
|
||||
super.render(stack, mouseX, mouseY, delta);
|
||||
|
|
|
@ -11,7 +11,7 @@ import net.minecraft.world.inventory.*;
|
|||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.SlotItemHandler;
|
||||
|
||||
public class MagicalScrubberMenu extends AbstractContainerMenu
|
||||
|
@ -22,7 +22,7 @@ public class MagicalScrubberMenu extends AbstractContainerMenu
|
|||
|
||||
public MagicalScrubberMenu(int id, Inventory inv, FriendlyByteBuf buf)
|
||||
{
|
||||
this(id, inv, inv.player.level().getBlockEntity(buf.readBlockPos()), new SimpleContainerData(1));
|
||||
this(id, inv, inv.player.getLevel().getBlockEntity(buf.readBlockPos()), new SimpleContainerData(1));
|
||||
}
|
||||
|
||||
public MagicalScrubberMenu(int id, Inventory inv, BlockEntity entity, ContainerData data){
|
||||
|
@ -31,15 +31,15 @@ public class MagicalScrubberMenu extends AbstractContainerMenu
|
|||
checkContainerSize(inv, 1);
|
||||
this.entity = (MagicalScrubberBlockEntity)entity;
|
||||
this.data=data;
|
||||
this.level = inv.player.level();
|
||||
this.level = inv.player.getLevel();
|
||||
|
||||
addPlayerInventory(inv);
|
||||
addPlayerHotbar(inv);
|
||||
|
||||
this.entity.getCapability(ForgeCapabilities.ITEM_HANDLER, Direction.UP).ifPresent(handler->{
|
||||
this.entity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.UP).ifPresent(handler->{
|
||||
addSlot(new SlotItemHandler(handler, 0, 16, 41));
|
||||
});
|
||||
this.entity.getCapability(ForgeCapabilities.ITEM_HANDLER, Direction.DOWN).ifPresent(handler->{
|
||||
this.entity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.DOWN).ifPresent(handler->{
|
||||
addSlot(new SlotItemHandler(handler, 0, 177, 41));
|
||||
});
|
||||
|
||||
|
|
|
@ -3,12 +3,11 @@ package dev.zontreck.otemod.implementation.scrubber;
|
|||
import java.util.Optional;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.implementation.MouseHelpers;
|
||||
import dev.zontreck.otemod.implementation.energy.screenrenderer.EnergyInfoArea;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
@ -48,22 +47,22 @@ public class MagicalScrubberScreen extends AbstractContainerScreen<MagicalScrubb
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void renderBg(GuiGraphics poseStack, float partialTick, int mouseX, int mouseY) {
|
||||
protected void renderBg(PoseStack poseStack, float partialTick, int mouseX, int mouseY) {
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
RenderSystem.setShaderTexture(0, TEXTURE);
|
||||
|
||||
|
||||
poseStack.blit(TEXTURE, this.leftPos, this.topPos, 0, 0, imageWidth, imageHeight);
|
||||
blit(poseStack, this.leftPos, this.topPos, 0, 0, imageWidth, imageHeight);
|
||||
renderUncraftingProgress(poseStack);
|
||||
EIA.draw(poseStack);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void renderLabels(GuiGraphics stack, int mouseX, int mouseY)
|
||||
protected void renderLabels(PoseStack stack, int mouseX, int mouseY)
|
||||
{
|
||||
stack.drawString(font, title.getString(), 63, 12, 0xFFFFFF);
|
||||
drawString(stack, font, title.getString(), 63, 12, 0xFFFFFF);
|
||||
|
||||
int x = (width - imageWidth )/2;
|
||||
int y = (height - imageHeight)/2;
|
||||
|
@ -71,22 +70,22 @@ public class MagicalScrubberScreen extends AbstractContainerScreen<MagicalScrubb
|
|||
//this.font.draw(stack, this.playerInventoryTitle.getString(), this.leftPos + 17, this.topPos + 123, 0xFFFFFF);
|
||||
}
|
||||
|
||||
private void renderEnergy(GuiGraphics stack, int mouseX, int mouseY, int x, int y) {
|
||||
private void renderEnergy(PoseStack stack, int mouseX, int mouseY, int x, int y) {
|
||||
if(isMouseAbove(mouseX, mouseY, x, y, 188, 69, 7, 72)){
|
||||
stack.renderTooltip(font, EIA.getTooltips(), Optional.empty(), mouseX-x, mouseY-y);
|
||||
renderTooltip(stack, EIA.getTooltips(), Optional.empty(), mouseX-x, mouseY-y, font);
|
||||
}
|
||||
}
|
||||
|
||||
private void renderUncraftingProgress(GuiGraphics stack)
|
||||
private void renderUncraftingProgress(PoseStack stack)
|
||||
{
|
||||
if(menu.isCrafting())
|
||||
{
|
||||
stack.blit(TEXTURE, leftPos+42, topPos+45, 1, 168, menu.getScaledProgress(), 6);
|
||||
blit(stack, leftPos+42, topPos+45, 1, 168, menu.getScaledProgress(), 6);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(GuiGraphics stack, int mouseX, int mouseY, float delta)
|
||||
public void render(PoseStack stack, int mouseX, int mouseY, float delta)
|
||||
{
|
||||
renderBackground(stack);
|
||||
super.render(stack, mouseX, mouseY, delta);
|
||||
|
|
|
@ -73,7 +73,7 @@ public class StarterContainer
|
|||
if(invalid)return;
|
||||
boolean isEmpty=true;
|
||||
CompoundTag saved = myInventory.serializeNBT();
|
||||
ChatHelpers.broadcastToAbove(owner, Component.literal(ChatColor.BOLD+ChatColor.DARK_GREEN+"Saving the starter kit's contents..."), server);
|
||||
ChatHelpers.broadcastToAbove(owner, ChatHelpers.macro(ChatColor.BOLD+ChatColor.DARK_GREEN+"Saving the starter kit's contents..."), server);
|
||||
|
||||
main_accessor.setLastChanged(Instant.now().getEpochSecond());
|
||||
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
package dev.zontreck.otemod.implementation.vault;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.networking.ModMessages;
|
||||
import dev.zontreck.otemod.networking.packets.OpenStarterVaultC2SPacket;
|
||||
import dev.zontreck.otemod.networking.packets.OpenVaultC2SPacket;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
@ -39,7 +35,7 @@ public class StarterScreen extends AbstractContainerScreen <StarterMenu>
|
|||
}
|
||||
|
||||
@Override
|
||||
public void render(GuiGraphics stack, int mouseX, int mouseY, float partialTicks)
|
||||
public void render(PoseStack stack, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
this.renderBackground(stack);
|
||||
super.render(stack, mouseX, mouseY, partialTicks);
|
||||
|
@ -58,13 +54,13 @@ public class StarterScreen extends AbstractContainerScreen <StarterMenu>
|
|||
|
||||
|
||||
@Override
|
||||
protected void renderBg(GuiGraphics pGuiGraphics, float pPartialTick, int pMouseX, int pMouseY)
|
||||
protected void renderBg(PoseStack pGuiGraphics, float pPartialTick, int pMouseX, int pMouseY)
|
||||
{
|
||||
renderBackground(pGuiGraphics);
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
RenderSystem.setShaderColor (1.0f, 1.0f, 1.0f, 1.0f);
|
||||
RenderSystem.setShaderTexture(0, TEXTURE);
|
||||
|
||||
pGuiGraphics.blit(TEXTURE, this.leftPos, this.topPos, 0, 0, this.imageWidth, this.imageHeight);
|
||||
blit(pGuiGraphics, this.leftPos, this.topPos, 0, 0, this.imageWidth, this.imageHeight);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ public class VaultContainer
|
|||
if(VAULT_NUMBER == -1)return; // We have no need to save the trash
|
||||
boolean isEmpty=true;
|
||||
CompoundTag saved = myInventory.serializeNBT();
|
||||
ChatHelpers.broadcastToAbove(owner, Component.literal(ChatColor.BOLD+ChatColor.DARK_GREEN+"Saving the vault's contents..."), server);
|
||||
ChatHelpers.broadcastToAbove(owner, ChatHelpers.macro(ChatColor.BOLD+ChatColor.DARK_GREEN+"Saving the vault's contents..."), server);
|
||||
|
||||
Profile profile=null;
|
||||
try {
|
||||
|
|
|
@ -5,14 +5,11 @@ import java.util.UUID;
|
|||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.commands.vaults.VaultCommand;
|
||||
import dev.zontreck.otemod.networking.ModMessages;
|
||||
import dev.zontreck.otemod.networking.packets.OpenVaultC2SPacket;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.components.Button.OnPress;
|
||||
import net.minecraft.client.gui.font.TextFieldHelper;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
@ -46,7 +43,7 @@ public class VaultScreen extends AbstractContainerScreen <VaultMenu>
|
|||
}
|
||||
|
||||
@Override
|
||||
public void render(GuiGraphics stack, int mouseX, int mouseY, float partialTicks)
|
||||
public void render(PoseStack stack, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
this.renderBackground(stack);
|
||||
super.render(stack, mouseX, mouseY, partialTicks);
|
||||
|
@ -64,28 +61,31 @@ public class VaultScreen extends AbstractContainerScreen <VaultMenu>
|
|||
|
||||
// This is where custom controls would be added!
|
||||
|
||||
this.addWidget(Button.builder(Component.literal(""), (BTN)->{
|
||||
this.addWidget(new Button(this.leftPos + 7, this.topPos + 86, 16, 16, ChatHelpers.macro(""), (BTN)->{
|
||||
|
||||
thePlayer.closeContainer();
|
||||
ModMessages.sendToServer(new OpenVaultC2SPacket(0, true, -1));
|
||||
}).size(16,16).pos(this.leftPos+7, this.topPos+86).build());
|
||||
}));
|
||||
|
||||
|
||||
this.addWidget(Button.builder(Component.literal(""), (BTN)->{
|
||||
this.addWidget(new Button(this.leftPos + 187, this.topPos + 88, 16, 16, ChatHelpers.macro(""), (BTN)->{
|
||||
|
||||
thePlayer.closeContainer();
|
||||
ModMessages.sendToServer(new OpenVaultC2SPacket(0, true, 1));
|
||||
}).size(16,16).pos(this.leftPos+187, this.topPos+84).build());
|
||||
}));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void renderBg(GuiGraphics pGuiGraphics, float pPartialTick, int pMouseX, int pMouseY)
|
||||
protected void renderBg(PoseStack pGuiGraphics, float pPartialTick, int pMouseX, int pMouseY)
|
||||
{
|
||||
renderBackground(pGuiGraphics);
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
RenderSystem.setShaderColor (1.0f, 1.0f, 1.0f, 1.0f);
|
||||
RenderSystem.setShaderTexture(0, TEXTURE);
|
||||
|
||||
pGuiGraphics.blit(TEXTURE, this.leftPos, this.topPos, 0, 0, this.imageWidth, this.imageHeight);
|
||||
blit(pGuiGraphics, this.leftPos, this.topPos, 0, 0, this.imageWidth, this.imageHeight);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package dev.zontreck.otemod.implementation.vault;
|
|||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import dev.zontreck.libzontreck.util.ServerUtilities;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import net.minecraftforge.client.event.ContainerScreenEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerContainerEvent;
|
||||
|
@ -16,7 +17,7 @@ public class VaultWatcher {
|
|||
@SubscribeEvent
|
||||
public void onClosedContainer(PlayerContainerEvent.Close ev)
|
||||
{
|
||||
if(ev.getEntity().level().isClientSide)return;
|
||||
if(ServerUtilities.isClient()) return;
|
||||
//OTEMod.LOGGER.info("Player closed a container");
|
||||
// Player closed the container
|
||||
// Check if it is a vault Container
|
||||
|
|
|
@ -3,12 +3,8 @@ package dev.zontreck.otemod.integrations;
|
|||
import com.mojang.blaze3d.platform.InputConstants;
|
||||
|
||||
import net.minecraft.client.KeyMapping;
|
||||
import net.minecraft.client.multiplayer.ClientRegistryLayer;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.client.event.RegisterKeyMappingsEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class KeyBindings {
|
||||
|
@ -22,9 +18,4 @@ public class KeyBindings {
|
|||
return key;
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerKeyMappings(RegisterKeyMappingsEvent event)
|
||||
{
|
||||
event.register(OPEN_VAULT);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import dev.zontreck.libzontreck.lore.ExtraLore;
|
|||
import dev.zontreck.libzontreck.lore.LoreContainer;
|
||||
import dev.zontreck.libzontreck.lore.LoreEntry;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.libzontreck.util.ServerUtilities;
|
||||
import net.minecraft.core.particles.ItemParticleOption;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
@ -61,7 +62,7 @@ public class ThrownPossBall extends ThrowableItemProjectile
|
|||
|
||||
for (int i = 0; i < 8; ++i)
|
||||
{
|
||||
this.level().addParticle(new ItemParticleOption(ParticleTypes.ITEM, this.getItem()), this.getX(), this.getY(), this.getZ(), ((double)this.random.nextFloat() - 0.5) * 0.08, ((double)this.random.nextFloat() - 0.5) * 0.08, ((double)this.random.nextFloat() - 0.5) * 0.08);
|
||||
this.getLevel().addParticle(new ItemParticleOption(ParticleTypes.ITEM, this.getItem()), this.getX(), this.getY(), this.getZ(), ((double)this.random.nextFloat() - 0.5) * 0.08, ((double)this.random.nextFloat() - 0.5) * 0.08, ((double)this.random.nextFloat() - 0.5) * 0.08);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +74,7 @@ public class ThrownPossBall extends ThrowableItemProjectile
|
|||
{
|
||||
// Don't capture the entity
|
||||
|
||||
pResult.getEntity().hurt(this.damageSources().thrown(this, this.getOwner()), 0.1F);
|
||||
pResult.getEntity().hurt(this.shooter.getLastDamageSource().thrown(this, this.getOwner()), 0.1F);
|
||||
} else {
|
||||
if(pResult.getEntity() instanceof LivingEntity le && !(le instanceof Player))
|
||||
{
|
||||
|
@ -101,7 +102,7 @@ public class ThrownPossBall extends ThrowableItemProjectile
|
|||
@Override
|
||||
protected void onHit(HitResult pResult) {
|
||||
super.onHit(pResult);
|
||||
if(!this.level().isClientSide)
|
||||
if(ServerUtilities.isServer())
|
||||
{
|
||||
// We do two things here
|
||||
|
||||
|
@ -118,19 +119,19 @@ public class ThrownPossBall extends ThrowableItemProjectile
|
|||
// Spawn poss ball item with the entity NBT
|
||||
ItemEntity entity;
|
||||
if(shooter != null)
|
||||
entity = new ItemEntity(level(), shooter.position().x, shooter.position().y, shooter.position().z, item, 0, 0, 0);
|
||||
entity = new ItemEntity(getLevel(), shooter.position().x, shooter.position().y, shooter.position().z, item, 0, 0, 0);
|
||||
else
|
||||
entity = new ItemEntity(level(), shooter.position().x, shooter.position().y, shooter.position().z, item, 0, 0, 0);
|
||||
level().addFreshEntity(entity);
|
||||
entity = new ItemEntity(getLevel(), shooter.position().x, shooter.position().y, shooter.position().z, item, 0, 0, 0);
|
||||
getLevel().addFreshEntity(entity);
|
||||
} else {
|
||||
// Spawn the real entity
|
||||
Optional<Entity> entity = EntityType.create(tag.getCompound("entity"), level());
|
||||
Optional<Entity> entity = EntityType.create(tag.getCompound("entity"), getLevel());
|
||||
if(entity.isPresent())
|
||||
{
|
||||
Entity xEntity = entity.get();
|
||||
xEntity.setUUID(UUID.randomUUID());
|
||||
xEntity.setPos(position());
|
||||
level().addFreshEntity(xEntity);
|
||||
getLevel().addFreshEntity(xEntity);
|
||||
}
|
||||
|
||||
LoreContainer cont = new LoreContainer(item);
|
||||
|
@ -147,10 +148,10 @@ public class ThrownPossBall extends ThrowableItemProjectile
|
|||
ItemEntity x;
|
||||
|
||||
if(shooter!=null)
|
||||
x = new ItemEntity(level(), shooter.position().x, shooter.position().y, shooter.position().z, item, 0, 0, 0);
|
||||
x = new ItemEntity(getLevel(), shooter.position().x, shooter.position().y, shooter.position().z, item, 0, 0, 0);
|
||||
else
|
||||
x = new ItemEntity(level(), position().x, position().y, position().z, item, 0, 0, 0);
|
||||
level().addFreshEntity(x);
|
||||
x = new ItemEntity(getLevel(), position().x, position().y, position().z, item, 0, 0, 0);
|
||||
getLevel().addFreshEntity(x);
|
||||
}
|
||||
} else {
|
||||
// No capture
|
||||
|
@ -168,14 +169,14 @@ public class ThrownPossBall extends ThrowableItemProjectile
|
|||
ItemEntity entity;
|
||||
|
||||
if(shooter!= null)
|
||||
entity = new ItemEntity(level(),shooter.position().x, shooter.position().y, shooter.position().z, item, 0, 0, 0);
|
||||
entity = new ItemEntity(getLevel(),shooter.position().x, shooter.position().y, shooter.position().z, item, 0, 0, 0);
|
||||
else
|
||||
|
||||
entity = new ItemEntity(level(), position().x, position().y, position().z, item, 0, 0, 0);
|
||||
level().addFreshEntity(entity);
|
||||
entity = new ItemEntity(getLevel(), position().x, position().y, position().z, item, 0, 0, 0);
|
||||
getLevel().addFreshEntity(entity);
|
||||
}
|
||||
|
||||
this.level().broadcastEntityEvent(this, (byte)3);
|
||||
this.getLevel().broadcastEntityEvent(this, (byte)3);
|
||||
this.discard();
|
||||
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import net.minecraft.world.level.block.Blocks;
|
|||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
import net.minecraftforge.event.world.ExplosionEvent;
|
||||
|
||||
public class UnstableSingularity extends SimpleFoiledItem
|
||||
{
|
||||
|
@ -24,7 +25,7 @@ public class UnstableSingularity extends SimpleFoiledItem
|
|||
|
||||
if(block.getBlock().defaultDestroyTime() < 0)
|
||||
{
|
||||
pContext.getLevel().explode(pContext.getPlayer(), pContext.getClickedPos().getX(), pContext.getClickedPos().getY(), pContext.getClickedPos().getZ(), 16, true, Level.ExplosionInteraction.TNT);
|
||||
pContext.getLevel().explode(pContext.getPlayer(), pContext.getClickedPos().getX(), pContext.getClickedPos().getY(), pContext.getClickedPos().getZ(), 16, true, Explosion.BlockInteraction.DESTROY);
|
||||
|
||||
pContext.getLevel().setBlock(pContext.getClickedPos(), Blocks.AIR.defaultBlockState(), 0, 0);
|
||||
|
||||
|
|
|
@ -32,13 +32,13 @@ public class ModMessages {
|
|||
net.messageBuilder(OpenVaultC2SPacket.class, id(), NetworkDirection.PLAY_TO_SERVER)
|
||||
.decoder(OpenVaultC2SPacket::new)
|
||||
.encoder(OpenVaultC2SPacket::toBytes)
|
||||
.consumerMainThread(OpenVaultC2SPacket::handle)
|
||||
.consumer(OpenVaultC2SPacket::handle)
|
||||
.add();
|
||||
|
||||
net.messageBuilder(EnergySyncS2CPacket.class, id(), NetworkDirection.PLAY_TO_CLIENT)
|
||||
.decoder(EnergySyncS2CPacket::new)
|
||||
.encoder(EnergySyncS2CPacket::toBytes)
|
||||
.consumerMainThread(EnergySyncS2CPacket::handle)
|
||||
.consumer(EnergySyncS2CPacket::handle)
|
||||
.add();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,28 @@
|
|||
package dev.zontreck.otemod.ore;
|
||||
|
||||
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.blocks.ModBlocks;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.data.worldgen.features.FeatureUtils;
|
||||
import net.minecraft.data.worldgen.features.OreFeatures;
|
||||
import net.minecraft.data.worldgen.placement.PlacementUtils;
|
||||
import net.minecraft.world.level.levelgen.GenerationStep;
|
||||
import net.minecraft.world.level.levelgen.VerticalAnchor;
|
||||
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.level.levelgen.feature.Feature;
|
||||
import net.minecraft.world.level.levelgen.feature.OreFeature;
|
||||
import net.minecraft.world.level.levelgen.feature.configurations.OreConfiguration;
|
||||
import net.minecraft.world.level.levelgen.placement.HeightRangePlacement;
|
||||
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
||||
import net.minecraftforge.event.world.BiomeLoadingEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class OreGenerator {
|
||||
/*
|
||||
|
||||
|
||||
public static final List<ConfiguredFeature<OreConfiguration, OreFeature>> OVERWORLD_ORES = new ArrayList();
|
||||
|
||||
|
@ -13,36 +33,39 @@ public class OreGenerator {
|
|||
|
||||
public static final List<OreConfiguration.TargetBlockState> NETHER_VAULTSTEEL_ORE = List.of( OreConfiguration.target(OreFeatures.NETHER_ORE_REPLACEABLES, ModBlocks.NETHER_VAULT_STEEL_ORE_BLOCK.get().defaultBlockState()));
|
||||
|
||||
public static final List<OreConfiguration.TargetBlockState> OVERWORLD_ILUSIUM_ORE = List.of(OreConfiguration.target(OreFeatures.STONE_ORE_REPLACEABLES, ModBlocks.ILUSIUM_ORE_BLOCK.get().defaultBlockState()), OreConfiguration.target(OreFeatures.DEEPSLATE_ORE_REPLACEABLES, ModBlocks.DEEPSLATE_ILUSIUM_ORE_BLOCK.get().defaultBlockState()));
|
||||
|
||||
public static final Holder<ConfiguredFeature<OreConfiguration, ?>> ETERNIUM_ORE = FeatureUtils.register("eternium_ore_block", Feature.ORE, new OreConfiguration(OVERWORLD_ETERNIUM_ORE, 8));
|
||||
|
||||
public static final Holder<ConfiguredFeature<OreConfiguration, ?>> VAULTSTEEL_ORE = FeatureUtils.register("vault_steel_ore_block", Feature.ORE, new OreConfiguration(OVERWORLD_VAULTSTEEL_ORE, 6));
|
||||
public static final Holder<ConfiguredFeature<OreConfiguration, ?>> ETERNIUM_ORE = FeatureUtils.register("eternium_ore_block", Feature.ORE, new OreConfiguration(OVERWORLD_ETERNIUM_ORE, 4));
|
||||
|
||||
public static final Holder<ConfiguredFeature<OreConfiguration, ?>> VAULTSTEEL_ORE_NETHER = FeatureUtils.register("nether_vault_steel_ore_block", Feature.ORE, new OreConfiguration(NETHER_VAULTSTEEL_ORE, 8));
|
||||
public static final Holder<ConfiguredFeature<OreConfiguration, ?>> VAULTSTEEL_ORE = FeatureUtils.register("vault_steel_ore_block", Feature.ORE, new OreConfiguration(OVERWORLD_VAULTSTEEL_ORE, 2));
|
||||
|
||||
public static final Holder<ConfiguredFeature<OreConfiguration, ?>> ILUSIUM_ORE = FeatureUtils.register("ilusium_ore_block", Feature.ORE, new OreConfiguration(OVERWORLD_ILUSIUM_ORE, 8));
|
||||
|
||||
public static final Holder<ConfiguredFeature<OreConfiguration, ?>> VAULTSTEEL_ORE_NETHER = FeatureUtils.register("nether_vault_steel_ore_block", Feature.ORE, new OreConfiguration(NETHER_VAULTSTEEL_ORE, 2));
|
||||
|
||||
public static final Holder<PlacedFeature> ETERNIUM_ORE_PLACED = PlacementUtils.register("eternium_ore_placed",
|
||||
ETERNIUM_ORE, ModdedOrePlacement.commonOrePlacement(3, // VeinsPerChunk
|
||||
ETERNIUM_ORE, ModdedOrePlacement.rareOrePlacement(3, // VeinsPerChunk
|
||||
HeightRangePlacement.triangle(VerticalAnchor.absolute(-20), VerticalAnchor.absolute(20))));
|
||||
|
||||
public static final Holder<PlacedFeature> ILUSIUM_ORE_PLACED = PlacementUtils.register("ilusium_ore_placed", ILUSIUM_ORE, ModdedOrePlacement.commonOrePlacement(4, HeightRangePlacement.triangle(VerticalAnchor.absolute(-20), VerticalAnchor.absolute(30))));
|
||||
|
||||
public static final Holder<PlacedFeature> VAULT_STEEL_ORE_PLACED = PlacementUtils.register("vaultsteel_ore_placed", VAULTSTEEL_ORE, ModdedOrePlacement.rareOrePlacement(4, // Veins per chunk
|
||||
HeightRangePlacement.triangle(VerticalAnchor.absolute(-63), VerticalAnchor.absolute(-50))));
|
||||
|
||||
public static final Holder<PlacedFeature> NETHER_VAULTSTEEL_ORE_PLACED = PlacementUtils.register("nether_vaultsteel_ore_placed", VAULTSTEEL_ORE_NETHER, ModdedOrePlacement.rareOrePlacement(5, // Veins per chunk
|
||||
HeightRangePlacement.triangle(VerticalAnchor.absolute(1), VerticalAnchor.absolute(16))));
|
||||
|
||||
//public static final Holder<PlacedFeature> DEEPSLATE_AION_ORE_PLACED = PlacementUtils.register("deepslate_aion_ore_placed",
|
||||
// DEEPSLATE_AION_ORE, ModdedOrePlacement.commonOrePlacement(3, // VeinsPerChunk
|
||||
// HeightRangePlacement.triangle(VerticalAnchor.aboveBottom(-20), VerticalAnchor.aboveBottom(0))));
|
||||
|
||||
@SubscribeEvent
|
||||
public static void generateOres(final BiomeLoadingEvent ev)
|
||||
{
|
||||
|
||||
List<Holder<PlacedFeature>> base = ev.getGeneration().getFeatures(GenerationStep.Decoration.UNDERGROUND_ORES);
|
||||
|
||||
//ShapedAionResources.LOGGER.info("Register: AION_ORE");
|
||||
base.add(ETERNIUM_ORE_PLACED);
|
||||
base.add(VAULT_STEEL_ORE_PLACED);
|
||||
base.add(NETHER_VAULTSTEEL_ORE_PLACED);
|
||||
//base.add(DEEPSLATE_AION_ORE_PLACED);
|
||||
}*/
|
||||
base.add(ILUSIUM_ORE_PLACED);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import net.minecraft.world.SimpleContainer;
|
|||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.*;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.registries.ForgeRegistryEntry;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class CompressionChamberRecipe implements Recipe<SimpleContainer> {
|
||||
|
@ -34,7 +35,7 @@ public class CompressionChamberRecipe implements Recipe<SimpleContainer> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ItemStack assemble(SimpleContainer simpleContainer, RegistryAccess registryAccess) {
|
||||
public ItemStack assemble(SimpleContainer simpleContainer) {
|
||||
return output;
|
||||
}
|
||||
|
||||
|
@ -44,7 +45,7 @@ public class CompressionChamberRecipe implements Recipe<SimpleContainer> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getResultItem(RegistryAccess registryAccess) {
|
||||
public ItemStack getResultItem() {
|
||||
return output.copy();
|
||||
}
|
||||
|
||||
|
@ -74,7 +75,7 @@ public class CompressionChamberRecipe implements Recipe<SimpleContainer> {
|
|||
public static final String ID = "compressing";
|
||||
}
|
||||
|
||||
public static class Serializer implements RecipeSerializer<CompressionChamberRecipe>
|
||||
public static class Serializer extends ForgeRegistryEntry<RecipeSerializer<?>> implements RecipeSerializer<CompressionChamberRecipe>
|
||||
{
|
||||
public static final Serializer INSTANCE = new Serializer();
|
||||
public static final ResourceLocation ID = new ResourceLocation(OTEMod.MOD_ID, Type.ID);
|
||||
|
|
|
@ -6,12 +6,11 @@ import java.util.Map;
|
|||
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||
import dev.zontreck.libzontreck.vectors.WorldPosition;
|
||||
import dev.zontreck.otemod.configs.OTEServerConfig;
|
||||
import net.minecraft.client.telemetry.events.WorldLoadEvent;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
import net.minecraftforge.event.level.ExplosionEvent;
|
||||
import net.minecraftforge.event.level.LevelEvent;
|
||||
import net.minecraftforge.event.server.ServerStoppingEvent;
|
||||
import net.minecraftforge.event.world.ExplosionEvent;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
||||
public class EventHandler {
|
||||
|
@ -19,17 +18,17 @@ public class EventHandler {
|
|||
@SubscribeEvent
|
||||
public void onDetonate(ExplosionEvent ev)
|
||||
{
|
||||
if(ev.getLevel().isClientSide)return;
|
||||
if(ev.getWorld().isClientSide)return;
|
||||
|
||||
//Entity explodes = ev.getExplosion().getSourceMob();
|
||||
// Register blocks to be healed
|
||||
WorldPosition wpos = new WorldPosition(new Vector3(ev.getExplosion().getPosition()), (ServerLevel) ev.getLevel());
|
||||
WorldPosition wpos = new WorldPosition(new Vector3(ev.getExplosion().getPosition()), (ServerLevel) ev.getWorld());
|
||||
|
||||
if(OTEServerConfig.EXCLUDE_DIMS.get().contains(wpos.Dimension)){
|
||||
// Dimension is on the exclusion list. Do not process.
|
||||
return;
|
||||
}
|
||||
WorldProp wp = WorldProp.acquire((ServerLevel)ev.getLevel());
|
||||
WorldProp wp = WorldProp.acquire((ServerLevel)ev.getWorld());
|
||||
|
||||
if(wp!=null){
|
||||
wp.onDetonate(ev);
|
||||
|
@ -45,21 +44,21 @@ public class EventHandler {
|
|||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onLoadLevel(LevelEvent.Load ev)
|
||||
public void onLoadLevel(WorldEvent.Load ev)
|
||||
{
|
||||
if(!ev.getLevel().isClientSide() && ev.getLevel() instanceof ServerLevel)
|
||||
if(!ev.getWorld().isClientSide() && ev.getWorld() instanceof ServerLevel)
|
||||
{
|
||||
healers.put((ServerLevel)ev.getLevel(), WorldProp.acquire((ServerLevel)ev.getLevel()));
|
||||
healers.put((ServerLevel)ev.getWorld(), WorldProp.acquire((ServerLevel)ev.getWorld()));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onUnload(LevelEvent.Unload ev)
|
||||
public void onUnload(WorldEvent.Unload ev)
|
||||
{
|
||||
if(!ev.getLevel().isClientSide())
|
||||
if(!ev.getWorld().isClientSide())
|
||||
{
|
||||
healers.remove(ev.getLevel());
|
||||
healers.remove(ev.getWorld());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,16 +69,16 @@ public class EventHandler {
|
|||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onSaving(LevelEvent.Save ev)
|
||||
public void onSaving(WorldEvent.Save ev)
|
||||
{
|
||||
WorldProp.SaveAll();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onLevelTick(TickEvent.LevelTickEvent ev)
|
||||
public void onLevelTick(TickEvent.WorldTickEvent ev)
|
||||
{
|
||||
if(!ev.level.isClientSide){
|
||||
WorldProp wp = WorldProp.acquire((ServerLevel)ev.level);
|
||||
if(!ev.world.isClientSide){
|
||||
WorldProp wp = WorldProp.acquire((ServerLevel)ev.world);
|
||||
if(wp!=null){
|
||||
wp.onTick();
|
||||
}
|
||||
|
|
|
@ -4,9 +4,6 @@ import dev.zontreck.libzontreck.exceptions.InvalidDeserialization;
|
|||
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||
import dev.zontreck.libzontreck.vectors.WorldPosition;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.HolderGetter;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtUtils;
|
||||
import net.minecraft.nbt.Tag;
|
||||
|
@ -149,11 +146,9 @@ public class StoredBlock
|
|||
} catch (InvalidDeserialization e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
HolderGetter<Block> hg = position.getActualDimension().holderLookup(Registries.BLOCK);
|
||||
|
||||
|
||||
state = NbtUtils.readBlockState(hg, tag.getCompound("state"));
|
||||
state = NbtUtils.readBlockState(tag.getCompound("state"));
|
||||
|
||||
final CompoundTag tmp = tag.getCompound("entity");
|
||||
blockEntity = tmp.isEmpty() ? null : tmp;
|
||||
|
|
|
@ -15,7 +15,7 @@ import net.minecraft.tags.BlockTags;
|
|||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.event.level.ExplosionEvent;
|
||||
import net.minecraftforge.event.world.ExplosionEvent;
|
||||
|
||||
public class WorldProp implements Supplier<Object>
|
||||
{
|
||||
|
@ -34,7 +34,7 @@ public class WorldProp implements Supplier<Object>
|
|||
|
||||
public void onDetonate(ExplosionEvent ev)
|
||||
{
|
||||
Level w = ev.getLevel();
|
||||
Level w = ev.getWorld();
|
||||
//int maxTicks = 0;
|
||||
|
||||
for(BlockPos p : ev.getExplosion().getToBlow())
|
||||
|
|
Reference in a new issue