SteamWar/BauSystem2.0
Archiviert
12
0

Update some stuff
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2022-07-21 16:44:52 +02:00
Ursprung a0c644dd1c
Commit 6c3ea5ccc7
5 geänderte Dateien mit 90 neuen und 28 gelöschten Zeilen

Datei anzeigen

@ -26,43 +26,34 @@ import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity;
import net.minecraft.network.syncher.DataWatcher; import net.minecraft.network.syncher.DataWatcher;
import net.minecraft.network.syncher.DataWatcherObject; import net.minecraft.network.syncher.DataWatcherObject;
import net.minecraft.network.syncher.DataWatcherRegistry; import net.minecraft.network.syncher.DataWatcherRegistry;
import net.minecraft.tags.TagsBlock;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.*; import net.minecraft.world.entity.*;
import net.minecraft.world.entity.item.EntityTNTPrimed; import net.minecraft.world.entity.item.EntityTNTPrimed;
import net.minecraft.world.level.Explosion; import net.minecraft.world.level.Explosion;
import net.minecraft.world.level.ExplosionDamageCalculator; import net.minecraft.world.level.ExplosionDamageCalculator;
import net.minecraft.world.level.RayTrace;
import net.minecraft.world.level.World; import net.minecraft.world.level.World;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.IBlockData; import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.AxisAlignedBB;
import net.minecraft.world.phys.MovingObjectPosition;
import net.minecraft.world.phys.MovingObjectPositionBlock;
import net.minecraft.world.phys.Vec3D; import net.minecraft.world.phys.Vec3D;
import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShape;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_19_R1.SpigotTimings;
import org.bukkit.entity.Explosive; import org.bukkit.entity.Explosive;
import org.bukkit.entity.Vehicle;
import org.bukkit.event.entity.ExplosionPrimeEvent; import org.bukkit.event.entity.ExplosionPrimeEvent;
import org.bukkit.event.vehicle.VehicleBlockCollisionEvent;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List; import java.util.List;
public class FakeTNT19 extends EntityTNTPrimed { public class FakeTNT19 extends EntityTNTPrimed {
private static final DataWatcherObject<Integer> b; private static final DataWatcherObject<Integer> b;
private static final int c = 80; private static final int c = 80;
private List<FakeTNT19> fakeTNT19s; private List<FakeTNT19> fakeTNT19s;
private List<FakeTNT19> spawnList = new ArrayList<>();
private int count;
@Nullable @Nullable
public EntityLiving d; public EntityLiving d;
public float yield; public float yield;
public boolean isIncendiary; public boolean isIncendiary;
public int offset = 0;
public FakeTNT19(List<FakeTNT19> fakeTNT19s, EntityTypes<? extends EntityTNTPrimed> type, World world) { public FakeTNT19(List<FakeTNT19> fakeTNT19s, EntityTypes<? extends EntityTNTPrimed> type, World world) {
super(type, world); super(type, world);
@ -72,17 +63,17 @@ public class FakeTNT19 extends EntityTNTPrimed {
super.q = true; super.q = true;
} }
public FakeTNT19(List<FakeTNT19> fakeTNT19s, World world, double x, double y, double z, int tickoffset) { public FakeTNT19(List<FakeTNT19> fakeTNT19s, World world, double x, double y, double z, int fuse, int count) {
this(fakeTNT19s, EntityTypes.av, world); this(fakeTNT19s, EntityTypes.av, world);
this.e(x, y, z); this.e(x, y, z);
double d3 = world.w.j() * 6.2831854820251465D; double d3 = world.w.j() * 6.2831854820251465D;
this.n(-Math.sin(d3) * 0.02D, 0.20000000298023224D, -Math.cos(d3) * 0.02D); this.n(-Math.sin(d3) * 0.02D, 0.20000000298023224D, -Math.cos(d3) * 0.02D);
this.a(tickoffset); this.a(fuse);
super.t = x; super.t = x;
super.u = y; super.u = y;
super.v = z; super.v = z;
this.d = null; this.d = null;
this.offset = tickoffset; this.count = count;
} }
protected void a_() { protected void a_() {
@ -173,8 +164,7 @@ public class FakeTNT19 extends EntityTNTPrimed {
} }
} }
@Override public void k(List<FakeTNT19> spawnList) {
public void k() {
if (!this.aN()) { if (!this.aN()) {
this.f(this.de().b(0.0D, -0.04D, 0.0D)); this.f(this.de().b(0.0D, -0.04D, 0.0D));
} }
@ -196,6 +186,16 @@ public class FakeTNT19 extends EntityTNTPrimed {
} else { } else {
this.aZ(); this.aZ();
} }
if (i == 1 && count > 1) {
for (int c = 0; c < count - 1; c++) {
FakeTNT19 fakeTNT19 = new FakeTNT19(fakeTNT19s, this.s, this.dg(), this.di(), this.dm(), i, 1);
fakeTNT19.y = this.y;
fakeTNT19.f(new Vec3D(this.de().c, this.de().d, this.de().e));
spawnList.add(fakeTNT19);
}
count = 1;
}
} }
private void j1() { private void j1() {

Datei anzeigen

@ -79,10 +79,18 @@ public class SimulatorPreview19 implements SimulatorPreview {
while(hasSomeLeft.get()) { while(hasSomeLeft.get()) {
hasSomeLeft.set(false); hasSomeLeft.set(false);
pairs.forEach(pair -> { pairs.forEach(pair -> {
if (pair.getValue() > 0) {
hasSomeLeft.set(true);
SimulatorPreview.SimulatorPreviewTNTData previewTNTData = pair.getKey(); SimulatorPreview.SimulatorPreviewTNTData previewTNTData = pair.getKey();
FakeTNT19 fakeTNT19 = new FakeTNT19(fakeTNT19s, WORLD, previewTNTData.getX(), previewTNTData.getY(), previewTNTData.getZ(), previewTNTData.getFuseTicks()); if (!previewTNTData.isXVelocity() && !previewTNTData.isZVelocity()) {
FakeTNT19 fakeTNT19 = new FakeTNT19(fakeTNT19s, WORLD, previewTNTData.getX(), previewTNTData.getY(), previewTNTData.getZ(), previewTNTData.getFuseTicks(), pair.getValue());
TNTPrimed tntPrimed = (TNTPrimed) fakeTNT19.getBukkitEntity();
if (!previewTNTData.isXVelocity()) tntPrimed.setVelocity(tntPrimed.getVelocity().setX(0));
if (!previewTNTData.isYVelocity()) tntPrimed.setVelocity(tntPrimed.getVelocity().setY(0));
if (!previewTNTData.isZVelocity()) tntPrimed.setVelocity(tntPrimed.getVelocity().setZ(0));
fakeTNT19s.add(fakeTNT19);
pair.setValue(0);
} else if (pair.getValue() > 0) {
hasSomeLeft.set(true);
FakeTNT19 fakeTNT19 = new FakeTNT19(fakeTNT19s, WORLD, previewTNTData.getX(), previewTNTData.getY(), previewTNTData.getZ(), previewTNTData.getFuseTicks(), 1);
TNTPrimed tntPrimed = (TNTPrimed) fakeTNT19.getBukkitEntity(); TNTPrimed tntPrimed = (TNTPrimed) fakeTNT19.getBukkitEntity();
if (!previewTNTData.isXVelocity()) tntPrimed.setVelocity(tntPrimed.getVelocity().setX(0)); if (!previewTNTData.isXVelocity()) tntPrimed.setVelocity(tntPrimed.getVelocity().setX(0));
if (!previewTNTData.isYVelocity()) tntPrimed.setVelocity(tntPrimed.getVelocity().setY(0)); if (!previewTNTData.isYVelocity()) tntPrimed.setVelocity(tntPrimed.getVelocity().setY(0));
@ -101,17 +109,24 @@ public class SimulatorPreview19 implements SimulatorPreview {
} }
private void calculateTick(List<FakeTNT19> fakeTNT19s, Record record, Map<FakeTNT19, Record.TNTRecord> tntRecords) { private void calculateTick(List<FakeTNT19> fakeTNT19s, Record record, Map<FakeTNT19, Record.TNTRecord> tntRecords) {
Iterator<FakeTNT19> iterator = fakeTNT19s.iterator(); int i = 0;
while (iterator.hasNext()) { while (i < fakeTNT19s.size()) {
FakeTNT19 fakeTNT19 = iterator.next(); List<FakeTNT19> spawnList = new ArrayList<>();
fakeTNT19.k(); FakeTNT19 fakeTNT19 = fakeTNT19s.get(i);
fakeTNT19.k(spawnList);
TNTPrimed tntPrimed = ((TNTPrimed) (fakeTNT19.getBukkitEntity())); TNTPrimed tntPrimed = ((TNTPrimed) (fakeTNT19.getBukkitEntity()));
if (tntPrimed.getFuseTicks() <= 0) { if (tntPrimed.getFuseTicks() <= 0) {
tntRecords.computeIfAbsent(fakeTNT19, ignore -> record.spawn()).explode(tntPrimed); tntRecords.computeIfAbsent(fakeTNT19, ignore -> record.spawn()).explode(tntPrimed);
iterator.remove(); fakeTNT19s.remove(i);
i--;
} else { } else {
tntRecords.computeIfAbsent(fakeTNT19, ignore -> record.spawn()).explode(tntPrimed); tntRecords.computeIfAbsent(fakeTNT19, ignore -> record.spawn()).explode(tntPrimed);
} }
if (!spawnList.isEmpty()) {
fakeTNT19s.addAll(i, spawnList);
i += spawnList.size();
}
i++;
} }
} }
} }

Datei anzeigen

@ -19,10 +19,10 @@
package de.steamwar.bausystem.features.simulator; package de.steamwar.bausystem.features.simulator;
import de.steamwar.bausystem.features.simulator.show.PreviewEntityShowMode;
import de.steamwar.bausystem.features.tracer.TNTPosition; import de.steamwar.bausystem.features.tracer.TNTPosition;
import de.steamwar.bausystem.features.tracer.show.Record; import de.steamwar.bausystem.features.tracer.show.Record;
import de.steamwar.bausystem.features.tracer.show.ShowModeParameter; import de.steamwar.bausystem.features.tracer.show.ShowModeParameter;
import de.steamwar.bausystem.features.tracer.show.mode.TraceEntityShowMode;
import de.steamwar.bausystem.shared.Pair; import de.steamwar.bausystem.shared.Pair;
import de.steamwar.bausystem.shared.ShowMode; import de.steamwar.bausystem.shared.ShowMode;
import lombok.experimental.UtilityClass; import lombok.experimental.UtilityClass;
@ -57,7 +57,7 @@ public class SimulatorPreviewStorage {
pair.getValue().add(player); pair.getValue().add(player);
ShowModeParameter showModeParameter = new ShowModeParameter(); ShowModeParameter showModeParameter = new ShowModeParameter();
TraceEntityShowMode showMode = new TraceEntityShowMode(player, showModeParameter); PreviewEntityShowMode showMode = new PreviewEntityShowMode(player, showModeParameter);
pair.getKey().showAll(showMode); pair.getKey().showAll(showMode);
showModes.put(player, new Pair<>(tntSimulator, showMode)); showModes.put(player, new Pair<>(tntSimulator, showMode));
} }

Datei anzeigen

@ -132,7 +132,9 @@ public class TNTSimulatorListener implements Listener {
simulatorShowHide(e.getPlayer(), i -> null, PlayerInventory::getItemInMainHand, e.getPlayer().getLocation()); simulatorShowHide(e.getPlayer(), i -> null, PlayerInventory::getItemInMainHand, e.getPlayer().getLocation());
} else { } else {
TNTSimulator tntSimulator = simulatorShowHide(e.getPlayer(), i -> null, PlayerInventory::getItemInOffHand, e.getPlayer().getLocation()); TNTSimulator tntSimulator = simulatorShowHide(e.getPlayer(), i -> null, PlayerInventory::getItemInOffHand, e.getPlayer().getLocation());
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
if (tntSimulator != null) SimulatorPreviewStorage.show(e.getPlayer(), tntSimulator); if (tntSimulator != null) SimulatorPreviewStorage.show(e.getPlayer(), tntSimulator);
}, 10);
} }
} }

Datei anzeigen

@ -0,0 +1,45 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.simulator.show;
import de.steamwar.bausystem.features.tracer.TNTPosition;
import de.steamwar.bausystem.features.tracer.show.ShowModeParameter;
import de.steamwar.bausystem.features.tracer.show.mode.FactoredEntityShowMode;
import org.bukkit.entity.Player;
public class PreviewEntityShowMode extends FactoredEntityShowMode {
public PreviewEntityShowMode(Player player, ShowModeParameter showModeParameter) {
super(player, showModeParameter, 10);
}
@Override
public void show(TNTPosition position) {
if (position.getVelocity().lengthSquared() < 1) {
return;
}
super.show(position);
}
@Override
public void hide() {
super.hide();
}
}