mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-11 20:13:55 +00:00
Added an entity, weathertype, and gamemode registry.
This commit is contained in:
@ -22,10 +22,11 @@ package com.sk89q.worldedit.forge;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.entity.metadata.EntityType;
|
||||
import com.sk89q.worldedit.entity.metadata.EntityProperties;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.NullWorld;
|
||||
import com.sk89q.worldedit.world.entity.EntityTypes;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
@ -40,7 +41,7 @@ class ForgeEntity implements Entity {
|
||||
|
||||
ForgeEntity(net.minecraft.entity.Entity entity) {
|
||||
checkNotNull(entity);
|
||||
this.entityRef = new WeakReference<net.minecraft.entity.Entity>(entity);
|
||||
this.entityRef = new WeakReference<>(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -51,7 +52,7 @@ class ForgeEntity implements Entity {
|
||||
if (id != null) {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
entity.writeToNBT(tag);
|
||||
return new BaseEntity(id, NBTConverter.fromNative(tag));
|
||||
return new BaseEntity(EntityTypes.get(id), NBTConverter.fromNative(tag));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@ -99,8 +100,8 @@ class ForgeEntity implements Entity {
|
||||
public <T> T getFacet(Class<? extends T> cls) {
|
||||
net.minecraft.entity.Entity entity = entityRef.get();
|
||||
if (entity != null) {
|
||||
if (EntityType.class.isAssignableFrom(cls)) {
|
||||
return (T) new ForgeEntityType(entity);
|
||||
if (EntityProperties.class.isAssignableFrom(cls)) {
|
||||
return (T) new ForgeEntityProperties(entity);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package com.sk89q.worldedit.forge;
|
||||
|
||||
import com.sk89q.worldedit.entity.metadata.EntityType;
|
||||
import com.sk89q.worldedit.entity.metadata.EntityProperties;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.IMerchant;
|
||||
@ -45,11 +45,11 @@ import net.minecraft.entity.player.EntityPlayerMP;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
public class ForgeEntityType implements EntityType {
|
||||
public class ForgeEntityProperties implements EntityProperties {
|
||||
|
||||
private final Entity entity;
|
||||
|
||||
public ForgeEntityType(Entity entity) {
|
||||
public ForgeEntityProperties(Entity entity) {
|
||||
checkNotNull(entity);
|
||||
this.entity = entity;
|
||||
}
|
@ -47,6 +47,7 @@ import com.sk89q.worldedit.util.TreeGenerator.TreeType;
|
||||
import com.sk89q.worldedit.world.AbstractWorld;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
||||
import com.sk89q.worldedit.world.weather.WeatherType;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockLeaves;
|
||||
import net.minecraft.block.BlockOldLeaf;
|
||||
@ -350,6 +351,27 @@ public class ForgeWorld extends AbstractWorld {
|
||||
return generator != null && generator.generate(getWorld(), random, ForgeAdapter.toBlockPos(position));
|
||||
}
|
||||
|
||||
@Override
|
||||
public WeatherType getWeather() {
|
||||
// TODO Weather implementation
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getRemainingWeatherDuration() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWeather(WeatherType weatherType) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWeather(WeatherType weatherType, long duration) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlock(Vector position) {
|
||||
World world = getWorld();
|
||||
@ -421,7 +443,7 @@ public class ForgeWorld extends AbstractWorld {
|
||||
@Override
|
||||
public Entity createEntity(Location location, BaseEntity entity) {
|
||||
World world = getWorld();
|
||||
net.minecraft.entity.Entity createdEntity = EntityList.createEntityByIDFromName(new ResourceLocation(entity.getTypeId()), world);
|
||||
net.minecraft.entity.Entity createdEntity = EntityList.createEntityByIDFromName(new ResourceLocation(entity.getType().getId()), world);
|
||||
if (createdEntity != null) {
|
||||
CompoundTag nativeTag = entity.getNbtData();
|
||||
if (nativeTag != null) {
|
||||
|
Reference in New Issue
Block a user