mirror of
https://github.com/Minestom/Minestom.git
synced 2025-02-09 08:51:38 +01:00
Update
This commit is contained in:
parent
7cbb964e21
commit
ab3aabf6b0
@ -35,7 +35,7 @@ dependencies {
|
|||||||
implementation 'com.github.Querz:NBT:4.1'
|
implementation 'com.github.Querz:NBT:4.1'
|
||||||
implementation 'com.github.luben:zstd-jni:1.4.3-1'
|
implementation 'com.github.luben:zstd-jni:1.4.3-1'
|
||||||
implementation 'com.esotericsoftware:reflectasm:1.11.9'
|
implementation 'com.esotericsoftware:reflectasm:1.11.9'
|
||||||
implementation 'com.github.LynnOwens:starlite:9971b899f7'
|
|
||||||
// https://mvnrepository.com/artifact/com.google.code.gson/gson
|
// https://mvnrepository.com/artifact/com.google.code.gson/gson
|
||||||
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
|
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package fr.themode.demo;
|
package fr.themode.demo;
|
||||||
|
|
||||||
import fr.themode.demo.entity.ChickenCreature;
|
|
||||||
import fr.themode.demo.generator.ChunkGeneratorDemo;
|
import fr.themode.demo.generator.ChunkGeneratorDemo;
|
||||||
import fr.themode.demo.generator.NoiseTestGenerator;
|
import fr.themode.demo.generator.NoiseTestGenerator;
|
||||||
import fr.themode.minestom.MinecraftServer;
|
import fr.themode.minestom.MinecraftServer;
|
||||||
@ -117,8 +116,8 @@ public class PlayerInit {
|
|||||||
p.teleport(player.getPosition());
|
p.teleport(player.getPosition());
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
ChickenCreature chickenCreature = new ChickenCreature(player.getPosition());
|
//ChickenCreature chickenCreature = new ChickenCreature(player.getPosition());
|
||||||
chickenCreature.setInstance(player.getInstance());
|
//chickenCreature.setInstance(player.getInstance());
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package fr.themode.demo.entity;
|
package fr.themode.demo.entity;
|
||||||
|
|
||||||
|
import fr.themode.minestom.MinecraftServer;
|
||||||
import fr.themode.minestom.entity.Entity;
|
import fr.themode.minestom.entity.Entity;
|
||||||
import fr.themode.minestom.entity.EntityCreature;
|
import fr.themode.minestom.entity.EntityCreature;
|
||||||
import fr.themode.minestom.entity.EntityType;
|
import fr.themode.minestom.entity.EntityType;
|
||||||
@ -86,7 +87,7 @@ public class ChickenCreature extends EntityCreature {
|
|||||||
//move(randomX * speed, 0, randomZ * speed, true);
|
//move(randomX * speed, 0, randomZ * speed, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Player player = MinecraftServer.getConnectionManager().getPlayer("TheMode911");
|
Player player = MinecraftServer.getConnectionManager().getPlayer("TheMode911");
|
||||||
//moveTo(player.getPosition().clone().add(2, 0, 2));
|
moveTo(player.getPosition().clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package fr.themode.demo.entity;
|
package fr.themode.demo.entity;
|
||||||
|
|
||||||
|
import fr.themode.minestom.entity.EntityType;
|
||||||
import fr.themode.minestom.entity.LivingEntity;
|
import fr.themode.minestom.entity.LivingEntity;
|
||||||
import fr.themode.minestom.entity.ObjectEntity;
|
import fr.themode.minestom.entity.ObjectEntity;
|
||||||
|
|
||||||
@ -8,7 +9,7 @@ public class TestArrow extends ObjectEntity {
|
|||||||
private LivingEntity shooter;
|
private LivingEntity shooter;
|
||||||
|
|
||||||
public TestArrow(LivingEntity shooter) {
|
public TestArrow(LivingEntity shooter) {
|
||||||
super(2);
|
super(EntityType.ARROW.getId());
|
||||||
this.shooter = shooter;
|
this.shooter = shooter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@ public class NoiseTestGenerator extends ChunkGenerator {
|
|||||||
|
|
||||||
private Random random = new Random();
|
private Random random = new Random();
|
||||||
private FastNoise fastNoise = new FastNoise();
|
private FastNoise fastNoise = new FastNoise();
|
||||||
private int totalChunk = 15;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
fastNoise.SetNoiseType(FastNoise.NoiseType.Simplex);
|
fastNoise.SetNoiseType(FastNoise.NoiseType.Simplex);
|
||||||
|
@ -9,7 +9,6 @@ import java.lang.management.ThreadMXBean;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static fr.themode.minestom.MinecraftServer.*;
|
import static fr.themode.minestom.MinecraftServer.*;
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
public class BenchmarkManager {
|
public class BenchmarkManager {
|
||||||
|
|
||||||
@ -19,12 +18,8 @@ public class BenchmarkManager {
|
|||||||
THREAD_NAME_PLAYERS_ENTITIES, THREAD_NAME_SCHEDULER);
|
THREAD_NAME_PLAYERS_ENTITIES, THREAD_NAME_SCHEDULER);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
assertTrue(threadMXBean.isThreadCpuTimeSupported());
|
|
||||||
assertTrue(threadMXBean.isCurrentThreadCpuTimeSupported());
|
|
||||||
|
|
||||||
threadMXBean.setThreadContentionMonitoringEnabled(true);
|
threadMXBean.setThreadContentionMonitoringEnabled(true);
|
||||||
threadMXBean.setThreadCpuTimeEnabled(true);
|
threadMXBean.setThreadCpuTimeEnabled(true);
|
||||||
assertTrue(threadMXBean.isThreadCpuTimeEnabled());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<Long, Long> lastCpuTimeMap = new HashMap<>();
|
private Map<Long, Long> lastCpuTimeMap = new HashMap<>();
|
||||||
@ -74,6 +69,10 @@ public class BenchmarkManager {
|
|||||||
this.enabled = false;
|
this.enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addThreadMonitor(String threadName) {
|
||||||
|
threads.add(threadName);
|
||||||
|
}
|
||||||
|
|
||||||
public long getUsedMemory() {
|
public long getUsedMemory() {
|
||||||
return Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
|
return Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,6 @@ public abstract class EntityCreature extends LivingEntity {
|
|||||||
setNextPathPosition();
|
setNextPathPosition();
|
||||||
//System.out.println("END TARGET");
|
//System.out.println("END TARGET");
|
||||||
} else {
|
} else {
|
||||||
// TODO jump support
|
|
||||||
moveTowards(targetPosition, getAttributeValue(Attribute.MOVEMENT_SPEED));
|
moveTowards(targetPosition, getAttributeValue(Attribute.MOVEMENT_SPEED));
|
||||||
//System.out.println("MOVE TOWARD " + targetPosition);
|
//System.out.println("MOVE TOWARD " + targetPosition);
|
||||||
}
|
}
|
||||||
@ -123,8 +122,8 @@ public abstract class EntityCreature extends LivingEntity {
|
|||||||
|
|
||||||
public void jump(float height) {
|
public void jump(float height) {
|
||||||
// FIXME magic value
|
// FIXME magic value
|
||||||
Vector velocity = new Vector(0, height * 6, 0);
|
Vector velocity = new Vector(0, height * 8, 0);
|
||||||
setVelocity(velocity, 250);
|
setVelocity(velocity, 350);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void moveTo(Position position) {
|
public void moveTo(Position position) {
|
||||||
@ -151,5 +150,8 @@ public abstract class EntityCreature extends LivingEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.targetPosition = blockPosition.toPosition().subtract(0.5f, 0, 0.5f);
|
this.targetPosition = blockPosition.toPosition().subtract(0.5f, 0, 0.5f);
|
||||||
|
// FIXME: jump support
|
||||||
|
//if(blockPosition.getY() > getPosition().getY())
|
||||||
|
// jump(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -604,7 +604,8 @@ public class Player extends LivingEntity {
|
|||||||
if (dimension == null)
|
if (dimension == null)
|
||||||
throw new IllegalArgumentException("Dimension cannot be null!");
|
throw new IllegalArgumentException("Dimension cannot be null!");
|
||||||
if (dimension.equals(getDimension()))
|
if (dimension.equals(getDimension()))
|
||||||
return;
|
throw new IllegalArgumentException("The dimension need to be different than the current one!");
|
||||||
|
|
||||||
RespawnPacket respawnPacket = new RespawnPacket();
|
RespawnPacket respawnPacket = new RespawnPacket();
|
||||||
respawnPacket.dimension = dimension;
|
respawnPacket.dimension = dimension;
|
||||||
respawnPacket.gameMode = gameMode;
|
respawnPacket.gameMode = gameMode;
|
||||||
|
@ -12,7 +12,7 @@ import java.util.function.Consumer;
|
|||||||
|
|
||||||
public class EntityPathFinder {
|
public class EntityPathFinder {
|
||||||
|
|
||||||
private ExecutorService pathfindingPool = new MinestomThread(MinecraftServer.THREAD_COUNT_ENTITIES_PATHFINDING, MinecraftServer.THREAD_NAME_ENTITIES_PATHFINDING);
|
private static ExecutorService pathfindingPool = new MinestomThread(MinecraftServer.THREAD_COUNT_ENTITIES_PATHFINDING, MinecraftServer.THREAD_NAME_ENTITIES_PATHFINDING);
|
||||||
|
|
||||||
|
|
||||||
private Entity entity;
|
private Entity entity;
|
||||||
|
@ -333,17 +333,17 @@ public class PlayerInventory implements InventoryModifier, InventoryClickHandler
|
|||||||
ItemStack cursor = getCursorItem();
|
ItemStack cursor = getCursorItem();
|
||||||
ItemStack clicked = getItemStack(slot, OFFSET);
|
ItemStack clicked = getItemStack(slot, OFFSET);
|
||||||
|
|
||||||
boolean slotClick = convertToPacketSlot(slot) < 9;
|
boolean hotbarClick = convertToPacketSlot(slot) < 9;
|
||||||
InventoryClickResult clickResult = clickProcessor.shiftClick(getInventoryCondition(), player, slot, clicked, cursor,
|
InventoryClickResult clickResult = clickProcessor.shiftClick(getInventoryCondition(), player, slot, clicked, cursor,
|
||||||
new InventoryClickLoopHandler(0, items.length, 1,
|
new InventoryClickLoopHandler(0, items.length, 1,
|
||||||
i -> {
|
i -> {
|
||||||
if (slotClick) {
|
if (hotbarClick) {
|
||||||
return i < 9 ? i + 9 : i - 9;
|
return i < 9 ? i + 9 : i - 9;
|
||||||
} else {
|
} else {
|
||||||
return convertSlot(i, OFFSET);
|
return convertSlot(i, OFFSET);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
index -> items[index],
|
index -> getItemStack(index, OFFSET),
|
||||||
(index, itemStack) -> setItemStack(index, OFFSET, itemStack)));
|
(index, itemStack) -> setItemStack(index, OFFSET, itemStack)));
|
||||||
|
|
||||||
if (clickResult == null)
|
if (clickResult == null)
|
||||||
|
@ -76,6 +76,10 @@ public class ItemStack implements DataContainer {
|
|||||||
return materialId;
|
return materialId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Material getMaterial() {
|
||||||
|
return Material.fromId(getMaterialId());
|
||||||
|
}
|
||||||
|
|
||||||
public void setAmount(byte amount) {
|
public void setAmount(byte amount) {
|
||||||
this.amount = amount;
|
this.amount = amount;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user