This commit is contained in:
Modmuss50 2015-11-23 14:49:35 +00:00
parent fa9cd98b5a
commit abb9b5102f
65 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,54 @@
/*
* This file was made by modmuss50. View the licence file to see what licence this is is on. You can always ask me if you would like to use part or all of this file in your project.
*/
package techreborn.partSystem.QLib;
import reborncore.common.misc.vecmath.Vecs3d;
import reborncore.common.misc.vecmath.Vecs3dCube;
import uk.co.qmunity.lib.vec.Vec3d;
import uk.co.qmunity.lib.vec.Vec3dCube;
import java.util.ArrayList;
import java.util.List;
/**
* Created by mark on 09/12/14.
*/
public class ModLib2QLib {
public static Vec3d convert(Vecs3d input) {
return new Vec3d(input.getX(), input.getY(), input.getZ());
}
public static Vec3dCube convert(Vecs3dCube input) {
return new Vec3dCube(input.toAABB());
}
public static Vecs3d convert(Vec3d input) {
return new Vecs3d(input.getX(), input.getY(), input.getZ());
}
public static Vecs3dCube convert(Vec3dCube input) {
return new Vecs3dCube(input.toAABB());
}
public static List<Vecs3dCube> convert(List<Vec3dCube> input) {
List<Vecs3dCube> list = new ArrayList<Vecs3dCube>();
for (Vec3dCube cube : input) {
list.add(new Vecs3dCube(cube.toAABB()));
}
return list;
}
// Its got to be called becuase of some weird thing see:
// https://stackoverflow.com/questions/1998544/method-has-the-same-erasure-as-another-method-in-type
public static List<Vec3dCube> convert2(List<Vecs3dCube> input) {
List<Vec3dCube> list = new ArrayList<Vec3dCube>();
for (Vecs3dCube cube : input) {
list.add(new Vec3dCube(cube.toAABB()));
}
return list;
}
}

View file

@ -0,0 +1,149 @@
/*
* This file was made by modmuss50. View the licence file to see what licence this is is on. You can always ask me if you would like to use part or all of this file in your project.
*/
package techreborn.partSystem.QLib;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import reborncore.common.misc.Location;
import reborncore.common.misc.vecmath.Vecs3d;
import reborncore.common.misc.vecmath.Vecs3dCube;
import techreborn.partSystem.ModPart;
import uk.co.qmunity.lib.client.render.RenderHelper;
import uk.co.qmunity.lib.part.*;
import uk.co.qmunity.lib.raytrace.QMovingObjectPosition;
import uk.co.qmunity.lib.raytrace.RayTracer;
import uk.co.qmunity.lib.vec.Vec3d;
import uk.co.qmunity.lib.vec.Vec3dCube;
import uk.co.qmunity.lib.vec.Vec3i;
import java.util.ArrayList;
import java.util.List;
public class QModPart extends PartBase implements IPartCollidable,
IPartSelectable, IPartRenderPlacement, IPartTicking,
IPartUpdateListener {
ModPart iModPart;
public QModPart(ModPart iModPart) {
this.iModPart = iModPart;
}
@Override
public void setParent(ITilePartHolder parent) {
super.setParent(parent);
}
@Override
public String getType() {
return iModPart.getName();
}
@Override
public ItemStack getItem() {
return iModPart.getItem();
}
@Override
public void addCollisionBoxesToList(List<Vec3dCube> boxes, Entity entity) {
List<Vecs3dCube> cubes = new ArrayList<Vecs3dCube>();
iModPart.addCollisionBoxesToList(cubes, entity);
for (Vecs3dCube cube : cubes) {
if (cube != null)
boxes.add(ModLib2QLib.convert(cube));
}
}
@Override
public void renderDynamic(Vec3d translation, double delta, int pass) {
iModPart.renderDynamic(ModLib2QLib.convert(translation), delta);
}
@Override
public boolean renderStatic(Vec3i translation, RenderHelper renderer, RenderBlocks renderBlocks, int pass) {
return iModPart.renderStatic(new Vecs3d(translation.getX(), translation.getY(), translation.getZ()), pass);
}
@Override
public QMovingObjectPosition rayTrace(Vec3d start, Vec3d end) {
return RayTracer.instance().rayTraceCubes(this, start, end);
}
@Override
public List<Vec3dCube> getSelectionBoxes() {
return ModLib2QLib.convert2(iModPart.getSelectionBoxes());
}
@Override
public World getWorld() {
return getParent().getWorld();
}
@Override
public void update() {
if (iModPart.world == null || iModPart.location == null) {
iModPart.setWorld(getWorld());
iModPart.setLocation(new Location(getX(), getY(), getZ()));
}
iModPart.tick();
}
@Override
public void onPartChanged(IPart part) {
iModPart.nearByChange();
}
@Override
public void onNeighborBlockChange() {
iModPart.nearByChange();
}
@Override
public void onNeighborTileChange() {
if (iModPart.world == null || iModPart.location == null) {
iModPart.setWorld(getWorld());
iModPart.setLocation(new Location(getX(), getY(), getZ()));
}
iModPart.nearByChange();
}
@Override
public void onAdded() {
if (iModPart.world == null || iModPart.location == null) {
iModPart.setWorld(getWorld());
iModPart.setLocation(new Location(getX(), getY(), getZ()));
}
iModPart.nearByChange();
iModPart.onAdded();
}
@Override
public void onRemoved() {
iModPart.onRemoved();
}
@Override
public void onLoaded() {
if (iModPart.world == null || iModPart.location == null) {
iModPart.setWorld(getWorld());
iModPart.setLocation(new Location(getX(), getY(), getZ()));
}
iModPart.nearByChange();
}
@Override
public void onUnloaded() {
}
@Override
public void onConverted() {
}
}

View file

@ -0,0 +1,117 @@
/*
* This file was made by modmuss50. View the licence file to see what licence this is is on. You can always ask me if you would like to use part or all of this file in your project.
*/
package techreborn.partSystem.QLib;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraft.util.EnumFacing;
import reborncore.common.misc.Location;
import reborncore.common.misc.vecmath.Vecs3dCube;
import techreborn.partSystem.IModPart;
import techreborn.partSystem.IPartProvider;
import techreborn.partSystem.ModPart;
import techreborn.partSystem.ModPartRegistry;
import uk.co.qmunity.lib.QLModInfo;
import uk.co.qmunity.lib.part.IPart;
import uk.co.qmunity.lib.part.IPartFactory;
import uk.co.qmunity.lib.part.PartRegistry;
import uk.co.qmunity.lib.part.compat.MultipartCompatibility;
import uk.co.qmunity.lib.tile.TileMultipart;
import uk.co.qmunity.lib.vec.Vec3dCube;
import uk.co.qmunity.lib.vec.Vec3i;
public class QModPartFactory implements IPartFactory, IPartProvider {
@Override
public IPart createPart(String type, boolean client) {
for (ModPart modPart : ModPartRegistry.parts) {
if (modPart.getName().equals(type)) {
return new QModPart((ModPart) modPart.copy());
}
}
return null;
}
@Override
public boolean placePart(ItemStack item, EntityPlayer player, World world,
int x, int y, int z, int face, float x_, float y_, float z_,
ModPart modPart) {
IPart part = createPart(
item,
player,
world,
new MovingObjectPosition(x, y, z, face, Vec3
.createVectorHelper(x + x_, y + y_, z + z_)), modPart);
if (part == null)
return false;
EnumFacing dir = EnumFacing.getOrientation(face);
return MultipartCompatibility.placePartInWorld(part, world, new Vec3i(
x, y, z), dir, player, item);
}
@Override
public boolean isTileFromProvider(TileEntity tileEntity) {
return tileEntity instanceof TileMultipart;
}
@Override
public IModPart getPartFromWorld(World world, Location location, String name) {
IPart part = MultipartCompatibility.getPart(world, location.getX(), location.getY(), location.getZ(), name);
if (part != null) {
if (part instanceof QModPart) {
return ((QModPart) part).iModPart;
}
}
return null;
}
@Override
public void init() {
}
public String getCreatedPartType(ItemStack item, EntityPlayer player,
World world, MovingObjectPosition mop, ModPart modPart) {
return modPart.getName();
}
public IPart createPart(ItemStack item, EntityPlayer player, World world,
MovingObjectPosition mop, ModPart modPart) {
return PartRegistry.createPart(
getCreatedPartType(item, player, world, mop, modPart),
world.isRemote);
}
@Override
public String modID() {
return QLModInfo.MODID;
}
@Override
public void registerPart() {
PartRegistry.registerFactory(new QModPartFactory());
}
@Override
public boolean checkOcclusion(World world, Location location,
Vecs3dCube cube) {
return MultipartCompatibility.checkOcclusion(world, location.x,
location.y, location.z, new Vec3dCube(cube.toAABB()));
}
@Override
public boolean hasPart(World world, Location location, String name) {
if (MultipartCompatibility.getPartHolder(world, location.getX(), location.getY(), location.getZ()) == null) {
return false;
}
return MultipartCompatibility.getPart(world, location.getX(), location.getY(), location.getZ(), name) == null;
}
}