Fixed UV's for the ends of the shaft

This commit is contained in:
malte0811 2018-05-13 18:54:26 +02:00
parent eb7f73464f
commit b43150d6c9
9 changed files with 43 additions and 27 deletions

View file

@ -28,7 +28,7 @@ package malte0811.industrialWires;
import malte0811.industrialWires.controlpanel.PanelUtils;
import malte0811.industrialWires.converter.EUCapability;
import malte0811.industrialWires.converter.MechMBPart;
import malte0811.industrialWires.converter.MultiblockConverter;
import malte0811.industrialWires.converter.MultiblockMechMB;
import malte0811.industrialWires.crafting.Recipes;
import malte0811.industrialWires.entities.EntityBrokenPart;
import malte0811.industrialWires.hv.MarxOreHandler;
@ -221,8 +221,8 @@ public class IndustrialWires {
public void init(FMLInitializationEvent e) {
MultiblockMarx.INSTANCE = new MultiblockMarx();
MultiblockHandler.registerMultiblock(MultiblockMarx.INSTANCE);
MultiblockConverter.INSTANCE = new MultiblockConverter();
MultiblockHandler.registerMultiblock(MultiblockConverter.INSTANCE);
MultiblockMechMB.INSTANCE = new MultiblockMechMB();
MultiblockHandler.registerMultiblock(MultiblockMechMB.INSTANCE);
packetHandler.registerMessage(MessageTileSyncIW.HandlerClient.class, MessageTileSyncIW.class, 0, Side.CLIENT);
packetHandler.registerMessage(MessagePanelInteract.HandlerServer.class, MessagePanelInteract.class, 1, Side.SERVER);

View file

@ -18,6 +18,7 @@ package malte0811.industrialWires.blocks.converter;
import blusunrize.immersiveengineering.api.ApiUtils;
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IPlayerInteraction;
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IRedstoneOutput;
import blusunrize.immersiveengineering.common.util.Utils;
import ic2.api.energy.event.EnergyTileLoadEvent;
import ic2.api.energy.event.EnergyTileUnloadEvent;
import ic2.api.energy.tile.IEnergyAcceptor;
@ -38,6 +39,7 @@ import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.*;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
@ -69,7 +71,6 @@ public class TileEntityMechMB extends TileEntityIWMultiblock implements ITickabl
private static final double DECAY_BASE = Math.exp(Math.log(.8) / (2 * 60 * 60 * 20));
public static final double TICK_ANGLE_PER_SPEED = 180 / 20 / Math.PI;
private static final double SYNC_THRESHOLD = .95;
private static final int TURN_SOUND_LENGTH = 7;
public MechMBPart[] mechanical = null;
private int[] offsets = null;
@ -97,6 +98,11 @@ public class TileEntityMechMB extends TileEntityIWMultiblock implements ITickabl
angle %= 360;
if (energyState.clientUpdate()||firstTick) {
IndustrialWires.proxy.updateMechMBTurningSound(this, energyState);
int otherEndOffset = offsets[offsets.length-1]+mechanical[mechanical.length-1].getLength();
TileEntity otherEnd = Utils.getExistingTileEntity(world, pos.offset(facing, -otherEndOffset));
if (otherEnd instanceof TileEntityMechMB) {
IndustrialWires.proxy.updateMechMBTurningSound((TileEntityMechMB) otherEnd, energyState);
}
}
}
if (firstTick) {
@ -181,7 +187,8 @@ public class TileEntityMechMB extends TileEntityIWMultiblock implements ITickabl
double maxTransferred = 0;
for (int i = 0; i < requested.length; i++) {
Waveform wf = availableWfList.get(i);
double transferred = transferElectric(section, Arrays.copyOf(available, sectionLength), availableWf, wf, requested[i], true);
double transferred = transferElectric(section, Arrays.copyOf(available, sectionLength), availableWf, wf,
Arrays.copyOf(requested[i], sectionLength), true);
if (transferred > maxTransferred) {
maxTransferred = transferred;
maxId = i;
@ -224,6 +231,11 @@ public class TileEntityMechMB extends TileEntityIWMultiblock implements ITickabl
double totalRequested = 0;
for (int i = 0; i < available.length; i++) {
if (availableWf[i].equals(waveform)) {
if (available[i]>requested[i]) {
requested[i] = 0;
} else {
available[i] = 0;
}
totalAvailable += available[i];
} else {
available[i] = 0;
@ -576,6 +588,8 @@ public class TileEntityMechMB extends TileEntityIWMultiblock implements ITickabl
public AxisAlignedBB getBoundingBoxNoRot() {
Vec3i offset = getOffsetDir();
TileEntityMechMB master = masterOr(this, this);
if (master==this&&!offset.equals(Vec3i.NULL_VECTOR))
return new AxisAlignedBB(0, 0, 0, 0, 0, 0);
int comp = getPart(offset.getZ(), master);
if (comp < 0) {
if (offset.getZ() == 0) {
@ -589,11 +603,12 @@ public class TileEntityMechMB extends TileEntityIWMultiblock implements ITickabl
return part.getBoundingBox(offsetPart);
}
private AxisAlignedBB aabb = null;
public AxisAlignedBB aabb = null;
@Override
public AxisAlignedBB getBoundingBox() {
if (aabb == null) {
if (aabb == null || aabb.minX==aabb.maxX)
{
aabb = IBlockBoundsDirectional.super.getBoundingBox();
}
return aabb;

View file

@ -66,7 +66,7 @@ import javax.annotation.Nonnull;
import java.util.Locale;
import java.util.Map;
import static malte0811.industrialWires.client.render.TileRenderMBConverter.BASE_MODELS;
import static malte0811.industrialWires.client.render.TileRenderMechMB.BASE_MODELS;
@Mod.EventBusSubscriber(modid = IndustrialWires.MODID, value = Side.CLIENT)
public class ClientEventHandler {

View file

@ -128,7 +128,7 @@ public class ClientProxy extends CommonProxy {
ModelLoaderRegistry.registerLoader(new PanelModelLoader());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityJacobsLadder.class, new TileRenderJacobsLadder());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMarx.class, new TileRenderMarx());
TileRenderMBConverter tesr = new TileRenderMBConverter();
TileRenderMechMB tesr = new TileRenderMechMB();
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMechMB.class, tesr);
((IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager()).registerReloadListener(tesr);
RenderingRegistry.registerEntityRenderingHandler(EntityBrokenPart.class, EntityRenderBrokenPart::new);

View file

@ -45,11 +45,11 @@ import java.util.*;
import static malte0811.industrialWires.blocks.converter.TileEntityMechMB.TICK_ANGLE_PER_SPEED;
import static malte0811.industrialWires.converter.MechMBPart.SHAFT_KEY;
public class TileRenderMBConverter extends TileEntitySpecialRenderer<TileEntityMechMB> implements IResourceManagerReloadListener {
public class TileRenderMechMB extends TileEntitySpecialRenderer<TileEntityMechMB> implements IResourceManagerReloadListener {
public static final Map<ResourceLocation, IBakedModel> BASE_MODELS = new HashMap<>();
public static final Set<TileEntityMechMB> TES_WITH_MODELS = Collections.newSetFromMap(new WeakHashMap<>());
private static final Set<TileEntityMechMB> TES_WITH_MODELS = Collections.newSetFromMap(new WeakHashMap<>());
static {
IEApi.renderCacheClearers.add(TileRenderMBConverter::clearCache);
IEApi.renderCacheClearers.add(TileRenderMechMB::clearCache);
}
@Override
public void render(TileEntityMechMB te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
@ -96,7 +96,6 @@ public class TileRenderMBConverter extends TileEntitySpecialRenderer<TileEntityM
offset += part.getLength();
}
//Add shaft model in the end blocks
//TODO handle ends not being in the same indices for all quads
List<BakedQuad> shaftQuads = MechMBPart.INSTANCES.get(SHAFT_KEY).getRotatingQuads();
Vector3f tmp = new Vector3f();
Matrix4 id = new Matrix4();
@ -106,18 +105,18 @@ public class TileRenderMBConverter extends TileEntitySpecialRenderer<TileEntityM
RawQuad raw = RawQuad.unbake(q);
Vector3f.add(raw.vertices[0], raw.vertices[1], tmp);
tmp.scale(.5F);
Vector3f middle0 = new Vector3f(tmp);
Vector3f middle01 = new Vector3f(tmp);
Vector3f.add(raw.vertices[2], raw.vertices[3], tmp);
tmp.scale(.5F);
Vector3f middle1 = new Vector3f(tmp);
RawQuad start = new RawQuad(raw.vertices[0], middle0, middle1, raw.vertices[3],
Vector3f middle23 = new Vector3f(tmp);
RawQuad start = new RawQuad(raw.vertices[0], middle01, middle23, raw.vertices[3],
raw.facing, raw.tex, raw.colorA, raw.normal, new float[][]{
raw.uvs[0], {raw.uvs[1][0], .5F}, {raw.uvs[2][0], .5F}, raw.uvs[3]
raw.uvs[0], {raw.uvs[1][0], 8}, {raw.uvs[2][0], 8}, raw.uvs[3]
}, -1);
te.rotatingModel.add(ClientUtilsIW.bakeQuad(start, id, id));
RawQuad end = new RawQuad(middle0, raw.vertices[1], raw.vertices[2], middle1,
RawQuad end = new RawQuad(middle01, raw.vertices[1], raw.vertices[2], middle23,
raw.facing, raw.tex, raw.colorA, raw.normal, new float[][]{
{raw.uvs[0][0], .5F}, raw.uvs[1], raw.uvs[2], {raw.uvs[3][0], .5F}
{raw.uvs[0][0], 8}, raw.uvs[1], raw.uvs[2], {raw.uvs[3][0], 8}
}, -1);
te.rotatingModel.add(ClientUtilsIW.bakeQuad(end, translate, id));
}

View file

@ -55,14 +55,14 @@ public final class MechEnergy {
public void decaySpeed(double decay) {
speed *= decay;
if (speed < .1)
if (speed < .01)
speed = 0;
}
private static final int TICKS_FOR_ADJUSTMENT = 30;
private double targetSpeed;
private double oldSpeed = -1;
private int ticksTillReached;
private int ticksTillReached = -1;
//ONLY USE FOR SYNCING
@SideOnly(Side.CLIENT)

View file

@ -24,7 +24,7 @@ import com.google.common.collect.HashBiMap;
import malte0811.industrialWires.IndustrialWires;
import malte0811.industrialWires.blocks.converter.MechanicalMBBlockType;
import malte0811.industrialWires.blocks.converter.TileEntityMechMB;
import malte0811.industrialWires.client.render.TileRenderMBConverter;
import malte0811.industrialWires.client.render.TileRenderMechMB;
import malte0811.industrialWires.entities.EntityBrokenPart;
import malte0811.industrialWires.util.LocalSidedWorld;
import malte0811.industrialWires.util.MiscUtils;
@ -70,7 +70,7 @@ public abstract class MechMBPart {
@SideOnly(Side.CLIENT)
public List<BakedQuad> getRotatingQuads() {
return TileRenderMBConverter.BASE_MODELS.get(getRotatingBaseModel())
return TileRenderMechMB.BASE_MODELS.get(getRotatingBaseModel())
.getQuads(null, null, 123);
}

View file

@ -37,11 +37,11 @@ import java.util.function.Consumer;
import static malte0811.industrialWires.blocks.converter.MechanicalMBBlockType.*;
public class MultiblockConverter implements MultiblockHandler.IMultiblock {
public static MultiblockConverter INSTANCE;
public class MultiblockMechMB implements MultiblockHandler.IMultiblock {
public static MultiblockMechMB INSTANCE;
@Override
public String getUniqueName() {
return "iw:converter";
return IndustrialWires.MODID+":mech_mb";
}
@Override
@ -120,7 +120,7 @@ public class MultiblockConverter implements MultiblockHandler.IMultiblock {
formEnd(w, mutPos, END, (te, master) -> {
if (master) {
te.offset = BlockPos.ORIGIN;
te.setMechanical(parts.toArray(new MechMBPart[parts.size()]), 0);
te.setMechanical(parts.toArray(new MechMBPart[0]), 0);
te.energyState = new MechEnergy(finalWeight, 0);
} else {
te.offset = new BlockPos(0, -1, 0);

View file

@ -197,6 +197,8 @@ public class EntityBrokenPart extends /*EntityArrow*/ Entity {
}
public void breakBlocks(double speedSq) {
if (world.isRemote)
return;
AxisAlignedBB axisalignedbb = this.getEntityBoundingBox();
axisalignedbb = axisalignedbb.grow(motionX, motionY, motionZ);
BlockPos.PooledMutableBlockPos min = BlockPos.PooledMutableBlockPos.retain(axisalignedbb.minX - .1,