Skip to content

Commit

Permalink
Merge branch 'master' into mc1.11
Browse files Browse the repository at this point in the history
  • Loading branch information
ExE-Boss committed Oct 24, 2017
2 parents 606b3b3 + 297857e commit f4b5660
Show file tree
Hide file tree
Showing 48 changed files with 674 additions and 213 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@
import nova.core.wrapper.mc.forge.v17.wrapper.block.forward.FWBlock;
import nova.core.wrapper.mc.forge.v17.wrapper.block.forward.FWTile;
import nova.core.wrapper.mc.forge.v17.wrapper.block.forward.FWTileRenderer;
import nova.core.wrapper.mc.forge.v17.wrapper.entity.EntityConverter;
import nova.core.wrapper.mc.forge.v17.wrapper.entity.backward.BWEntityFX;
import nova.core.wrapper.mc.forge.v17.wrapper.entity.forward.FWEntity;
import nova.core.wrapper.mc.forge.v17.wrapper.entity.forward.FWEntityFX;
import nova.core.wrapper.mc.forge.v17.wrapper.entity.forward.FWEntityRenderer;
import nova.core.wrapper.mc.forge.v17.wrapper.item.FWItem;
import nova.internal.core.Game;
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;

import java.io.IOException;
Expand Down Expand Up @@ -156,7 +156,7 @@ public Entity spawnParticle(net.minecraft.world.World world, EntityFactory facto
if (build instanceof BWEntityFX) {
EntityFX entityFX = ((BWEntityFX) build).createEntityFX();
FMLClientHandler.instance().getClient().effectRenderer.addEffect(entityFX);
return Game.natives().toNova(entityFX);
return EntityConverter.instance().toNova(entityFX);
} else {
FWEntityFX bwEntityFX = new FWEntityFX(world, factory);
FMLClientHandler.instance().getClient().effectRenderer.addEffect(bwEntityFX);
Expand All @@ -174,7 +174,7 @@ public Entity spawnParticle(net.minecraft.world.World world, Entity entity) {
entityFX.posY = position.getY();
entityFX.posZ = position.getZ();
FMLClientHandler.instance().getClient().effectRenderer.addEffect(entityFX);
return Game.natives().toNova(entityFX);
return EntityConverter.instance().toNova(entityFX);
} else {
FWEntityFX bwEntityFX = new FWEntityFX(world, entity);
FMLClientHandler.instance().getClient().effectRenderer.addEffect(bwEntityFX);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import nova.core.event.PlayerEvent;
import nova.core.wrapper.mc.forge.v17.wrapper.entity.EntityConverter;
import nova.internal.core.Game;

/**
Expand All @@ -32,12 +33,12 @@
public class FMLEventHandler {
@SubscribeEvent
public void playerJoin(cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent evt) {
Game.events().publish(new PlayerEvent.Join(Game.natives().toNova(evt.player)));
Game.events().publish(new PlayerEvent.Join(EntityConverter.instance().toNova(evt.player)));
}

@SubscribeEvent
public void playerLeave(cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedOutEvent evt) {
Game.events().publish(new PlayerEvent.Leave(Game.natives().toNova(evt.player)));
Game.events().publish(new PlayerEvent.Leave(EntityConverter.instance().toNova(evt.player)));
}

@SubscribeEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import nova.core.event.PlayerEvent;
import nova.core.item.Item;
import nova.core.item.ItemDictionary;
import nova.core.wrapper.mc.forge.v17.wrapper.block.world.WorldConverter;
import nova.core.wrapper.mc.forge.v17.wrapper.entity.EntityConverter;
import nova.core.wrapper.mc.forge.v17.wrapper.item.ItemConverter;
import nova.internal.core.Game;
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
Expand All @@ -38,12 +40,12 @@
public class ForgeEventHandler {
@SubscribeEvent
public void worldUnload(WorldEvent.Load evt) {
Game.events().publish(new nova.core.event.WorldEvent.Load(Game.natives().toNova(evt.world)));
Game.events().publish(new nova.core.event.WorldEvent.Load(WorldConverter.instance().toNova(evt.world)));
}

@SubscribeEvent
public void worldLoad(WorldEvent.Unload evt) {
Game.events().publish(new nova.core.event.WorldEvent.Unload(Game.natives().toNova(evt.world)));
Game.events().publish(new nova.core.event.WorldEvent.Unload(WorldConverter.instance().toNova(evt.world)));
}

@SubscribeEvent
Expand All @@ -58,20 +60,20 @@ public void onOreRegister(OreDictionary.OreRegisterEvent event) {

@SubscribeEvent
public void playerJoin(cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent evt) {
Game.events().publish(new PlayerEvent.Join(Game.natives().toNova(evt.player)));
Game.events().publish(new PlayerEvent.Join(EntityConverter.instance().toNova(evt.player)));
}

@SubscribeEvent
public void playerLeave(cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedOutEvent evt) {
Game.events().publish(new PlayerEvent.Leave(Game.natives().toNova(evt.player)));
Game.events().publish(new PlayerEvent.Leave(EntityConverter.instance().toNova(evt.player)));
}

@SubscribeEvent
public void playerInteractEvent(PlayerInteractEvent event) {
nova.core.event.PlayerEvent.Interact evt = new nova.core.event.PlayerEvent.Interact(
Game.natives().toNova(event.world),
WorldConverter.instance().toNova(event.world),
new Vector3D(event.x, event.y, event.z),
Game.natives().toNova(event.entityPlayer),
EntityConverter.instance().toNova(event.entityPlayer),
nova.core.event.PlayerEvent.Interact.Action.values()[event.action.ordinal()]
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import nova.core.retention.Data;
import nova.core.retention.Storable;
import nova.core.util.registry.RetentionManager;
import nova.core.wrapper.mc.forge.v17.wrapper.data.DataConverter;
import nova.internal.core.Game;

import java.io.File;
Expand Down Expand Up @@ -59,13 +60,13 @@ public void saveAll() {
public void save(String filename, Storable storable) {
Data saveMap = new Data();
storable.save(saveMap);
saveFile(filename, Game.natives().toNative(saveMap));
saveFile(filename, DataConverter.instance().toNative(saveMap));
}

@Override
public void load(String filename, Storable storable) {
NBTTagCompound nbt = loadFile(filename);
storable.load(Game.natives().toNova(nbt));
storable.load(DataConverter.instance().toNova(nbt));
}

/**
Expand All @@ -76,7 +77,7 @@ public void load(String filename, Storable storable) {
*/
public boolean saveFile(File file, NBTTagCompound data) {
try {
File tempFile = new File(file.getParent(), file.getName() + "_tmp.dat");
File tempFile = new File(file.getParent(), file.getName().replaceFirst("\\.nbt$", ".tmp.nbt"));

CompressedStreamTools.writeCompressed(data, new FileOutputStream(tempFile));

Expand All @@ -94,7 +95,7 @@ public boolean saveFile(File file, NBTTagCompound data) {
}

public boolean saveFile(File saveDirectory, String filename, NBTTagCompound data) {
return saveFile(new File(saveDirectory, filename + ".dat"), data);
return saveFile(new File(saveDirectory, filename + ".nbt"), data);
}

public boolean saveFile(String filename, NBTTagCompound data) {
Expand Down Expand Up @@ -122,7 +123,7 @@ public NBTTagCompound loadFile(File file) {
* @return The NBT data
*/
public NBTTagCompound loadFile(File saveDirectory, String filename) {
return loadFile(new File(saveDirectory, filename + ".dat"));
return loadFile(new File(saveDirectory, filename + ".nbt"));
}

public NBTTagCompound loadFile(String filename) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import net.minecraft.entity.player.EntityPlayer;
import nova.core.entity.Entity;
import nova.core.entity.component.Player;
import nova.core.network.handler.PacketHandler;
import nova.core.wrapper.mc.forge.v17.network.MCPacket;
import nova.core.wrapper.mc.forge.v17.network.netty.MCNetworkManager;
import nova.core.wrapper.mc.forge.v17.wrapper.entity.EntityConverter;
import nova.internal.core.Game;

/**
Expand Down Expand Up @@ -65,7 +65,7 @@ public void handle(EntityPlayer player) {
MCNetworkManager network = (MCNetworkManager) Game.network();
PacketHandler<?> packetHandler = network.getPacketType(data.readInt());
int subId = data.readInt();
MCPacket packet = new MCPacket(data.slice(), ((Entity) Game.natives().toNova(player)).components.get(Player.class));
MCPacket packet = new MCPacket(data.slice(), EntityConverter.instance().toNova(player).components.get(Player.class));
//Set the ID of the packet
packet.setID(subId);
packetHandler.read(packet);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public EnumFacing toNative(Direction novaObj) {
case SOUTH: return EnumFacing.SOUTH;
case WEST: return EnumFacing.WEST;
case EAST: return EnumFacing.EAST;
default: return (EnumFacing) null;
default: return null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ private void registerNOVAToMinecraft() {
public boolean canReplace() {
return true;
}
}, evt -> {
});
}, evt -> {});

blockManager.register(airBlock);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import nova.core.block.component.LightEmitter;
import nova.core.component.misc.Collider;
import nova.core.component.renderer.StaticRenderer;
import nova.core.component.transform.BlockTransform;
import nova.core.item.ItemFactory;
import nova.core.render.model.CustomModel;
import nova.core.retention.Data;
Expand All @@ -47,6 +46,7 @@
import nova.core.wrapper.mc.forge.v17.wrapper.cuboid.CuboidConverter;
import nova.core.wrapper.mc.forge.v17.wrapper.data.DataConverter;
import nova.core.wrapper.mc.forge.v17.wrapper.entity.EntityConverter;
import nova.core.wrapper.mc.forge.v17.wrapper.item.ItemConverter;
import nova.internal.core.Game;
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;

Expand All @@ -69,9 +69,11 @@ public BWBlock(net.minecraft.block.Block block) {
public BWBlock(net.minecraft.block.Block block, World world, Vector3D pos) {
this.mcBlock = block;
components.add(new BWBlockTransform(this, world, pos));
components.add(new BlockProperty.Opacity().setOpacity(mcBlock.getMaterial().isOpaque() ? 1 : 0));
if (mcBlock.isReplaceable(blockAccess(), xi(), yi(), zi()))
components.add(BlockProperty.Replaceable.instance());
components.add(new BlockProperty.Opacity()).setOpacity(() -> mcBlock.getMaterial().isOpaque() ? 1 : 0);
BlockProperty.Replaceable replaceable = components.add(new BlockProperty.Replaceable());
if (block != Blocks.air) {
replaceable.setReplaceable(() -> mcBlock.canPlaceBlockAt((net.minecraft.world.World) blockAccess(), xi(), yi(), zi()));
}

BlockProperty.BlockSound blockSound = components.add(new BlockProperty.BlockSound());
blockSound.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.PLACE, new Sound("", mcBlock.stepSound.func_150496_b()));
Expand Down Expand Up @@ -113,7 +115,7 @@ public BWBlock(net.minecraft.block.Block block, World world, Vector3D pos) {

@Override
public ItemFactory getItemFactory() {
return Game.natives().toNova(new ItemStack(Item.getItemFromBlock(mcBlock)));
return ItemConverter.instance().toNova(new ItemStack(Item.getItemFromBlock(mcBlock))).getFactory();
}

public int xi() {
Expand Down Expand Up @@ -147,11 +149,6 @@ public Optional<TileEntity> getTileEntity() {
return Optional.ofNullable(mcTileEntity);
}

@Override
public boolean canReplace() {
return mcBlock.canPlaceBlockAt((net.minecraft.world.World) blockAccess(), xi(), yi(), zi());
}

@Override
public boolean shouldDisplacePlacement() {
if (mcBlock == Blocks.snow_layer && (blockAccess().getBlockMetadata(xi(), yi(), zi()) & 7) < 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import nova.core.component.transform.BlockTransform;
import nova.core.world.World;
import nova.core.wrapper.mc.forge.v17.wrapper.block.world.WorldConverter;
import nova.internal.core.Game;
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;

import java.util.Optional;
Expand Down Expand Up @@ -61,8 +60,8 @@ public IBlockAccess blockAccess() {

@Override
public void setWorld(World world) {
net.minecraft.world.World oldWorld = Game.natives().toNative(this.world);
net.minecraft.world.World newWorld = Game.natives().toNative(world);
net.minecraft.world.World oldWorld = (net.minecraft.world.World) WorldConverter.instance().toNative(this.world);
net.minecraft.world.World newWorld = (net.minecraft.world.World) WorldConverter.instance().toNative(world);
Optional<TileEntity> tileEntity = Optional.ofNullable(oldWorld.getTileEntity((int) position.getX(), (int) position.getY(), (int) position.getZ()));
Optional<NBTTagCompound> nbt = Optional.empty();
if (tileEntity.isPresent()) {
Expand All @@ -82,7 +81,7 @@ public void setWorld(World world) {

@Override
public void setPosition(Vector3D position) {
net.minecraft.world.World world = Game.natives().toNative(this.world);
net.minecraft.world.World world = (net.minecraft.world.World) WorldConverter.instance().toNative(this.world);
Optional<TileEntity> tileEntity = Optional.ofNullable(world.getTileEntity((int) this.position.getX(), (int) this.position.getY(), (int) this.position.getZ()));
Optional<NBTTagCompound> nbt = Optional.empty();
if (tileEntity.isPresent()) {
Expand Down
Loading

0 comments on commit f4b5660

Please sign in to comment.