diff --git a/src/main/java/dev/zontreck/otemod/OTEMod.java b/src/main/java/dev/zontreck/otemod/OTEMod.java index 823e544..a710864 100644 --- a/src/main/java/dev/zontreck/otemod/OTEMod.java +++ b/src/main/java/dev/zontreck/otemod/OTEMod.java @@ -11,6 +11,7 @@ import java.util.Map; import java.util.Set; import com.mojang.logging.LogUtils; +import dev.zontreck.otemod.integrations.KeyBindings; import net.minecraft.client.gui.screens.MenuScreens; import net.minecraft.client.renderer.entity.EntityRenderers; import net.minecraft.network.chat.Component; @@ -115,6 +116,8 @@ public class OTEMod ModEnchantments.register(bus); ModEntityTypes.register(bus); + MinecraftForge.EVENT_BUS.register(new KeyBindings()); + GeckoLib.initialize(); //MenuInitializer.register(bus); } @@ -192,7 +195,7 @@ public class OTEMod @SubscribeEvent public void onItemExpire(final ItemExpireEvent ev) { - if(ev.getEntity().level.isClientSide)return; + if(ev.getEntity().level().isClientSide)return; if(OTEServerConfig.ITEM_DESPAWN_TIMER.get()<=0)return; diff --git a/src/main/java/dev/zontreck/otemod/blocks/AuroraDoorBlock.java b/src/main/java/dev/zontreck/otemod/blocks/AuroraDoorBlock.java index fb8549c..cc2acee 100644 --- a/src/main/java/dev/zontreck/otemod/blocks/AuroraDoorBlock.java +++ b/src/main/java/dev/zontreck/otemod/blocks/AuroraDoorBlock.java @@ -5,17 +5,18 @@ import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.DoorBlock; 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 { public static final BlockBehaviour.Properties DOOR_PROPS; static { - DOOR_PROPS = BlockBehaviour.Properties.of(Blocks.IRON_DOOR.defaultBlockState().getMaterial()).requiresCorrectToolForDrops().strength(10, 100000f).sound(SoundType.NETHERITE_BLOCK); + DOOR_PROPS = BlockBehaviour.Properties.copy(Blocks.IRON_DOOR).requiresCorrectToolForDrops().strength(10, 100000f).sound(SoundType.NETHERITE_BLOCK); } public AuroraDoorBlock() { - super(DOOR_PROPS, SoundEvents.IRON_DOOR_CLOSE, SoundEvents.IRON_DOOR_OPEN); + super(DOOR_PROPS, BlockSetType.IRON); } diff --git a/src/main/java/dev/zontreck/otemod/blocks/ModBlocks.java b/src/main/java/dev/zontreck/otemod/blocks/ModBlocks.java index 1a1d5ad..4b870ba 100644 --- a/src/main/java/dev/zontreck/otemod/blocks/ModBlocks.java +++ b/src/main/java/dev/zontreck/otemod/blocks/ModBlocks.java @@ -10,7 +10,6 @@ import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.SoundType; 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; @@ -26,30 +25,30 @@ public class ModBlocks { OTEMod.LOGGER.info("Registering all blocks..."); } - public static final RegistryObject ETERNIUM_ORE_BLOCK = BLOCKS.register("eternium_ore_block", () -> new Block(BlockBehaviour.Properties.of(Material.METAL).requiresCorrectToolForDrops().strength(7F).explosionResistance(1200).destroyTime(6))); + public static final RegistryObject ETERNIUM_ORE_BLOCK = BLOCKS.register("eternium_ore_block", () -> new Block(BlockBehaviour.Properties.of().requiresCorrectToolForDrops().strength(7F).explosionResistance(1200).destroyTime(6))); public static final RegistryObject ETERNIUM_ORE_BLOCK_I = ITEMS.register("eternium_ore_block", () -> new BlockItem(ETERNIUM_ORE_BLOCK.get(), new Item.Properties())); - public static final RegistryObject VAULT_STEEL_ORE_BLOCK = BLOCKS.register("vault_steel_ore_block", ()->new Block(BlockBehaviour.Properties.of(Material.METAL).requiresCorrectToolForDrops().strength(8F).explosionResistance(1200).destroyTime(100))); + public static final RegistryObject 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 VAULT_STEEL_ORE_BLOCK_I = ITEMS.register("vault_steel_ore_block", ()->new BlockItem(VAULT_STEEL_ORE_BLOCK.get(), new Item.Properties())); - public static final RegistryObject NETHER_VAULT_STEEL_ORE_BLOCK = BLOCKS.register("nether_vault_steel_ore_block", ()->new Block(BlockBehaviour.Properties.of(Material.METAL).requiresCorrectToolForDrops().strength(8F).explosionResistance(1200).destroyTime(100))); + public static final RegistryObject 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 NETHER_VAULT_STEEL_ORE_BLOCK_I = ITEMS.register("nether_vault_steel_ore_block", ()->new BlockItem(NETHER_VAULT_STEEL_ORE_BLOCK.get(), new Item.Properties())); - public static final RegistryObject ETERNIUM_BLOCK = BLOCKS.register("eternium_block", ()->new Block(BlockBehaviour.Properties.of(Material.METAL).requiresCorrectToolForDrops().strength(8F).explosionResistance(1200).destroyTime(100))); + public static final RegistryObject ETERNIUM_BLOCK = BLOCKS.register("eternium_block", ()->new Block(BlockBehaviour.Properties.of().requiresCorrectToolForDrops().strength(8F).explosionResistance(1200).destroyTime(100))); public static final RegistryObject ETERNIUM_BLOCK_I = ITEMS.register("eternium_block", ()->new FoiledBlockItem(ETERNIUM_BLOCK.get(), new Item.Properties())); - public static final RegistryObject DEEPSLATE_ETERNIUM_ORE_BLOCK = BLOCKS.register("deepslate_eternium_ore_block", () -> new Block(BlockBehaviour.Properties.of(Material.METAL).requiresCorrectToolForDrops().strength(5f).explosionResistance(1200).destroyTime(7))); + public static final RegistryObject 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 DEEPSLATE_ETERNIUM_ORE_BLOCK_I = ITEMS.register("deepslate_eternium_ore_block", () -> new BlockItem(DEEPSLATE_ETERNIUM_ORE_BLOCK.get(), new Item.Properties())); - public static final RegistryObject AURORA_BLOCK = BLOCKS.register("aurora_block", () -> new Block(BlockBehaviour.Properties.of(Material.STONE).requiresCorrectToolForDrops().strength(9f).explosionResistance(100000f).destroyTime(10).sound(SoundType.NETHERITE_BLOCK))); + public static final RegistryObject 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 AURORA_BLOCK_I = ITEMS.register("aurora_block", () -> new BlockItem(AURORA_BLOCK.get(), new Item.Properties())); diff --git a/src/main/java/dev/zontreck/otemod/chat/ChatServerOverride.java b/src/main/java/dev/zontreck/otemod/chat/ChatServerOverride.java index 5c27154..876a557 100644 --- a/src/main/java/dev/zontreck/otemod/chat/ChatServerOverride.java +++ b/src/main/java/dev/zontreck/otemod/chat/ChatServerOverride.java @@ -81,7 +81,7 @@ public class ChatServerOverride { @SubscribeEvent public void onClone(final PlayerEvent.Clone ev) { - if(ev.getEntity().level.isClientSide)return; + if(ev.getEntity().level().isClientSide)return; // Fix for fly ability not copying to new instance on death or other circumstances Player old = ev.getOriginal(); Player n = ev.getEntity(); @@ -92,7 +92,7 @@ public class ChatServerOverride { @SubscribeEvent public void onChat(final ServerChatEvent ev){ - if(ev.getPlayer().level.isClientSide)return; + if(ev.getPlayer().level().isClientSide)return; // Player has chatted, apply override if(!OTEServerConfig.USE_CUSTOM_CHATREPLACER.get()) return; diff --git a/src/main/java/dev/zontreck/otemod/enchantments/FlightEnchantment.java b/src/main/java/dev/zontreck/otemod/enchantments/FlightEnchantment.java index 7f7014d..5be072a 100644 --- a/src/main/java/dev/zontreck/otemod/enchantments/FlightEnchantment.java +++ b/src/main/java/dev/zontreck/otemod/enchantments/FlightEnchantment.java @@ -29,7 +29,7 @@ public class FlightEnchantment extends Enchantment { if(ev.getEntity() instanceof Player) { - if(ev.getEntity().level.isClientSide)return; + if(ev.getEntity().level().isClientSide)return; ServerPlayer sp = (ServerPlayer)ev.getEntity(); @@ -68,7 +68,7 @@ public class FlightEnchantment extends Enchantment @SubscribeEvent public static void onGameModeChange(PlayerEvent.PlayerChangeGameModeEvent ev) { - if(ev.getEntity().level.isClientSide)return; + if(ev.getEntity().level().isClientSide)return; recheck((ServerPlayer)ev.getEntity()); } diff --git a/src/main/java/dev/zontreck/otemod/events/EventHandler.java b/src/main/java/dev/zontreck/otemod/events/EventHandler.java index edd925f..44a87b8 100644 --- a/src/main/java/dev/zontreck/otemod/events/EventHandler.java +++ b/src/main/java/dev/zontreck/otemod/events/EventHandler.java @@ -92,7 +92,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(Component.literal(DeathMessages.getRandomDeathMessage(Profile.get_profile_of(event.getEntity().getStringUUID()), event.getSource())), event.getEntity().level().getServer()); } catch (UserProfileNotYetExistsException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -101,7 +101,7 @@ public class EventHandler { @SubscribeEvent public void onEntityKilled(LivingDropsEvent ev){ - if(ev.getEntity().level.isClientSide)return; + if(ev.getEntity().level().isClientSide)return; Entity killedentity = ev.getEntity(); Entity ent = ev.getSource().getEntity(); @@ -127,7 +127,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.level(), killed.getX(), killed.getY(), killed.getZ(), egg)); LoreHandlers.updateItem(stack, ItemStatType.EGGING); } }else{ diff --git a/src/main/java/dev/zontreck/otemod/events/LoreHandlers.java b/src/main/java/dev/zontreck/otemod/events/LoreHandlers.java index 4be7bf5..78abea2 100644 --- a/src/main/java/dev/zontreck/otemod/events/LoreHandlers.java +++ b/src/main/java/dev/zontreck/otemod/events/LoreHandlers.java @@ -115,7 +115,7 @@ public class LoreHandlers { @SubscribeEvent public void onEntityKilled(LivingDeathEvent ev) { - if(ev.getEntity().level.isClientSide)return; + if(ev.getEntity().level().isClientSide)return; // Handle two things diff --git a/src/main/java/dev/zontreck/otemod/implementation/DeathMessages.java b/src/main/java/dev/zontreck/otemod/implementation/DeathMessages.java index ef6813f..1334024 100644 --- a/src/main/java/dev/zontreck/otemod/implementation/DeathMessages.java +++ b/src/main/java/dev/zontreck/otemod/implementation/DeathMessages.java @@ -7,6 +7,7 @@ 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 { @@ -34,7 +35,7 @@ public class DeathMessages { { sourceName = "A godlike player"; } - if(source.isFall()) + if(source.is(DamageTypes.FALL)) { msg = rng.nextInt(0,messages_falling.size()-1); return ChatHelpers.macroize(messages_falling.get(msg), String.valueOf(playerWhoDied.deaths), playerWhoDied.name_color + playerWhoDied.nickname); diff --git a/src/main/java/dev/zontreck/otemod/implementation/scrubber/ItemScrubberMenu.java b/src/main/java/dev/zontreck/otemod/implementation/scrubber/ItemScrubberMenu.java index 67e319d..41ddfe6 100644 --- a/src/main/java/dev/zontreck/otemod/implementation/scrubber/ItemScrubberMenu.java +++ b/src/main/java/dev/zontreck/otemod/implementation/scrubber/ItemScrubberMenu.java @@ -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.level().getBlockEntity(buf.readBlockPos()), new SimpleContainerData(1)); } public ItemScrubberMenu(int id, Inventory inv, BlockEntity entity, ContainerData data){ @@ -31,7 +31,7 @@ public class ItemScrubberMenu extends AbstractContainerMenu checkContainerSize(inv, 1); this.entity = (ItemScrubberBlockEntity)entity; this.data=data; - this.level = inv.player.level; + this.level = inv.player.level(); addPlayerInventory(inv); addPlayerHotbar(inv); diff --git a/src/main/java/dev/zontreck/otemod/implementation/scrubber/MagicalScrubberMenu.java b/src/main/java/dev/zontreck/otemod/implementation/scrubber/MagicalScrubberMenu.java index 271841e..2a0c9f9 100644 --- a/src/main/java/dev/zontreck/otemod/implementation/scrubber/MagicalScrubberMenu.java +++ b/src/main/java/dev/zontreck/otemod/implementation/scrubber/MagicalScrubberMenu.java @@ -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.level().getBlockEntity(buf.readBlockPos()), new SimpleContainerData(1)); } public MagicalScrubberMenu(int id, Inventory inv, BlockEntity entity, ContainerData data){ @@ -31,7 +31,7 @@ public class MagicalScrubberMenu extends AbstractContainerMenu checkContainerSize(inv, 1); this.entity = (MagicalScrubberBlockEntity)entity; this.data=data; - this.level = inv.player.level; + this.level = inv.player.level(); addPlayerInventory(inv); addPlayerHotbar(inv); diff --git a/src/main/java/dev/zontreck/otemod/implementation/vault/VaultWatcher.java b/src/main/java/dev/zontreck/otemod/implementation/vault/VaultWatcher.java index 6234d29..daa96f4 100644 --- a/src/main/java/dev/zontreck/otemod/implementation/vault/VaultWatcher.java +++ b/src/main/java/dev/zontreck/otemod/implementation/vault/VaultWatcher.java @@ -16,7 +16,7 @@ public class VaultWatcher { @SubscribeEvent public void onClosedContainer(PlayerContainerEvent.Close ev) { - if(ev.getEntity().level.isClientSide)return; + if(ev.getEntity().level().isClientSide)return; //OTEMod.LOGGER.info("Player closed a container"); // Player closed the container // Check if it is a vault Container diff --git a/src/main/java/dev/zontreck/otemod/integrations/KeyBindings.java b/src/main/java/dev/zontreck/otemod/integrations/KeyBindings.java index 8752e27..438f079 100644 --- a/src/main/java/dev/zontreck/otemod/integrations/KeyBindings.java +++ b/src/main/java/dev/zontreck/otemod/integrations/KeyBindings.java @@ -5,18 +5,23 @@ 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.client.ClientRegistry; +import net.minecraftforge.client.event.RegisterKeyMappingsEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; public class KeyBindings { public static final String KEY_CATEGORY_OTEMOD = "key.category.otemod"; public static final String KEY_OPEN_VAULT = "key.otemod.open_vault"; - public static final KeyMapping OPEN_VAULT = registerKeyMapping(KEY_OPEN_VAULT, InputConstants.KEY_V, KEY_CATEGORY_OTEMOD); + public static final KeyMapping OPEN_VAULT = createKeyMapping(KEY_OPEN_VAULT, InputConstants.KEY_V, KEY_CATEGORY_OTEMOD); - private static KeyMapping registerKeyMapping(String name, int keycode, String category){ + private static KeyMapping createKeyMapping(String name, int keycode, String category){ final KeyMapping key = new KeyMapping(name, keycode, category); - - ClientRegistry.registerKeyBinding(key); return key; } + + @SubscribeEvent + public static void registerKeyMappings(RegisterKeyMappingsEvent event) + { + event.register(OPEN_VAULT); + } }