tmp
This commit is contained in:
parent
8e1edd46bf
commit
83a4221e19
@ -5,6 +5,7 @@ import com.jenny.magic.blocks.entities.blockEntities;
|
||||
import com.jenny.magic.conditions.conditions;
|
||||
import com.jenny.magic.config.ConfigServer;
|
||||
import com.jenny.magic.enchantments.enchantments;
|
||||
import com.jenny.magic.entities.client.ProjectileBlocks;
|
||||
import com.jenny.magic.entities.entities;
|
||||
import com.jenny.magic.items.items;
|
||||
import com.jenny.magic.networking.networking;
|
||||
@ -35,6 +36,7 @@ public class Magic {
|
||||
entities.register(modEventBus);
|
||||
items.register(modEventBus);
|
||||
blocks.register(modEventBus);
|
||||
ProjectileBlocks.register(modEventBus);
|
||||
blockEntities.register(modEventBus);
|
||||
enchantments.register(modEventBus);
|
||||
creativeTab.register(modEventBus);
|
||||
|
@ -18,7 +18,6 @@ public class blocks {
|
||||
public static final RegistryObject<Block> ANTI_SPAWNER = BLOCKS.register("anti_spawner", () -> new AntiSpawner(BlockBehaviour.Properties.of().strength(10.0F, 15.0F)));
|
||||
public static final RegistryObject<Item> ANTI_SPAWNER_ITEM = ITEMS.register("anti_spawner", () -> new BlockItemTooltip(ANTI_SPAWNER.get(), new Item.Properties()));
|
||||
|
||||
|
||||
public static void register(IEventBus bus) {
|
||||
BLOCKS.register(bus);
|
||||
ITEMS.register(bus);
|
||||
|
@ -14,7 +14,6 @@ public class conditions {
|
||||
public static void register() {
|
||||
for (RegistryObject<Item> item : items()) {
|
||||
String name = item.get().toString();
|
||||
System.out.println("test123: " + name);
|
||||
CraftingHelper.register(new ConfigCondition(name, ConfigServer.C_DISABLED_LIST));
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import static com.jenny.magic.Magic.MODID;
|
||||
public class ConfigServer {
|
||||
public static final ForgeConfigSpec SPEC;
|
||||
public static final ForgeConfigSpec.ConfigValue<Integer> C_TELEPORT_SCROLL_RANGE, C_TELEPORT_SCROLL_RANGE_RANDOM, C_BROADCAST_RANGE;
|
||||
public static final ForgeConfigSpec.ConfigValue<Boolean> C_PREVENT_BREAKING;
|
||||
public static final ForgeConfigSpec.ConfigValue<List<String>> C_DISABLED_LIST;
|
||||
private static final ForgeConfigSpec.Builder BUILDER = new ForgeConfigSpec.Builder();
|
||||
|
||||
@ -28,6 +29,9 @@ public class ConfigServer {
|
||||
C_BROADCAST_RANGE =
|
||||
BUILDER.comment("up to which distance to send particle effects to players")
|
||||
.defineInRange("scroll_teleport_random_range", 128, 1, 60000000);
|
||||
C_PREVENT_BREAKING =
|
||||
BUILDER.comment("prevent using wands with 1 durability to keep them from breaking")
|
||||
.define("prevent_breaking", true);
|
||||
SPEC = BUILDER.build();
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.jenny.magic.datagen;
|
||||
|
||||
import com.jenny.magic.blocks.blocks;
|
||||
import com.jenny.magic.entities.client.ProjectileBlocks;
|
||||
import net.minecraft.data.PackOutput;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
@ -25,6 +26,7 @@ public class ModBlockStateProvider extends BlockStateProvider {
|
||||
protected void registerStatesAndModels() {
|
||||
test(blocks.ANTI_SPAWNER);
|
||||
//blockWithItem(blocks.ANTI_SPAWNER);
|
||||
simpleBlock(ProjectileBlocks.PROJECTILE_HURTFUL.get(), cubeAll(ProjectileBlocks.PROJECTILE_HURTFUL.get()));
|
||||
}
|
||||
|
||||
private void test(@NotNull RegistryObject<Block> blockRegistryObject) {
|
||||
@ -34,6 +36,11 @@ public class ModBlockStateProvider extends BlockStateProvider {
|
||||
simpleBlockItem(block, model);
|
||||
}
|
||||
|
||||
private void BlockCubeAll(@NotNull RegistryObject<Block> blockRegistryObject) {
|
||||
Block block = blockRegistryObject.get();
|
||||
this.getVariantBuilder(block).forAllStates(blockState -> ConfiguredModel.builder().modelFile(cubeAll(block)).build());
|
||||
}
|
||||
|
||||
private void blockWithItem(@NotNull RegistryObject<Block> blockRegistryObject) {
|
||||
simpleBlockWithItem(blockRegistryObject.get(), cubeAll(blockRegistryObject.get()));
|
||||
}
|
||||
|
@ -16,16 +16,13 @@ public abstract class BaseWandProjectile extends AbstractArrow {
|
||||
}
|
||||
|
||||
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));
|
||||
Vec3 delta = new Vec3(f, f1, f2).normalize().multiply(pVelocity, pVelocity, pVelocity).add(pShooter.getDeltaMovement());
|
||||
Vec3 pos = pShooter.position().add(delta.scale(0.3).add(0, pShooter.getEyeHeight(), 0));
|
||||
this.setDeltaMovement(delta);
|
||||
this.setPos(pos);
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
@ -40,7 +37,6 @@ public abstract class BaseWandProjectile extends AbstractArrow {
|
||||
|
||||
@Override
|
||||
protected void onHitEntity(@NotNull EntityHitResult pResult) {
|
||||
System.out.println(level().isClientSide);
|
||||
if (level().isClientSide) {
|
||||
hitParticles();
|
||||
}
|
||||
@ -49,7 +45,6 @@ public abstract class BaseWandProjectile extends AbstractArrow {
|
||||
|
||||
@Override
|
||||
protected void onHitBlock(@NotNull BlockHitResult pResult) {
|
||||
System.out.println(level().isClientSide);
|
||||
if (level().isClientSide) {
|
||||
hitParticles();
|
||||
}
|
||||
|
@ -10,15 +10,17 @@ 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 net.minecraft.world.level.block.Block;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class BaseProjectileRenderer<T extends BaseWandProjectile> extends EntityRenderer<T> {
|
||||
private final BlockRenderDispatcher blockRenderer;
|
||||
private final Block block;
|
||||
|
||||
public BaseProjectileRenderer(EntityRendererProvider.Context pContext) {
|
||||
public BaseProjectileRenderer(EntityRendererProvider.Context pContext, Block block) {
|
||||
super(pContext);
|
||||
this.blockRenderer = pContext.getBlockRenderDispatcher();
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
public void render(@NotNull T pEntity, float pEntityYaw, float pPartialTicks, @NotNull PoseStack pPoseStack, @NotNull MultiBufferSource pBuffer, int pPackedLight) {
|
||||
@ -26,7 +28,7 @@ public class BaseProjectileRenderer<T extends BaseWandProjectile> extends Entity
|
||||
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);
|
||||
TntMinecartRenderer.renderWhiteSolidBlock(this.blockRenderer, block.defaultBlockState(), pPoseStack, pBuffer, pPackedLight, false);
|
||||
pPoseStack.popPose();
|
||||
super.render(pEntity, pEntityYaw, pPartialTicks, pPoseStack, pBuffer, pPackedLight);
|
||||
}
|
||||
|
@ -0,0 +1,19 @@
|
||||
package com.jenny.magic.entities.client;
|
||||
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
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 ProjectileBlocks {
|
||||
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MODID);
|
||||
public static final RegistryObject<Block> PROJECTILE_HURTFUL = BLOCKS.register("projectile_hurtful", () -> new Block(BlockBehaviour.Properties.of()));
|
||||
|
||||
public static void register(IEventBus bus) {
|
||||
BLOCKS.register(bus);
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package com.jenny.magic.entities;
|
||||
|
||||
import com.jenny.magic.entities.client.BaseProjectileRenderer;
|
||||
import com.jenny.magic.entities.client.ProjectileBlocks;
|
||||
import net.minecraft.client.renderer.entity.EntityRenderers;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.MobCategory;
|
||||
@ -24,6 +25,6 @@ public class entities {
|
||||
}
|
||||
|
||||
public static void registerRenderers() {
|
||||
EntityRenderers.register(PROJECTILE_HURTFUL.get(), BaseProjectileRenderer::new);
|
||||
EntityRenderers.register(PROJECTILE_HURTFUL.get(), (context) -> new BaseProjectileRenderer<>(context, ProjectileBlocks.PROJECTILE_HURTFUL.get()));
|
||||
}
|
||||
}
|
||||
|
@ -63,7 +63,6 @@ public class TeleportScrollRandom extends ScrollTeleportRandom {
|
||||
0,
|
||||
rng.nextIntBetweenInclusive(-maxDist, maxDist)
|
||||
);
|
||||
System.out.println("test123 " + randomLocation.x + ";" + randomLocation.z);
|
||||
BlockPos blockPos = new BlockPos((int) randomLocation.x, 0, (int) randomLocation.z);
|
||||
int yMax = player.level().getChunk(((int) randomLocation.x) >> 4, ((int) randomLocation.z) >> 4, ChunkStatus.FULL, true).getHeight(Heightmap.Types.WORLD_SURFACE, ((int) randomLocation.x) % 16, ((int) randomLocation.z) % 16);
|
||||
randomLocation = randomLocation.add(0, yMax + 1, 0);
|
||||
|
@ -1,14 +1,24 @@
|
||||
package com.jenny.magic.items.wands;
|
||||
|
||||
import com.jenny.magic.config.ConfigServer;
|
||||
import com.jenny.magic.entities.BaseWandProjectile;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResultHolder;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
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 static com.jenny.magic.Magic.MODID;
|
||||
|
||||
public abstract class BaseWand extends Item {
|
||||
public BaseWand(Item.Properties properties) {
|
||||
@ -18,12 +28,15 @@ public abstract class BaseWand extends Item {
|
||||
@Override
|
||||
public @NotNull InteractionResultHolder<ItemStack> use(@NotNull Level pLevel, Player pPlayer, @NotNull InteractionHand pUsedHand) {
|
||||
ItemStack itemstack = pPlayer.getItemInHand(pUsedHand);
|
||||
if (!ConfigServer.C_PREVENT_BREAKING.get() || itemstack.getMaxDamage() - itemstack.getDamageValue() > 1) {
|
||||
BaseWandProjectile projectile = newProjectile(pLevel);
|
||||
projectile.shootFromRotation(pPlayer, pPlayer.getXRot(), pPlayer.getYRot(), 0.0F, 2.0F);
|
||||
pLevel.addFreshEntity(projectile);
|
||||
itemstack.hurtAndBreak(1, pPlayer, (player) -> player.broadcastBreakEvent(pPlayer.getUsedItemHand()));
|
||||
return InteractionResultHolder.success(itemstack);
|
||||
}
|
||||
return InteractionResultHolder.pass(itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidRepairItem(@NotNull ItemStack pStack, @NotNull ItemStack pRepairCandidate) {
|
||||
@ -39,4 +52,14 @@ public abstract class BaseWand extends Item {
|
||||
}
|
||||
|
||||
abstract BaseWandProjectile newProjectile(Level level);
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,6 @@ public class ManaAmountS2C {
|
||||
NetworkEvent.Context context = supplier.get();
|
||||
context.enqueueWork(() -> {
|
||||
ManaClient.mana = this.mana;
|
||||
System.out.println("test187 " + this.mana);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 137 B |
Before Width: | Height: | Size: 272 B After Width: | Height: | Size: 272 B |
Loading…
x
Reference in New Issue
Block a user