mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-09 07:20:04 -04:00
add nbt to libraries, wip (2) entities
This commit is contained in:
parent
b968d772ba
commit
b955be22cc
1
.idea/dictionaries/moritz.xml
generated
1
.idea/dictionaries/moritz.xml
generated
@ -4,6 +4,7 @@
|
||||
<w>clientbound</w>
|
||||
<w>cooldown</w>
|
||||
<w>gamemode</w>
|
||||
<w>jitpack</w>
|
||||
<w>minosoft</w>
|
||||
<w>mojang</w>
|
||||
<w>motd</w>
|
||||
|
15
.idea/jarRepositories.xml
generated
15
.idea/jarRepositories.xml
generated
@ -1,6 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RemoteRepositoriesConfiguration">
|
||||
<remote-repository>
|
||||
<option name="id" value="jitpack.io" />
|
||||
<option name="name" value="jitpack.io" />
|
||||
<option name="url" value="http://www.jitpack.io" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="jitpack.io" />
|
||||
<option name="name" value="jitpack.io" />
|
||||
<option name="url" value="https://www.jitpack.io" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Central Repository" />
|
||||
@ -11,6 +21,11 @@
|
||||
<option name="name" value="Maven Central repository" />
|
||||
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="jitpack.io" />
|
||||
<option name="name" value="jitpack.io" />
|
||||
<option name="url" value="https://jitpack.io" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="jboss.community" />
|
||||
<option name="name" value="JBoss Community repository" />
|
||||
|
24
pom.xml
24
pom.xml
@ -1,4 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Codename Minosoft
|
||||
~ Copyright (C) 2020 Moritz Zwerger
|
||||
~
|
||||
~ 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 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 General Public License for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
~
|
||||
~ This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
@ -7,6 +20,12 @@
|
||||
<groupId>de.bixilon</groupId>
|
||||
<artifactId>Minosoft</artifactId>
|
||||
<version>0.1</version>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>http://www.jitpack.io</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
@ -37,6 +56,11 @@
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
<version>1.25</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.Querz</groupId>
|
||||
<artifactId>NBT</artifactId>
|
||||
<version>5.4</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -14,6 +14,7 @@
|
||||
package de.bixilon.minosoft.game.datatypes;
|
||||
|
||||
import de.bixilon.minosoft.game.datatypes.blocks.Block;
|
||||
import de.bixilon.minosoft.game.datatypes.entities.Entity;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -23,6 +24,7 @@ import java.util.Map;
|
||||
*/
|
||||
public class World {
|
||||
public final HashMap<ChunkLocation, Chunk> chunks;
|
||||
public final HashMap<Integer, Entity> entities;
|
||||
final String name;
|
||||
boolean hardcore;
|
||||
boolean raining;
|
||||
@ -30,6 +32,7 @@ public class World {
|
||||
public World(String name) {
|
||||
this.name = name;
|
||||
chunks = new HashMap<>();
|
||||
entities = new HashMap<>();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Codename Minosoft
|
||||
* Copyright (C) 2020 Moritz Zwerger
|
||||
*
|
||||
* 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 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.game.datatypes.entities;
|
||||
|
||||
import de.bixilon.minosoft.game.datatypes.Identifier;
|
||||
|
||||
public enum Entities {
|
||||
ZOMBIE(new Identifier("zombie"), 54, Zombie.class);
|
||||
|
||||
final Identifier identifier;
|
||||
final int type;
|
||||
final Class<? extends Entity> clazz;
|
||||
|
||||
Entities(Identifier identifier, int type, Class<? extends Entity> clazz) {
|
||||
this.identifier = identifier;
|
||||
this.type = type;
|
||||
this.clazz = clazz;
|
||||
}
|
||||
|
||||
public static Entities byIdentifier(Identifier identifier) {
|
||||
for (Entities b : values()) {
|
||||
if (b.getIdentifier().equals(identifier)) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Entities byType(int type) {
|
||||
for (Entities b : values()) {
|
||||
if (b.getType() == type) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Identifier getIdentifier() {
|
||||
return identifier;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public Class<? extends Entity> getClazz() {
|
||||
return clazz;
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Codename Minosoft
|
||||
* Copyright (C) 2020 Moritz Zwerger
|
||||
*
|
||||
* 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 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.game.datatypes.entities;
|
||||
|
||||
public interface Entity {
|
||||
Entities getEntityType();
|
||||
|
||||
int getId();
|
||||
|
||||
Location getLocation();
|
||||
|
||||
void setLocation(Location location);
|
||||
|
||||
Velocity getVelocity();
|
||||
|
||||
void setVelocity(Velocity velocity);
|
||||
|
||||
int getYaw();
|
||||
|
||||
void setYaw(int yaw);
|
||||
|
||||
int getPitch();
|
||||
|
||||
void setPitch(int pitch);
|
||||
|
||||
float getWidth();
|
||||
|
||||
float getHeight();
|
||||
|
||||
EntityMetaData getMetaData();
|
||||
|
||||
void setMetaData(EntityMetaData data);
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Codename Minosoft
|
||||
* Copyright (C) 2020 Moritz Zwerger
|
||||
*
|
||||
* 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 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.game.datatypes.entities;
|
||||
|
||||
import net.querz.nbt.io.NBTUtil;
|
||||
import net.querz.nbt.io.NamedTag;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class EntityMetaData {
|
||||
NamedTag nbt;
|
||||
|
||||
public EntityMetaData(byte[] nbt) {
|
||||
try {
|
||||
this.nbt = NBTUtil.read(new String(nbt));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public EntityMetaData(String nbt) {
|
||||
try {
|
||||
this.nbt = NBTUtil.read(nbt);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Codename Minosoft
|
||||
* Copyright (C) 2020 Moritz Zwerger
|
||||
*
|
||||
* 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 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.game.datatypes.entities;
|
||||
|
||||
public class Velocity {
|
||||
private final short x;
|
||||
private final short y;
|
||||
private final short z;
|
||||
|
||||
public Velocity(short x, short y, short z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public short getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public short getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public short getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (super.equals(obj)) {
|
||||
return true;
|
||||
}
|
||||
Velocity that = (Velocity) obj;
|
||||
return that.getX() == getX() && that.getY() == getY() && that.getZ() == getZ();
|
||||
}
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Codename Minosoft
|
||||
* Copyright (C) 2020 Moritz Zwerger
|
||||
*
|
||||
* 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 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.game.datatypes.entities;
|
||||
|
||||
public class Zombie implements Entity {
|
||||
final int id;
|
||||
Location location;
|
||||
Velocity velocity;
|
||||
int yaw;
|
||||
int pitch;
|
||||
EntityMetaData data;
|
||||
|
||||
public Zombie(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entities getEntityType() {
|
||||
return Entities.ZOMBIE;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocation(Location location) {
|
||||
this.location = location;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Velocity getVelocity() {
|
||||
return velocity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVelocity(Velocity velocity) {
|
||||
this.velocity = velocity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getYaw() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setYaw(int yaw) {
|
||||
this.yaw = yaw;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPitch() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPitch(int pitch) {
|
||||
this.pitch = pitch;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWidth() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getHeight() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityMetaData getMetaData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMetaData(EntityMetaData data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user