mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-12-22 19:39:24 +01:00
Render package ported
This commit is contained in:
parent
aa015521bc
commit
99b7e0bf43
14 changed files with 370 additions and 337 deletions
|
@ -2,6 +2,7 @@ package de.ellpeck.actuallyadditions.mod.blocks;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.state.IProperty;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.recipe.CompostRecipe;
|
||||
|
@ -187,7 +188,7 @@ public class BlockCompost extends BlockContainerBase implements IHudDisplay {
|
|||
public static CompostProperty COMPOST_PROP = new CompostProperty();
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
private static class CompostProperty implements IUnlistedProperty<Pair> {
|
||||
private static class CompostProperty implements IProperty<Pair> {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
|
|
|
@ -30,7 +30,7 @@ public enum TheColoredLampColors implements IStringSerializable {
|
|||
}
|
||||
|
||||
public static TheColoredLampColors getColorFromDyeName(String color) {
|
||||
if (color.substring(0, 3).equals("dye")) {
|
||||
if (color.startsWith("dye")) {
|
||||
String actualName = color.substring(3);
|
||||
for (int i = 0; i < values().length; i++) {
|
||||
String aName = values()[i].oreName;
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
package de.ellpeck.actuallyadditions.mod.blocks.metalists;
|
||||
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.Rarity;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
public enum TheMiscBlocks implements IStringSerializable {
|
||||
|
||||
QUARTZ_PILLAR("black_quartz_pillar", EnumRarity.RARE),
|
||||
QUARTZ_CHISELED("black_quartz_chiseled", EnumRarity.RARE),
|
||||
QUARTZ("black_quartz", EnumRarity.RARE),
|
||||
ORE_QUARTZ("ore_black_quartz", EnumRarity.EPIC),
|
||||
WOOD_CASING("wood_casing", EnumRarity.COMMON),
|
||||
CHARCOAL_BLOCK("charcoal", EnumRarity.COMMON),
|
||||
ENDERPEARL_BLOCK("enderpearl", EnumRarity.RARE),
|
||||
LAVA_FACTORY_CASE("lava_factory_case", EnumRarity.UNCOMMON),
|
||||
ENDER_CASING("ender_casing", EnumRarity.EPIC),
|
||||
IRON_CASING("iron_casing", EnumRarity.RARE);
|
||||
QUARTZ_PILLAR("black_quartz_pillar", Rarity.RARE),
|
||||
QUARTZ_CHISELED("black_quartz_chiseled", Rarity.RARE),
|
||||
QUARTZ("black_quartz", Rarity.RARE),
|
||||
ORE_QUARTZ("ore_black_quartz", Rarity.EPIC),
|
||||
WOOD_CASING("wood_casing", Rarity.COMMON),
|
||||
CHARCOAL_BLOCK("charcoal", Rarity.COMMON),
|
||||
ENDERPEARL_BLOCK("enderpearl", Rarity.RARE),
|
||||
LAVA_FACTORY_CASE("lava_factory_case", Rarity.UNCOMMON),
|
||||
ENDER_CASING("ender_casing", Rarity.EPIC),
|
||||
IRON_CASING("iron_casing", Rarity.RARE);
|
||||
|
||||
public final String name;
|
||||
public final EnumRarity rarity;
|
||||
public final Rarity rarity;
|
||||
|
||||
TheMiscBlocks(String name, EnumRarity rarity) {
|
||||
TheMiscBlocks(String name, Rarity rarity) {
|
||||
this.name = name;
|
||||
this.rarity = rarity;
|
||||
}
|
||||
|
|
|
@ -1,24 +1,23 @@
|
|||
package de.ellpeck.actuallyadditions.mod.blocks.metalists;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.Rarity;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
public enum TheWildPlants implements IStringSerializable {
|
||||
|
||||
CANOLA("canola", EnumRarity.RARE, InitBlocks.blockCanola),
|
||||
FLAX("flax", EnumRarity.RARE, InitBlocks.blockFlax),
|
||||
RICE("rice", EnumRarity.RARE, InitBlocks.blockRice),
|
||||
COFFEE("coffee", EnumRarity.RARE, InitBlocks.blockCoffee);
|
||||
CANOLA("canola", Rarity.RARE, InitBlocks.blockCanola),
|
||||
FLAX("flax", Rarity.RARE, InitBlocks.blockFlax),
|
||||
RICE("rice", Rarity.RARE, InitBlocks.blockRice),
|
||||
COFFEE("coffee", Rarity.RARE, InitBlocks.blockCoffee);
|
||||
|
||||
final String name;
|
||||
final EnumRarity rarity;
|
||||
final Rarity rarity;
|
||||
final Block normal;
|
||||
|
||||
TheWildPlants(String name, EnumRarity rarity, Block normal) {
|
||||
TheWildPlants(String name, Rarity rarity, Block normal) {
|
||||
this.name = name;
|
||||
this.rarity = rarity;
|
||||
this.normal = Preconditions.checkNotNull(normal, "TheWildPlants was loaded before block init!");
|
||||
|
@ -29,7 +28,7 @@ public enum TheWildPlants implements IStringSerializable {
|
|||
return this.name;
|
||||
}
|
||||
|
||||
public EnumRarity getRarity() {
|
||||
public Rarity getRarity() {
|
||||
return this.rarity;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,29 +1,29 @@
|
|||
package de.ellpeck.actuallyadditions.mod.blocks.render;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.BlockCompost;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.Direction;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.BlockCompost;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
import java.util.Random;
|
||||
|
||||
public class ActualCompostModel implements IBakedModel {
|
||||
|
||||
public static final Map<Pair<IBlockState, Float>, IBakedModel> MODELS = new HashMap<>();
|
||||
public static final Map<Pair<BlockState, Float>, IBakedModel> MODELS = new HashMap<>();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(IBlockState state, EnumFacing side, long rand) {
|
||||
if (state instanceof IExtendedBlockState) {
|
||||
Pair<IBlockState, Float> data = ((IExtendedBlockState) state).getValue(BlockCompost.COMPOST_PROP);
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand) {
|
||||
// if (state instanceof BlockState) {
|
||||
if (state != null) {
|
||||
Pair<BlockState, Float> data = state.get(BlockCompost.COMPOST_PROP);
|
||||
if (data == null || data.getRight() <= 0) return CompostModel.compostBase.getQuads(state, side, rand);
|
||||
IBakedModel model = MODELS.get(data);
|
||||
if (model == null) {
|
||||
|
@ -32,6 +32,7 @@ public class ActualCompostModel implements IBakedModel {
|
|||
}
|
||||
return model.getQuads(state, side, rand);
|
||||
}
|
||||
|
||||
return CompostModel.compostBase.getQuads(state, side, rand);
|
||||
}
|
||||
|
||||
|
@ -45,6 +46,12 @@ public class ActualCompostModel implements IBakedModel {
|
|||
return false;
|
||||
}
|
||||
|
||||
// No clue what this one is.
|
||||
@Override
|
||||
public boolean func_230044_c_() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuiltInRenderer() {
|
||||
return false;
|
||||
|
@ -57,7 +64,6 @@ public class ActualCompostModel implements IBakedModel {
|
|||
|
||||
@Override
|
||||
public ItemOverrideList getOverrides() {
|
||||
return ItemOverrideList.NONE;
|
||||
return ItemOverrideList.EMPTY;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,59 +1,57 @@
|
|||
package de.ellpeck.actuallyadditions.mod.blocks.render;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.vecmath.Vector3f;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
import net.minecraft.util.Direction;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
// todo: come back and fix this render as It's broken atm :cry:
|
||||
public class CompostModel implements IBakedModel {
|
||||
public static IBakedModel compostBase;
|
||||
private final IBakedModel display;
|
||||
private final ImmutableList<BakedQuad> general;
|
||||
private final ImmutableMap<EnumFacing, ImmutableList<BakedQuad>> faces;
|
||||
private final ImmutableMap<Direction, ImmutableList<BakedQuad>> faces;
|
||||
|
||||
public CompostModel(IBlockState flowerState, float height) {
|
||||
this.display = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState(flowerState);
|
||||
public CompostModel(BlockState flowerState, float height) {
|
||||
this.display = Minecraft.getInstance().getBlockRendererDispatcher().getModelForState(flowerState);
|
||||
|
||||
TRSRTransformation transform = TRSRTransformation.blockCenterToCorner(new TRSRTransformation(new Vector3f(0, -.218F, 0), null, new Vector3f(0.75F, height / 1.81F, 0.75F), null));
|
||||
// TRSRTransformation transform = TRSRTransformation.blockCenterToCorner(new TRSRTransformation(new Vector3f(0, -.218F, 0), null, new Vector3f(0.75F, height / 1.81F, 0.75F), null));
|
||||
|
||||
ImmutableList.Builder<BakedQuad> builder;
|
||||
EnumMap<EnumFacing, ImmutableList<BakedQuad>> faces = new EnumMap<>(EnumFacing.class);
|
||||
EnumMap<Direction, ImmutableList<BakedQuad>> faces = new EnumMap<>(Direction.class);
|
||||
|
||||
for (EnumFacing face : EnumFacing.values()) {
|
||||
for (Direction face : Direction.values()) {
|
||||
builder = ImmutableList.builder();
|
||||
if (!this.display.isBuiltInRenderer()) {
|
||||
for (BakedQuad quad : this.display.getQuads(flowerState, face, 0)) {
|
||||
Transformer transformer = new Transformer(transform, quad.getFormat());
|
||||
quad.pipe(transformer);
|
||||
builder.add(transformer.build());
|
||||
}
|
||||
builder.addAll(compostBase.getQuads(null, face, 0));
|
||||
// for (BakedQuad quad : this.display.getQuads(flowerState, face, 0)) {
|
||||
// Transformer transformer = new Transformer(transform, quad.getFormat());
|
||||
// quad.pipe(transformer);
|
||||
// builder.add(transformer.build());
|
||||
// }
|
||||
builder.addAll(compostBase.getQuads(null, face, new Random()));
|
||||
}
|
||||
faces.put(face, builder.build());
|
||||
}
|
||||
|
||||
if (!this.display.isBuiltInRenderer()) {
|
||||
builder = ImmutableList.builder();
|
||||
for (BakedQuad quad : this.display.getQuads(flowerState, null, 0)) {
|
||||
Transformer transformer = new Transformer(transform, quad.getFormat());
|
||||
quad.pipe(transformer);
|
||||
builder.add(transformer.build());
|
||||
}
|
||||
builder.addAll(compostBase.getQuads(null, null, 0));
|
||||
// for (BakedQuad quad : this.display.getQuads(flowerState, null, 0)) {
|
||||
// Transformer transformer = new Matrix4f(transform, quad.getFormat());
|
||||
// quad.pipe(transformer);
|
||||
// builder.add(transformer.build());
|
||||
// }
|
||||
builder.addAll(compostBase.getQuads(null, null, new Random()));
|
||||
this.general = builder.build();
|
||||
} else this.general = ImmutableList.of();
|
||||
|
||||
|
@ -61,7 +59,7 @@ public class CompostModel implements IBakedModel {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) {
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand) {
|
||||
if (side == null) return this.general;
|
||||
return this.faces.get(side);
|
||||
}
|
||||
|
@ -76,6 +74,12 @@ public class CompostModel implements IBakedModel {
|
|||
return false;
|
||||
}
|
||||
|
||||
// No idea what this does.. Something? I'm sure
|
||||
@Override
|
||||
public boolean func_230044_c_() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuiltInRenderer() {
|
||||
return false;
|
||||
|
@ -88,7 +92,7 @@ public class CompostModel implements IBakedModel {
|
|||
|
||||
@Override
|
||||
public ItemOverrideList getOverrides() {
|
||||
return ItemOverrideList.NONE;
|
||||
return ItemOverrideList.EMPTY;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package de.ellpeck.actuallyadditions.mod.blocks.render;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.items.ItemBattery;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBatteryBox;
|
||||
|
@ -9,37 +8,41 @@ import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
|||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.Quaternion;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderBatteryBox extends TileEntitySpecialRenderer<TileEntityBatteryBox> {
|
||||
import java.text.NumberFormat;
|
||||
|
||||
// todo: migrate to client package
|
||||
public class RenderBatteryBox extends TileEntityRenderer<TileEntityBatteryBox> {
|
||||
|
||||
public RenderBatteryBox(TileEntityRendererDispatcher rendererDispatcherIn) {
|
||||
super(rendererDispatcherIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(TileEntityBatteryBox tile, double x, double y, double z, float par5, int par6, float f) {
|
||||
if (!(tile instanceof TileEntityBatteryBox)) { return; }
|
||||
|
||||
public void render(TileEntityBatteryBox tile, float partialTicks, MatrixStack matrices, IRenderTypeBuffer bufferIn, int combinedLightIn, int combinedOverlayIn) {
|
||||
// BlockPos pos = tile.getPos();
|
||||
ItemStack stack = tile.inv.getStackInSlot(0);
|
||||
if (StackUtil.isValid(stack) && stack.getItem() instanceof ItemBattery) {
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate((float) x + 0.5F, (float) y + 1F, (float) z + 0.5F);
|
||||
matrices.push();
|
||||
// matrices.translate((float) pos.getX() + 0.5F, (float) pos.getY() + 1F, (float) pos.getZ() + 0.5F);
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
matrices.push();
|
||||
|
||||
GlStateManager.scale(0.0075F, 0.0075F, 0.0075F);
|
||||
GlStateManager.rotate(180F, 1F, 0F, 0F);
|
||||
GlStateManager.translate(0F, 0F, -50F);
|
||||
matrices.scale(0.0075F, 0.0075F, 0.0075F);
|
||||
matrices.rotate(new Quaternion(180F, 1F, 0F, 0F));
|
||||
matrices.translate(0F, 0F, -50F);
|
||||
|
||||
if (stack.hasCapability(CapabilityEnergy.ENERGY, null)) {
|
||||
IEnergyStorage cap = stack.getCapability(CapabilityEnergy.ENERGY, null);
|
||||
stack.getCapability(CapabilityEnergy.ENERGY).ifPresent(cap -> {
|
||||
NumberFormat format = NumberFormat.getInstance();
|
||||
FontRenderer font = Minecraft.getMinecraft().fontRenderer;
|
||||
FontRenderer font = Minecraft.getInstance().fontRenderer;
|
||||
|
||||
String s = format.format(cap.getEnergyStored()) + "/" + format.format(cap.getMaxEnergyStored());
|
||||
float lengthS = -font.getStringWidth(s) / 2F;
|
||||
|
@ -47,29 +50,29 @@ public class RenderBatteryBox extends TileEntitySpecialRenderer<TileEntityBatter
|
|||
float lengthS2 = -font.getStringWidth(s2) / 2F;
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
font.drawString(s, lengthS, 10F, 0xFFFFFF, false);
|
||||
font.drawString(s2, lengthS2, 20F, 0xFFFFFF, false);
|
||||
font.drawString(s, lengthS, 10F, 0xFFFFFF);
|
||||
font.drawString(s2, lengthS2, 20F, 0xFFFFFF);
|
||||
|
||||
GlStateManager.translate(-50F, 0F, 50F);
|
||||
GlStateManager.rotate(90F, 0F, 1F, 0F);
|
||||
matrices.translate(-50F, 0F, 50F);
|
||||
matrices.rotate(new Quaternion(90F, 0F, 1F, 0F));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
matrices.pop();
|
||||
|
||||
double boop = Minecraft.getSystemTime() / 800D;
|
||||
GlStateManager.translate(0D, Math.sin(boop % (2 * Math.PI)) * 0.065, 0D);
|
||||
GlStateManager.rotate((float) (boop * 40D % 360), 0, 1, 0);
|
||||
double boop = Util.milliTime() / 800D;
|
||||
matrices.translate(0D, Math.sin(boop % (2 * Math.PI)) * 0.065, 0D);
|
||||
matrices.rotate(new Quaternion((float) (boop * 40D % 360), 0, 1, 0));
|
||||
|
||||
float scale = stack.getItem() instanceof ItemBlock ? 0.85F : 0.65F;
|
||||
GlStateManager.scale(scale, scale, scale);
|
||||
float scale = stack.getItem() instanceof BlockItem ? 0.85F : 0.65F;
|
||||
matrices.scale(scale, scale, scale);
|
||||
try {
|
||||
AssetUtil.renderItemInWorld(stack);
|
||||
} catch (Exception e) {
|
||||
ActuallyAdditions.LOGGER.error("Something went wrong trying to render an item in a battery box! The item is " + stack.getItem().getRegistryName() + "!", e);
|
||||
}
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
matrices.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,42 +1,47 @@
|
|||
package de.ellpeck.actuallyadditions.mod.blocks.render;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityDisplayStand;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.Quaternion;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraft.util.Util;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderDisplayStand extends TileEntitySpecialRenderer<TileEntityDisplayStand> {
|
||||
// todo: migrate to client package
|
||||
public class RenderDisplayStand extends TileEntityRenderer<TileEntityDisplayStand> {
|
||||
|
||||
public RenderDisplayStand(TileEntityRendererDispatcher rendererDispatcherIn) {
|
||||
super(rendererDispatcherIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(TileEntityDisplayStand tile, double x, double y, double z, float par5, int par6, float f) {
|
||||
if (!(tile instanceof TileEntityDisplayStand)) { return; }
|
||||
public void render(TileEntityDisplayStand tile, float partialTicks, MatrixStack matrices, IRenderTypeBuffer bufferIn, int combinedLightIn, int combinedOverlayIn) {
|
||||
// BlockPos pos = tile.getPos();
|
||||
|
||||
ItemStack stack = tile.inv.getStackInSlot(0);
|
||||
if (StackUtil.isValid(stack)) {
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate((float) x + 0.5F, (float) y + 1F, (float) z + 0.5F);
|
||||
matrices.push();
|
||||
// matrices.translate((float) pos.getX() + 0.5F, (float) pos.getY() + 1F, (float) pos.getZ() + 0.5F);
|
||||
|
||||
double boop = Minecraft.getSystemTime() / 800D;
|
||||
GlStateManager.translate(0D, Math.sin(boop % (2 * Math.PI)) * 0.065, 0D);
|
||||
GlStateManager.rotate((float) (boop * 40D % 360), 0, 1, 0);
|
||||
double boop = Util.nanoTime() / 800D;
|
||||
matrices.translate(0D, Math.sin(boop % (2 * Math.PI)) * 0.065, 0D);
|
||||
matrices.rotate(new Quaternion((float) (boop * 40D % 360), 0, 1, 0));
|
||||
|
||||
float scale = stack.getItem() instanceof ItemBlock ? 0.85F : 0.65F;
|
||||
GlStateManager.scale(scale, scale, scale);
|
||||
float scale = stack.getItem() instanceof BlockItem ? 0.85F : 0.65F;
|
||||
matrices.scale(scale, scale, scale);
|
||||
try {
|
||||
AssetUtil.renderItemInWorld(stack);
|
||||
} catch (Exception e) {
|
||||
ActuallyAdditions.LOGGER.error("Something went wrong trying to render an item in a display stand! The item is " + stack.getItem().getRegistryName() + "!", e);
|
||||
}
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
matrices.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,58 +1,69 @@
|
|||
package de.ellpeck.actuallyadditions.mod.blocks.render;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||
import de.ellpeck.actuallyadditions.api.recipe.EmpowererRecipe;
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityEmpowerer;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.Quaternion;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderEmpowerer extends TileEntitySpecialRenderer<TileEntityEmpowerer> {
|
||||
// todo: migrate to client package
|
||||
public class RenderEmpowerer extends TileEntityRenderer<TileEntityEmpowerer> {
|
||||
public RenderEmpowerer(TileEntityRendererDispatcher rendererDispatcherIn) {
|
||||
super(rendererDispatcherIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(TileEntityEmpowerer tile, double x, double y, double z, float par5, int par6, float f) {
|
||||
if (!(tile instanceof TileEntityEmpowerer)) { return; }
|
||||
|
||||
public void render(TileEntityEmpowerer tile, float partialTicks, MatrixStack matrices, IRenderTypeBuffer bufferIn, int combinedLightIn, int combinedOverlayIn) {
|
||||
// BlockPos pos = tile.getPos();
|
||||
ItemStack stack = tile.inv.getStackInSlot(0);
|
||||
if (StackUtil.isValid(stack)) {
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate((float) x + 0.5F, (float) y + 1F, (float) z + 0.5F);
|
||||
matrices.push();
|
||||
// matrices.translate((float) pos.getX() + 0.5F, (float) pos.getY() + 1F, (float) pos.getZ() + 0.5F);
|
||||
|
||||
double boop = Minecraft.getSystemTime() / 800D;
|
||||
GlStateManager.translate(0D, Math.sin(boop % (2 * Math.PI)) * 0.065, 0D);
|
||||
GlStateManager.rotate((float) (boop * 40D % 360), 0, 1, 0);
|
||||
double boop = Util.nanoTime() / 800D;
|
||||
matrices.translate(0D, Math.sin(boop % (2 * Math.PI)) * 0.065, 0D);
|
||||
matrices.rotate(new Quaternion((float) (boop * 40D % 360), 0, 1, 0));
|
||||
|
||||
float scale = stack.getItem() instanceof ItemBlock ? 0.85F : 0.65F;
|
||||
GlStateManager.scale(scale, scale, scale);
|
||||
float scale = stack.getItem() instanceof BlockItem ? 0.85F : 0.65F;
|
||||
matrices.scale(scale, scale, scale);
|
||||
try {
|
||||
AssetUtil.renderItemInWorld(stack);
|
||||
} catch (Exception e) {
|
||||
ActuallyAdditions.LOGGER.error("Something went wrong trying to render an item in an empowerer! The item is " + stack.getItem().getRegistryName() + ":" + stack.getMetadata() + "!", e);
|
||||
ActuallyAdditions.LOGGER.error("Something went wrong trying to render an item in an empowerer! The item is {}!", stack.getItem().getRegistryName(), e);
|
||||
}
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
matrices.pop();
|
||||
}
|
||||
|
||||
int index = tile.recipeForRenderIndex;
|
||||
if (index >= 0 && ActuallyAdditionsAPI.EMPOWERER_RECIPES.size() > index) {
|
||||
EmpowererRecipe recipe = ActuallyAdditionsAPI.EMPOWERER_RECIPES.get(index);
|
||||
if (recipe != null) {
|
||||
for (int i = 0; i < EnumFacing.HORIZONTALS.length; i++) {
|
||||
EnumFacing facing = EnumFacing.HORIZONTALS[i];
|
||||
BlockPos offset = tile.getPos().offset(facing, 3);
|
||||
Direction.Plane.HORIZONTAL.iterator().forEachRemaining(e -> {
|
||||
BlockPos offset = tile.getPos().offset(e, 3);
|
||||
|
||||
AssetUtil.renderLaser(tile.getPos().getX() + 0.5, tile.getPos().getY() + 0.5, tile.getPos().getZ() + 0.5, offset.getX() + 0.5, offset.getY() + 0.95, offset.getZ() + 0.5, 80, 1F, 0.1F, recipe.getParticleColors());
|
||||
}
|
||||
});
|
||||
|
||||
// original code of the above if it doesn't work
|
||||
// @since 1.15-port
|
||||
// for (int i = 0; i < Direction.Plane.HORIZONTAL; i++) {
|
||||
// EnumFacing facing = EnumFacing.HORIZONTALS[i];
|
||||
// BlockPos offset = tile.getPos().offset(facing, 3);
|
||||
//
|
||||
// AssetUtil.renderLaser(tile.getPos().getX() + 0.5, tile.getPos().getY() + 0.5, tile.getPos().getZ() + 0.5, offset.getX() + 0.5, offset.getY() + 0.95, offset.getZ() + 0.5, 80, 1F, 0.1F, recipe.getParticleColors());
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package de.ellpeck.actuallyadditions.mod.blocks.render;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||
import de.ellpeck.actuallyadditions.api.laser.IConnectionPair;
|
||||
import de.ellpeck.actuallyadditions.api.laser.LaserType;
|
||||
|
@ -12,72 +13,76 @@ import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
|||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import io.netty.util.internal.ConcurrentSet;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.Quaternion;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderLaserRelay extends TileEntitySpecialRenderer<TileEntityLaserRelay> {
|
||||
// todo: migrate to client package
|
||||
public class RenderLaserRelay extends TileEntityRenderer<TileEntityLaserRelay> {
|
||||
|
||||
private static final float[] COLOR = new float[] { 1F, 0F, 0F };
|
||||
private static final float[] COLOR_ITEM = new float[] { 0F, 124F / 255F, 16F / 255F };
|
||||
private static final float[] COLOR_FLUIDS = new float[] { 0F, 97F / 255F, 198F / 255F };
|
||||
private static final float[] COLOR_INFRARED = new float[] { 209F / 255F, 179F / 255F, 239F / 255F };
|
||||
|
||||
public RenderLaserRelay(TileEntityRendererDispatcher rendererDispatcherIn) {
|
||||
super(rendererDispatcherIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(TileEntityLaserRelay tile, double x, double y, double z, float par5, int par6, float f) {
|
||||
if (tile instanceof TileEntityLaserRelay) {
|
||||
TileEntityLaserRelay relay = tile;
|
||||
boolean hasInvis = false;
|
||||
public void render(TileEntityLaserRelay tile, float partialTicks, MatrixStack matrices, IRenderTypeBuffer bufferIn, int combinedLightIn, int combinedOverlayIn) {
|
||||
TileEntityLaserRelay relay = tile;
|
||||
boolean hasInvis = false;
|
||||
|
||||
EntityPlayer player = Minecraft.getMinecraft().player;
|
||||
boolean hasGoggles = ItemEngineerGoggles.isWearing(player);
|
||||
// BlockPos pos = tile.getPos();
|
||||
PlayerEntity player = Minecraft.getInstance().player;
|
||||
boolean hasGoggles = ItemEngineerGoggles.isWearing(player);
|
||||
|
||||
ItemStack upgrade = relay.inv.getStackInSlot(0);
|
||||
if (StackUtil.isValid(upgrade)) {
|
||||
if (upgrade.getItem() == InitItems.itemLaserUpgradeInvisibility) {
|
||||
hasInvis = true;
|
||||
}
|
||||
|
||||
ItemStack hand = player.getHeldItemMainhand();
|
||||
if (hasGoggles || StackUtil.isValid(hand) && (hand.getItem() == ConfigValues.itemCompassConfigurator || hand.getItem() instanceof ItemLaserWrench) || "themattabase".equals(player.getName())) {
|
||||
GlStateManager.pushMatrix();
|
||||
|
||||
float yTrans = tile.getBlockMetadata() == 0 ? 0.2F : 0.8F;
|
||||
GlStateManager.translate((float) x + 0.5F, (float) y + yTrans, (float) z + 0.5F);
|
||||
GlStateManager.scale(0.2F, 0.2F, 0.2F);
|
||||
|
||||
double boop = Minecraft.getSystemTime() / 800D;
|
||||
GlStateManager.rotate((float) (boop * 40D % 360), 0, 1, 0);
|
||||
|
||||
AssetUtil.renderItemInWorld(upgrade);
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
ItemStack upgrade = relay.inv.getStackInSlot(0);
|
||||
if (StackUtil.isValid(upgrade)) {
|
||||
if (upgrade.getItem() == InitItems.itemLaserUpgradeInvisibility) {
|
||||
hasInvis = true;
|
||||
}
|
||||
|
||||
ConcurrentSet<IConnectionPair> connections = ActuallyAdditionsAPI.connectionHandler.getConnectionsFor(tile.getPos(), tile.getWorld());
|
||||
if (connections != null && !connections.isEmpty()) {
|
||||
for (IConnectionPair pair : connections) {
|
||||
if (!pair.doesSuppressRender() && tile.getPos().equals(pair.getPositions()[0])) {
|
||||
BlockPos first = tile.getPos();
|
||||
BlockPos second = pair.getPositions()[1];
|
||||
ItemStack hand = player.getHeldItemMainhand();
|
||||
if (hasGoggles || StackUtil.isValid(hand) && (hand.getItem() == ConfigValues.itemCompassConfigurator || hand.getItem() instanceof ItemLaserWrench) || "themattabase".equals(player.getName())) {
|
||||
matrices.push();
|
||||
|
||||
TileEntity secondTile = tile.getWorld().getTileEntity(second);
|
||||
if (secondTile instanceof TileEntityLaserRelay) {
|
||||
ItemStack secondUpgrade = ((TileEntityLaserRelay) secondTile).inv.getStackInSlot(0);
|
||||
boolean otherInvis = StackUtil.isValid(secondUpgrade) && secondUpgrade.getItem() == InitItems.itemLaserUpgradeInvisibility;
|
||||
float yTrans = .2f; // tile.getBlockMetadata() == 0 ? 0.2F : 0.8F; old logic for meta data
|
||||
// matrices.translate((float) pos.getX() + 0.5F, (float) pos.getY() + yTrans, (float) pos.getZ() + 0.5F);
|
||||
matrices.scale(0.2F, 0.2F, 0.2F);
|
||||
|
||||
if (hasGoggles || !hasInvis || !otherInvis) {
|
||||
float[] color = hasInvis && otherInvis ? COLOR_INFRARED : relay.type == LaserType.ITEM ? COLOR_ITEM : relay.type == LaserType.FLUID ? COLOR_FLUIDS : COLOR;
|
||||
double boop = Util.nanoTime() / 800D;
|
||||
matrices.rotate(new Quaternion((float) (boop * 40D % 360), 0, 1, 0));
|
||||
|
||||
AssetUtil.renderLaser(first.getX() + 0.5, first.getY() + 0.5, first.getZ() + 0.5, second.getX() + 0.5, second.getY() + 0.5, second.getZ() + 0.5, 120, hasInvis && otherInvis ? 0.1F : 0.35F, 0.05, color);
|
||||
}
|
||||
AssetUtil.renderItemInWorld(upgrade);
|
||||
|
||||
matrices.pop();
|
||||
}
|
||||
}
|
||||
|
||||
ConcurrentSet<IConnectionPair> connections = ActuallyAdditionsAPI.connectionHandler.getConnectionsFor(tile.getPos(), tile.getWorld());
|
||||
if (connections != null && !connections.isEmpty()) {
|
||||
for (IConnectionPair pair : connections) {
|
||||
if (!pair.doesSuppressRender() && tile.getPos().equals(pair.getPositions()[0])) {
|
||||
BlockPos first = tile.getPos();
|
||||
BlockPos second = pair.getPositions()[1];
|
||||
|
||||
TileEntity secondTile = tile.getWorld().getTileEntity(second);
|
||||
if (secondTile instanceof TileEntityLaserRelay) {
|
||||
ItemStack secondUpgrade = ((TileEntityLaserRelay) secondTile).inv.getStackInSlot(0);
|
||||
boolean otherInvis = StackUtil.isValid(secondUpgrade) && secondUpgrade.getItem() == InitItems.itemLaserUpgradeInvisibility;
|
||||
|
||||
if (hasGoggles || !hasInvis || !otherInvis) {
|
||||
float[] color = hasInvis && otherInvis ? COLOR_INFRARED : relay.type == LaserType.ITEM ? COLOR_ITEM : relay.type == LaserType.FLUID ? COLOR_FLUIDS : COLOR;
|
||||
|
||||
AssetUtil.renderLaser(first.getX() + 0.5, first.getY() + 0.5, first.getZ() + 0.5, second.getX() + 0.5, second.getY() + 0.5, second.getZ() + 0.5, 120, hasInvis && otherInvis ? 0.1F : 0.35F, 0.05, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,63 +1,67 @@
|
|||
package de.ellpeck.actuallyadditions.mod.blocks.render;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import de.ellpeck.actuallyadditions.api.lens.ILensItem;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.Quaternion;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderReconstructorLens extends TileEntitySpecialRenderer<TileEntityAtomicReconstructor> {
|
||||
// todo: migrate to client package
|
||||
public class RenderReconstructorLens extends TileEntityRenderer<TileEntityAtomicReconstructor> {
|
||||
|
||||
public RenderReconstructorLens(TileEntityRendererDispatcher rendererDispatcherIn) {
|
||||
super(rendererDispatcherIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(TileEntityAtomicReconstructor tile, double x, double y, double z, float par5, int par6, float f) {
|
||||
if (tile == null) return;
|
||||
|
||||
public void render(TileEntityAtomicReconstructor tile, float partialTicks, MatrixStack matrices, IRenderTypeBuffer bufferIn, int combinedLightIn, int combinedOverlayIn) {
|
||||
ItemStack stack = tile.inv.getStackInSlot(0);
|
||||
|
||||
if (StackUtil.isValid(stack) && stack.getItem() instanceof ILensItem) {
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate((float) x + 0.5F, (float) y - 0.5F, (float) z + 0.5F);
|
||||
GlStateManager.rotate(180F, 0.0F, 0.0F, 1.0F);
|
||||
matrices.push();
|
||||
// matrices.translate((float) pos.getX() + 0.5F, (float) pos.getY() - 0.5F, (float) pos.getZ() + 0.5F);
|
||||
matrices.rotate(new Quaternion(180F, 0.0F, 0.0F, 1.0F));
|
||||
|
||||
IBlockState state = tile.getWorld().getBlockState(tile.getPos());
|
||||
int meta = state.getBlock().getMetaFromState(state);
|
||||
BlockState state = tile.getWorld().getBlockState(tile.getPos());
|
||||
// int meta = state.getBlock().getMetaFromState(state);
|
||||
int meta = 0; // todo: fix this logic, I'm assuming it's facing meta but I don't know
|
||||
if (meta == 0) {
|
||||
GlStateManager.translate(0F, -0.5F, 0F);
|
||||
GlStateManager.rotate(90F, 1F, 0F, 0F);
|
||||
matrices.translate(0F, -0.5F, 0F);
|
||||
matrices.rotate(new Quaternion(90F, 1F, 0F, 0F));
|
||||
}
|
||||
if (meta == 1) {
|
||||
GlStateManager.translate(0F, -1.5F - 0.5F / 16F, 0F);
|
||||
GlStateManager.rotate(90F, 1F, 0F, 0F);
|
||||
matrices.translate(0F, -1.5F - 0.5F / 16F, 0F);
|
||||
matrices.rotate(new Quaternion(90F, 1F, 0F, 0F));
|
||||
}
|
||||
if (meta == 2) {
|
||||
GlStateManager.translate(0F, -1F, 0F);
|
||||
GlStateManager.translate(0F, 0F, -0.5F);
|
||||
matrices.translate(0F, -1F, 0F);
|
||||
matrices.translate(0F, 0F, -0.5F);
|
||||
}
|
||||
if (meta == 3) {
|
||||
GlStateManager.translate(0F, -1F, 0F);
|
||||
GlStateManager.translate(0F, 0F, 0.5F + 0.5F / 16F);
|
||||
matrices.translate(0F, -1F, 0F);
|
||||
matrices.translate(0F, 0F, 0.5F + 0.5F / 16F);
|
||||
}
|
||||
if (meta == 4) {
|
||||
GlStateManager.translate(0F, -1F, 0F);
|
||||
GlStateManager.translate(0.5F + 0.5F / 16F, 0F, 0F);
|
||||
GlStateManager.rotate(90F, 0F, 1F, 0F);
|
||||
matrices.translate(0F, -1F, 0F);
|
||||
matrices.translate(0.5F + 0.5F / 16F, 0F, 0F);
|
||||
matrices.rotate(new Quaternion(90F, 0F, 1F, 0F));
|
||||
}
|
||||
if (meta == 5) {
|
||||
GlStateManager.translate(0F, -1F, 0F);
|
||||
GlStateManager.translate(-0.5F, 0F, 0F);
|
||||
GlStateManager.rotate(90F, 0F, 1F, 0F);
|
||||
matrices.translate(0F, -1F, 0F);
|
||||
matrices.translate(-0.5F, 0F, 0F);
|
||||
matrices.rotate(new Quaternion(90F, 0F, 1F, 0F));
|
||||
}
|
||||
|
||||
GlStateManager.scale(0.5F, 0.5F, 0.5F);
|
||||
matrices.scale(0.5F, 0.5F, 0.5F);
|
||||
AssetUtil.renderItemInWorld(stack);
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
matrices.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package de.ellpeck.actuallyadditions.mod.blocks.render;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
||||
import de.ellpeck.actuallyadditions.mod.misc.cloud.ISmileyCloudEasterEgg;
|
||||
import de.ellpeck.actuallyadditions.mod.misc.cloud.SmileyCloudEasterEggs;
|
||||
|
@ -9,82 +8,87 @@ import de.ellpeck.actuallyadditions.mod.misc.special.RenderSpecial;
|
|||
import de.ellpeck.actuallyadditions.mod.misc.special.SpecialRenderInit;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntitySmileyCloud;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import net.minecraft.block.BlockHorizontal;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.HorizontalBlock;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.Quaternion;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderSmileyCloud extends TileEntitySpecialRenderer<TileEntitySmileyCloud> {
|
||||
import java.util.Locale;
|
||||
|
||||
// todo: migrate to client package
|
||||
public class RenderSmileyCloud extends TileEntityRenderer<TileEntitySmileyCloud> {
|
||||
|
||||
public RenderSmileyCloud(TileEntityRendererDispatcher rendererDispatcherIn) {
|
||||
super(rendererDispatcherIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(TileEntitySmileyCloud theCloud, double x, double y, double z, float par5, int partial, float f) {
|
||||
if (theCloud instanceof TileEntitySmileyCloud) {
|
||||
public void render(TileEntitySmileyCloud theCloud, float partialTicks, MatrixStack matrices, IRenderTypeBuffer bufferIn, int combinedLightIn, int combinedOverlayIn) {
|
||||
matrices.push();
|
||||
// matrices.translate((float) x + 0.5F, (float) y - 0.5F, (float) z + 0.5F);
|
||||
matrices.rotate(new Quaternion(180F, 0.0F, 0.0F, 1.0F));
|
||||
matrices.translate(0.0F, -2F, 0.0F);
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate((float) x + 0.5F, (float) y - 0.5F, (float) z + 0.5F);
|
||||
GlStateManager.rotate(180F, 0.0F, 0.0F, 1.0F);
|
||||
GlStateManager.translate(0.0F, -2F, 0.0F);
|
||||
if (theCloud.name != null && !theCloud.name.isEmpty()) {
|
||||
boolean renderedEaster = false;
|
||||
|
||||
if (theCloud.name != null && !theCloud.name.isEmpty()) {
|
||||
boolean renderedEaster = false;
|
||||
easterEggs: for (ISmileyCloudEasterEgg cloud : SmileyCloudEasterEggs.CLOUD_STUFF) {
|
||||
for (String triggerName : cloud.getTriggerNames()) {
|
||||
if (triggerName != null && theCloud.name != null) {
|
||||
if (triggerName.equalsIgnoreCase(theCloud.name)) {
|
||||
matrices.push();
|
||||
|
||||
easterEggs: for (ISmileyCloudEasterEgg cloud : SmileyCloudEasterEggs.CLOUD_STUFF) {
|
||||
for (String triggerName : cloud.getTriggerNames()) {
|
||||
if (triggerName != null && theCloud.name != null) {
|
||||
if (triggerName.equalsIgnoreCase(theCloud.name)) {
|
||||
GlStateManager.pushMatrix();
|
||||
|
||||
IBlockState state = theCloud.getWorld().getBlockState(theCloud.getPos());
|
||||
if (state.getBlock() == InitBlocks.blockSmileyCloud) {
|
||||
switch (state.getValue(BlockHorizontal.FACING)) {
|
||||
BlockState state = theCloud.getWorld().getBlockState(theCloud.getPos());
|
||||
if (state.getBlock() == InitBlocks.blockSmileyCloud) {
|
||||
switch (state.get(HorizontalBlock.HORIZONTAL_FACING)) {
|
||||
case NORTH:
|
||||
GlStateManager.rotate(180, 0, 1, 0);
|
||||
matrices.rotate(new Quaternion(180, 0, 1, 0));
|
||||
break;
|
||||
case EAST:
|
||||
GlStateManager.rotate(270, 0, 1, 0);
|
||||
matrices.rotate(new Quaternion(270, 0, 1, 0));
|
||||
break;
|
||||
case WEST:
|
||||
GlStateManager.rotate(90, 0, 1, 0);
|
||||
matrices.rotate(new Quaternion(90, 0, 1, 0));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
cloud.renderExtra(0.0625F);
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
renderedEaster = true;
|
||||
break easterEggs;
|
||||
}
|
||||
|
||||
cloud.renderExtra(0.0625F);
|
||||
matrices.pop();
|
||||
|
||||
renderedEaster = true;
|
||||
break easterEggs;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String nameLower = theCloud.name.toLowerCase(Locale.ROOT);
|
||||
if (SpecialRenderInit.SPECIAL_LIST.containsKey(nameLower)) {
|
||||
RenderSpecial render = SpecialRenderInit.SPECIAL_LIST.get(nameLower);
|
||||
if (render != null) {
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate(0F, renderedEaster ? 0.05F : 0.25F, 0F);
|
||||
GlStateManager.rotate(180F, 1.0F, 0.0F, 1.0F);
|
||||
GlStateManager.scale(0.75F, 0.75F, 0.75F);
|
||||
render.render();
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
String nameLower = theCloud.name.toLowerCase(Locale.ROOT);
|
||||
if (SpecialRenderInit.SPECIAL_LIST.containsKey(nameLower)) {
|
||||
RenderSpecial render = SpecialRenderInit.SPECIAL_LIST.get(nameLower);
|
||||
if (render != null) {
|
||||
matrices.push();
|
||||
matrices.translate(0F, renderedEaster ? 0.05F : 0.25F, 0F);
|
||||
matrices.rotate(new Quaternion(180F, 1.0F, 0.0F, 1.0F));
|
||||
matrices.scale(0.75F, 0.75F, 0.75F);
|
||||
render.render();
|
||||
matrices.pop();
|
||||
}
|
||||
}
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
matrices.pop();
|
||||
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
if (theCloud.name != null && !theCloud.name.isEmpty() && !mc.gameSettings.hideGUI) {
|
||||
if (mc.player.getDistanceSq(theCloud.getPos()) <= 36) {
|
||||
AssetUtil.renderNameTag(theCloud.name, x + 0.5F, y + 1.5F, z + 0.5F);
|
||||
}
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
if (theCloud.name != null && !theCloud.name.isEmpty() && !mc.gameSettings.hideGUI) {
|
||||
BlockPos pos = theCloud.getPos();
|
||||
if (mc.player.getDistanceSq(pos.getX(), pos.getY(), pos.getZ()) <= 36) {
|
||||
AssetUtil.renderNameTag(theCloud.name, pos.getX() + 0.5F, pos.getY() + 1.5F, pos.getZ() + 0.5F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,54 +1,44 @@
|
|||
package de.ellpeck.actuallyadditions.mod.blocks.render;
|
||||
|
||||
import javax.vecmath.Matrix3f;
|
||||
import javax.vecmath.Matrix4f;
|
||||
import javax.vecmath.Vector3f;
|
||||
import javax.vecmath.Vector4f;
|
||||
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement;
|
||||
import net.minecraftforge.client.model.pipeline.UnpackedBakedQuad;
|
||||
import net.minecraftforge.client.model.pipeline.VertexTransformer;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
|
||||
public class Transformer extends VertexTransformer {
|
||||
|
||||
protected final Matrix4f transformation;
|
||||
protected final Matrix3f normalTransformation;
|
||||
|
||||
public Transformer(TRSRTransformation transformation, VertexFormat format) {
|
||||
super(new UnpackedBakedQuad.Builder(format));
|
||||
// position transform
|
||||
this.transformation = transformation.getMatrix();
|
||||
// normal transform
|
||||
this.normalTransformation = new Matrix3f();
|
||||
this.transformation.getRotationScale(this.normalTransformation);
|
||||
this.normalTransformation.invert();
|
||||
this.normalTransformation.transpose();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(int element, float... data) {
|
||||
VertexFormatElement.EnumUsage usage = this.parent.getVertexFormat().getElement(element).getUsage();
|
||||
|
||||
// transform normals and position
|
||||
if (usage == VertexFormatElement.EnumUsage.POSITION && data.length >= 3) {
|
||||
Vector4f vec = new Vector4f(data);
|
||||
vec.setW(1.0f);
|
||||
this.transformation.transform(vec);
|
||||
data = new float[4];
|
||||
vec.get(data);
|
||||
} else if (usage == VertexFormatElement.EnumUsage.NORMAL && data.length >= 3) {
|
||||
Vector3f vec = new Vector3f(data);
|
||||
this.normalTransformation.transform(vec);
|
||||
vec.normalize();
|
||||
data = new float[4];
|
||||
vec.get(data);
|
||||
}
|
||||
super.put(element, data);
|
||||
}
|
||||
|
||||
public UnpackedBakedQuad build() {
|
||||
return ((UnpackedBakedQuad.Builder) this.parent).build();
|
||||
}
|
||||
}
|
||||
//public class Transformer extends VertexTransformer {
|
||||
//
|
||||
// protected final Matrix4f transformation;
|
||||
// protected final Matrix3f normalTransformation;
|
||||
//
|
||||
// public Transformer(TRSRTransformation transformation, VertexFormat format) {
|
||||
// super(new UnpackedBakedQuad.Builder(format));
|
||||
// // position transform
|
||||
// this.transformation = transformation.getMatrix();
|
||||
// // normal transform
|
||||
// this.normalTransformation = new Matrix3f();
|
||||
// this.transformation.getRotationScale(this.normalTransformation);
|
||||
// this.normalTransformation.invert();
|
||||
// this.normalTransformation.transpose();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void put(int element, float... data) {
|
||||
// VertexFormatElement.EnumUsage usage = this.parent.getVertexFormat().getElement(element).getUsage();
|
||||
//
|
||||
// // transform normals and position
|
||||
// if (usage == VertexFormatElement.EnumUsage.POSITION && data.length >= 3) {
|
||||
// Vector4f vec = new Vector4f(data);
|
||||
// vec.setW(1.0f);
|
||||
// this.transformation.transform(vec);
|
||||
// data = new float[4];
|
||||
// vec.get(data);
|
||||
// } else if (usage == VertexFormatElement.EnumUsage.NORMAL && data.length >= 3) {
|
||||
// Vector3f vec = new Vector3f(data);
|
||||
// this.normalTransformation.transform(vec);
|
||||
// vec.normalize();
|
||||
// data = new float[4];
|
||||
// vec.get(data);
|
||||
// }
|
||||
// super.put(element, data);
|
||||
// }
|
||||
//
|
||||
// public UnpackedBakedQuad build() {
|
||||
// return ((UnpackedBakedQuad.Builder) this.parent).build();
|
||||
// }
|
||||
//}
|
|
@ -11,6 +11,7 @@ import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
|||
import io.netty.util.internal.ConcurrentSet;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
|
@ -34,7 +35,7 @@ public class ItemEngineerGoggles extends ItemArmorAA implements IGoggles {
|
|||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
public static boolean isWearing(EntityPlayer player) {
|
||||
public static boolean isWearing(PlayerEntity player) {
|
||||
ItemStack face = player.inventory.armorInventory.get(3);
|
||||
return StackUtil.isValid(face) && face.getItem() instanceof IGoggles;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue