tmp
This commit is contained in:
parent
314bcb4032
commit
3dede03182
@ -1,12 +1,13 @@
|
|||||||
package com.jenny.magic;
|
package com.jenny.magic;
|
||||||
|
|
||||||
import com.jenny.magic.blocks.blocks;
|
import com.jenny.magic.blocks.blocks;
|
||||||
import com.jenny.magic.blocks.conditions.conditions;
|
|
||||||
import com.jenny.magic.blocks.entities.blockEntities;
|
import com.jenny.magic.blocks.entities.blockEntities;
|
||||||
import com.jenny.magic.blocks.networking.networking;
|
import com.jenny.magic.conditions.conditions;
|
||||||
import com.jenny.magic.config.ConfigServer;
|
import com.jenny.magic.config.ConfigServer;
|
||||||
|
import com.jenny.magic.enchantments.enchantments;
|
||||||
import com.jenny.magic.entities.entities;
|
import com.jenny.magic.entities.entities;
|
||||||
import com.jenny.magic.items.items;
|
import com.jenny.magic.items.items;
|
||||||
|
import com.jenny.magic.networking.networking;
|
||||||
import com.mojang.logging.LogUtils;
|
import com.mojang.logging.LogUtils;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.eventbus.api.IEventBus;
|
import net.minecraftforge.eventbus.api.IEventBus;
|
||||||
@ -34,6 +35,7 @@ public class Magic {
|
|||||||
items.register(modEventBus);
|
items.register(modEventBus);
|
||||||
blocks.register(modEventBus);
|
blocks.register(modEventBus);
|
||||||
blockEntities.register(modEventBus);
|
blockEntities.register(modEventBus);
|
||||||
|
enchantments.register(modEventBus);
|
||||||
creativeTab.register(modEventBus);
|
creativeTab.register(modEventBus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,18 +5,15 @@ import com.jenny.magic.blocks.entities.blockEntities;
|
|||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.BaseEntityBlock;
|
import net.minecraft.world.level.block.BaseEntityBlock;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.RenderShape;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public class AntiSpawner extends BaseEntityBlock {
|
public class AntiSpawner extends BaseEntityBlock {
|
||||||
public static final VoxelShape SHAPE = Block.box(0, 0, 0, 16, 16, 16);
|
|
||||||
|
|
||||||
protected AntiSpawner(Properties pProperties) {
|
protected AntiSpawner(Properties pProperties) {
|
||||||
super(pProperties);
|
super(pProperties);
|
||||||
}
|
}
|
||||||
@ -26,6 +23,11 @@ public class AntiSpawner extends BaseEntityBlock {
|
|||||||
return new AntiSpawnerBE(pPos, pState);
|
return new AntiSpawnerBE(pPos, pState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RenderShape getRenderShape(BlockState pState) {
|
||||||
|
return RenderShape.MODEL;
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(@NotNull Level pLevel, @NotNull BlockState pState, @NotNull BlockEntityType<T> pBlockEntityType) {
|
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(@NotNull Level pLevel, @NotNull BlockState pState, @NotNull BlockEntityType<T> pBlockEntityType) {
|
||||||
|
@ -22,7 +22,6 @@ public class AntiSpawnerBE extends BlockEntity {
|
|||||||
for (Entity e : pLevel.getEntities(null, area)) {
|
for (Entity e : pLevel.getEntities(null, area)) {
|
||||||
if (e instanceof Monster && ((Monster) e).getSpawnType() == MobSpawnType.NATURAL) {
|
if (e instanceof Monster && ((Monster) e).getSpawnType() == MobSpawnType.NATURAL) {
|
||||||
e.remove(Entity.RemovalReason.KILLED);
|
e.remove(Entity.RemovalReason.KILLED);
|
||||||
e.remove(Entity.RemovalReason.KILLED);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package com.jenny.magic.blocks.conditions;
|
package com.jenny.magic.conditions;
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
@ -1,4 +1,4 @@
|
|||||||
package com.jenny.magic.blocks.conditions;
|
package com.jenny.magic.conditions;
|
||||||
|
|
||||||
import com.jenny.magic.blocks.blocks;
|
import com.jenny.magic.blocks.blocks;
|
||||||
import com.jenny.magic.config.ConfigServer;
|
import com.jenny.magic.config.ConfigServer;
|
38
src/main/java/com/jenny/magic/enchantments/Homing.java
Normal file
38
src/main/java/com/jenny/magic/enchantments/Homing.java
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
package com.jenny.magic.enchantments;
|
||||||
|
|
||||||
|
import com.jenny.magic.items.BaseWand;
|
||||||
|
import net.minecraft.world.entity.EquipmentSlot;
|
||||||
|
import net.minecraft.world.item.Item;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.item.enchantment.Enchantment;
|
||||||
|
import net.minecraft.world.item.enchantment.EnchantmentCategory;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class Homing extends Enchantment {
|
||||||
|
|
||||||
|
protected Homing(Rarity pRarity, EnchantmentCategory pCategory, EquipmentSlot[] pApplicableSlots) {
|
||||||
|
super(pRarity, pCategory, pApplicableSlots);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaxLevel() {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canEnchant(@NotNull ItemStack pStack) {
|
||||||
|
return canApplyAtEnchantingTable(pStack) && isApplicableWand(pStack.getItem());
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isApplicableWand(Item item) {
|
||||||
|
return item instanceof BaseWand;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isTradeable() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDiscoverable() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
25
src/main/java/com/jenny/magic/enchantments/enchantments.java
Normal file
25
src/main/java/com/jenny/magic/enchantments/enchantments.java
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package com.jenny.magic.enchantments;
|
||||||
|
|
||||||
|
import net.minecraft.world.entity.EquipmentSlot;
|
||||||
|
import net.minecraft.world.item.enchantment.Enchantment;
|
||||||
|
import net.minecraft.world.item.enchantment.EnchantmentCategory;
|
||||||
|
import net.minecraftforge.eventbus.api.IEventBus;
|
||||||
|
import net.minecraftforge.registries.DeferredRegister;
|
||||||
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
|
import net.minecraftforge.registries.RegistryObject;
|
||||||
|
|
||||||
|
import static com.jenny.magic.Magic.MODID;
|
||||||
|
|
||||||
|
public class enchantments {
|
||||||
|
public static final DeferredRegister<Enchantment> ENCHANTMENTS =
|
||||||
|
DeferredRegister.create(ForgeRegistries.ENCHANTMENTS, MODID);
|
||||||
|
|
||||||
|
public static RegistryObject<Enchantment> HOMING =
|
||||||
|
ENCHANTMENTS.register("homing",
|
||||||
|
() -> new Homing(Enchantment.Rarity.VERY_RARE,
|
||||||
|
EnchantmentCategory.WEAPON, new EquipmentSlot[]{EquipmentSlot.MAINHAND}));
|
||||||
|
|
||||||
|
public static void register(IEventBus eventBus) {
|
||||||
|
ENCHANTMENTS.register(eventBus);
|
||||||
|
}
|
||||||
|
}
|
@ -45,7 +45,6 @@ public abstract class BaseWandProjectile extends AbstractArrow {
|
|||||||
hitParticles();
|
hitParticles();
|
||||||
}
|
}
|
||||||
hitEntity(pResult);
|
hitEntity(pResult);
|
||||||
//this.discard();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -55,7 +54,6 @@ public abstract class BaseWandProjectile extends AbstractArrow {
|
|||||||
hitParticles();
|
hitParticles();
|
||||||
}
|
}
|
||||||
super.onHitBlock(pResult);
|
super.onHitBlock(pResult);
|
||||||
//this.discard();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Vec3 particlePos(double dist) {
|
protected Vec3 particlePos(double dist) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.jenny.magic.items;
|
package com.jenny.magic.items;
|
||||||
|
|
||||||
import com.jenny.magic.blocks.networking.networking;
|
import com.jenny.magic.networking.networking;
|
||||||
import com.jenny.magic.blocks.networking.packets.ManaAmountS2C;
|
import com.jenny.magic.networking.packets.ManaAmountS2C;
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.core.particles.ParticleOptions;
|
import net.minecraft.core.particles.ParticleOptions;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.jenny.magic.items;
|
package com.jenny.magic.items;
|
||||||
|
|
||||||
import com.jenny.magic.blocks.mana.ManaClient;
|
|
||||||
import com.jenny.magic.entities.BaseWandProjectile;
|
import com.jenny.magic.entities.BaseWandProjectile;
|
||||||
|
import com.jenny.magic.mana.ManaClient;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.InteractionResultHolder;
|
import net.minecraft.world.InteractionResultHolder;
|
||||||
@ -10,7 +10,7 @@ import net.minecraft.world.item.ItemStack;
|
|||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
abstract class BaseWand extends BaseItem {
|
public abstract class BaseWand extends QualityItem {
|
||||||
public BaseWand(Properties properties) {
|
public BaseWand(Properties properties) {
|
||||||
super(properties.stacksTo(1));
|
super(properties.stacksTo(1));
|
||||||
}
|
}
|
||||||
|
49
src/main/java/com/jenny/magic/items/QualityItem.java
Normal file
49
src/main/java/com/jenny/magic/items/QualityItem.java
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
package com.jenny.magic.items;
|
||||||
|
|
||||||
|
import net.minecraft.ChatFormatting;
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.network.chat.MutableComponent;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.item.TooltipFlag;
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
public class QualityItem extends BaseItem {
|
||||||
|
public QualityItem(Properties pProperties) {
|
||||||
|
super(pProperties);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getDefaultInstance() {
|
||||||
|
return setQuality(new ItemStack(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ItemStack setQuality(@NotNull ItemStack itemStack) {
|
||||||
|
float quality = (float) new Random(System.nanoTime()).nextInt(0, 21) / 10 + 1;
|
||||||
|
CompoundTag tag;
|
||||||
|
if (itemStack.getTag() != null) {
|
||||||
|
tag = itemStack.getTag();
|
||||||
|
} else {
|
||||||
|
tag = new CompoundTag();
|
||||||
|
}
|
||||||
|
tag.putFloat("magic_quality", quality);
|
||||||
|
itemStack.setTag(tag);
|
||||||
|
return itemStack;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected float getQuality(@NotNull ItemStack itemStack) {
|
||||||
|
return itemStack.getTag() != null ? itemStack.getTag().getFloat("magic_quality") : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void appendHoverText(@NotNull ItemStack pStack, @Nullable Level pLevel, @NotNull List<Component> pTooltipComponents, @NotNull TooltipFlag pIsAdvanced) {
|
||||||
|
MutableComponent toolTip = Component.literal(Float.toString(getQuality(pStack)));
|
||||||
|
pTooltipComponents.add(toolTip.withStyle(ChatFormatting.DARK_RED));
|
||||||
|
super.appendHoverText(pStack, pLevel, pTooltipComponents, pIsAdvanced);
|
||||||
|
}
|
||||||
|
}
|
@ -4,8 +4,8 @@ import com.jenny.magic.entities.BaseWandProjectile;
|
|||||||
import com.jenny.magic.entities.HurtfulProjectile;
|
import com.jenny.magic.entities.HurtfulProjectile;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
|
|
||||||
public class HurtfulWand extends BaseWand {
|
public class WandHurtful extends BaseWand {
|
||||||
public HurtfulWand(Properties p_41383_) {
|
public WandHurtful(Properties p_41383_) {
|
||||||
super(p_41383_);
|
super(p_41383_);
|
||||||
}
|
}
|
||||||
|
|
44
src/main/java/com/jenny/magic/items/WandVacuum.java
Normal file
44
src/main/java/com/jenny/magic/items/WandVacuum.java
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
package com.jenny.magic.items;
|
||||||
|
|
||||||
|
import com.jenny.magic.networking.networking;
|
||||||
|
import com.jenny.magic.networking.packets.EffectS2C;
|
||||||
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
import net.minecraft.world.InteractionHand;
|
||||||
|
import net.minecraft.world.InteractionResult;
|
||||||
|
import net.minecraft.world.InteractionResultHolder;
|
||||||
|
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.context.UseOnContext;
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
|
import net.minecraft.world.phys.AABB;
|
||||||
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class WandVacuum extends BaseItem {
|
||||||
|
public WandVacuum(Properties pProperties) {
|
||||||
|
super(pProperties);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull InteractionResultHolder<ItemStack> use(@NotNull Level pLevel, @NotNull Player pPlayer, @NotNull InteractionHand pUsedHand) {
|
||||||
|
use(pPlayer.position(), pPlayer, pPlayer.getItemInHand(pUsedHand), pLevel);
|
||||||
|
return InteractionResultHolder.success(pPlayer.getItemInHand(pUsedHand));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull InteractionResult useOn(@NotNull UseOnContext pContext) {
|
||||||
|
use(pContext.getClickedPos().getCenter().add(0, 0.5, 0), pContext.getPlayer(), pContext.getItemInHand(), pContext.getLevel());
|
||||||
|
return InteractionResult.SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void use(Vec3 pos, Player player, @NotNull ItemStack itemStack, Level level) {
|
||||||
|
if (!level.isClientSide) {
|
||||||
|
AABB aabb = new AABB(player.position().subtract(20, 20, 20), player.position().add(20, 20, 20));
|
||||||
|
for (ItemEntity e : level.getEntitiesOfClass(ItemEntity.class, aabb)) {
|
||||||
|
e.playerTouch(player);
|
||||||
|
}
|
||||||
|
networking.sendToPlayer(new EffectS2C(EffectS2C.Effect.WAND_VACUUM, player.position(), player.position()), (ServerPlayer) player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -12,12 +12,15 @@ import static com.jenny.magic.Magic.MODID;
|
|||||||
|
|
||||||
public class items {
|
public class items {
|
||||||
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
|
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
|
||||||
public static final RegistryObject<Item> WAND_HURTFUL = ITEMS.register("wand_hurtful", () -> new HurtfulWand(new Item.Properties()));
|
public static final RegistryObject<Item> WAND_HURTFUL = ITEMS.register("wand_hurtful", () -> new WandHurtful(new Item.Properties()));
|
||||||
|
public static final RegistryObject<Item> WAND_VAUUM = ITEMS.register("wand_vacuum", () -> new WandVacuum(new Item.Properties()));
|
||||||
public static final RegistryObject<Item> SCROLL_TELEPORT = ITEMS.register("scroll_teleport", () -> new TeleportScrollPersistent(new Item.Properties().stacksTo(1)));
|
public static final RegistryObject<Item> SCROLL_TELEPORT = ITEMS.register("scroll_teleport", () -> new TeleportScrollPersistent(new Item.Properties().stacksTo(1)));
|
||||||
public static final RegistryObject<Item> SCROLL_TELEPORT_BRITTLE = ITEMS.register("scroll_teleport_brittle", () -> new TeleportScrollConsumable(new Item.Properties().stacksTo(16)));
|
public static final RegistryObject<Item> SCROLL_TELEPORT_BRITTLE = ITEMS.register("scroll_teleport_brittle", () -> new TeleportScrollConsumable(new Item.Properties().stacksTo(16)));
|
||||||
public static final RegistryObject<Item> SCROLL_TELEPORT_RANDOM = ITEMS.register("scroll_teleport_random", () -> new TeleportScrollRandom(new Item.Properties().stacksTo(1)));
|
public static final RegistryObject<Item> SCROLL_TELEPORT_RANDOM = ITEMS.register("scroll_teleport_random", () -> new TeleportScrollRandom(new Item.Properties().stacksTo(1)));
|
||||||
//public static final RegistryObject<Item> SCROLL_TELEPORT_RANDOM_BIOME = ITEMS.register("scroll_teleport_random_biome", () -> new TeleportScrollRandomBiome(new Item.Properties().stacksTo(16)));
|
//public static final RegistryObject<Item> SCROLL_TELEPORT_RANDOM_BIOME = ITEMS.register("scroll_teleport_random_biome", () -> new TeleportScrollRandomBiome(new Item.Properties().stacksTo(16)));
|
||||||
public static final RegistryObject<Item> SCROLL_TELEPORT_BIOME_PLAINS = ITEMS.register("scroll_teleport_biome_plains", () -> new TeleportScrollBiome(new Item.Properties().stacksTo(16), Biomes.PLAINS, ChatFormatting.GREEN));
|
public static final RegistryObject<Item> SCROLL_TELEPORT_BIOME_PLAINS = ITEMS.register("scroll_teleport_biome_plains", () -> new TeleportScrollBiome(new Item.Properties().stacksTo(16), Biomes.PLAINS, ChatFormatting.GREEN));
|
||||||
|
public static final RegistryObject<Item> DRAGON_HEART = ITEMS.register("dragon_heart", () -> new QualityItem(new Item.Properties()));
|
||||||
|
|
||||||
|
|
||||||
public static void register(IEventBus bus) {
|
public static void register(IEventBus bus) {
|
||||||
ITEMS.register(bus);
|
ITEMS.register(bus);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package com.jenny.magic.blocks.mana;
|
package com.jenny.magic.mana;
|
||||||
|
|
||||||
public class ManaClient {
|
public class ManaClient {
|
||||||
public static int mana = 100;
|
public static int mana = 100;
|
20
src/main/java/com/jenny/magic/mana/ManaServer.java
Normal file
20
src/main/java/com/jenny/magic/mana/ManaServer.java
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package com.jenny.magic.mana;
|
||||||
|
|
||||||
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
import net.minecraftforge.event.server.ServerLifecycleEvent;
|
||||||
|
import net.minecraftforge.fml.common.Mod;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import static com.jenny.magic.Magic.MODID;
|
||||||
|
|
||||||
|
@Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.DEDICATED_SERVER)
|
||||||
|
public class ManaServer {
|
||||||
|
public static HashMap<String, Integer> mana = new HashMap<>();
|
||||||
|
|
||||||
|
public static void serverLoad(ServerLifecycleEvent event) {
|
||||||
|
if event.
|
||||||
|
}
|
||||||
|
|
||||||
|
public st
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
package com.jenny.magic.mixins;
|
package com.jenny.magic.mixins;
|
||||||
|
|
||||||
import com.jenny.magic.blocks.mana.ManaClient;
|
import com.jenny.magic.mana.ManaClient;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.Gui;
|
import net.minecraft.client.gui.Gui;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
|
@ -0,0 +1,63 @@
|
|||||||
|
package com.jenny.magic.mixins;
|
||||||
|
|
||||||
|
import net.minecraft.core.NonNullList;
|
||||||
|
import net.minecraft.core.RegistryAccess;
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.world.inventory.CraftingContainer;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.item.crafting.Ingredient;
|
||||||
|
import net.minecraft.world.item.crafting.ShapelessRecipe;
|
||||||
|
import org.spongepowered.asm.mixin.Final;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Overwrite;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
|
||||||
|
@Mixin(ShapelessRecipe.class)
|
||||||
|
public class ShapelessRecipeMixin {
|
||||||
|
@Final
|
||||||
|
@Shadow
|
||||||
|
ItemStack result;
|
||||||
|
|
||||||
|
@Final
|
||||||
|
@Shadow
|
||||||
|
NonNullList<Ingredient> ingredients;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xJenny69
|
||||||
|
* @reason allow "magic_quality" tag to be passed on
|
||||||
|
*/
|
||||||
|
@Overwrite
|
||||||
|
public ItemStack assemble(CraftingContainer pContainer, RegistryAccess pRegistryAccess) {
|
||||||
|
for (Ingredient ingredient : ingredients) {
|
||||||
|
for (ItemStack itemStack : ingredient.getItems()) {
|
||||||
|
if (itemStack.getTag() != null && itemStack.getTag().contains("magic_quality")) {
|
||||||
|
CompoundTag tag = result.getTag();
|
||||||
|
tag.putFloat("magic_quality", itemStack.getTag().getFloat("magic_quality"));
|
||||||
|
result.setTag(tag);
|
||||||
|
return result.copy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result.copy();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author
|
||||||
|
* @reason
|
||||||
|
*/
|
||||||
|
@Overwrite
|
||||||
|
public ItemStack getResultItem(RegistryAccess pRegistryAccess) {
|
||||||
|
for (Ingredient ingredient : ingredients) {
|
||||||
|
for (ItemStack itemStack : ingredient.getItems()) {
|
||||||
|
if (itemStack.getTag() != null && itemStack.getTag().contains("magic_quality")) {
|
||||||
|
CompoundTag tag = result.getTag();
|
||||||
|
tag.putFloat("magic_quality", itemStack.getTag().getFloat("magic_quality"));
|
||||||
|
result.setTag(tag);
|
||||||
|
return result.copy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result.copy();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package com.jenny.magic.blocks.networking;
|
package com.jenny.magic.networking;
|
||||||
|
|
||||||
import com.jenny.magic.blocks.networking.packets.ManaAmountS2C;
|
import com.jenny.magic.networking.packets.EffectS2C;
|
||||||
|
import com.jenny.magic.networking.packets.ManaAmountS2C;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraftforge.network.NetworkDirection;
|
import net.minecraftforge.network.NetworkDirection;
|
||||||
@ -32,6 +33,12 @@ public class networking {
|
|||||||
.encoder(ManaAmountS2C::toBytes)
|
.encoder(ManaAmountS2C::toBytes)
|
||||||
.consumerMainThread(ManaAmountS2C::handle)
|
.consumerMainThread(ManaAmountS2C::handle)
|
||||||
.add();
|
.add();
|
||||||
|
|
||||||
|
net.messageBuilder(EffectS2C.class, id(), NetworkDirection.PLAY_TO_CLIENT)
|
||||||
|
.decoder(EffectS2C::new)
|
||||||
|
.encoder(EffectS2C::toBytes)
|
||||||
|
.consumerMainThread(EffectS2C::handle)
|
||||||
|
.add();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <MSG> void sendToServer(MSG message) {
|
public static <MSG> void sendToServer(MSG message) {
|
@ -0,0 +1,51 @@
|
|||||||
|
package com.jenny.magic.networking.packets;
|
||||||
|
|
||||||
|
import com.jenny.magic.particles.effects;
|
||||||
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
public class EffectS2C {
|
||||||
|
private final Effect effectID;
|
||||||
|
private final Vec3 vector1, vector2;
|
||||||
|
|
||||||
|
public EffectS2C(Effect effectID, @Nullable Vec3 origin, @Nullable Vec3 target) {
|
||||||
|
this.effectID = effectID;
|
||||||
|
this.vector1 = origin;
|
||||||
|
this.vector2 = target;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EffectS2C(FriendlyByteBuf buf) {
|
||||||
|
this.effectID = Effect.values()[buf.getByte(2)];
|
||||||
|
this.vector1 = new Vec3(buf.getFloat(3), buf.getFloat(7), buf.getFloat(11));
|
||||||
|
this.vector2 = new Vec3(buf.getFloat(15), buf.getFloat(19), buf.getFloat(23));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void toBytes(FriendlyByteBuf buf) {
|
||||||
|
buf.writeByte(0);
|
||||||
|
buf.writeByte(this.effectID.ordinal());
|
||||||
|
buf.writeFloat((float) vector1.x);
|
||||||
|
buf.writeFloat((float) vector1.y);
|
||||||
|
buf.writeFloat((float) vector1.z);
|
||||||
|
buf.writeFloat((float) vector2.x);
|
||||||
|
buf.writeFloat((float) vector2.y);
|
||||||
|
buf.writeFloat((float) vector2.z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean handle(Supplier<NetworkEvent.Context> supplier) {
|
||||||
|
NetworkEvent.Context context = supplier.get();
|
||||||
|
context.enqueueWork(() -> {
|
||||||
|
System.out.println("test069 " + this.effectID + " " + this.vector1 + " " + this.vector2);
|
||||||
|
effects.executeEffect(this.effectID, this.vector1, this.vector2);
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Effect {
|
||||||
|
SCROLL_HEALTH,
|
||||||
|
WAND_VACUUM
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
package com.jenny.magic.blocks.networking.packets;
|
package com.jenny.magic.networking.packets;
|
||||||
|
|
||||||
import com.jenny.magic.blocks.mana.ManaClient;
|
import com.jenny.magic.mana.ManaClient;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraftforge.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
|
|
59
src/main/java/com/jenny/magic/particles/effects.java
Normal file
59
src/main/java/com/jenny/magic/particles/effects.java
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
package com.jenny.magic.particles;
|
||||||
|
|
||||||
|
import com.jenny.magic.networking.packets.EffectS2C;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.core.particles.ParticleTypes;
|
||||||
|
import net.minecraft.util.RandomSource;
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
public class effects {
|
||||||
|
public static void executeEffect(EffectS2C.Effect effect, @Nullable Vec3 origin, @Nullable Vec3 destination) {
|
||||||
|
if (effect == EffectS2C.Effect.WAND_VACUUM) {
|
||||||
|
wandVacuum(origin, destination);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void scrollTeleport(Vec3 origin, Vec3 destination) {
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void wandVacuum(Vec3 origin, Vec3 destination) {
|
||||||
|
for (int i = 0; i < 20; i++) {
|
||||||
|
Vec3 randPos = randPos2D(5);
|
||||||
|
Vec3 pos = origin.add(randPos);
|
||||||
|
Vec3 delta = randPos.scale(-0.1).add(0, 0.2, 0);
|
||||||
|
level().addParticle(ParticleTypes.GLOW_SQUID_INK, pos.x, pos.y, pos.z, delta.x, delta.y, delta.z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vec3 randPos(float maxDist) {
|
||||||
|
return new Vec3(
|
||||||
|
rng().nextFloat() * 2 - 1,
|
||||||
|
rng().nextFloat() * 2 - 1,
|
||||||
|
rng().nextFloat() * 2 - 1).normalize().scale(maxDist);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vec3 randPos2D(float maxDist) {
|
||||||
|
return new Vec3(
|
||||||
|
rng().nextFloat() * 2 - 1,
|
||||||
|
0,
|
||||||
|
rng().nextFloat() * 2 - 1).normalize().scale(maxDist);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vec3 randPosRandDist(float maxDist) {
|
||||||
|
return new Vec3(
|
||||||
|
rng().nextFloat() * 2 - 1,
|
||||||
|
rng().nextFloat() * 2 - 1,
|
||||||
|
rng().nextFloat() * 2 - 1).normalize().scale(rng().nextFloat() * maxDist);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Level level() {
|
||||||
|
return Minecraft.getInstance().level;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static RandomSource rng() {
|
||||||
|
return level().getRandom();
|
||||||
|
}
|
||||||
|
}
|
@ -2,11 +2,14 @@
|
|||||||
"item.magic.scroll_teleport": "Teleport scroll",
|
"item.magic.scroll_teleport": "Teleport scroll",
|
||||||
"item.magic.scroll_teleport_brittle": "Brittle teleport scroll",
|
"item.magic.scroll_teleport_brittle": "Brittle teleport scroll",
|
||||||
"item.magic.scroll_teleport_random": "Random teleport scroll",
|
"item.magic.scroll_teleport_random": "Random teleport scroll",
|
||||||
|
"item.magic.wand_hurtful": "Hurtful Wand",
|
||||||
|
"item.magic.wand_vacuum": "Vaccum Wand",
|
||||||
"tooltip.magic.scroll_teleport.unset": "No location set",
|
"tooltip.magic.scroll_teleport.unset": "No location set",
|
||||||
"tooltip.magic.scroll_teleport.set": "Teleports to: ",
|
"tooltip.magic.scroll_teleport.set": "Teleports to: ",
|
||||||
"tooltip.magic.scroll_teleport_random": "Using it a second time teleports you back",
|
"tooltip.magic.scroll_teleport_random": "Using it a second time teleports you back",
|
||||||
"tooltip.magic.scroll_teleport_random.back": "Will teleport you back to ",
|
"tooltip.magic.scroll_teleport_random.back": "Will teleport you back to ",
|
||||||
"tooltip.magic.scroll_teleport_biome": "teleports you to the Biome ",
|
"tooltip.magic.scroll_teleport_biome": "teleports you to the Biome ",
|
||||||
|
"enchantment.magic.homing": "Homing",
|
||||||
"message.magic.scroll_teleport.set": "Location set.",
|
"message.magic.scroll_teleport.set": "Location set.",
|
||||||
"message.magic.scroll_teleport.dim": "You're not in the same dimension.",
|
"message.magic.scroll_teleport.dim": "You're not in the same dimension.",
|
||||||
"message.magic.scroll_teleport.dist": "You're too far away",
|
"message.magic.scroll_teleport.dist": "You're too far away",
|
||||||
|
15
src/main/resources/data/magic/recipes/nbt_test.json
Normal file
15
src/main/resources/data/magic/recipes/nbt_test.json
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"type": "minecraft:crafting_shapeless",
|
||||||
|
"category": "combat",
|
||||||
|
"ingredients": [
|
||||||
|
{
|
||||||
|
"item": "magic:dragon_heart"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"item": "minecraft:diamond"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"result": {
|
||||||
|
"item": "magic:wand_hurtful"
|
||||||
|
}
|
||||||
|
}
|
@ -5,6 +5,7 @@
|
|||||||
"compatibilityLevel": "JAVA_8",
|
"compatibilityLevel": "JAVA_8",
|
||||||
"refmap": "magic.refmap.json",
|
"refmap": "magic.refmap.json",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
|
"ShapelessRecipeMixin"
|
||||||
],
|
],
|
||||||
"client": [
|
"client": [
|
||||||
"ExperienceToMana"
|
"ExperienceToMana"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user