use of net.minecraftforge.common.property.IExtendedBlockState in project ImmersiveEngineering by BluSunrize.
the class IESmartObjModel method getQuads.
public List<BakedQuad> getQuads(IBlockState blockState, EnumFacing side, long rand, OBJState objstate, Map<String, String> tex, boolean addAnimationAndTex) {
texReplace = tex;
this.tempState = blockState;
if (blockState instanceof IExtendedBlockState) {
IExtendedBlockState exState = (IExtendedBlockState) blockState;
ExtBlockstateAdapter adapter;
if (objstate != null) {
if (objstate.parent == null || objstate.parent == TRSRTransformation.identity())
objstate.parent = this.getState();
if (objstate.getVisibilityMap().containsKey(Group.ALL) || objstate.getVisibilityMap().containsKey(Group.ALL_EXCEPT))
this.updateStateVisibilityMap(objstate);
}
if (addAnimationAndTex)
adapter = new ExtBlockstateAdapter(exState, MinecraftForgeClient.getRenderLayer(), ExtBlockstateAdapter.CONNS_OBJ_CALLBACK, new Object[] { objstate, tex });
else
adapter = new ExtBlockstateAdapter(exState, MinecraftForgeClient.getRenderLayer(), ExtBlockstateAdapter.CONNS_OBJ_CALLBACK);
List<BakedQuad> quads = modelCache.get(adapter);
if (quads == null) {
IESmartObjModel model = null;
if (objstate != null)
model = new IESmartObjModel(baseModel, getModel(), objstate, getFormat(), getTextures(), transformationMap, isDynamic);
if (model == null)
model = new IESmartObjModel(baseModel, getModel(), this.getState(), getFormat(), getTextures(), transformationMap, isDynamic);
model.tempState = blockState;
model.texReplace = tex;
quads = model.buildQuads();
modelCache.put(adapter, quads);
}
return Collections.synchronizedList(Lists.newArrayList(quads));
}
if (bakedQuads == null)
bakedQuads = buildQuads();
List<BakedQuad> quadList = Lists.newArrayList(bakedQuads);
return Collections.synchronizedList(quadList);
}
use of net.minecraftforge.common.property.IExtendedBlockState in project ImmersiveEngineering by BluSunrize.
the class ModelConveyor method getQuads.
@Override
public List<BakedQuad> getQuads(@Nullable IBlockState blockState, @Nullable EnumFacing side, long rand) {
TileEntity tile = null;
String key = "default";
EnumFacing facing = EnumFacing.NORTH;
IConveyorBelt conveyor = defaultBelt;
if (blockState == null)
key = conveyor != null ? ConveyorHandler.reverseClassRegistry.get(conveyor.getClass()).toString() : "immersiveengineering:conveyor";
else {
facing = blockState.getValue(IEProperties.FACING_ALL);
if (blockState instanceof IExtendedBlockState) {
IExtendedBlockState exState = (IExtendedBlockState) blockState;
if (exState.getUnlistedNames().contains(BlockConveyor.ICONEYOR_PASSTHROUGH))
conveyor = ((IExtendedBlockState) blockState).getValue(BlockConveyor.ICONEYOR_PASSTHROUGH);
if (exState.getUnlistedNames().contains(IEProperties.TILEENTITY_PASSTHROUGH))
tile = ((IExtendedBlockState) blockState).getValue(IEProperties.TILEENTITY_PASSTHROUGH);
if (conveyor != null && tile != null)
key = conveyor.getModelCacheKey(tile, facing);
}
}
List<BakedQuad> cachedQuads = modelCache.get(key);
if (cachedQuads != null)
return ImmutableList.copyOf(cachedQuads);
else {
if (conveyor == null)
conveyor = ConveyorHandler.getConveyor(new ResourceLocation(key), tile);
cachedQuads = Collections.synchronizedList(Lists.newArrayList());
Matrix4f facingMatrix = TRSRTransformation.getMatrix(facing);
if (conveyor != null)
facingMatrix = conveyor.modifyBaseRotationMatrix(facingMatrix, tile, facing);
Matrix4 matrix = new Matrix4(facingMatrix);
ConveyorDirection conDir = conveyor != null ? conveyor.getConveyorDirection() : ConveyorDirection.HORIZONTAL;
boolean[] walls = conveyor != null && tile != null ? new boolean[] { conveyor.renderWall(tile, facing, 0), conveyor.renderWall(tile, facing, 1) } : new boolean[] { true, true };
TextureAtlasSprite tex_conveyor = ClientUtils.mc().getTextureMapBlocks().getMissingSprite();
TextureAtlasSprite tex_conveyor_colour = null;
int colourStripes = -1;
if (conveyor != null) {
tex_conveyor = ClientUtils.getSprite(tile != null ? (conveyor.isActive(tile) ? conveyor.getActiveTexture() : conveyor.getInactiveTexture()) : conveyor.getActiveTexture());
if ((colourStripes = conveyor.getDyeColour()) >= 0)
tex_conveyor_colour = ClientUtils.getSprite(conveyor.getColouredStripesTexture());
}
cachedQuads.addAll(getBaseConveyor(facing, 1, matrix, conDir, tex_conveyor, walls, new boolean[] { true, true }, tex_conveyor_colour, colourStripes));
if (conveyor != null)
cachedQuads = conveyor.modifyQuads(cachedQuads, tile, facing);
modelCache.put(key, ImmutableList.copyOf(cachedQuads));
return ImmutableList.copyOf(cachedQuads);
}
}
use of net.minecraftforge.common.property.IExtendedBlockState in project ImmersiveEngineering by BluSunrize.
the class ConnModelReal method getQuads.
@Nonnull
@Override
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) {
if (side == null && state instanceof IExtendedBlockState) {
IExtendedBlockState ext = (IExtendedBlockState) state;
Object[] additional = null;
if (ext.getUnlistedProperties().containsKey(IEProperties.TILEENTITY_PASSTHROUGH)) {
TileEntity te = ext.getValue(IEProperties.TILEENTITY_PASSTHROUGH);
if (te instanceof IEBlockInterfaces.ICacheData)
additional = ((IEBlockInterfaces.ICacheData) te).getCacheData();
}
int x = 0, z = 0;
if (ext.getUnlistedProperties().containsKey(IEProperties.CONNECTIONS)) {
Set<Connection> conns = ext.getValue(IEProperties.CONNECTIONS);
if (conns != null && conns.size() > 0) {
BlockPos tmp = conns.iterator().next().start;
x = (tmp.getX() % 16 + 16) % 16;
z = (tmp.getZ() % 16 + 16) % 16;
}
}
ExtBlockstateAdapter ad = new ExtBlockstateAdapter(ext, null, ExtBlockstateAdapter.ONLY_OBJ_CALLBACK, additional);
Pair<Byte, ExtBlockstateAdapter> key = new ImmutablePair<>((byte) ((x << 4) | z), ad);
try {
IBakedModel ret = cache.get(key, () -> new AssembledBakedModel(ext, textureAtlasSprite, base, layers));
return ret.getQuads(state, null, rand);
} catch (ExecutionException e) {
e.printStackTrace();
}
}
return getBaseQuads(MinecraftForgeClient.getRenderLayer(), state, side, rand);
}
use of net.minecraftforge.common.property.IExtendedBlockState in project Charset by CharsetMC.
the class RendererWire method getGeneralQuads.
@Override
public List<BakedQuad> getGeneralQuads() {
List<BakedQuad> quads = new ArrayList<BakedQuad>();
PartWireBase wire = null;
if (state instanceof IExtendedBlockState) {
wire = ((IExtendedBlockState) state).getValue(PartWireBase.PROPERTY);
}
if (wire != null) {
renderers.get(getRendererId()).handlePartState(state);
renderers.get(getRendererId()).addWire(wire, wire.location, wire.getRedstoneLevel() > 0, quads);
} else if (stack != null) {
if (ItemWire.isFreestanding(stack)) {
renderers.get(getRendererId()).handleItemState(stack);
renderers.get(getRendererId()).addWireFreestanding(null, false, quads);
} else {
renderers.get(getRendererId()).handleItemState(stack);
renderers.get(getRendererId()).addWire(null, WireFace.DOWN, false, quads);
}
}
return quads;
}
use of net.minecraftforge.common.property.IExtendedBlockState in project Immersive-Tech by FerroO2000.
the class BlockConnectors method getExtendedState.
@Override
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
state = super.getExtendedState(state, world, pos);
if (state instanceof IExtendedBlockState) {
IExtendedBlockState ext = (IExtendedBlockState) state;
TileEntity te = world.getTileEntity(pos);
if (!(te instanceof TileEntityImmersiveConnectable))
return state;
state = ext.withProperty(IEProperties.CONNECTIONS, ((TileEntityImmersiveConnectable) te).genConnBlockstate());
}
return state;
}
Aggregations