Added Monolith particles

Changes to be committed:
	modified:   src/main/java/org/dimdev/dimdoors/DimensionalDoorsClientInitializer.java
	modified:   src/main/java/org/dimdev/dimdoors/DimensionalDoorsInitializer.java
	modified:   src/main/java/org/dimdev/dimdoors/entity/ModEntityTypes.java
	modified:   src/main/java/org/dimdev/dimdoors/entity/MonolithEntity.java
	modified:   src/main/java/org/dimdev/dimdoors/entity/ai/MonolithTask.java
	modified:   src/main/java/org/dimdev/dimdoors/rift/registry/LinkProperties.java
	modified:   src/main/java/org/dimdev/dimdoors/world/ModBiomes.java
	modified:   src/main/java/org/dimdev/dimdoors/world/limbo/LimboBiome.java
	modified:   src/main/resources/assets/dimdoors/lang/en_us.json
This commit is contained in:
SD 2020-07-17 12:48:10 +05:30
parent 161d773f0a
commit 1a98f92a76
No known key found for this signature in database
GPG key ID: E36B57EE08544BC5
9 changed files with 61 additions and 27 deletions

View file

@ -8,6 +8,7 @@ import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandler; import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandler;
import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandlerRegistry; import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandlerRegistry;
import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback; import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback;
import net.fabricmc.fabric.api.network.ClientSidePacketRegistry;
import net.fabricmc.fabric.api.resource.ResourceManagerHelper; import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
import net.fabricmc.fabric.api.resource.SimpleSynchronousResourceReloadListener; import net.fabricmc.fabric.api.resource.SimpleSynchronousResourceReloadListener;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@ -30,6 +31,7 @@ import org.dimdev.dimdoors.block.ModBlocks;
import org.dimdev.dimdoors.client.CustomSkyProvider; import org.dimdev.dimdoors.client.CustomSkyProvider;
import org.dimdev.dimdoors.client.LimboSkyProvider; import org.dimdev.dimdoors.client.LimboSkyProvider;
import org.dimdev.dimdoors.entity.ModEntityTypes; import org.dimdev.dimdoors.entity.ModEntityTypes;
import org.dimdev.dimdoors.entity.MonolithEntity;
import org.dimdev.dimdoors.fluid.ModFluids; import org.dimdev.dimdoors.fluid.ModFluids;
import org.dimdev.dimdoors.world.ModDimensions; import org.dimdev.dimdoors.world.ModDimensions;
@ -52,6 +54,8 @@ public class DimensionalDoorsClientInitializer implements ClientModInitializer {
OpenWorlds.registerSkyRenderer(ModDimensions.POCKET_TYPE, new CustomSkyProvider(null, null, new Vec3i(0, 0, 0))); OpenWorlds.registerSkyRenderer(ModDimensions.POCKET_TYPE, new CustomSkyProvider(null, null, new Vec3i(0, 0, 0)));
OpenWorlds.registerSkyRenderer(ModDimensions.LIMBO_TYPE, new LimboSkyProvider()); OpenWorlds.registerSkyRenderer(ModDimensions.LIMBO_TYPE, new LimboSkyProvider());
ClientSidePacketRegistry.INSTANCE.register(DimensionalDoorsInitializer.MONOLITH_PARTICLE_PACKET, MonolithEntity::spawnParticles);
} }
private void putCutout(Block block) { private void putCutout(Block block) {

View file

@ -1,7 +1,7 @@
package org.dimdev.dimdoors; package org.dimdev.dimdoors;
import net.fabricmc.api.ModInitializer; import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.registry.CommandRegistry; import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
import org.dimdev.dimdoors.block.ModBlocks; import org.dimdev.dimdoors.block.ModBlocks;
import org.dimdev.dimdoors.commands.CommandPocket; import org.dimdev.dimdoors.commands.CommandPocket;
import org.dimdev.dimdoors.commands.CommandSaveSchem; import org.dimdev.dimdoors.commands.CommandSaveSchem;
@ -14,7 +14,12 @@ import org.dimdev.dimdoors.rift.targets.*;
import org.dimdev.dimdoors.world.ModBiomes; import org.dimdev.dimdoors.world.ModBiomes;
import org.dimdev.dimdoors.world.ModDimensions; import org.dimdev.dimdoors.world.ModDimensions;
import net.minecraft.util.Identifier;
public class DimensionalDoorsInitializer implements ModInitializer { public class DimensionalDoorsInitializer implements ModInitializer {
public static final Identifier MONOLITH_PARTICLE_PACKET = new Identifier("dimdoors", "monolith_particle_packet");
@Override @Override
public void onInitialize() { public void onInitialize() {
ModBlocks.init(); ModBlocks.init();
@ -23,7 +28,7 @@ public class DimensionalDoorsInitializer implements ModInitializer {
ModEntityTypes.init(); ModEntityTypes.init();
ModBiomes.init(); ModBiomes.init();
registerCommands(); this.registerCommands();
VirtualTarget.registry.put("available_link", RandomTarget.class); VirtualTarget.registry.put("available_link", RandomTarget.class);
VirtualTarget.registry.put("escape", EscapeTarget.class); VirtualTarget.registry.put("escape", EscapeTarget.class);
@ -43,10 +48,11 @@ public class DimensionalDoorsInitializer implements ModInitializer {
} }
private void registerCommands() { private void registerCommands() {
CommandRegistry.INSTANCE.register(false, DimTeleportCommand::register); CommandRegistrationCallback.EVENT.register((dispatcher, dedicated)->{
CommandRegistry.INSTANCE.register(false, SchematicCommand::register); DimTeleportCommand.register(dispatcher);
CommandRegistry.INSTANCE.register(false, CommandPocket::register); SchematicCommand.register(dispatcher);
CommandRegistry.INSTANCE.register(false, CommandSaveSchem::register); CommandPocket.register(dispatcher);
CommandSaveSchem.register(dispatcher);
});
} }
} }

View file

@ -36,7 +36,7 @@ public class ModEntityTypes {
EntityRendererRegistry.INSTANCE.register(MASK, MaskRenderer::new); EntityRendererRegistry.INSTANCE.register(MASK, MaskRenderer::new);
} }
private static <E extends Entity> EntityType<E> register(String id, EntityType.EntityFactory<E> factory, int a, int b) { private static <E extends Entity> EntityType<E> register(String id, EntityType.EntityFactory<E> factory, int width, int height) {
return Registry.register(Registry.ENTITY_TYPE, id, FabricEntityTypeBuilder.create(SpawnGroup.MONSTER, factory).dimensions(EntityDimensions.fixed(a, b)).fireImmune().spawnableFarFromPlayer().build()); return Registry.register(Registry.ENTITY_TYPE, id, FabricEntityTypeBuilder.create(SpawnGroup.MONSTER, factory).dimensions(EntityDimensions.fixed(width, height)).fireImmune().build());
} }
} }

View file

@ -1,5 +1,7 @@
package org.dimdev.dimdoors.entity; package org.dimdev.dimdoors.entity;
import java.util.Random;
import net.minecraft.entity.*; import net.minecraft.entity.*;
import net.minecraft.entity.ai.control.LookControl; import net.minecraft.entity.ai.control.LookControl;
import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.damage.DamageSource;
@ -9,6 +11,7 @@ import net.minecraft.entity.data.TrackedDataHandlerRegistry;
import net.minecraft.entity.mob.MobEntity; import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.particle.ParticleTypes; import net.minecraft.particle.ParticleTypes;
import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundCategory;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@ -20,6 +23,10 @@ import org.dimdev.dimdoors.entity.ai.MonolithTask;
import org.dimdev.dimdoors.sound.ModSoundEvents; import org.dimdev.dimdoors.sound.ModSoundEvents;
import org.dimdev.dimdoors.world.ModDimensions; import org.dimdev.dimdoors.world.ModDimensions;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.network.PacketContext;
public class MonolithEntity extends MobEntity { public class MonolithEntity extends MobEntity {
public final EntityDimensions DIMENSIONS = EntityDimensions.fixed(3f, 3f); public final EntityDimensions DIMENSIONS = EntityDimensions.fixed(3f, 3f);
@ -31,6 +38,7 @@ public class MonolithEntity extends MobEntity {
public static final int MAX_AGGRO_RANGE = 35; public static final int MAX_AGGRO_RANGE = 35;
private static final TrackedData<Integer> AGGRO = DataTracker.registerData(MonolithEntity.class, TrackedDataHandlerRegistry.INTEGER); private static final TrackedData<Integer> AGGRO = DataTracker.registerData(MonolithEntity.class, TrackedDataHandlerRegistry.INTEGER);
private static final float EYE_HEIGHT = 1.5f; private static final float EYE_HEIGHT = 1.5f;
private static Random random;
public float pitchLevel; public float pitchLevel;
private int aggro = 0; private int aggro = 0;
@ -39,6 +47,7 @@ public class MonolithEntity extends MobEntity {
public MonolithEntity(EntityType<? extends MonolithEntity> type, World world) { public MonolithEntity(EntityType<? extends MonolithEntity> type, World world) {
super(ModEntityTypes.MONOLITH, world); super(ModEntityTypes.MONOLITH, world);
random = this.getRandom();
noClip = true; noClip = true;
aggroCap = MathHelper.nextInt(getRandom(), MIN_AGGRO_CAP, MAX_AGGRO_CAP); aggroCap = MathHelper.nextInt(getRandom(), MIN_AGGRO_CAP, MAX_AGGRO_CAP);
setNoGravity(true); setNoGravity(true);
@ -216,15 +225,21 @@ public class MonolithEntity extends MobEntity {
return EYE_HEIGHT; return EYE_HEIGHT;
} }
private void spawnParticles(PlayerEntity player) { @Environment(EnvType.CLIENT)
public static void spawnParticles(PacketContext context, PacketByteBuf data) {
PlayerEntity player = context.getPlayer();
int aggro = data.readInt();
context.getTaskQueue().execute(()->{
int count = 10 * aggro / MAX_AGGRO; int count = 10 * aggro / MAX_AGGRO;
for (int i = 1; i < count; ++i) { for (int i = 1; i < count; ++i) {
player.world.addParticle(ParticleTypes.PORTAL, player.getX() + (getRandom().nextDouble() - 0.5D) * getWidth(), player.world.addParticle(ParticleTypes.PORTAL, player.getX() + (random.nextDouble() - 0.5D) * 3.0,
player.getY() + getRandom().nextDouble() * player.getHeight() - 0.75D, player.getY() + random.nextDouble() * player.getHeight() - 0.75D,
player.getZ() + (getRandom().nextDouble() - 0.5D) * player.getWidth(), player.getZ() + (random.nextDouble() - 0.5D) * player.getWidth(),
(getRandom().nextDouble() - 0.5D) * 2.0D, -getRandom().nextDouble(), (random.nextDouble() - 0.5D) * 2.0D, -random.nextDouble(),
(getRandom().nextDouble() - 0.5D) * 2.0D); (random.nextDouble() - 0.5D) * 2.0D);
} }
});
} }
public float getAggroProgress() { public float getAggroProgress() {

View file

@ -1,16 +1,22 @@
package org.dimdev.dimdoors.entity.ai; package org.dimdev.dimdoors.entity.ai;
import io.netty.buffer.Unpooled;
import net.minecraft.entity.ai.TargetPredicate; import net.minecraft.entity.ai.TargetPredicate;
import net.minecraft.entity.ai.goal.Goal; import net.minecraft.entity.ai.goal.Goal;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundCategory;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import org.dimdev.dimdoors.DimensionalDoorsInitializer;
import org.dimdev.dimdoors.ModConfig; import org.dimdev.dimdoors.ModConfig;
import org.dimdev.dimdoors.entity.MonolithEntity; import org.dimdev.dimdoors.entity.MonolithEntity;
import org.dimdev.dimdoors.sound.ModSoundEvents; import org.dimdev.dimdoors.sound.ModSoundEvents;
import java.util.EnumSet; import java.util.EnumSet;
import net.fabricmc.fabric.api.network.ServerSidePacketRegistry;
import static net.minecraft.predicate.entity.EntityPredicates.EXCEPT_SPECTATOR; import static net.minecraft.predicate.entity.EntityPredicates.EXCEPT_SPECTATOR;
import static org.dimdev.dimdoors.entity.MonolithEntity.MAX_AGGRO; import static org.dimdev.dimdoors.entity.MonolithEntity.MAX_AGGRO;
@ -57,6 +63,10 @@ public class MonolithTask extends Goal {
// of the sounds that would usually play for a moment would // of the sounds that would usually play for a moment would
// keep playing constantly and would get very annoying. // keep playing constantly and would get very annoying.
mob.playSounds(target.getPos()); mob.playSounds(target.getPos());
PacketByteBuf data = new PacketByteBuf(Unpooled.buffer());
data.writeInt(this.mob.getAggro());
ServerSidePacketRegistry.INSTANCE.sendToPlayer(target, DimensionalDoorsInitializer.MONOLITH_PARTICLE_PACKET, data);
} }
if (visibility) { if (visibility) {

View file

@ -1,10 +1,9 @@
package org.dimdev.dimdoors.rift.registry; package org.dimdev.dimdoors.rift.registry;
import net.minecraft.nbt.CompoundTag;
import org.dimdev.annotatednbt.Saved; import org.dimdev.annotatednbt.Saved;
import org.dimdev.annotatednbt.AnnotatedNbt;
import java.util.HashSet; import java.util.HashSet;
import java.util.Objects;
import java.util.Set; import java.util.Set;
@ -36,7 +35,7 @@ public class LinkProperties {
if (Float.compare(this.entranceWeight, other.entranceWeight) != 0) return false; if (Float.compare(this.entranceWeight, other.entranceWeight) != 0) return false;
final Object this$groups = this.groups; final Object this$groups = this.groups;
final Object other$groups = other.groups; final Object other$groups = other.groups;
if (this$groups == null ? other$groups != null : !this$groups.equals(other$groups)) return false; if (!Objects.equals(this$groups, other$groups)) return false;
if (this.linksRemaining != other.linksRemaining) return false; if (this.linksRemaining != other.linksRemaining) return false;
if (this.oneWay != other.oneWay) return false; if (this.oneWay != other.oneWay) return false;
return true; return true;

View file

@ -18,7 +18,6 @@ public final class ModBiomes {
} }
public static void init() { public static void init() {
// just loads the class // just loads the class
} }
} }

View file

@ -1,14 +1,14 @@
package org.dimdev.dimdoors.world.limbo; package org.dimdev.dimdoors.world.limbo;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.dimdev.dimdoors.block.ModBlocks;
import org.dimdev.dimdoors.entity.ModEntityTypes;
import org.dimdev.dimdoors.sound.ModSoundEvents;
import net.minecraft.entity.SpawnGroup; import net.minecraft.entity.SpawnGroup;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.BiomeEffects; import net.minecraft.world.biome.BiomeEffects;
import net.minecraft.world.gen.surfacebuilder.SurfaceBuilder; import net.minecraft.world.gen.surfacebuilder.SurfaceBuilder;
import net.minecraft.world.gen.surfacebuilder.TernarySurfaceConfig; import net.minecraft.world.gen.surfacebuilder.TernarySurfaceConfig;
import org.dimdev.dimdoors.block.ModBlocks;
import org.dimdev.dimdoors.entity.ModEntityTypes;
import org.dimdev.dimdoors.sound.ModSoundEvents;
public class LimboBiome extends Biome { public class LimboBiome extends Biome {
public LimboBiome() { public LimboBiome() {
@ -37,6 +37,6 @@ public class LimboBiome extends Biome {
) )
.parent(null) .parent(null)
.noises(ImmutableList.of(new Biome.MixedNoisePoint(0.0F, 0.0F, 0.0F, -0.5F, 1.0F)))); .noises(ImmutableList.of(new Biome.MixedNoisePoint(0.0F, 0.0F, 0.0F, -0.5F, 1.0F))));
addSpawn(SpawnGroup.MONSTER, new Biome.SpawnEntry(ModEntityTypes.MONOLITH, 100, 1, 1)); this.addSpawn(SpawnGroup.MONSTER, new Biome.SpawnEntry(ModEntityTypes.MONOLITH, 1, 0, 1));
} }
} }

View file

@ -91,7 +91,8 @@
"item.dimdoors.creepy_record": "Music Disc", "item.dimdoors.creepy_record": "Music Disc",
"item.dimdoors.creepy_record.desc": "Creepy - The sound of Limbo", "item.dimdoors.creepy_record.desc": "Creepy - The sound of Limbo",
"item.dimdoors.eternal_fluid_bucket": "Eternal Fluid Bucket", "item.dimdoors.eternal_fluid_bucket": "Eternal Fluid Bucket",
"item.dimdoors.white_void_record": "White Void Record", "item.dimdoors.white_void_record": "Music Disc",
"item.dimdoors.white_void_record.desc": "White Void - The sound of Pocket",
"fluid.dimdoors.eternal_fabric": "Eternal Fabric", "fluid.dimdoors.eternal_fabric": "Eternal Fabric",
"entity.dimdoors.monolith": "", "entity.dimdoors.monolith": "",
"commands.dimteleport.usage": "/dimteleport <dimension> <x> <y> <z> [yaw] [pitch]", "commands.dimteleport.usage": "/dimteleport <dimension> <x> <y> <z> [yaw] [pitch]",