Made Laser Relay sit on walls when placed on them

This commit is contained in:
Ellpeck 2015-10-23 14:24:12 +02:00
parent 606a0d80a4
commit 247122c312
5 changed files with 74 additions and 7 deletions

View file

@ -81,16 +81,16 @@ public class BlockCoffeeMachine extends BlockContainerBase implements IActAddIte
int rotation = MathHelper.floor_double((double)(player.rotationYaw*4.0F/360.0F)+0.5D) & 3; int rotation = MathHelper.floor_double((double)(player.rotationYaw*4.0F/360.0F)+0.5D) & 3;
if(rotation == 0){ if(rotation == 0){
world.setBlockMetadataWithNotify(x, y, z, 2, 0); world.setBlockMetadataWithNotify(x, y, z, 2, 2);
} }
if(rotation == 1){ if(rotation == 1){
world.setBlockMetadataWithNotify(x, y, z, 1, 3); world.setBlockMetadataWithNotify(x, y, z, 1, 2);
} }
if(rotation == 2){ if(rotation == 2){
world.setBlockMetadataWithNotify(x, y, z, 0, 2); world.setBlockMetadataWithNotify(x, y, z, 0, 2);
} }
if(rotation == 3){ if(rotation == 3){
world.setBlockMetadataWithNotify(x, y, z, 3, 3); world.setBlockMetadataWithNotify(x, y, z, 3, 2);
} }
} }

View file

@ -34,9 +34,6 @@ public class BlockLaserRelay extends BlockContainerBase implements IActAddItemOr
this.setHardness(1.5F); this.setHardness(1.5F);
this.setResistance(10.0F); this.setResistance(10.0F);
this.setStepSound(soundTypeStone); this.setStepSound(soundTypeStone);
float f = 1F/16F;
this.setBlockBounds(2*f, 0F, 2*f, 1-2*f, 1-1*f, 1-2*f);
} }
@Override @Override
@ -44,6 +41,11 @@ public class BlockLaserRelay extends BlockContainerBase implements IActAddItemOr
return false; return false;
} }
@Override
public int onBlockPlaced(World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata){
return side;
}
@Override @Override
public int getRenderType(){ public int getRenderType(){
return AssetUtil.LASER_RELAY_RENDER_ID; return AssetUtil.LASER_RELAY_RENDER_ID;

View file

@ -198,4 +198,9 @@ public class ModelLaserRelay extends ModelBaseAA{
model.rotateAngleY = y; model.rotateAngleY = y;
model.rotateAngleZ = z; model.rotateAngleZ = z;
} }
@Override
public boolean doesRotate(){
return true;
}
} }

View file

@ -0,0 +1,60 @@
/*
* This file ("RenderLaserRelay.java") is part of the Actually Additions Mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015 Ellpeck
*/
package ellpeck.actuallyadditions.blocks.render;
import net.minecraft.tileentity.TileEntity;
import org.lwjgl.opengl.GL11;
public class RenderLaserRelay extends RenderTileEntity{
public RenderLaserRelay(ModelBaseAA model){
super(model);
}
@Override
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float par5){
GL11.glPushMatrix();
GL11.glTranslatef((float)x+0.5F, (float)y-0.5F, (float)z+0.5F);
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
GL11.glTranslatef(0.0F, -2.0F, 0.0F);
this.bindTexture(resLoc);
if(theModel.doesRotate()){
int meta = tile.getWorldObj().getBlockMetadata(tile.xCoord, tile.yCoord, tile.zCoord);
if(meta == 0){
GL11.glRotatef(180F, 1F, 0F, 0F);
GL11.glTranslatef(0F, -2F, 0F);
}
if(meta == 3){
GL11.glRotatef(-90, 1F, 0F, 0F);
GL11.glTranslatef(0F, -1F, 1F);
}
if(meta == 2){
GL11.glRotatef(90, 1F, 0F, 0F);
GL11.glTranslatef(0F, -1F, -1F);
}
if(meta == 4){
GL11.glRotatef(90, 0F, 0F, 1F);
GL11.glTranslatef(1F, -1F, 0F);
}
if(meta == 5){
GL11.glRotatef(90, 0F, 0F, -1F);
GL11.glTranslatef(-1F, -1F, 0F);
}
}
theModel.render(0.0625F);
theModel.renderExtra(0.0625F, tile);
GL11.glPopMatrix();
}
}

View file

@ -82,7 +82,7 @@ public class ClientProxy implements IProxy{
ClientRegistry.bindTileEntitySpecialRenderer(TileEntitySmileyCloud.class, new RenderSmileyCloud(new ModelSmileyCloud())); ClientRegistry.bindTileEntitySpecialRenderer(TileEntitySmileyCloud.class, new RenderSmileyCloud(new ModelSmileyCloud()));
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(InitBlocks.blockSmileyCloud), new RenderItems(new ModelSmileyCloud())); MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(InitBlocks.blockSmileyCloud), new RenderItems(new ModelSmileyCloud()));
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityLaserRelay.class, new RenderTileEntity(new ModelLaserRelay())); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityLaserRelay.class, new RenderLaserRelay(new ModelLaserRelay()));
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(InitBlocks.blockLaserRelay), new RenderItems(new ModelLaserRelay())); MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(InitBlocks.blockLaserRelay), new RenderItems(new ModelLaserRelay()));
VillagerRegistry.instance().registerVillagerSkin(ConfigIntValues.JAM_VILLAGER_ID.getValue(), new ResourceLocation(ModUtil.MOD_ID_LOWER, "textures/entity/villager/jamVillager.png")); VillagerRegistry.instance().registerVillagerSkin(ConfigIntValues.JAM_VILLAGER_ID.getValue(), new ResourceLocation(ModUtil.MOD_ID_LOWER, "textures/entity/villager/jamVillager.png"));