mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
i did nothing productive all day
This commit is contained in:
parent
943e243573
commit
8d8116b3d0
@ -1,35 +1,62 @@
|
|||||||
package com.hbm.blocks.network;
|
package com.hbm.blocks.network;
|
||||||
|
|
||||||
import com.hbm.entity.item.EntityMovingItem;
|
import com.hbm.entity.item.EntityMovingItem;
|
||||||
|
import com.hbm.lib.RefStrings;
|
||||||
|
|
||||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.AxisAlignedBB;
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
|
import net.minecraft.util.IIcon;
|
||||||
import net.minecraft.util.MathHelper;
|
import net.minecraft.util.MathHelper;
|
||||||
import net.minecraft.world.IBlockAccess;
|
import net.minecraft.world.IBlockAccess;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public class BlockConveyor extends Block {
|
public class BlockConveyor extends Block {
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
protected IIcon sideIcon;
|
||||||
|
|
||||||
public BlockConveyor(Material p_i45394_1_) {
|
public BlockConveyor(Material p_i45394_1_) {
|
||||||
super(p_i45394_1_);
|
super(p_i45394_1_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
|
@SideOnly(Side.CLIENT)
|
||||||
|
public void registerBlockIcons(IIconRegister iconRegister) {
|
||||||
|
super.registerBlockIcons(iconRegister);
|
||||||
|
this.sideIcon = iconRegister.registerIcon(RefStrings.MODID + ":conveyor_side");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public IIcon getIcon(int side, int metadata) {
|
||||||
|
|
||||||
|
if((metadata == 2 || metadata == 3) && (side == 4 || side == 5))
|
||||||
|
return this.sideIcon;
|
||||||
|
if((metadata == 4 || metadata == 5) && (side == 2 || side == 3))
|
||||||
|
return this.sideIcon;
|
||||||
|
|
||||||
|
return super.getIcon(side, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
|
||||||
|
|
||||||
if(!world.isRemote) {
|
if(!world.isRemote) {
|
||||||
|
|
||||||
if(entity instanceof EntityItem && entity.ticksExisted > 10 && !entity.isDead) {
|
if(entity instanceof EntityItem && entity.ticksExisted > 10 && !entity.isDead) {
|
||||||
|
|
||||||
EntityMovingItem item = new EntityMovingItem(world);
|
EntityMovingItem item = new EntityMovingItem(world);
|
||||||
item.setItemStack(((EntityItem)entity).getEntityItem());
|
item.setItemStack(((EntityItem) entity).getEntityItem());
|
||||||
item.setPositionAndRotation(x + 0.5, y + 0.125, z + 0.5, 0, 0);
|
item.setPositionAndRotation(x + 0.5, y + 0.25, z + 0.5, 0, 0);
|
||||||
world.spawnEntityInWorld(item);
|
world.spawnEntityInWorld(item);
|
||||||
|
|
||||||
entity.setDead();
|
entity.setDead();
|
||||||
@ -37,7 +64,7 @@ public class BlockConveyor extends Block {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int renderID = RenderingRegistry.getNextAvailableRenderId();
|
public static int renderID = RenderingRegistry.getNextAvailableRenderId();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRenderType() {
|
public int getRenderType() {
|
||||||
@ -56,32 +83,28 @@ public class BlockConveyor extends Block {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
|
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
|
||||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F);
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.25F, 1.0F);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
|
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
|
||||||
return AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y, z + 1);
|
return AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 0.25, z + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) {
|
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) {
|
||||||
int i = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
|
int i = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
|
||||||
|
|
||||||
if(i == 0)
|
if(i == 0) {
|
||||||
{
|
|
||||||
world.setBlockMetadataWithNotify(x, y, z, 2, 2);
|
world.setBlockMetadataWithNotify(x, y, z, 2, 2);
|
||||||
}
|
}
|
||||||
if(i == 1)
|
if(i == 1) {
|
||||||
{
|
|
||||||
world.setBlockMetadataWithNotify(x, y, z, 5, 2);
|
world.setBlockMetadataWithNotify(x, y, z, 5, 2);
|
||||||
}
|
}
|
||||||
if(i == 2)
|
if(i == 2) {
|
||||||
{
|
|
||||||
world.setBlockMetadataWithNotify(x, y, z, 3, 2);
|
world.setBlockMetadataWithNotify(x, y, z, 3, 2);
|
||||||
}
|
}
|
||||||
if(i == 3)
|
if(i == 3) {
|
||||||
{
|
|
||||||
world.setBlockMetadataWithNotify(x, y, z, 4, 2);
|
world.setBlockMetadataWithNotify(x, y, z, 4, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -88,38 +88,34 @@ public class EntityMovingItem extends Entity {
|
|||||||
worldObj.spawnEntityInWorld(item);
|
worldObj.spawnEntityInWorld(item);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(worldObj.getBlock((int)Math.floor(posX), (int)Math.floor(posY), (int)Math.floor(posZ)) == ModBlocks.conveyor) {
|
||||||
|
|
||||||
|
if(schedule <= 0) {
|
||||||
|
ForgeDirection dir = ForgeDirection.getOrientation(worldObj.getBlockMetadata((int)Math.floor(posX), (int)Math.floor(posY), (int)Math.floor(posZ)));
|
||||||
|
|
||||||
|
if(worldObj.getBlock((int)Math.floor(posX), (int)Math.floor(posY) + 1, (int)Math.floor(posZ)) == ModBlocks.conveyor && motionY >= 0) {
|
||||||
|
dir = ForgeDirection.DOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(worldObj.getBlock((int)Math.floor(posX), (int)Math.floor(posY) - 1, (int)Math.floor(posZ)) == ModBlocks.conveyor && motionY <= 0) {
|
||||||
|
dir = ForgeDirection.UP;
|
||||||
|
}
|
||||||
|
|
||||||
|
double speed = 0.0625;
|
||||||
|
|
||||||
|
schedule = (int) (1 / speed);
|
||||||
|
motionX = -speed * dir.offsetX;
|
||||||
|
motionY = -speed * dir.offsetY;
|
||||||
|
motionZ = -speed * dir.offsetZ;
|
||||||
|
|
||||||
|
this.velocityChanged = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
schedule--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
this.moveEntity(motionX, motionY, motionZ);
|
||||||
if(worldObj.getBlock((int)Math.floor(posX), (int)Math.floor(posY), (int)Math.floor(posZ)) == ModBlocks.conveyor) {
|
|
||||||
|
|
||||||
if(schedule <= 0) {
|
|
||||||
ForgeDirection dir = ForgeDirection.getOrientation(worldObj.getBlockMetadata((int)Math.floor(posX), (int)Math.floor(posY), (int)Math.floor(posZ)));
|
|
||||||
|
|
||||||
if(worldObj.getBlock((int)Math.floor(posX), (int)Math.floor(posY) + 1, (int)Math.floor(posZ)) == ModBlocks.conveyor && motionY >= 0) {
|
|
||||||
dir = ForgeDirection.DOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(worldObj.getBlock((int)Math.floor(posX), (int)Math.floor(posY) - 1, (int)Math.floor(posZ)) == ModBlocks.conveyor && motionY <= 0) {
|
|
||||||
dir = ForgeDirection.UP;
|
|
||||||
}
|
|
||||||
|
|
||||||
double speed = 0.1;
|
|
||||||
|
|
||||||
schedule = (int) (1 / speed);
|
|
||||||
motionX = -speed * dir.offsetX;
|
|
||||||
motionY = -speed * dir.offsetY;
|
|
||||||
motionZ = -speed * dir.offsetZ;
|
|
||||||
|
|
||||||
this.velocityChanged = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.lastTickPosX = this.prevPosX = this.posX;
|
|
||||||
this.lastTickPosY = this.prevPosY = this.posY;
|
|
||||||
this.lastTickPosZ = this.prevPosZ = this.posZ;
|
|
||||||
|
|
||||||
this.setPosition(posX + motionX, posY + motionY, posZ + motionZ);
|
|
||||||
schedule--;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -20,44 +20,60 @@ public class RenderConveyor implements ISimpleBlockRenderingHandler {
|
|||||||
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {
|
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {
|
||||||
|
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
Tessellator tessellator = Tessellator.instance;
|
Tessellator tessellator = Tessellator.instance;
|
||||||
IIcon iicon = block.getIcon(0, 0);
|
IIcon iicon = block.getIcon(0, 0);
|
||||||
tessellator.setColorOpaque_F(1, 1, 1);
|
tessellator.setColorOpaque_F(1, 1, 1);
|
||||||
|
|
||||||
if (renderer.hasOverrideBlockTexture())
|
if(renderer.hasOverrideBlockTexture()) {
|
||||||
{
|
iicon = renderer.overrideBlockTexture;
|
||||||
iicon = renderer.overrideBlockTexture;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
GL11.glTranslated(0, -0.125, 0);
|
GL11.glTranslated(0, -0.125, 0);
|
||||||
tessellator.startDrawingQuads();
|
tessellator.startDrawingQuads();
|
||||||
ObjUtil.renderWithIcon((WavefrontObject) ResourceManager.arrow, iicon, tessellator, 0, false);
|
ObjUtil.renderWithIcon((WavefrontObject) ResourceManager.arrow, iicon, tessellator, 0, false);
|
||||||
tessellator.draw();
|
tessellator.draw();
|
||||||
|
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
|
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
|
||||||
|
|
||||||
Tessellator tessellator = Tessellator.instance;
|
Tessellator tessellator = Tessellator.instance;
|
||||||
int meta = world.getBlockMetadata(x, y, z);
|
int meta = world.getBlockMetadata(x, y, z);
|
||||||
|
|
||||||
tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
|
tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
|
||||||
tessellator.setColorOpaque_F(1, 1, 1);
|
tessellator.setColorOpaque_F(1, 1, 1);
|
||||||
|
|
||||||
if(meta == 2)
|
if(meta == 2) {
|
||||||
renderer.uvRotateTop = 3;
|
renderer.uvRotateTop = 3;
|
||||||
if(meta == 3)
|
renderer.uvRotateBottom = 0;
|
||||||
|
renderer.uvRotateWest = 3;
|
||||||
|
}
|
||||||
|
if(meta == 3) {
|
||||||
renderer.uvRotateTop = 0;
|
renderer.uvRotateTop = 0;
|
||||||
if(meta == 4)
|
renderer.uvRotateBottom = 3;
|
||||||
|
renderer.uvRotateEast = 3;
|
||||||
|
}
|
||||||
|
if(meta == 4) {
|
||||||
renderer.uvRotateTop = 1;
|
renderer.uvRotateTop = 1;
|
||||||
if(meta == 5)
|
renderer.uvRotateBottom = 1;
|
||||||
|
renderer.uvRotateSouth = 3;
|
||||||
|
}
|
||||||
|
if(meta == 5) {
|
||||||
renderer.uvRotateTop = 2;
|
renderer.uvRotateTop = 2;
|
||||||
|
renderer.uvRotateBottom = 2;
|
||||||
|
renderer.uvRotateNorth = 3;
|
||||||
|
}
|
||||||
|
|
||||||
renderer.setRenderBounds((double)0, 0.0D, (double)0, (double)1, 0.125D, (double)1);
|
renderer.setRenderBounds((double) 0, 0.0D, (double) 0, (double) 1, 0.25D, (double) 1);
|
||||||
renderer.renderStandardBlock(block, x, y, z);
|
renderer.renderStandardBlock(block, x, y, z);
|
||||||
renderer.uvRotateTop = 0;
|
renderer.uvRotateTop = 0;
|
||||||
|
renderer.uvRotateBottom = 0;
|
||||||
|
renderer.uvRotateNorth = 0;
|
||||||
|
renderer.uvRotateSouth = 0;
|
||||||
|
renderer.uvRotateEast = 0;
|
||||||
|
renderer.uvRotateWest = 0;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
src/main/resources/assets/hbm/textures/blocks/conveyor_side.png
Normal file
BIN
src/main/resources/assets/hbm/textures/blocks/conveyor_side.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 205 B |
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"animation": { }
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user