mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-12-22 14:59:22 +01:00
ender ocular and textures
This commit is contained in:
parent
095e5e92cf
commit
00b1141a08
14 changed files with 265 additions and 18 deletions
|
@ -2,21 +2,33 @@ package de.ellpeck.naturesaura.blocks;
|
|||
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityEnderCrate;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.render.RenderEnderCrate;
|
||||
import de.ellpeck.naturesaura.reg.ITESRProvider;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.BlockFaceShape;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.Tuple;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockEnderCrate extends BlockContainerImpl {
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockEnderCrate extends BlockContainerImpl implements ITESRProvider {
|
||||
public BlockEnderCrate() {
|
||||
super(Material.ROCK, "ender_crate", TileEntityEnderCrate.class, "ender_crate");
|
||||
this.setSoundType(SoundType.STONE);
|
||||
this.setHardness(5F);
|
||||
this.setLightLevel(0.75F);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -31,4 +43,26 @@ public class BlockEnderCrate extends BlockContainerImpl {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) {
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
int j = rand.nextInt(2) * 2 - 1;
|
||||
int k = rand.nextInt(2) * 2 - 1;
|
||||
double d0 = (double) pos.getX() + 0.5D + 0.25D * (double) j;
|
||||
double d1 = (double) ((float) pos.getY() + rand.nextFloat());
|
||||
double d2 = (double) pos.getZ() + 0.5D + 0.25D * (double) k;
|
||||
double d3 = (double) (rand.nextFloat() * (float) j);
|
||||
double d4 = ((double) rand.nextFloat() - 0.5D) * 0.125D;
|
||||
double d5 = (double) (rand.nextFloat() * (float) k);
|
||||
worldIn.spawnParticle(EnumParticleTypes.PORTAL, d0, d1, d2, d3, d4, d5);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Tuple<Class, TileEntitySpecialRenderer> getTESR() {
|
||||
return new Tuple<>(TileEntityEnderCrate.class, new RenderEnderCrate());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,147 @@
|
|||
package de.ellpeck.naturesaura.blocks.tiles.render;
|
||||
|
||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityEnderCrate;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.GLAllocation;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.nio.FloatBuffer;
|
||||
import java.util.Random;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderEnderCrate extends TileEntitySpecialRenderer<TileEntityEnderCrate> {
|
||||
private static final ResourceLocation END_SKY_TEXTURE = new ResourceLocation("textures/environment/end_sky.png");
|
||||
private static final ResourceLocation END_PORTAL_TEXTURE = new ResourceLocation("textures/entity/end_portal.png");
|
||||
private static final Random RANDOM = new Random(31100L);
|
||||
private static final FloatBuffer MODELVIEW = GLAllocation.createDirectFloatBuffer(16);
|
||||
private static final FloatBuffer PROJECTION = GLAllocation.createDirectFloatBuffer(16);
|
||||
private final FloatBuffer buffer = GLAllocation.createDirectFloatBuffer(16);
|
||||
|
||||
@Override
|
||||
public void render(TileEntityEnderCrate te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
|
||||
GlStateManager.disableLighting();
|
||||
RANDOM.setSeed(31100L);
|
||||
GlStateManager.getFloat(2982, MODELVIEW);
|
||||
GlStateManager.getFloat(2983, PROJECTION);
|
||||
double d0 = x * x + y * y + z * z;
|
||||
int i = this.getPasses(d0);
|
||||
float f = this.getOffset();
|
||||
boolean flag = false;
|
||||
|
||||
for (int j = 0; j < i; ++j) {
|
||||
GlStateManager.pushMatrix();
|
||||
float f1 = 2.0F / (float) (18 - j);
|
||||
|
||||
if (j == 0) {
|
||||
this.bindTexture(END_SKY_TEXTURE);
|
||||
f1 = 0.15F;
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
|
||||
if (j >= 1) {
|
||||
this.bindTexture(END_PORTAL_TEXTURE);
|
||||
flag = true;
|
||||
Minecraft.getMinecraft().entityRenderer.setupFogColor(true);
|
||||
}
|
||||
|
||||
if (j == 1) {
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ONE);
|
||||
}
|
||||
|
||||
GlStateManager.texGen(GlStateManager.TexGen.S, 9216);
|
||||
GlStateManager.texGen(GlStateManager.TexGen.T, 9216);
|
||||
GlStateManager.texGen(GlStateManager.TexGen.R, 9216);
|
||||
GlStateManager.texGen(GlStateManager.TexGen.S, 9474, this.getBuffer(1.0F, 0.0F, 0.0F, 0.0F));
|
||||
GlStateManager.texGen(GlStateManager.TexGen.T, 9474, this.getBuffer(0.0F, 1.0F, 0.0F, 0.0F));
|
||||
GlStateManager.texGen(GlStateManager.TexGen.R, 9474, this.getBuffer(0.0F, 0.0F, 1.0F, 0.0F));
|
||||
GlStateManager.enableTexGenCoord(GlStateManager.TexGen.S);
|
||||
GlStateManager.enableTexGenCoord(GlStateManager.TexGen.T);
|
||||
GlStateManager.enableTexGenCoord(GlStateManager.TexGen.R);
|
||||
GlStateManager.popMatrix();
|
||||
GlStateManager.matrixMode(5890);
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.loadIdentity();
|
||||
GlStateManager.translate(0.5F, 0.5F, 0.0F);
|
||||
GlStateManager.scale(0.5F, 0.5F, 1.0F);
|
||||
float f2 = (float) (j + 1);
|
||||
GlStateManager.translate(17.0F / f2, (2.0F + f2 / 1.5F) * ((float) Minecraft.getSystemTime() % 800000.0F / 800000.0F), 0.0F);
|
||||
GlStateManager.rotate((f2 * f2 * 4321.0F + f2 * 9.0F) * 2.0F, 0.0F, 0.0F, 1.0F);
|
||||
GlStateManager.scale(4.5F - f2 / 4.0F, 4.5F - f2 / 4.0F, 1.0F);
|
||||
GlStateManager.multMatrix(PROJECTION);
|
||||
GlStateManager.multMatrix(MODELVIEW);
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
BufferBuilder bufferbuilder = tessellator.getBuffer();
|
||||
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_COLOR);
|
||||
float f3 = (RANDOM.nextFloat() * 0.5F + 0.1F) * f1;
|
||||
float f4 = (RANDOM.nextFloat() * 0.5F + 0.4F) * f1;
|
||||
float f5 = (RANDOM.nextFloat() * 0.5F + 0.5F) * f1;
|
||||
|
||||
float indent = 1.95F / 16F;
|
||||
bufferbuilder.pos(x + indent, y + (double) f, z - indent + 1.0D).color(f3, f4, f5, 1.0F).endVertex();
|
||||
bufferbuilder.pos(x - indent + 1.0D, y + (double) f, z - indent + 1.0D).color(f3, f4, f5, 1.0F).endVertex();
|
||||
bufferbuilder.pos(x - indent + 1.0D, y + (double) f, z + indent).color(f3, f4, f5, 1.0F).endVertex();
|
||||
bufferbuilder.pos(x + indent, y + (double) f, z + indent).color(f3, f4, f5, 1.0F).endVertex();
|
||||
|
||||
tessellator.draw();
|
||||
GlStateManager.popMatrix();
|
||||
GlStateManager.matrixMode(5888);
|
||||
this.bindTexture(END_SKY_TEXTURE);
|
||||
}
|
||||
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.disableTexGenCoord(GlStateManager.TexGen.S);
|
||||
GlStateManager.disableTexGenCoord(GlStateManager.TexGen.T);
|
||||
GlStateManager.disableTexGenCoord(GlStateManager.TexGen.R);
|
||||
GlStateManager.enableLighting();
|
||||
|
||||
if (flag) {
|
||||
Minecraft.getMinecraft().entityRenderer.setupFogColor(false);
|
||||
}
|
||||
}
|
||||
|
||||
protected int getPasses(double dist) {
|
||||
int i;
|
||||
|
||||
if (dist > 36864.0D) {
|
||||
i = 1;
|
||||
} else if (dist > 25600.0D) {
|
||||
i = 3;
|
||||
} else if (dist > 16384.0D) {
|
||||
i = 5;
|
||||
} else if (dist > 9216.0D) {
|
||||
i = 7;
|
||||
} else if (dist > 4096.0D) {
|
||||
i = 9;
|
||||
} else if (dist > 1024.0D) {
|
||||
i = 11;
|
||||
} else if (dist > 576.0D) {
|
||||
i = 13;
|
||||
} else if (dist > 256.0D) {
|
||||
i = 14;
|
||||
} else {
|
||||
i = 15;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
protected float getOffset() {
|
||||
return 1.001F;
|
||||
}
|
||||
|
||||
private FloatBuffer getBuffer(float a, float b, float c, float d) {
|
||||
this.buffer.clear();
|
||||
this.buffer.put(a).put(b).put(c).put(d);
|
||||
this.buffer.flip();
|
||||
return this.buffer;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
package de.ellpeck.naturesaura.gui;
|
||||
|
||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityEnderCrate;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
|
@ -9,12 +8,8 @@ import net.minecraftforge.items.IItemHandler;
|
|||
import net.minecraftforge.items.SlotItemHandler;
|
||||
|
||||
public class ContainerEnderCrate extends Container {
|
||||
private final TileEntityEnderCrate crate;
|
||||
|
||||
public ContainerEnderCrate(EntityPlayer player, TileEntityEnderCrate crate) {
|
||||
this.crate = crate;
|
||||
IItemHandler handler = this.crate.getItemHandler(null);
|
||||
|
||||
public ContainerEnderCrate(EntityPlayer player, IItemHandler handler) {
|
||||
int i = (3 - 4) * 18;
|
||||
for (int j = 0; j < 3; ++j)
|
||||
for (int k = 0; k < 9; ++k)
|
||||
|
@ -28,7 +23,7 @@ public class ContainerEnderCrate extends Container {
|
|||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer playerIn) {
|
||||
return !this.crate.isInvalid();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package de.ellpeck.naturesaura.gui;
|
||||
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityEnderCrate;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
|
@ -10,17 +9,20 @@ import net.minecraft.util.ResourceLocation;
|
|||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiEnderCrate extends GuiContainer {
|
||||
private static final ResourceLocation CHEST_GUI_TEXTURE = new ResourceLocation("textures/gui/container/generic_54.png");
|
||||
private final EntityPlayer player;
|
||||
private final TileEntityEnderCrate crate;
|
||||
private final String nameKey;
|
||||
private final String name;
|
||||
|
||||
public GuiEnderCrate(EntityPlayer player, TileEntityEnderCrate crate) {
|
||||
super(new ContainerEnderCrate(player, crate));
|
||||
public GuiEnderCrate(EntityPlayer player, IItemHandler handler, String nameKey, String name) {
|
||||
super(new ContainerEnderCrate(player, handler));
|
||||
this.player = player;
|
||||
this.crate = crate;
|
||||
this.nameKey = nameKey;
|
||||
this.name = name;
|
||||
this.allowUserInput = false;
|
||||
this.ySize = 114 + 3 * 18;
|
||||
}
|
||||
|
@ -34,7 +36,7 @@ public class GuiEnderCrate extends GuiContainer {
|
|||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
String display = I18n.format("info." + NaturesAura.MOD_ID + ".ender_crate", TextFormatting.ITALIC + this.crate.name + TextFormatting.RESET);
|
||||
String display = I18n.format("info." + NaturesAura.MOD_ID + "." + this.nameKey, TextFormatting.ITALIC + this.name + TextFormatting.RESET);
|
||||
this.fontRenderer.drawString(display, 8, 6, 4210752);
|
||||
this.fontRenderer.drawString(this.player.inventory.getDisplayName().getFormattedText(), 8, this.ySize - 96 + 2, 4210752);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package de.ellpeck.naturesaura.gui;
|
||||
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.api.misc.IWorldData;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityEnderCrate;
|
||||
import de.ellpeck.naturesaura.items.ModItems;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -25,8 +28,12 @@ public class GuiHandler implements IGuiHandler {
|
|||
if (tile instanceof TileEntityEnderCrate) {
|
||||
TileEntityEnderCrate crate = (TileEntityEnderCrate) tile;
|
||||
if (crate.canOpen())
|
||||
return new ContainerEnderCrate(player, crate);
|
||||
return new ContainerEnderCrate(player, crate.getItemHandler(null));
|
||||
}
|
||||
} else if (id == 1) {
|
||||
ItemStack stack = player.getHeldItemMainhand();
|
||||
if (stack.getItem() == ModItems.ENDER_ACCESS && stack.hasDisplayName())
|
||||
return new ContainerEnderCrate(player, IWorldData.getOverworldData(world).getEnderStorage(stack.getDisplayName()));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -39,7 +46,13 @@ public class GuiHandler implements IGuiHandler {
|
|||
if (tile instanceof TileEntityEnderCrate) {
|
||||
TileEntityEnderCrate crate = (TileEntityEnderCrate) tile;
|
||||
if (crate.canOpen())
|
||||
return new GuiEnderCrate(player, crate);
|
||||
return new GuiEnderCrate(player, crate.getItemHandler(null), "ender_crate", crate.name);
|
||||
}
|
||||
} else if (id == 1) {
|
||||
ItemStack stack = player.getHeldItemMainhand();
|
||||
if (stack.getItem() == ModItems.ENDER_ACCESS && stack.hasDisplayName()) {
|
||||
String name = stack.getDisplayName();
|
||||
return new GuiEnderCrate(player, IWorldData.getOverworldData(world).getEnderStorage(name), "ender_access", name);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package de.ellpeck.naturesaura.items;
|
||||
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemEnderAccess extends ItemImpl {
|
||||
public ItemEnderAccess() {
|
||||
super("ender_access");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) {
|
||||
if (handIn != EnumHand.MAIN_HAND)
|
||||
return new ActionResult<>(EnumActionResult.PASS, playerIn.getHeldItem(handIn));
|
||||
ItemStack stack = playerIn.getHeldItemMainhand();
|
||||
if (stack.hasDisplayName()) {
|
||||
if (!worldIn.isRemote)
|
||||
playerIn.openGui(NaturesAura.MOD_ID, 1, worldIn, (int) playerIn.posX, (int) playerIn.posY, (int) playerIn.posZ);
|
||||
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
|
||||
}
|
||||
return new ActionResult<>(EnumActionResult.FAIL, stack);
|
||||
}
|
||||
}
|
|
@ -54,5 +54,5 @@ public final class ModItems {
|
|||
public static final Item TOKEN_TERROR = new ItemImpl("token_terror");
|
||||
public static final Item TOKEN_RAGE = new ItemImpl("token_rage");
|
||||
public static final Item TOKEN_GRIEF = new ItemImpl("token_grief");
|
||||
|
||||
public static final Item ENDER_ACCESS = new ItemEnderAccess();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"forge_marker": 1,
|
||||
"defaults": {
|
||||
"model": "minecraft:cube",
|
||||
"textures": {
|
||||
"particle": "naturesaura:blocks/ender_crate",
|
||||
"up": "naturesaura:blocks/ender_crate_top",
|
||||
"down": "naturesaura:blocks/ender_crate_bottom",
|
||||
"north": "#particle",
|
||||
"east": "#particle",
|
||||
"south": "#particle",
|
||||
"west": "#particle"
|
||||
},
|
||||
"transform": "forge:default-block"
|
||||
},
|
||||
"variants": {
|
||||
"normal": [{}],
|
||||
"inventory": [{}]
|
||||
}
|
||||
}
|
|
@ -90,6 +90,7 @@ item.naturesaura.token_joy.name=Token of Joy
|
|||
item.naturesaura.token_rage.name=Token of Rage
|
||||
item.naturesaura.token_sorrow.name=Token of Sorrow
|
||||
item.naturesaura.token_terror.name=Token of Terror
|
||||
item.naturesaura.ender_access.name=Ender Ocular
|
||||
|
||||
container.naturesaura.tree_ritual.name=Ritual of the Forest
|
||||
container.naturesaura.altar.name=Natural Altar Infusion
|
||||
|
@ -105,7 +106,8 @@ info.naturesaura.same_position=This seems to be the position from your notes...
|
|||
info.naturesaura.too_far=The distance seems too great...
|
||||
info.naturesaura.stored_pos_gone=Your notes seem out of date...
|
||||
info.naturesaura.empty=Empty
|
||||
info.naturesaura.ender_crate=Ender Crate (%s)
|
||||
info.naturesaura.ender_crate=Ender Crate: %s
|
||||
info.naturesaura.ender_access=Ender Ocular: %s
|
||||
|
||||
advancement.naturesaura.root=Nature's Aura
|
||||
advancement.naturesaura.root.desc=Becoming a magical botanist
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "naturesaura:items/ender_access"
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 693 B |
Binary file not shown.
After Width: | Height: | Size: 560 B |
Binary file not shown.
After Width: | Height: | Size: 390 B |
Binary file not shown.
After Width: | Height: | Size: 695 B |
Loading…
Reference in a new issue