Last active
August 29, 2015 14:24
-
-
Save ElvishJerricco/b60b58dec4ae67ae7aad to your computer and use it in GitHub Desktop.
PartBase
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class PartBase<E extends Enum<E> & IEnumPartFactory> | |
extends TMultiPart implements JNormalOcclusion, JIconHitEffects, IWorldPosition { | |
public abstract E getPartConstructor(); | |
@Override | |
public Iterable<Cuboid6> getOcclusionBoxes() { | |
return getCollisionBoxes(); | |
} | |
@Override | |
public Cuboid6 getBounds() { | |
return getRenderBounds(); | |
} | |
@Override | |
public Iterable<IndexedCuboid6> getSubParts() { | |
List<IndexedCuboid6> cubes = new ArrayList<IndexedCuboid6>(); | |
int i = 0; | |
for (Cuboid6 cuboid : getCollisionBoxes()) { | |
cubes.add(new IndexedCuboid6(i, cuboid)); | |
i++; | |
} | |
return cubes; | |
} | |
@Override | |
public IBlockAccess getWorld() { | |
return world(); | |
} | |
@Override | |
public int getX() { | |
return x(); | |
} | |
@Override | |
public int getY() { | |
return y(); | |
} | |
@Override | |
public int getZ() { | |
return z(); | |
} | |
@Override | |
public IIcon getBreakingIcon(Object subPart, int side) { | |
return getBrokenIcon(side); | |
} | |
@Override | |
public String getType() { | |
return getPartConstructor().getPartType(); | |
} | |
@Override | |
public boolean occlusionTest(TMultiPart npart) { | |
return NormalOcclusionTest.apply(this, npart); | |
} | |
@Override | |
public Cuboid6 getRenderBounds() { | |
Cuboid6 cuboid = new Cuboid6(0,0,0,0,0,0); | |
for (Cuboid6 box : getCollisionBoxes()) { | |
cuboid.enclose(box); | |
} | |
return cuboid; | |
} | |
@Override | |
public void addHitEffects(MovingObjectPosition hit, EffectRenderer effectRenderer) { | |
IconHitEffects.addHitEffects(this, hit, effectRenderer); | |
} | |
// Define as abstract; It's a fundamental override | |
@Override | |
public abstract Iterable<Cuboid6> getCollisionBoxes(); | |
@Override | |
public ItemStack pickItem(MovingObjectPosition hit) { | |
return getPartConstructor().getItem(); | |
} | |
@Override | |
public Iterable<ItemStack> getDrops() { | |
return Collections.singletonList(getPartConstructor().getItem()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment