use of net.minecraft.util.Direction in project BluePower by Qmunity.
the class TileManager method getSlotsForFace.
@Override
public int[] getSlotsForFace(Direction side) {
Direction direction = getFacingDirection();
if (side == direction || side == direction.getOpposite()) {
return new int[] {};
}
int[] slots = new int[inventory.size()];
for (int i = 0; i < slots.length; i++) slots[i] = i;
return slots;
}
use of net.minecraft.util.Direction in project BluePower by Qmunity.
the class BPMultipartModel method getQuads.
@Nonnull
@Override
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, @Nonnull IModelData extraData) {
BlockRendererDispatcher brd = Minecraft.getInstance().getBlockRenderer();
Map<BlockState, IModelData> stateInfo = extraData.getData(TileBPMultipart.STATE_INFO);
if (stateInfo != null) {
return stateInfo.keySet().stream().flatMap(i -> brd.getBlockModel(i).getQuads(i, side, rand, stateInfo.get(i)).stream().map(q -> stateInfo.get(i).hasProperty(TileWire.COLOR_INFO) ? transform(q, stateInfo.get(i).getData(TileWire.COLOR_INFO), stateInfo.get(i).hasProperty(TileWire.LIGHT_INFO) ? stateInfo.get(i).getData(TileWire.LIGHT_INFO) : false) : q)).collect(Collectors.toList());
} else {
return Collections.emptyList();
}
}
use of net.minecraft.util.Direction in project BluePower by Qmunity.
the class RenderLamp method render.
@Override
public void render(TileLamp te, float v, MatrixStack matrixStack, IRenderTypeBuffer iRenderTypeBuffer, int partialTicks, int destroyStage) {
if (// || Loader.isModLoaded("albedo"))
!(te.getBlockState().getBlock() instanceof BlockLamp))
return;
BlockState stateLamp = te.getBlockState();
BlockLamp bLamp = (BlockLamp) stateLamp.getBlock();
if (te.getLevel() == null) {
return;
}
int power = stateLamp.getValue(BlockLamp.POWER);
int color = bLamp.getColor(stateLamp, te.getLevel(), te.getBlockPos(), 0);
int redMask = 0xFF0000, greenMask = 0xFF00, blueMask = 0xFF;
int r = (color & redMask) >> 16;
int g = (color & greenMask) >> 8;
int b = (color & blueMask);
AxisAlignedBB box = stateLamp.getShape(te.getLevel(), te.getBlockPos()).bounds();
// Define our base Glow
box = box.equals(new AxisAlignedBB(0, 0, 0, 1, 1, 1)) ? box.inflate(0.05) : box.inflate(0.03125);
boolean[] renderFaces = new boolean[] { true, true, true, true, true, true };
// Remove overlapping Glow
if (stateLamp.getShape(te.getLevel(), te.getBlockPos()).bounds().equals(new AxisAlignedBB(0, 0, 0, 1, 1, 1))) {
for (Direction face : Direction.values()) {
BlockState state = te.getLevel().getBlockState(te.getBlockPos().relative(face.getOpposite()));
if (state.getBlock() instanceof BlockLamp && state.getShape(te.getLevel(), te.getBlockPos()).bounds().equals(new AxisAlignedBB(0, 0, 0, 1, 1, 1))) {
if (state.getValue(BlockLamp.POWER) > 0) {
renderFaces[face.get3DDataValue()] = false;
double offsetx = (face.getStepX() * 0.05) > 0 ? (face.getStepX() * 0.05) : 0;
double offsety = (face.getStepY() * 0.05) > 0 ? (face.getStepY() * 0.05) : 0;
double offsetz = (face.getStepZ() * 0.05) > 0 ? (face.getStepZ() * 0.05) : 0;
double toffsetx = (face.getStepX() * 0.05) < 0 ? (face.getStepX() * 0.05) : 0;
double toffsety = (face.getStepY() * 0.05) < 0 ? (face.getStepY() * 0.05) : 0;
double toffsetz = (face.getStepZ() * 0.05) < 0 ? (face.getStepZ() * 0.05) : 0;
box = new AxisAlignedBB(box.minX + offsetx, box.minY + offsety, box.minZ + offsetz, box.maxX + toffsetx, box.maxY + toffsety, box.maxZ + toffsetz);
}
}
}
}
matrixStack.pushPose();
double powerDivision = power / 18D;
com.bluepowermod.client.render.RenderHelper.drawColoredCube(box, iRenderTypeBuffer.getBuffer(BPRenderTypes.LAMP_GLOW), matrixStack, r, g, b, (int) (powerDivision * 200), 200, renderFaces);
matrixStack.popPose();
}
use of net.minecraft.util.Direction in project BluePower by Qmunity.
the class Renderers method onModelBakeEvent.
@SubscribeEvent
public void onModelBakeEvent(ModelBakeEvent event) {
// Register Multipart Model
BPMultipartModel multipartModel = new BPMultipartModel();
event.getModelRegistry().put(new ModelResourceLocation("bluepower:multipart", "waterlogged=false"), multipartModel);
event.getModelRegistry().put(new ModelResourceLocation("bluepower:multipart", "waterlogged=true"), multipartModel);
BPMicroblockModel microblockModel = new BPMicroblockModel();
for (Direction dir : Direction.values()) {
// Register Microblock Models
event.getModelRegistry().put(new ModelResourceLocation("bluepower:half_block", "face=" + dir.getName()), event.getModelRegistry().get(new ModelResourceLocation("bluepower:half_block", "facing=" + dir.getName() + ",waterlogged=true")));
event.getModelRegistry().put(new ModelResourceLocation("bluepower:half_block", "facing=" + dir.getName() + ",waterlogged=true"), microblockModel);
event.getModelRegistry().put(new ModelResourceLocation("bluepower:half_block", "facing=" + dir.getName() + ",waterlogged=false"), microblockModel);
event.getModelRegistry().put(new ModelResourceLocation("bluepower:panel", "face=" + dir.getName()), event.getModelRegistry().get(new ModelResourceLocation("bluepower:panel", "facing=" + dir.getName() + ",waterlogged=true")));
event.getModelRegistry().put(new ModelResourceLocation("bluepower:panel", "facing=" + dir.getName() + ",waterlogged=true"), microblockModel);
event.getModelRegistry().put(new ModelResourceLocation("bluepower:panel", "facing=" + dir.getName() + ",waterlogged=false"), microblockModel);
event.getModelRegistry().put(new ModelResourceLocation("bluepower:cover", "face=" + dir.getName()), event.getModelRegistry().get(new ModelResourceLocation("bluepower:cover", "facing=" + dir.getName() + ",waterlogged=true")));
event.getModelRegistry().put(new ModelResourceLocation("bluepower:cover", "facing=" + dir.getName() + ",waterlogged=true"), microblockModel);
event.getModelRegistry().put(new ModelResourceLocation("bluepower:cover", "facing=" + dir.getName() + ",waterlogged=false"), microblockModel);
}
event.getModelRegistry().put(new ModelResourceLocation("bluepower:half_block", "inventory"), microblockModel);
event.getModelRegistry().put(new ModelResourceLocation("bluepower:panel", "inventory"), microblockModel);
event.getModelRegistry().put(new ModelResourceLocation("bluepower:cover", "inventory"), microblockModel);
}
use of net.minecraft.util.Direction in project BluePower by Qmunity.
the class TileSortingMachine method triggerSorting.
private void triggerSorting() {
Direction dir = getOutputDirection().getOpposite();
// might need opposite
TileEntity inputTE = getTileCache(dir);
if (inputTE instanceof IInventory) {
IInventory inputInv = (IInventory) inputTE;
int[] accessibleSlots;
if (inputInv instanceof ISidedInventory) {
accessibleSlots = ((ISidedInventory) inputInv).getSlotsForFace(dir.getOpposite());
} else {
accessibleSlots = new int[inputInv.getContainerSize()];
for (int i = 0; i < accessibleSlots.length; i++) accessibleSlots[i] = i;
}
for (int slot : accessibleSlots) {
ItemStack stack = inputInv.getItem(slot);
if (!stack.isEmpty() && IOHelper.canTakeItemThroughFaceFromInventory(inputInv, stack, slot, dir.getOpposite().ordinal())) {
if (tryProcessItem(stack, false)) {
if (stack.getCount() == 0)
inputInv.setItem(slot, ItemStack.EMPTY);
return;
}
}
}
if (sortMode == SortMode.ANYSTACK_SEQUENTIAL) {
for (int i = curColumn; i < inventory.size(); i += 8) {
ItemStack filterStack = inventory.get(i);
if (!filterStack.isEmpty()) {
ItemStack extractedStack = IOHelper.extract(inputTE, dir.getOpposite(), filterStack, true, false);
if (!extractedStack.isEmpty()) {
addItemToOutputBuffer(extractedStack.copy(), colors[curColumn]);
gotoNextNonEmptyColumn();
break;
}
}
}
} else if (sortMode == SortMode.ALLSTACK_SEQUENTIAL) {
if (matchAndProcessColumn(inputInv, accessibleSlots, curColumn)) {
gotoNextNonEmptyColumn();
}
} else if (sortMode == SortMode.RANDOM_ALLSTACKS) {
for (int i = 0; i < 8; i++) {
if (matchAndProcessColumn(inputInv, accessibleSlots, i)) {
break;
}
}
}
}
}
Aggregations