Implement universalLimbo

This commit is contained in:
SD 2021-03-16 09:06:10 +05:30
parent 004209078c
commit 48ff64cefd
9 changed files with 33 additions and 18 deletions

View file

@ -87,10 +87,10 @@ sourceSets {
}
dependencies {
minecraft "com.mojang:minecraft:21w08b"
mappings "net.fabricmc:yarn:21w08b+build.8:v2"
minecraft "com.mojang:minecraft:21w10a"
mappings "net.fabricmc:yarn:21w10a+build.2:v2"
modImplementation "net.fabricmc:fabric-loader:0.11.2"
modImplementation "net.fabricmc.fabric-api:fabric-api:0.31.1+1.17"
modImplementation "net.fabricmc.fabric-api:fabric-api:0.32.1+1.17"
includeCompile("com.flowpowered", "flow-math", "1.0.3")
includeCompile("org.jgrapht", "jgrapht-core", "1.1.0")
includeCompile("com.github.DimensionalDevelopment", "poly2tri.java", "0.1.1")

View file

@ -10,6 +10,7 @@ import org.dimdev.dimdoors.entity.ai.MonolithAggroGoal;
import org.dimdev.dimdoors.fluid.ModFluids;
import org.dimdev.dimdoors.network.ExtendedClientPlayNetworkHandler;
import org.dimdev.dimdoors.particle.ModParticleTypes;
import org.dimdev.dimdoors.particle.client.MonolithParticle;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.api.EnvType;
@ -28,6 +29,11 @@ public class DimensionalDoorsClientInitializer implements ClientModInitializer {
ModParticleTypes.initClient();
ClientPlayNetworking.registerGlobalReceiver(MonolithAggroGoal.MONOLITH_PARTICLE_PACKET, (client, networkHandler, buf, sender) -> MonolithEntity.spawnParticles(buf, client));
ClientPlayNetworking.registerGlobalReceiver(MonolithAggroGoal.MONOLITH_TP_PARTICLE_PACKET, ((client, handler, buf, responseSender) -> {
client.execute(() -> {
client.particleManager.addParticle(new MonolithParticle(client.world, client.player.getX(), client.player.getY(), client.player.getZ()));
});
}));
registerListeners();
}

View file

@ -88,7 +88,7 @@ public final class ModConfig implements ConfigData {
public static class World {
@RequiresRestart
public double clusterGenChance = 0.0002;
public double clusterGenChance = 20000;
@RequiresRestart
public int gatewayGenChance = 200;
@RequiresRestart

View file

@ -41,15 +41,15 @@ public final class DimensionalPortalRenderer {
private static void renderModels(VertexConsumerProvider vertexConsumers, MatrixStack matrices, int light, int overlay, boolean tall, int offset) {
renderSingleModel(vertexConsumers.getBuffer(RENDER_LAYERS.get(0)), matrices, light, overlay, 0.15F, tall);
for (int i = 1; i < offset; ++i) {
renderSingleModel(vertexConsumers.getBuffer(RENDER_LAYERS.get(i)), matrices, light, overlay, 2.0F / (float) (18 - i), tall);
for (int count = 1; count < offset; ++count) {
renderSingleModel(vertexConsumers.getBuffer(RENDER_LAYERS.get(count)), matrices, light, overlay, 2.0F / (float) (18 - count), tall);
}
}
private static void renderSingleModel(VertexConsumer vertexConsumer, MatrixStack matrices, int light, int overlay, float v, boolean tall) {
float r = MathHelper.clamp((RANDOM.nextFloat() * 0.3F + 0.1F) * v, 0, 1);
float g = MathHelper.clamp((RANDOM.nextFloat() * 0.4F + 0.1F) * v, 0, 1);
float b = MathHelper.clamp((RANDOM.nextFloat() * 0.5F + 0.6F) * v, 0, 1);
private static void renderSingleModel(VertexConsumer vertexConsumer, MatrixStack matrices, int light, int overlay, float delta, boolean tall) {
float r = MathHelper.clamp((RANDOM.nextFloat() * 0.3F + 0.1F) * delta, 0, 1);
float g = MathHelper.clamp((RANDOM.nextFloat() * 0.4F + 0.1F) * delta, 0, 1);
float b = MathHelper.clamp((RANDOM.nextFloat() * 0.5F + 0.6F) * delta, 0, 1);
ModelPart model = tall ? TALL_MODEL : MODEL;
model.render(matrices, vertexConsumer, light, overlay, r, g, b, 1);

View file

@ -14,10 +14,12 @@ import net.minecraft.entity.ai.goal.Goal;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.SoundCategory;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs;
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
import static net.minecraft.predicate.entity.EntityPredicates.EXCEPT_SPECTATOR;
@ -25,6 +27,7 @@ import static org.dimdev.dimdoors.entity.MonolithEntity.MAX_AGGRO;
public class MonolithAggroGoal extends Goal {
public static final Identifier MONOLITH_PARTICLE_PACKET = new Identifier("dimdoors", "monolith_particle_packet");
public static final Identifier MONOLITH_TP_PARTICLE_PACKET = new Identifier("dimdoors", "monolith_tp_particle_packet");
protected final MonolithEntity mob;
protected PlayerEntity target;
protected final float range;
@ -102,6 +105,7 @@ public class MonolithAggroGoal extends Goal {
this.mob.setAggro(0);
this.target.teleport(this.target.getX(), this.target.getY() + 256, this.target.getZ());
this.target.world.playSound(null, new BlockPos(this.target.getPos()), ModSoundEvents.CRACK, SoundCategory.HOSTILE, 13, 1);
ServerPlayNetworking.send((ServerPlayerEntity) this.target, MONOLITH_PARTICLE_PACKET, PacketByteBufs.empty());
}
}
}

View file

@ -7,6 +7,7 @@ import net.minecraft.util.Identifier;
public class ModStats {
public static final Identifier DEATHS_IN_POCKETS = StatsAccessor.invokeRegister("dimdoors:deaths_in_pocket", StatFormatter.DEFAULT);
public static final Identifier TIMES_SENT_TO_LIMBO = StatsAccessor.invokeRegister("dimdoors:times_sent_to_limbo", StatFormatter.DEFAULT);
public static void init() {
// just loads the class

View file

@ -1,6 +1,6 @@
package org.dimdev.dimdoors.mixin;
import org.dimdev.dimdoors.entity.stat.ModStats;
import org.dimdev.dimdoors.DimensionalDoorsInitializer;
import org.dimdev.dimdoors.mixin.accessor.EntityAccessor;
import org.dimdev.dimdoors.world.ModBiomes;
import org.dimdev.dimdoors.world.ModDimensions;
@ -34,19 +34,18 @@ public abstract class PlayerEntityMixin extends LivingEntity {
cir.setReturnValue(false);
}
}
/*
@Inject(method = "onDeath", at = @At("HEAD"), cancellable = true)
public void checkDeath(DamageSource source, CallbackInfo ci) {
this.doOnDeathStuff(source, ci);
}
*/
@Unique
protected void doOnDeathStuff(DamageSource source, CallbackInfo ci) {
if (ModDimensions.isPocketDimension(this.world)) {
if (ModDimensions.isPocketDimension(this.world) || DimensionalDoorsInitializer.getConfig().getLimboConfig().universalLimbo) {
((EntityAccessor) this).setRemovalReason(null);
this.dead = false;
this.setHealth(this.getMaxHealth());
this.incrementStat(ModStats.DEATHS_IN_POCKETS);
ci.cancel();
}
}

View file

@ -1,5 +1,6 @@
package org.dimdev.dimdoors.mixin;
import org.dimdev.dimdoors.entity.stat.ModStats;
import org.dimdev.dimdoors.util.TeleportUtil;
import org.dimdev.dimdoors.world.ModDimensions;
import org.spongepowered.asm.mixin.Mixin;
@ -20,9 +21,13 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntityMixin {
}
@Inject(method = "onDeath", at = @At("HEAD"), cancellable = true)
public void checkDeath(DamageSource source, CallbackInfo ci) {
public void checkDeathServer(DamageSource source, CallbackInfo ci) {
this.doOnDeathStuff(source, ci);
if (ci.isCancelled()) {
if (ModDimensions.isPocketDimension(this.world)) {
this.incrementStat(ModStats.DEATHS_IN_POCKETS);
}
this.incrementStat(ModStats.TIMES_SENT_TO_LIMBO);
TeleportUtil.teleportRandom(this, ModDimensions.LIMBO_DIMENSION, 384);
}
}

View file

@ -26,7 +26,7 @@ public class MonolithParticle extends Particle {
private final MonolithModel model;
private final RenderLayer layer;
private MonolithParticle(ClientWorld world, double x, double y, double z) {
public MonolithParticle(ClientWorld world, double x, double y, double z) {
super(world, x, y, z);
this.maxAge = 30;
this.model = new MonolithModel();