mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 08:48:34 +01:00
Made Laser Relay sit on walls when placed on them
This commit is contained in:
parent
606a0d80a4
commit
247122c312
5 changed files with 74 additions and 7 deletions
|
@ -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;
|
||||
|
||||
if(rotation == 0){
|
||||
world.setBlockMetadataWithNotify(x, y, z, 2, 0);
|
||||
world.setBlockMetadataWithNotify(x, y, z, 2, 2);
|
||||
}
|
||||
if(rotation == 1){
|
||||
world.setBlockMetadataWithNotify(x, y, z, 1, 3);
|
||||
world.setBlockMetadataWithNotify(x, y, z, 1, 2);
|
||||
}
|
||||
if(rotation == 2){
|
||||
world.setBlockMetadataWithNotify(x, y, z, 0, 2);
|
||||
}
|
||||
if(rotation == 3){
|
||||
world.setBlockMetadataWithNotify(x, y, z, 3, 3);
|
||||
world.setBlockMetadataWithNotify(x, y, z, 3, 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,9 +34,6 @@ public class BlockLaserRelay extends BlockContainerBase implements IActAddItemOr
|
|||
this.setHardness(1.5F);
|
||||
this.setResistance(10.0F);
|
||||
this.setStepSound(soundTypeStone);
|
||||
|
||||
float f = 1F/16F;
|
||||
this.setBlockBounds(2*f, 0F, 2*f, 1-2*f, 1-1*f, 1-2*f);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -44,6 +41,11 @@ public class BlockLaserRelay extends BlockContainerBase implements IActAddItemOr
|
|||
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
|
||||
public int getRenderType(){
|
||||
return AssetUtil.LASER_RELAY_RENDER_ID;
|
||||
|
|
|
@ -198,4 +198,9 @@ public class ModelLaserRelay extends ModelBaseAA{
|
|||
model.rotateAngleY = y;
|
||||
model.rotateAngleZ = z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesRotate(){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
|
@ -82,7 +82,7 @@ public class ClientProxy implements IProxy{
|
|||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntitySmileyCloud.class, new RenderSmileyCloud(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()));
|
||||
|
||||
VillagerRegistry.instance().registerVillagerSkin(ConfigIntValues.JAM_VILLAGER_ID.getValue(), new ResourceLocation(ModUtil.MOD_ID_LOWER, "textures/entity/villager/jamVillager.png"));
|
||||
|
|
Loading…
Reference in a new issue