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,43 +1,70 @@
|
||||
package com.hbm.blocks.network;
|
||||
|
||||
import com.hbm.entity.item.EntityMovingItem;
|
||||
import com.hbm.lib.RefStrings;
|
||||
|
||||
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.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockConveyor extends Block {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
protected IIcon sideIcon;
|
||||
|
||||
public BlockConveyor(Material p_i45394_1_) {
|
||||
super(p_i45394_1_);
|
||||
}
|
||||
|
||||
@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(entity instanceof EntityItem && entity.ticksExisted > 10 && !entity.isDead) {
|
||||
|
||||
|
||||
EntityMovingItem item = new EntityMovingItem(world);
|
||||
item.setItemStack(((EntityItem)entity).getEntityItem());
|
||||
item.setPositionAndRotation(x + 0.5, y + 0.125, z + 0.5, 0, 0);
|
||||
item.setItemStack(((EntityItem) entity).getEntityItem());
|
||||
item.setPositionAndRotation(x + 0.5, y + 0.25, z + 0.5, 0, 0);
|
||||
world.spawnEntityInWorld(item);
|
||||
|
||||
|
||||
entity.setDead();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static int renderID = RenderingRegistry.getNextAvailableRenderId();
|
||||
|
||||
public static int renderID = RenderingRegistry.getNextAvailableRenderId();
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
@ -53,35 +80,31 @@ public class BlockConveyor extends Block {
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
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
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
|
||||
return AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y, z + 1);
|
||||
}
|
||||
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
|
||||
return AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 0.25, z + 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
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;
|
||||
|
||||
if(i == 0)
|
||||
{
|
||||
|
||||
if(i == 0) {
|
||||
world.setBlockMetadataWithNotify(x, y, z, 2, 2);
|
||||
}
|
||||
if(i == 1)
|
||||
{
|
||||
if(i == 1) {
|
||||
world.setBlockMetadataWithNotify(x, y, z, 5, 2);
|
||||
}
|
||||
if(i == 2)
|
||||
{
|
||||
if(i == 2) {
|
||||
world.setBlockMetadataWithNotify(x, y, z, 3, 2);
|
||||
}
|
||||
if(i == 3)
|
||||
{
|
||||
if(i == 3) {
|
||||
world.setBlockMetadataWithNotify(x, y, z, 4, 2);
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,38 +88,34 @@ public class EntityMovingItem extends Entity {
|
||||
worldObj.spawnEntityInWorld(item);
|
||||
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.1;
|
||||
|
||||
if(worldObj.getBlock((int)Math.floor(posX), (int)Math.floor(posY), (int)Math.floor(posZ)) == ModBlocks.conveyor) {
|
||||
|
||||
schedule = (int) (1 / speed);
|
||||
motionX = -speed * dir.offsetX;
|
||||
motionY = -speed * dir.offsetY;
|
||||
motionZ = -speed * dir.offsetZ;
|
||||
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;
|
||||
}
|
||||
|
||||
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--;
|
||||
schedule--;
|
||||
}
|
||||
}
|
||||
this.moveEntity(motionX, motionY, motionZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -20,45 +20,61 @@ public class RenderConveyor implements ISimpleBlockRenderingHandler {
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {
|
||||
|
||||
GL11.glPushMatrix();
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
IIcon iicon = block.getIcon(0, 0);
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
IIcon iicon = block.getIcon(0, 0);
|
||||
tessellator.setColorOpaque_F(1, 1, 1);
|
||||
|
||||
if (renderer.hasOverrideBlockTexture())
|
||||
{
|
||||
iicon = renderer.overrideBlockTexture;
|
||||
}
|
||||
|
||||
GL11.glTranslated(0, -0.125, 0);
|
||||
tessellator.startDrawingQuads();
|
||||
ObjUtil.renderWithIcon((WavefrontObject) ResourceManager.arrow, iicon, tessellator, 0, false);
|
||||
if(renderer.hasOverrideBlockTexture()) {
|
||||
iicon = renderer.overrideBlockTexture;
|
||||
}
|
||||
|
||||
GL11.glTranslated(0, -0.125, 0);
|
||||
tessellator.startDrawingQuads();
|
||||
ObjUtil.renderWithIcon((WavefrontObject) ResourceManager.arrow, iicon, tessellator, 0, false);
|
||||
tessellator.draw();
|
||||
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
|
||||
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
|
||||
tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
|
||||
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
|
||||
tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
|
||||
tessellator.setColorOpaque_F(1, 1, 1);
|
||||
|
||||
if(meta == 2)
|
||||
if(meta == 2) {
|
||||
renderer.uvRotateTop = 3;
|
||||
if(meta == 3)
|
||||
renderer.uvRotateBottom = 0;
|
||||
renderer.uvRotateWest = 3;
|
||||
}
|
||||
if(meta == 3) {
|
||||
renderer.uvRotateTop = 0;
|
||||
if(meta == 4)
|
||||
renderer.uvRotateBottom = 3;
|
||||
renderer.uvRotateEast = 3;
|
||||
}
|
||||
if(meta == 4) {
|
||||
renderer.uvRotateTop = 1;
|
||||
if(meta == 5)
|
||||
renderer.uvRotateBottom = 1;
|
||||
renderer.uvRotateSouth = 3;
|
||||
}
|
||||
if(meta == 5) {
|
||||
renderer.uvRotateTop = 2;
|
||||
|
||||
renderer.setRenderBounds((double)0, 0.0D, (double)0, (double)1, 0.125D, (double)1);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.uvRotateTop = 0;
|
||||
|
||||
renderer.uvRotateBottom = 2;
|
||||
renderer.uvRotateNorth = 3;
|
||||
}
|
||||
|
||||
renderer.setRenderBounds((double) 0, 0.0D, (double) 0, (double) 1, 0.25D, (double) 1);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.uvRotateTop = 0;
|
||||
renderer.uvRotateBottom = 0;
|
||||
renderer.uvRotateNorth = 0;
|
||||
renderer.uvRotateSouth = 0;
|
||||
renderer.uvRotateEast = 0;
|
||||
renderer.uvRotateWest = 0;
|
||||
|
||||
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