teleport scroll
This commit is contained in:
21 files changed
+889
No files matched your search
@@ -0,0 +1,35 @@
|
||||
package com.jenny.magic;
|
||||
|
||||
import com.jenny.magic.entities.entities;
|
||||
import com.jenny.magic.items.items;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
|
||||
// The value here should match an entry in the META-INF/mods.toml file
|
||||
@Mod(Magic.MODID)
|
||||
public class Magic {
|
||||
public static final String MODID = "magic";
|
||||
|
||||
public Magic() {
|
||||
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
|
||||
entities.register(modEventBus);
|
||||
items.register(modEventBus);
|
||||
creativeTab.register(modEventBus);
|
||||
}
|
||||
|
||||
@Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
|
||||
public static class ClientModEvents {
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onClientSetup(FMLClientSetupEvent event) {
|
||||
entities.registerRenderers();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.jenny.magic;
|
||||
|
||||
import com.jenny.magic.items.items;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.CreativeModeTabs;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import static com.jenny.magic.Magic.MODID;
|
||||
|
||||
public class creativeTab {
|
||||
public static final DeferredRegister<CreativeModeTab> CREATIVE_MODE_TABS = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, MODID);
|
||||
public static final RegistryObject<CreativeModeTab> CREATIVE_TAB = CREATIVE_MODE_TABS.register(MODID, () -> CreativeModeTab.builder().withTabsBefore(CreativeModeTabs.SPAWN_EGGS).icon(() -> items.WAND_HURTFUL.get().getDefaultInstance()).displayItems((parameters, output) -> {
|
||||
output.acceptAll(Arrays.stream(getItems()).toList());
|
||||
}).title(Component.literal("Magic")).build());
|
||||
|
||||
public static void register(IEventBus bus) {
|
||||
CREATIVE_MODE_TABS.register(bus);
|
||||
}
|
||||
|
||||
public static ItemStack[] getItems() {
|
||||
ItemStack[] ret = new ItemStack[items.ITEMS.getEntries().size()];
|
||||
int i = 0;
|
||||
for (RegistryObject<Item> item : items.ITEMS.getEntries()) {
|
||||
ret[i] = item.get().getDefaultInstance();
|
||||
i++;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.jenny.magic.entities;
|
||||
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.projectile.AbstractArrow;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.EntityHitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class BaseWandProjectile extends AbstractArrow {
|
||||
protected BaseWandProjectile(EntityType<? extends AbstractArrow> pEntityType, Level pLevel) {
|
||||
super(pEntityType, pLevel);
|
||||
}
|
||||
|
||||
public void shootFromRotation(Entity pShooter, float pX, float pY, float pZ, float pVelocity) {
|
||||
this.setPos(pShooter.position().x, pShooter.getEyeY() - 0.1, pShooter.position().z);
|
||||
float f = -Mth.sin(pY * ((float) Math.PI / 180F)) * Mth.cos(pX * ((float) Math.PI / 180F));
|
||||
float f1 = -Mth.sin((pX + pZ) * ((float) Math.PI / 180F));
|
||||
float f2 = Mth.cos(pY * ((float) Math.PI / 180F)) * Mth.cos(pX * ((float) Math.PI / 180F));
|
||||
Vec3 vec = new Vec3(f, f1, f2).multiply(pVelocity, pVelocity, pVelocity);
|
||||
this.setPos(pShooter.position().x, pShooter.getEyeY() - 0.1, pShooter.position().z);
|
||||
this.setPos(new Vec3(pShooter.getX(), pShooter.getEyeY() - 0.1, pShooter.getZ()).add(vec.scale(1)));
|
||||
this.setDeltaMovement(vec);
|
||||
Vec3 vec3 = pShooter.getDeltaMovement();
|
||||
this.setDeltaMovement(this.getDeltaMovement().add(vec3.x, pShooter.onGround() ? 0.0D : vec3.y, vec3.z));
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
if (inGroundTime > 1) {
|
||||
discard();
|
||||
}
|
||||
super.tick();
|
||||
if (level().isClientSide) {
|
||||
spawnParticles();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onHitEntity(@NotNull EntityHitResult pResult) {
|
||||
System.out.println(level().isClientSide);
|
||||
if (level().isClientSide) {
|
||||
hitParticles();
|
||||
}
|
||||
hitEntity(pResult);
|
||||
//this.discard();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onHitBlock(@NotNull BlockHitResult pResult) {
|
||||
System.out.println(level().isClientSide);
|
||||
if (level().isClientSide) {
|
||||
hitParticles();
|
||||
}
|
||||
super.onHitBlock(pResult);
|
||||
//this.discard();
|
||||
}
|
||||
|
||||
protected Vec3 particlePos(double dist) {
|
||||
return new Vec3(
|
||||
level().getRandom().nextIntBetweenInclusive(-100, 100),
|
||||
level().getRandom().nextIntBetweenInclusive(-100, 100),
|
||||
level().getRandom().nextIntBetweenInclusive(-100, 100)
|
||||
).normalize().scale(dist + ((double) level().getRandom().nextIntBetweenInclusive(0, 100) / 100)).add(position());
|
||||
}
|
||||
|
||||
public void spawnParticles() {
|
||||
}
|
||||
|
||||
protected void hitEntity(EntityHitResult pResult) {
|
||||
}
|
||||
|
||||
protected void hitBlock(BlockHitResult pResult) {
|
||||
}
|
||||
|
||||
public void hitParticles() {
|
||||
}
|
||||
|
||||
public abstract String name();
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.jenny.magic.entities;
|
||||
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.EntityHitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class HurtfulProjectile extends BaseWandProjectile {
|
||||
public HurtfulProjectile(EntityType<? extends BaseWandProjectile> pEntityType, Level pLevel) {
|
||||
super(pEntityType, pLevel);
|
||||
}
|
||||
|
||||
public HurtfulProjectile(Level pLevel) {
|
||||
super(entities.PROJECTILE_HURTFUL.get(), pLevel);
|
||||
}
|
||||
|
||||
public String name() {
|
||||
return "hurtful_projectile";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void hitEntity(@NotNull EntityHitResult pResult) {
|
||||
if (pResult.getEntity() instanceof LivingEntity) {
|
||||
Entity owner = this.getOwner();
|
||||
DamageSource damagesource;
|
||||
if (owner == null) {
|
||||
damagesource = this.damageSources().arrow(this, this);
|
||||
} else {
|
||||
damagesource = this.damageSources().arrow(this, owner);
|
||||
if (owner instanceof LivingEntity) {
|
||||
((LivingEntity) owner).setLastHurtMob(pResult.getEntity());
|
||||
}
|
||||
}
|
||||
pResult.getEntity().hurt(this.damageSources().arrow(this, this.getOwner()), 5);
|
||||
this.doPostHurtEffects((LivingEntity) pResult.getEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hitParticles() {
|
||||
for (int i = 0; i < 20; i++) {
|
||||
Vec3 particlePos = particlePos(2);
|
||||
level().addParticle(ParticleTypes.LAVA, particlePos.x, particlePos.y, particlePos.z, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemStack getPickupItem() {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.jenny.magic.entities.client;
|
||||
|
||||
import com.jenny.magic.entities.BaseWandProjectile;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.math.Axis;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.block.BlockRenderDispatcher;
|
||||
import net.minecraft.client.renderer.entity.EntityRenderer;
|
||||
import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
||||
import net.minecraft.client.renderer.entity.TntMinecartRenderer;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlas;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class BaseProjectileRenderer<T extends BaseWandProjectile> extends EntityRenderer<T> {
|
||||
private final BlockRenderDispatcher blockRenderer;
|
||||
|
||||
public BaseProjectileRenderer(EntityRendererProvider.Context pContext) {
|
||||
super(pContext);
|
||||
this.blockRenderer = pContext.getBlockRenderDispatcher();
|
||||
}
|
||||
|
||||
public void render(@NotNull T pEntity, float pEntityYaw, float pPartialTicks, @NotNull PoseStack pPoseStack, @NotNull MultiBufferSource pBuffer, int pPackedLight) {
|
||||
pPoseStack.pushPose();
|
||||
pPoseStack.mulPose(Axis.YP.rotationDegrees(-90.0F));
|
||||
pPoseStack.scale(pEntity.getBbWidth(), pEntity.getBbHeight(), pEntity.getBbWidth());
|
||||
pPoseStack.mulPose(Axis.YP.rotationDegrees(90.0F));
|
||||
TntMinecartRenderer.renderWhiteSolidBlock(this.blockRenderer, Blocks.TNT.defaultBlockState(), pPoseStack, pBuffer, pPackedLight, false);
|
||||
pPoseStack.popPose();
|
||||
super.render(pEntity, pEntityYaw, pPartialTicks, pPoseStack, pBuffer, pPackedLight);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull ResourceLocation getTextureLocation(T pEntity) {
|
||||
//return new ResourceLocation(MOD_ID, String.format("textures/entity/%s.png", pEntity.name()));
|
||||
return TextureAtlas.LOCATION_BLOCKS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.jenny.magic.entities;
|
||||
|
||||
import com.jenny.magic.entities.client.BaseProjectileRenderer;
|
||||
import net.minecraft.client.renderer.entity.EntityRenderers;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.MobCategory;
|
||||
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 entities {
|
||||
public static final DeferredRegister<EntityType<?>> ENTITY_TYPES =
|
||||
DeferredRegister.create(ForgeRegistries.ENTITY_TYPES, MODID);
|
||||
|
||||
public static final RegistryObject<EntityType<HurtfulProjectile>> PROJECTILE_HURTFUL =
|
||||
ENTITY_TYPES.register("projectile_hurtful", () -> EntityType.Builder.<HurtfulProjectile>of(HurtfulProjectile::new, MobCategory.MISC)
|
||||
.sized(0.3F, 0.3F).fireImmune().clientTrackingRange(8).build("projectile_hurtful"));
|
||||
|
||||
public static void register(IEventBus eventBus) {
|
||||
ENTITY_TYPES.register(eventBus);
|
||||
}
|
||||
|
||||
public static void registerRenderers() {
|
||||
EntityRenderers.register(PROJECTILE_HURTFUL.get(), BaseProjectileRenderer::new);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.jenny.magic.items;
|
||||
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.core.particles.ParticleOptions;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.TooltipFlag;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.jenny.magic.Magic.MODID;
|
||||
|
||||
abstract class BaseItem extends Item {
|
||||
|
||||
public BaseItem(Properties pProperties) {
|
||||
super(pProperties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendHoverText(@NotNull ItemStack pStack, @Nullable Level pLevel, @NotNull List<Component> pTooltipComponents, @NotNull TooltipFlag pIsAdvanced) {
|
||||
String key = String.format("tooltip.%s.%s", MODID, this);
|
||||
MutableComponent toolTip = Component.translatable(key);
|
||||
if (!toolTip.getString().equals(key)) {
|
||||
pTooltipComponents.add(toolTip.withStyle(ChatFormatting.DARK_BLUE));
|
||||
super.appendHoverText(pStack, pLevel, pTooltipComponents, pIsAdvanced);
|
||||
}
|
||||
}
|
||||
|
||||
public void spawnParticles(@NotNull Level level, Vec3 pos, int count, double size, ParticleOptions particle, ParticleDirection direction) {
|
||||
RandomSource rng = level.getRandom();
|
||||
Vec3 position;
|
||||
Vec3 delta;
|
||||
for (int i = 0; i < count; i++) {
|
||||
delta = new Vec3(rng.nextIntBetweenInclusive(-100, 100), rng.nextIntBetweenInclusive(-100, 100), rng.nextIntBetweenInclusive(-100, 100)).normalize().scale(size);
|
||||
if (direction == ParticleDirection.OUTWARD) {
|
||||
position = pos;
|
||||
} else {
|
||||
position = pos.subtract(delta);
|
||||
delta = delta.scale(0.02 * size);
|
||||
}
|
||||
level.addParticle(particle, position.x, position.y, position.z, delta.x, delta.y, delta.z);
|
||||
}
|
||||
}
|
||||
|
||||
enum ParticleDirection {
|
||||
INWARD,
|
||||
OUTWARD
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.jenny.magic.items;
|
||||
|
||||
import com.jenny.magic.entities.BaseWandProjectile;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResultHolder;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
abstract class BaseWand extends BaseItem {
|
||||
public BaseWand(Properties properties) {
|
||||
super(properties.stacksTo(1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull InteractionResultHolder<ItemStack> use(@NotNull Level pLevel, Player pPlayer, @NotNull InteractionHand pUsedHand) {
|
||||
ItemStack itemstack = pPlayer.getItemInHand(pUsedHand);
|
||||
BaseWandProjectile projectile = newProjectile(pLevel);
|
||||
projectile.shootFromRotation(pPlayer, pPlayer.getXRot(), pPlayer.getYRot(), 0.0F, 2.0F);
|
||||
pLevel.addFreshEntity(projectile);
|
||||
return InteractionResultHolder.success(itemstack);
|
||||
}
|
||||
|
||||
abstract BaseWandProjectile newProjectile(Level level);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.jenny.magic.items;
|
||||
|
||||
import com.jenny.magic.entities.BaseWandProjectile;
|
||||
import com.jenny.magic.entities.HurtfulProjectile;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
public class HurtfulWand extends BaseWand {
|
||||
public HurtfulWand(Properties p_41383_) {
|
||||
super(p_41383_);
|
||||
}
|
||||
|
||||
@Override
|
||||
BaseWandProjectile newProjectile(Level level) {
|
||||
return new HurtfulProjectile(level);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
package com.jenny.magic.items;
|
||||
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.InteractionResultHolder;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.TooltipFlag;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.jenny.magic.Magic.MODID;
|
||||
|
||||
public class TeleportScroll extends BaseItem {
|
||||
public TeleportScroll(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 (itemStack.getTag() == null) {
|
||||
itemStack.setTag(new CompoundTag());
|
||||
}
|
||||
if (locationSet(itemStack.getTag()) && !player.isCrouching()) {
|
||||
if (level.isClientSide) {
|
||||
spawnParticles(level, player.position().add(0, player.getEyeHeight(), 0), 20, 5, ParticleTypes.POOF, ParticleDirection.INWARD);
|
||||
}
|
||||
player.setPos(getLocation(itemStack.getTag()));
|
||||
if (level.isClientSide) {
|
||||
spawnParticles(level, player.position().add(0, player.getEyeHeight(), 0), 20, 0.2, ParticleTypes.END_ROD, ParticleDirection.OUTWARD);
|
||||
}
|
||||
} else {
|
||||
itemStack.setTag(setLocation(pos, itemStack.getTag()));
|
||||
if (level.isClientSide) {
|
||||
MessageLocationSet();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean locationSet(@NotNull CompoundTag cTag) {
|
||||
return cTag.contains("teleport_x") && cTag.contains("teleport_y") && cTag.contains("teleport_z");
|
||||
}
|
||||
|
||||
private CompoundTag setLocation(@NotNull Vec3 playerPos, @NotNull CompoundTag cTag) {
|
||||
cTag.putDouble("teleport_x", playerPos.x);
|
||||
cTag.putDouble("teleport_y", playerPos.y);
|
||||
cTag.putDouble("teleport_z", playerPos.z);
|
||||
return cTag;
|
||||
}
|
||||
|
||||
private Vec3 getLocation(@NotNull CompoundTag cTag) {
|
||||
return new Vec3(
|
||||
cTag.getDouble("teleport_x"),
|
||||
cTag.getDouble("teleport_y"),
|
||||
cTag.getDouble("teleport_z")
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendHoverText(@NotNull ItemStack pStack, @Nullable Level pLevel, @NotNull List<Component> pTooltipComponents, @NotNull TooltipFlag pIsAdvanced) {
|
||||
if (pStack.getTag() != null && locationSet(pStack.getTag())) {
|
||||
String key = String.format("tooltip.%s.scroll_teleport.set", MODID);
|
||||
MutableComponent toolTip = Component.translatable(key);
|
||||
Vec3 pos = getLocation(pStack.getTag());
|
||||
MutableComponent toolTipPos = Component.literal((int) pos.x + ";" + (int) pos.y + ";" + (int) pos.z);
|
||||
pTooltipComponents.add(toolTip.withStyle(ChatFormatting.DARK_BLUE).append(toolTipPos.withStyle(ChatFormatting.WHITE)));
|
||||
} else {
|
||||
String key = String.format("tooltip.%s.scroll_teleport.unset", MODID);
|
||||
MutableComponent toolTip = Component.translatable(key);
|
||||
pTooltipComponents.add(toolTip.withStyle(ChatFormatting.DARK_BLUE));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void MessageLocationSet() {
|
||||
Minecraft.getInstance().player.sendSystemMessage(Component.translatable(String.format("message.%s.scroll_teleport.set", MODID)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.jenny.magic.items;
|
||||
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class TeleportScrollConsumable extends TeleportScroll {
|
||||
public TeleportScrollConsumable(Properties pProperties) {
|
||||
super(pProperties);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void use(Vec3 pos, Player player, @NotNull ItemStack itemStack, Level level) {
|
||||
super.use(pos, player, itemStack, level);
|
||||
itemStack.shrink(1);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.jenny.magic.items;
|
||||
|
||||
import net.minecraft.world.item.Item;
|
||||
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 items {
|
||||
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> SCROLL_TELEPORT = ITEMS.register("scroll_teleport", () -> new TeleportScroll(new Item.Properties().stacksTo(1)));
|
||||
public static final RegistryObject<Item> SCROLL_TELEPORT_CONSUME = ITEMS.register("scroll_teleport_consume", () -> new TeleportScrollConsumable(new Item.Properties().stacksTo(16)));
|
||||
|
||||
public static void register(IEventBus bus) {
|
||||
ITEMS.register(bus);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
# This is an example mods.toml file. It contains the data relating to the loading mods.
|
||||
# There are several mandatory fields (#mandatory), and many more that are optional (#optional).
|
||||
# The overall format is standard TOML format, v0.5.0.
|
||||
# Note that there are a couple of TOML lists in this file.
|
||||
# Find more information on toml format here: https://github.com/toml-lang/toml
|
||||
# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
|
||||
modLoader = "javafml" #mandatory
|
||||
# A version range to match for said mod loader - for regular FML @Mod it will be the forge version
|
||||
loaderVersion = "${loader_version_range}" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
|
||||
# The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties.
|
||||
# Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here.
|
||||
license = "${mod_license}"
|
||||
# A URL to refer people to when problems occur with this mod
|
||||
#issueTrackerURL="https://change.me.to.your.issue.tracker.example.invalid/" #optional
|
||||
# A list of mods - how many allowed here is determined by the individual mod loader
|
||||
[[mods]] #mandatory
|
||||
# The modid of the mod
|
||||
modId = "${mod_id}" #mandatory
|
||||
# The version number of the mod
|
||||
version = "${mod_version}" #mandatory
|
||||
# A display name for the mod
|
||||
displayName = "${mod_name}" #mandatory
|
||||
# A URL to query for updates for this mod. See the JSON update specification https://docs.minecraftforge.net/en/latest/misc/updatechecker/
|
||||
#updateJSONURL="https://change.me.example.invalid/updates.json" #optional
|
||||
# A URL for the "homepage" for this mod, displayed in the mod UI
|
||||
#displayURL="https://change.me.to.your.mods.homepage.example.invalid/" #optional
|
||||
# A file name (in the root of the mod JAR) containing a logo for display
|
||||
#logoFile="magic.png" #optional
|
||||
# A text field displayed in the mod UI
|
||||
#credits="Thanks for this example mod goes to Java" #optional
|
||||
# A text field displayed in the mod UI
|
||||
authors = "${mod_authors}" #optional
|
||||
# Display Test controls the display for your mod in the server connection screen
|
||||
# MATCH_VERSION means that your mod will cause a red X if the versions on client and server differ. This is the default behaviour and should be what you choose if you have server and client elements to your mod.
|
||||
# IGNORE_SERVER_VERSION means that your mod will not cause a red X if it's present on the server but not on the client. This is what you should use if you're a server only mod.
|
||||
# IGNORE_ALL_VERSION means that your mod will not cause a red X if it's present on the client or the server. This is a special case and should only be used if your mod has no server component.
|
||||
# NONE means that no display test is set on your mod. You need to do this yourself, see IExtensionPoint.DisplayTest for more information. You can define any scheme you wish with this value.
|
||||
# IMPORTANT NOTE: this is NOT an instruction as to which environments (CLIENT or DEDICATED SERVER) your mod loads on. Your mod should load (and maybe do nothing!) whereever it finds itself.
|
||||
#displayTest="MATCH_VERSION" # MATCH_VERSION is the default if nothing is specified (#optional)
|
||||
|
||||
# The description text for the mod (multi line!) (#mandatory)
|
||||
description = '''${mod_description}'''
|
||||
# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
|
||||
[[dependencies."${mod_id}"]] #optional
|
||||
# the modid of the dependency
|
||||
modId = "forge" #mandatory
|
||||
# Does this dependency have to exist - if not, ordering below must be specified
|
||||
mandatory = true #mandatory
|
||||
# The version range of the dependency
|
||||
versionRange = "${forge_version_range}" #mandatory
|
||||
# An ordering relationship for the dependency - BEFORE or AFTER required if the dependency is not mandatory
|
||||
# BEFORE - This mod is loaded BEFORE the dependency
|
||||
# AFTER - This mod is loaded AFTER the dependency
|
||||
ordering = "NONE"
|
||||
# Side this dependency is applied on - BOTH, CLIENT, or SERVER
|
||||
side = "BOTH"# Here's another dependency
|
||||
[[dependencies."${mod_id}"]]
|
||||
modId = "minecraft"
|
||||
mandatory = true
|
||||
# This version range declares a minimum of the current minecraft version up to but not including the next major version
|
||||
versionRange = "${minecraft_version_range}"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"item.magic.scroll_teleport": "Teleport scroll",
|
||||
"item.magic.scroll_teleport_consume": "Brittle teleport scroll",
|
||||
|
||||
"tooltip.magic.scroll_teleport.unset": "no location set",
|
||||
"tooltip.magic.scroll_teleport.set": "teleports to: ",
|
||||
"message.magic.scroll_teleport.set": "location set"
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "com.jenny.magic.mixin",
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"refmap": "magic.refmap.json",
|
||||
"mixins": [
|
||||
],
|
||||
"client": [
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"pack": {
|
||||
"description": "magic resources",
|
||||
"pack_format": 15
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user