cleanup plugin

This commit is contained in:
Brian Neumann-Fopiano 2023-05-16 23:32:01 -04:00
parent ec939b9f78
commit 35cc39e9e2
2 changed files with 268 additions and 268 deletions

View File

@ -1,245 +1,245 @@
/* /*
* Iris is a World Generator for Minecraft Bukkit Servers * Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software) * Copyright (c) 2022 Arcane Arts (Volmit Software)
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package com.volmit.iris.engine.jigsaw; package com.volmit.iris.engine.jigsaw;
import com.volmit.iris.core.loader.IrisData; import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.core.tools.IrisToolbelt; import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.framework.Engine; import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.object.*; import com.volmit.iris.engine.object.*;
import com.volmit.iris.engine.platform.PlatformChunkGenerator; import com.volmit.iris.engine.platform.PlatformChunkGenerator;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.context.IrisContext; import com.volmit.iris.util.context.IrisContext;
import com.volmit.iris.util.math.AxisAlignedBB; import com.volmit.iris.util.math.AxisAlignedBB;
import com.volmit.iris.util.math.BlockPosition; import com.volmit.iris.util.math.BlockPosition;
import com.volmit.iris.util.math.RNG; import com.volmit.iris.util.math.RNG;
import lombok.Data; import lombok.Data;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.block.TileState; import org.bukkit.block.TileState;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.InventoryHolder;
import org.bukkit.util.BlockVector; import org.bukkit.util.BlockVector;
@SuppressWarnings("ALL") @SuppressWarnings("ALL")
@Data @Data
public class PlannedPiece { public class PlannedPiece {
private IrisPosition position; private IrisPosition position;
private IrisObject object; private IrisObject object;
private IrisObject ogObject; private IrisObject ogObject;
private IrisJigsawPiece piece; private IrisJigsawPiece piece;
private IrisObjectRotation rotation; private IrisObjectRotation rotation;
private IrisData data; private IrisData data;
private KList<IrisJigsawPieceConnector> connected; private KList<IrisJigsawPieceConnector> connected;
private boolean dead = false; private boolean dead = false;
private AxisAlignedBB box; private AxisAlignedBB box;
private PlannedStructure structure; private PlannedStructure structure;
public PlannedPiece(PlannedStructure structure, IrisPosition position, IrisJigsawPiece piece) { public PlannedPiece(PlannedStructure structure, IrisPosition position, IrisJigsawPiece piece) {
this(structure, position, piece, 0, 0, 0); this(structure, position, piece, 0, 0, 0);
} }
public PlannedPiece(PlannedStructure structure, IrisPosition position, IrisJigsawPiece piece, int rx, int ry, int rz) { public PlannedPiece(PlannedStructure structure, IrisPosition position, IrisJigsawPiece piece, int rx, int ry, int rz) {
this(structure, position, piece, IrisObjectRotation.of(rx * 90D, ry * 90D, rz * 90D)); this(structure, position, piece, IrisObjectRotation.of(rx * 90D, ry * 90D, rz * 90D));
} }
public PlannedPiece(PlannedStructure structure, IrisPosition position, IrisJigsawPiece piece, IrisObjectRotation rot) { public PlannedPiece(PlannedStructure structure, IrisPosition position, IrisJigsawPiece piece, IrisObjectRotation rot) {
this.structure = structure; this.structure = structure;
this.position = position; this.position = position;
this.data = piece.getLoader(); this.data = piece.getLoader();
this.setRotation(rot); this.setRotation(rot);
this.ogObject = data.getObjectLoader().load(piece.getObject()); this.ogObject = data.getObjectLoader().load(piece.getObject());
this.object = structure.rotated(piece, rotation); this.object = structure.rotated(piece, rotation);
this.piece = rotation.rotateCopy(piece); this.piece = rotation.rotateCopy(piece);
this.piece.setLoadKey(piece.getLoadKey()); this.piece.setLoadKey(piece.getLoadKey());
this.object.setLoadKey(piece.getObject()); this.object.setLoadKey(piece.getObject());
this.ogObject.setLoadKey(piece.getObject()); this.ogObject.setLoadKey(piece.getObject());
this.connected = new KList<>(); this.connected = new KList<>();
} }
public void setPosition(IrisPosition p) { public void setPosition(IrisPosition p) {
this.position = p; this.position = p;
box = null; box = null;
} }
public String toString() { public String toString() {
return piece.getLoadKey() + "@(" + position.getX() + "," + position.getY() + "," + position.getZ() + ")[rot:" + rotation.toString() + "]"; return piece.getLoadKey() + "@(" + position.getX() + "," + position.getY() + "," + position.getZ() + ")[rot:" + rotation.toString() + "]";
} }
public AxisAlignedBB getBox() { public AxisAlignedBB getBox() {
if (box != null) { if (box != null) {
return box; return box;
} }
BlockVector v = getObject().getCenter(); BlockVector v = getObject().getCenter();
box = object.getAABB().shifted(position.add(new IrisPosition(object.getCenter()))); box = object.getAABB().shifted(position.add(new IrisPosition(object.getCenter())));
return box; return box;
} }
public boolean contains(IrisPosition p) { public boolean contains(IrisPosition p) {
return getBox().contains(p); return getBox().contains(p);
} }
public boolean collidesWith(PlannedPiece p) { public boolean collidesWith(PlannedPiece p) {
return getBox().intersects(p.getBox()); return getBox().intersects(p.getBox());
} }
public KList<IrisJigsawPieceConnector> getAvailableConnectors() { public KList<IrisJigsawPieceConnector> getAvailableConnectors() {
if (connected.isEmpty()) { if (connected.isEmpty()) {
return piece.getConnectors().copy(); return piece.getConnectors().copy();
} }
if (connected.size() == piece.getConnectors().size()) { if (connected.size() == piece.getConnectors().size()) {
return new KList<>(); return new KList<>();
} }
KList<IrisJigsawPieceConnector> c = new KList<>(); KList<IrisJigsawPieceConnector> c = new KList<>();
for (IrisJigsawPieceConnector i : piece.getConnectors()) { for (IrisJigsawPieceConnector i : piece.getConnectors()) {
if (!connected.contains(i)) { if (!connected.contains(i)) {
c.add(i); c.add(i);
} }
} }
return c; return c;
} }
public boolean connect(IrisJigsawPieceConnector c) { public boolean connect(IrisJigsawPieceConnector c) {
if (piece.getConnectors().contains(c)) { if (piece.getConnectors().contains(c)) {
return connected.addIfMissing(c); return connected.addIfMissing(c);
} }
return false; return false;
} }
public IrisPosition getWorldPosition(IrisJigsawPieceConnector c) { public IrisPosition getWorldPosition(IrisJigsawPieceConnector c) {
return getWorldPosition(c.getPosition()); return getWorldPosition(c.getPosition());
} }
public IrisPosition getWorldPosition(IrisPosition position) { public IrisPosition getWorldPosition(IrisPosition position) {
return this.position.add(position).add(new IrisPosition(object.getCenter())); return this.position.add(position).add(new IrisPosition(object.getCenter()));
} }
public boolean isFull() { public boolean isFull() {
return connected.size() >= piece.getConnectors().size() || isDead(); return connected.size() >= piece.getConnectors().size() || isDead();
} }
public void place(World world) { public void place(World world) {
PlatformChunkGenerator a = IrisToolbelt.access(world); PlatformChunkGenerator a = IrisToolbelt.access(world);
int minY = 0; int minY = 0;
if (a != null) { if (a != null) {
minY = a.getEngine().getMinHeight(); minY = a.getEngine().getMinHeight();
if (!a.getEngine().getDimension().isBedrock()) if (!a.getEngine().getDimension().isBedrock())
minY--; //If the dimension has no bedrock, allow it to go a block lower minY--; //If the dimension has no bedrock, allow it to go a block lower
} }
getPiece().getPlacementOptions().setTranslate(new IrisObjectTranslate()); getPiece().getPlacementOptions().setTranslate(new IrisObjectTranslate());
getPiece().getPlacementOptions().setRotation(rotation); getPiece().getPlacementOptions().setRotation(rotation);
int finalMinY = minY; int finalMinY = minY;
RNG rng = getStructure().getRng().nextParallelRNG(37555); RNG rng = getStructure().getRng().nextParallelRNG(37555);
// TODO: REAL CLASSES!!!!!!! // TODO: REAL CLASSES!!!!!!!
getOgObject().place(position.getX() + getObject().getCenter().getBlockX(), position.getY() + getObject().getCenter().getBlockY(), position.getZ() + getObject().getCenter().getBlockZ(), new IObjectPlacer() { getOgObject().place(position.getX() + getObject().getCenter().getBlockX(), position.getY() + getObject().getCenter().getBlockY(), position.getZ() + getObject().getCenter().getBlockZ(), new IObjectPlacer() {
@Override @Override
public int getHighest(int x, int z, IrisData data) { public int getHighest(int x, int z, IrisData data) {
return position.getY(); return position.getY();
} }
@Override @Override
public int getHighest(int x, int z, IrisData data, boolean ignoreFluid) { public int getHighest(int x, int z, IrisData data, boolean ignoreFluid) {
return position.getY(); return position.getY();
} }
@Override @Override
public void set(int x, int y, int z, BlockData d) { public void set(int x, int y, int z, BlockData d) {
Block block = world.getBlockAt(x, y, z); Block block = world.getBlockAt(x, y, z);
//Prevent blocks being set in or bellow bedrock //Prevent blocks being set in or bellow bedrock
if (y <= finalMinY || block.getType() == Material.BEDROCK) return; if (y <= finalMinY || block.getType() == Material.BEDROCK) return;
block.setBlockData(d); block.setBlockData(d);
if (a != null && getPiece().getPlacementOptions().getLoot().isNotEmpty() && if (a != null && getPiece().getPlacementOptions().getLoot().isNotEmpty() &&
block.getState() instanceof InventoryHolder) { block.getState() instanceof InventoryHolder) {
IrisLootTable table = getPiece().getPlacementOptions().getTable(block.getBlockData(), getData()); IrisLootTable table = getPiece().getPlacementOptions().getTable(block.getBlockData(), getData());
if (table == null) return; if (table == null) return;
Engine engine = a.getEngine(); Engine engine = a.getEngine();
engine.addItems(false, ((InventoryHolder) block.getState()).getInventory(), engine.addItems(false, ((InventoryHolder) block.getState()).getInventory(),
rng.nextParallelRNG(BlockPosition.toLong(x, y, z)), rng.nextParallelRNG(BlockPosition.toLong(x, y, z)),
new KList<>(table), InventorySlotType.STORAGE, x, y, z, 15); new KList<>(table), InventorySlotType.STORAGE, x, y, z, 15);
} }
} }
@Override @Override
public BlockData get(int x, int y, int z) { public BlockData get(int x, int y, int z) {
return world.getBlockAt(x, y, z).getBlockData(); return world.getBlockAt(x, y, z).getBlockData();
} }
@Override @Override
public boolean isPreventingDecay() { public boolean isPreventingDecay() {
return false; return false;
} }
@Override @Override
public boolean isCarved(int x, int y, int z) { public boolean isCarved(int x, int y, int z) {
return false; return false;
} }
@Override @Override
public boolean isSolid(int x, int y, int z) { public boolean isSolid(int x, int y, int z) {
return world.getBlockAt(x, y, z).getType().isSolid(); return world.getBlockAt(x, y, z).getType().isSolid();
} }
@Override @Override
public boolean isUnderwater(int x, int z) { public boolean isUnderwater(int x, int z) {
return false; return false;
} }
@Override @Override
public int getFluidHeight() { public int getFluidHeight() {
return 0; return 0;
} }
@Override @Override
public boolean isDebugSmartBore() { public boolean isDebugSmartBore() {
return false; return false;
} }
@Override @Override
public void setTile(int xx, int yy, int zz, TileData<? extends TileState> tile) { public void setTile(int xx, int yy, int zz, TileData<? extends TileState> tile) {
BlockState state = world.getBlockAt(xx, yy, zz).getState(); BlockState state = world.getBlockAt(xx, yy, zz).getState();
tile.toBukkitTry(state); tile.toBukkitTry(state);
state.update(); state.update();
} }
@Override @Override
public Engine getEngine() { public Engine getEngine() {
if (IrisToolbelt.isIrisWorld(world)) { if (IrisToolbelt.isIrisWorld(world)) {
return IrisToolbelt.access(world).getEngine(); return IrisToolbelt.access(world).getEngine();
} }
return IrisContext.get().getEngine(); return IrisContext.get().getEngine();
} }
}, piece.getPlacementOptions(), rng, getData()); }, piece.getPlacementOptions(), rng, getData());
} }
} }

View File

@ -1,24 +1,24 @@
name: ${name} name: ${name}
version: ${version} version: ${version}
main: ${main} main: ${main}
load: STARTUP load: STARTUP
authors: [ cyberpwn, NextdoorPsycho, Vatuu ] authors: [ cyberpwn, NextdoorPsycho, Vatuu ]
website: volmit.com website: volmit.com
description: More than a Dimension! description: More than a Dimension!
libraries: libraries:
- com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2 - com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2
- com.github.ben-manes.caffeine:caffeine:3.0.5 - com.github.ben-manes.caffeine:caffeine:3.0.5
- org.apache.commons:commons-lang3:3.12.0 - org.apache.commons:commons-lang3:3.12.0
- io.timeandspace:smoothie-map:2.0.2 - io.timeandspace:smoothie-map:2.0.2
- com.google.guava:guava:31.0.1-jre - com.google.guava:guava:31.0.1-jre
- com.google.code.gson:gson:2.8.9 - com.google.code.gson:gson:2.8.9
- org.zeroturnaround:zt-zip:1.14 - org.zeroturnaround:zt-zip:1.14
- it.unimi.dsi:fastutil:8.5.6 - it.unimi.dsi:fastutil:8.5.6
- org.ow2.asm:asm:9.2 - org.ow2.asm:asm:9.2
- rhino:js:1.7R2 - rhino:js:1.7R2
- bsf:bsf:2.4.0 - bsf:bsf:2.4.0
commands: commands:
iris: iris:
aliases: [ ir, irs ] aliases: [ ir, irs ]
api-version: ${apiversion} api-version: ${apiversion}
hotload-dependencies: false hotload-dependencies: false