Merge branch 'master' of https://github.com/Hynse/FoliaFlow into folia

# Conflicts:
#	src/main/java/xyz/hynse/foliaflow/FoliaFlow.java
This commit is contained in:
MidnightTale 2023-04-12 21:57:28 +07:00
commit f6d1ff313a
4 changed files with 69 additions and 27 deletions

21
LICENSE.md Normal file
View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023 Hynse
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View file

@ -1 +1,19 @@
# FoliaFlow
FoliaFlow is a Minecraft plugin that allows players to using gravity block duplication glitch
## Installation
To install EndBlockPorter, follow these steps:
1. Download the plugin JAR file from the [releases page](https://github.com/Hynse/FoliaFlow).
2. Copy the JAR file to the `plugins` folder of your Minecraft server.
3. Restart your server to enable the plugin.
## Contributing
If you would like to contribute to EndBlockPorter, feel free to submit a pull request with your changes. All contributions are welcome and appreciated.
## License
This plugin is licensed under the MIT license. See [LICENSE.md](https://github.com/Hynse/FoliaFlow/blob/master/LICENSE.md) for more information.

View file

@ -1,4 +1,4 @@
package xyz.hynse.bbsdfia; package xyz.hynse.foliaflow;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
@ -14,53 +14,58 @@ import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
public class Bbsdfia extends JavaPlugin implements Listener { public class FoliaFlow extends JavaPlugin implements Listener {
private final Vector velocity1 = new Vector(0, 0.5, -1); private final Vector velocity1 = new Vector(0, 0.5, -1);
private final Vector velocity2 = new Vector(-1, 0.5, 0); private final Vector velocity2 = new Vector(-1, 0.5, 0);
private final Vector velocity3 = new Vector(0, 0.5, 1); private final Vector velocity3 = new Vector(0, 0.5, 1);
private final Vector velocity4 = new Vector(1, 0.5, 0); private final Vector velocity4 = new Vector(1, 0.5, 0);
private final Vector[] velocities = {velocity1, velocity2, velocity3, velocity4}; private final Vector[] velocities = { velocity1, velocity2, velocity3, velocity4 };
private int counter = 0; private int counter = 0;
@Override @Override
public void onEnable() { public void onEnable() {
super.onEnable(); super.onEnable();
Bukkit.getPluginManager().registerEvents(this, this); getServer().getPluginManager().registerEvents(this, this);
Bukkit.getLogger().info("Bbsdfia plugin started"); getServer().getLogger().info("Bbsdfia plugin started");
} }
@Override @Override
public void onDisable() { public void onDisable() {
super.onDisable(); super.onDisable();
Bukkit.getLogger().info("Bbsdfia plugin stopped"); getServer().getLogger().info("Bbsdfia plugin stopped");
} }
@EventHandler @EventHandler
public void onFallingBlockToBlock(EntityChangeBlockEvent e) { public void onFallingBlockToBlock(EntityChangeBlockEvent e){
if (e.getEntityType() == EntityType.FALLING_BLOCK) { if(e.getEntityType() == EntityType.FALLING_BLOCK){
Entity entity = e.getEntity(); Entity entity = e.getEntity();
Location loc = entity.getLocation(); Location loc = entity.getLocation();
Vector vel = entity.getVelocity(); Vector vel = entity.getVelocity();
Block movingTo = getBlockMovingTo(loc, vel); Block movingTo = getBlockMovingTo(loc, vel);
if (movingTo != null && movingTo.getType() == Material.END_PORTAL) { if(movingTo != null && movingTo.getType() == Material.END_PORTAL){
Location spawnLoc = movingTo.getLocation(); Location spawnLoc = movingTo.getLocation();
spawnLoc.setX(spawnLoc.getX() + 0.5); spawnLoc.setX(spawnLoc.getX()+0.5);
spawnLoc.setY(spawnLoc.getY() + 0.5); spawnLoc.setY(spawnLoc.getY()+0.5);
spawnLoc.setZ(spawnLoc.getZ() + 0.5); spawnLoc.setZ(spawnLoc.getZ()+0.5);
// Spawn the falling block immediately FallingBlock dummy = loc.getWorld().spawnFallingBlock(spawnLoc, ((FallingBlock) entity).getBlockData());
FallingBlock overworldfallingblock = loc.getWorld().spawnFallingBlock(spawnLoc, ((FallingBlock) entity).getBlockData());
Vector dummyVel = vel.clone(); Vector dummyVel = vel.clone();
dummyVel.setY(-dummyVel.getY()); dummyVel.setY(-dummyVel.getY());
dummyVel.multiply(new Vector(2, 2, 2)); dummyVel.multiply(new Vector(2, 2, 2));
dummyVel.add(new Vector(0, -0.2, 0)); dummyVel.add(new Vector(0, -0.2, 0));
overworldfallingblock.setVelocity(dummyVel);
dummy.setVelocity(dummyVel);
} }
} }
} }
@EventHandler @EventHandler
public void onEntityChangeBlock(EntityChangeBlockEvent event) { public void onEntityChangeBlock(EntityChangeBlockEvent event) {
Entity entity = event.getEntity(); Entity entity = event.getEntity();
@ -70,11 +75,9 @@ public class Bbsdfia extends JavaPlugin implements Listener {
if (entity.getWorld().getEnvironment() != World.Environment.THE_END) { if (entity.getWorld().getEnvironment() != World.Environment.THE_END) {
return; return;
} }
// Spawn a new falling block entity with velocity
entity.remove(); entity.remove();
Location block = new Location(Bukkit.getWorld("world_the_end"), 100, 49, 0); Location fuck = new Location(Bukkit.getWorld("world_the_end"), 100, 49 ,0);
block.getBlock().setType(Material.AIR); fuck.getBlock().setType(Material.AIR);
World world = entity.getWorld(); World world = entity.getWorld();
Location location = entity.getLocation(); Location location = entity.getLocation();
byte data = ((FallingBlock) entity).getBlockData().getAsString().getBytes()[0]; byte data = ((FallingBlock) entity).getBlockData().getAsString().getBytes()[0];
@ -83,26 +86,26 @@ public class Bbsdfia extends JavaPlugin implements Listener {
int index = counter % 4; int index = counter % 4;
Vector velocity = velocities[index]; Vector velocity = velocities[index];
counter++; counter++;
FallingBlock newFallingBlock = world.spawnFallingBlock(location, material, data); FallingBlock newFallingBlock = world.spawnFallingBlock(location, material, data);
newFallingBlock.setVelocity(velocity); newFallingBlock.setVelocity(velocity);
} }
Block getBlockMovingTo(Location loc, Vector vel) {
Block getBlockMovingTo(Location loc, Vector vel){
double absMax = 0, max = 0; double absMax = 0, max = 0;
char dir = ' '; char dir = ' ';
Block relative = null; Block relative = null;
if (Math.abs(vel.getX()) > absMax) { if(Math.abs(vel.getX()) > absMax){
max = vel.getX(); max = vel.getX();
absMax = Math.abs(vel.getX()); absMax = Math.abs(vel.getX());
dir = 'x'; dir = 'x';
} }
if (Math.abs(vel.getY()) > absMax) { if(Math.abs(vel.getY()) > absMax){
max = vel.getY(); max = vel.getY();
absMax = Math.abs(vel.getY()); absMax = Math.abs(vel.getY());
dir = 'y'; dir = 'y';
} }
if (Math.abs(vel.getZ()) > absMax) { if(Math.abs(vel.getZ()) > absMax){
max = vel.getZ(); max = vel.getZ();
dir = 'z'; dir = 'z';
} }

View file

@ -1,5 +1,5 @@
name: bbsdfia name: FoliaFlow
version: '${version}' version: '${version}'
main: xyz.hynse.bbsdfia.Bbsdfia main: xyz.hynse.foliaflow.FoliaFlow
api-version: 1.19 api-version: 1.19
folia-supported: true folia-supported: true