2015-04-20 21:08:14 +02:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2015-04-20 22:02:25 +02:00
|
|
|
package techreborn.partSystem.QLib;
|
2015-04-20 21:08:14 +02:00
|
|
|
|
2015-04-23 21:49:30 +02:00
|
|
|
import net.minecraft.client.renderer.RenderBlocks;
|
2015-04-24 20:35:04 +02:00
|
|
|
import net.minecraft.entity.Entity;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.world.World;
|
2015-11-08 13:15:45 +01:00
|
|
|
import reborncore.common.misc.Location;
|
|
|
|
import reborncore.common.misc.vecmath.Vecs3d;
|
|
|
|
import reborncore.common.misc.vecmath.Vecs3dCube;
|
2015-04-20 22:02:25 +02:00
|
|
|
import techreborn.partSystem.ModPart;
|
2015-04-23 21:49:30 +02:00
|
|
|
import uk.co.qmunity.lib.client.render.RenderHelper;
|
2015-08-09 12:05:32 +02:00
|
|
|
import uk.co.qmunity.lib.part.*;
|
2015-04-20 21:08:14 +02:00
|
|
|
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;
|
2015-04-23 21:49:30 +02:00
|
|
|
import uk.co.qmunity.lib.vec.Vec3i;
|
2015-04-20 21:08:14 +02:00
|
|
|
|
2015-07-02 20:49:30 +02:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
2015-04-24 15:20:09 +02:00
|
|
|
public class QModPart extends PartBase implements IPartCollidable,
|
2015-08-09 12:05:32 +02:00
|
|
|
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() {
|
|
|
|
|
|
|
|
}
|
2015-04-20 21:08:14 +02:00
|
|
|
}
|