mirror of
https://github.com/GTNewHorizons/Draconic-Evolution.git
synced 2026-11-19 19:59:34 +00:00
Add an Earth block (#30)
* Add Earth tile * Fix * Fix NBT saving issue * Inventory item render * Spotless nonsense * Fix buildscript maybe? Co-authored-by: GTNH-Colen <[email protected]>
This commit is contained in:
1 parent
747b616165
commit
9bb9bf4fd7
13 files changed
+45017
-138
No files matched your search
@@ -26,6 +26,7 @@ import com.brandon3055.draconicevolution.common.tileentities.*;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.energynet.TileEnergyRelay;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.energynet.TileEnergyTransceiver;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.energynet.TileWirelessEnergyTransceiver;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.TileEarth;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.TileEnergyPylon;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.TileEnergyStorageCore;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.reactor.TileReactorCore;
|
||||
@@ -213,6 +214,7 @@ public class ClientProxy extends CommonProxy {
|
||||
Item.getItemFromBlock(ModBlocks.reactorEnergyInjector), new RenderReactorEnergyInjector());
|
||||
MinecraftForgeClient.registerItemRenderer(
|
||||
Item.getItemFromBlock(ModBlocks.reactorCore), new RenderReactorCore());
|
||||
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.earthBlock), new RenderEarthItem());
|
||||
MinecraftForgeClient.registerItemRenderer(
|
||||
Item.getItemFromBlock(ModBlocks.chaosCrystal), new RenderChaosShard());
|
||||
MinecraftForgeClient.registerItemRenderer(
|
||||
@@ -228,6 +230,7 @@ public class ClientProxy extends CommonProxy {
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileCustomSpawner.class, new RenderTileCustomSpawner());
|
||||
// ClientRegistry.bindTileEntitySpecialRenderer(TileTestBlock.class, new RenderTileCrystal());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEnergyStorageCore.class, new RenderTileEnergyStorageCore());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEarth.class, new RenderTileEarth());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEnergyPylon.class, new RenderTileEnergyPylon());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TilePlacedItem.class, new RenderTilePlacedItem());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileDissEnchanter.class, new RenderTileDissEnchanter());
|
||||
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
package com.brandon3055.draconicevolution.client.render.block;
|
||||
|
||||
import com.brandon3055.draconicevolution.client.handler.ResourceHandler;
|
||||
import com.brandon3055.draconicevolution.client.render.tile.RenderTileEarth;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
/**
|
||||
* Created by brandon3055 on 30/7/2015.
|
||||
*/
|
||||
public class RenderEarthItem implements IItemRenderer {
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
|
||||
GL11.glPushMatrix();
|
||||
|
||||
if (type == ItemRenderType.INVENTORY) GL11.glRotated(180, 0, 1, 0);
|
||||
else if (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
|
||||
GL11.glTranslated(0.5, 0.5, 0.5);
|
||||
if (type == ItemRenderType.EQUIPPED) GL11.glRotated(90, 0, 1, 0);
|
||||
}
|
||||
|
||||
ResourceHandler.bindResource("textures/models/Earth.png");
|
||||
GL11.glScaled(0.01, 0.01, 0.01);
|
||||
GL11.glRotatef(-180, 1F, 0F, 1F);
|
||||
GL11.glRotatef(90, 1F, 0F, 0F);
|
||||
GL11.glRotatef((System.currentTimeMillis() / 64) % 360, 0F, 0F, 1F);
|
||||
RenderTileEarth.modelCustom.renderAll();
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
package com.brandon3055.draconicevolution.client.render.tile;
|
||||
|
||||
import com.brandon3055.draconicevolution.common.lib.References;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.TileEarth;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.AdvancedModelLoader;
|
||||
import net.minecraftforge.client.model.IModelCustom;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
/**
|
||||
* Created by Brandon on 27/07/2014.
|
||||
*/
|
||||
public class RenderTileEarth extends TileEntitySpecialRenderer {
|
||||
|
||||
private static final ResourceLocation iner_model_texture =
|
||||
new ResourceLocation(References.MODID.toLowerCase(), "textures/models/Earth.png");
|
||||
public static IModelCustom modelCustom;
|
||||
|
||||
public RenderTileEarth() {
|
||||
modelCustom =
|
||||
AdvancedModelLoader.loadModel(new ResourceLocation(References.MODID.toLowerCase(), "models/Earth.obj"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float timeSinceLastTick) {
|
||||
if (!(tile instanceof TileEarth)) return;
|
||||
|
||||
TileEarth tileEarth = (TileEarth) tile;
|
||||
float scale = 0.01f * tileEarth.getSize();
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 150f, 150f);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5);
|
||||
FMLClientHandler.instance().getClient().getTextureManager().bindTexture(iner_model_texture);
|
||||
|
||||
float brightness = (float) Math.abs(Math.sin((float) Minecraft.getSystemTime() / 3000f) * 100f);
|
||||
|
||||
GL11.glScalef(scale, scale, scale);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glRotatef(-180, 1F, 0F, 1F);
|
||||
GL11.glRotatef(90, 1F, 0F, 0F);
|
||||
if (tileEarth.getRotationSpeed() != 0) {
|
||||
GL11.glRotatef((System.currentTimeMillis() / tileEarth.getRotationSpeed()) % 360, 0F, 0F, 1F);
|
||||
}
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 80f + brightness, 80f + brightness);
|
||||
modelCustom.renderAll();
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glDepthMask(true);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
@@ -165,6 +165,7 @@ public class CommonProxy {
|
||||
GameRegistry.registerTileEntity(TileGenerator.class, References.RESOURCESPREFIX + "TileGenerator");
|
||||
GameRegistry.registerTileEntity(
|
||||
TileEnergyStorageCore.class, References.RESOURCESPREFIX + "TileEnergyStorageCore");
|
||||
GameRegistry.registerTileEntity(TileEarth.class, References.RESOURCESPREFIX + "TileEarth");
|
||||
GameRegistry.registerTileEntity(
|
||||
TileInvisibleMultiblock.class, References.RESOURCESPREFIX + "TileInvisibleMultiblock");
|
||||
GameRegistry.registerTileEntity(TileEnergyPylon.class, References.RESOURCESPREFIX + "TileEnergyPylon");
|
||||
|
||||
@@ -29,6 +29,7 @@ public class ModBlocks {
|
||||
public static BlockDE longRangeDislocator;
|
||||
public static BlockDE generator;
|
||||
public static BlockDE energyStorageCore;
|
||||
public static BlockDE earthBlock;
|
||||
public static BlockDE draconiumBlock;
|
||||
public static BlockDE invisibleMultiblock;
|
||||
public static BlockDE energyPylon;
|
||||
@@ -71,6 +72,7 @@ public class ModBlocks {
|
||||
customSpawner = new CustomSpawner();
|
||||
generator = new Generator();
|
||||
energyStorageCore = new EnergyStorageCore();
|
||||
earthBlock = new Earth();
|
||||
draconiumBlock = new DraconiumBlock();
|
||||
invisibleMultiblock = new InvisibleMultiblock();
|
||||
energyPylon = new EnergyPylon();
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.brandon3055.draconicevolution.common.blocks.multiblock;
|
||||
|
||||
import com.brandon3055.draconicevolution.DraconicEvolution;
|
||||
import com.brandon3055.draconicevolution.common.ModBlocks;
|
||||
import com.brandon3055.draconicevolution.common.blocks.BlockDE;
|
||||
import com.brandon3055.draconicevolution.common.lib.References;
|
||||
import com.brandon3055.draconicevolution.common.lib.Strings;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.TileEarth;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class Earth extends BlockDE {
|
||||
|
||||
public Earth() {
|
||||
super(Material.iron);
|
||||
this.setHardness(10F);
|
||||
this.setResistance(20f);
|
||||
this.setCreativeTab(DraconicEvolution.tabBlocksItems);
|
||||
this.setBlockName(Strings.earthName);
|
||||
ModBlocks.register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister iconRegister) {
|
||||
blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "transparency");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRenderInPass(int a) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(int metadata) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity(World world, int metadata) {
|
||||
return new TileEarth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(
|
||||
World world,
|
||||
int x,
|
||||
int y,
|
||||
int z,
|
||||
EntityPlayer player,
|
||||
int p_149727_6_,
|
||||
float p_149727_7_,
|
||||
float p_149727_8_,
|
||||
float p_149727_9_) {
|
||||
TileEarth tile = (TileEarth) world.getTileEntity(x, y, z);
|
||||
|
||||
if (player.isSneaking()) {
|
||||
tile.incrementSize();
|
||||
} else {
|
||||
tile.increaseRotationSpeed();
|
||||
}
|
||||
|
||||
if (!world.isRemote) {
|
||||
player.addChatComponentMessage(new ChatComponentText("Rotation Speed:" + tile.getRotationSpeed()));
|
||||
player.addChatComponentMessage(new ChatComponentText("Size: " + tile.getSize()));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -47,6 +47,7 @@ public class Strings { // public st
|
||||
public static final String longRangeDislocatorName = "longRangeDislocator";
|
||||
public static final String generatorName = "generator";
|
||||
public static final String energyStorageCoreName = "energyStorageCore";
|
||||
public static final String earthName = "earth";
|
||||
public static final String draconiumBlockName = "draconium";
|
||||
public static final String invisibleMultiblockName = "invisibleMultiblock";
|
||||
public static final String energyPylonName = "energyPylon";
|
||||
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
package com.brandon3055.draconicevolution.common.tileentities.multiblocktiles;
|
||||
|
||||
import com.brandon3055.draconicevolution.common.tileentities.TileObjectSync;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
|
||||
public class TileEarth extends TileObjectSync {
|
||||
|
||||
// Prevent culling when block is out of frame so model can remain active.
|
||||
@Override
|
||||
public AxisAlignedBB getRenderBoundingBox() {
|
||||
return INFINITE_EXTENT_AABB;
|
||||
}
|
||||
|
||||
private static final int maxRotationSpeed = 64;
|
||||
private static final int maxSize = 200;
|
||||
|
||||
private int size = 1;
|
||||
private int rotationSpeed = 0;
|
||||
|
||||
public void incrementSize() {
|
||||
size++;
|
||||
}
|
||||
|
||||
public void increaseRotationSpeed() {
|
||||
rotationSpeed++;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return size % maxSize;
|
||||
}
|
||||
|
||||
public int getRotationSpeed() {
|
||||
return rotationSpeed % maxRotationSpeed;
|
||||
}
|
||||
|
||||
private static final String rotationSpeedNBTTag = "DE:rotationSpeed";
|
||||
private static final String sizeNBTTag = "DE:size";
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound compound) {
|
||||
super.writeToNBT(compound);
|
||||
compound.setInteger(rotationSpeedNBTTag, rotationSpeed);
|
||||
compound.setInteger(sizeNBTTag, size);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound compound) {
|
||||
super.readFromNBT(compound);
|
||||
rotationSpeed = compound.getInteger(rotationSpeedNBTTag);
|
||||
size = compound.getInteger(sizeNBTTag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket() {
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
writeToNBT(nbttagcompound);
|
||||
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, nbttagcompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
|
||||
readFromNBT(pkt.func_148857_g());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user