mirror of
https://github.com/GTNewHorizons/Chisel.git
synced 2026-11-17 19:25:06 +00:00
first commit
This commit is contained in:
commit
c79c767bb8
1389 files changed
+10744
No files matched your search
@@ -0,0 +1,5 @@
|
||||
package info.jbcs.minecraft.chisel;
|
||||
|
||||
public interface Carvable {
|
||||
CarvableVariation getVariation(int metadata);
|
||||
}
|
||||
@@ -0,0 +1,393 @@
|
||||
package info.jbcs.minecraft.chisel;
|
||||
|
||||
import info.jbcs.minecraft.chisel.CarvableVariation.CarvableVariationCTM;
|
||||
import info.jbcs.minecraft.chisel.block.BlockMarbleSlab;
|
||||
import info.jbcs.minecraft.chisel.item.ItemCarvable;
|
||||
import info.jbcs.minecraft.chisel.render.CTM;
|
||||
import info.jbcs.minecraft.chisel.render.TextureSubmap;
|
||||
import info.jbcs.minecraft.utilities.GeneralClient;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockPane;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
|
||||
public class CarvableHelper {
|
||||
static final String modName = "chisel";
|
||||
public static final ArrayList<Block> chiselBlocks = new ArrayList<Block>();
|
||||
|
||||
public static final int NORMAL = 0;
|
||||
public static final int TOPSIDE = 1;
|
||||
public static final int TOPBOTSIDE = 2;
|
||||
public static final int CTM3 = 3;
|
||||
public static final int CTMV = 4;
|
||||
public static final int CTMH = 5;
|
||||
public static final int V9 = 6;
|
||||
public static final int V4 = 7;
|
||||
public static final int CTMX = 8;
|
||||
|
||||
|
||||
public CarvableHelper() {
|
||||
}
|
||||
|
||||
public ArrayList<CarvableVariation> variations = new ArrayList<CarvableVariation>();
|
||||
CarvableVariation[] map = new CarvableVariation[16];
|
||||
public boolean forbidChiseling = false;
|
||||
String blockName;
|
||||
|
||||
public void addVariation(String description, int metadata, Block bb) {
|
||||
addVariation(description, metadata, null, bb, 0);
|
||||
}
|
||||
|
||||
public void addVariation(String description, int metadata, Block bb, int blockMeta) {
|
||||
addVariation(description, metadata, null, bb, blockMeta);
|
||||
}
|
||||
|
||||
public void addVariation(String description, int metadata, String texture) {
|
||||
addVariation(description, metadata, texture, null, 0);
|
||||
}
|
||||
|
||||
public void addVariation(String description, int metadata, String texture, Block block, int blockMeta) {
|
||||
if (variations.size() > 15)
|
||||
return;
|
||||
|
||||
if(blockName==null && block!=null) blockName=block.getLocalizedName();
|
||||
else if(blockName==null && description!=null) blockName=description;
|
||||
|
||||
CarvableVariation variation = new CarvableVariation();
|
||||
variation.description = description;
|
||||
variation.metadata = metadata;
|
||||
variation.blockName = blockName;
|
||||
|
||||
if (texture != null) {
|
||||
variation.texture = texture;
|
||||
|
||||
String path = "/assets/" + modName + "/textures/blocks/" + variation.texture;
|
||||
|
||||
boolean any = Chisel.class.getResource(path + ".png") != null;
|
||||
boolean ctm3 = Chisel.class.getResource(path + "-ctm1.png") != null && Chisel.class.getResource(path + "-ctm2.png") != null && Chisel.class.getResource(path + "-ctm3.png") != null;
|
||||
boolean ctmv = Chisel.class.getResource(path + "-ctmv.png") != null;
|
||||
boolean ctmh = Chisel.class.getResource(path + "-ctmh.png") != null;
|
||||
boolean side = Chisel.class.getResource(path + "-side.png") != null;
|
||||
boolean top = Chisel.class.getResource(path + "-top.png") != null;
|
||||
boolean bot = Chisel.class.getResource(path + "-bottom.png") != null;
|
||||
boolean v9 = Chisel.class.getResource(path + "-v9.png") != null;
|
||||
boolean v4 = Chisel.class.getResource(path + "-v4.png") != null;
|
||||
boolean ctmx = Chisel.class.getResource(path + "-ctm.png") != null;
|
||||
|
||||
if (ctm3) {
|
||||
variation.kind = 3;
|
||||
} else if (ctmh && top) {
|
||||
variation.kind = 5;
|
||||
} else if (ctmv && top) {
|
||||
variation.kind = CTMV;
|
||||
} else if (bot && top && side) {
|
||||
variation.kind = 2;
|
||||
} else if (top && side) {
|
||||
variation.kind = 1;
|
||||
} else if (v9) {
|
||||
variation.kind = V9;
|
||||
} else if (v4) {
|
||||
variation.kind = V4;
|
||||
} else if (any && ctmx && !Chisel.disableCTM) {
|
||||
variation.kind = CTMX;
|
||||
} else if (any) {
|
||||
variation.kind = 0;
|
||||
} else {
|
||||
throw new RuntimeException("No valid textures found for chisel block variation '" + description + "' (" + variation.texture + ")");
|
||||
}
|
||||
} else {
|
||||
variation.block = block;
|
||||
variation.kind = 2;
|
||||
variation.blockMeta = blockMeta;
|
||||
}
|
||||
|
||||
variations.add(variation);
|
||||
map[metadata] = variation;
|
||||
}
|
||||
|
||||
public CarvableVariation getVariation(int metadata){
|
||||
if (metadata < 0 || metadata > 15)
|
||||
metadata = 0;
|
||||
|
||||
CarvableVariation variation = map[metadata];
|
||||
if (variation == null)
|
||||
return null;
|
||||
|
||||
// if(variation.kind!=CTMX)
|
||||
// return null;
|
||||
|
||||
return variation;
|
||||
}
|
||||
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
if (metadata < 0 || metadata > 15)
|
||||
metadata = 0;
|
||||
|
||||
CarvableVariation variation = map[metadata];
|
||||
if (variation == null)
|
||||
return GeneralClient.getMissingIcon();
|
||||
|
||||
switch (variation.kind) {
|
||||
case 0:
|
||||
return variation.icon;
|
||||
case 1:
|
||||
if (side == 0 || side == 1)
|
||||
return variation.iconTop;
|
||||
else
|
||||
return variation.icon;
|
||||
case 2:
|
||||
if (side == 1)
|
||||
return variation.iconTop;
|
||||
else if (side == 0)
|
||||
return variation.iconBot;
|
||||
else
|
||||
return variation.icon;
|
||||
case 3:
|
||||
return variation.ctm.seams[0].icons[0];
|
||||
case 4:
|
||||
if (side < 2)
|
||||
return variation.iconTop;
|
||||
else
|
||||
return variation.seamsCtmVert.icons[0];
|
||||
case 5:
|
||||
if (side < 2)
|
||||
return variation.iconTop;
|
||||
else
|
||||
return variation.seamsCtmVert.icons[0];
|
||||
case V9:
|
||||
return variation.variations9.icons[4];
|
||||
case V4:
|
||||
return variation.variations9.icons[0];
|
||||
case CTMX:
|
||||
return variation.icon;
|
||||
}
|
||||
|
||||
return GeneralClient.getMissingIcon();
|
||||
}
|
||||
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
||||
int metadata=world.getBlockMetadata(x, y, z);
|
||||
|
||||
if (metadata < 0 || metadata > 15)
|
||||
metadata = 0;
|
||||
|
||||
CarvableVariation variation = map[metadata];
|
||||
if (variation == null)
|
||||
return GeneralClient.getMissingIcon();
|
||||
|
||||
switch (variation.kind) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
return getIcon(side,metadata);
|
||||
case 3:
|
||||
int tex = CTM.getTexture(world, x, y, z, side);
|
||||
|
||||
int row = tex / 16;
|
||||
int col = tex % 16;
|
||||
|
||||
return variation.ctm.seams[col / 4].icons[col % 4 + row * 4];
|
||||
case 4: {
|
||||
if(side<2)
|
||||
return variation.iconTop;
|
||||
|
||||
Block block = world.getBlock(x, y, z);
|
||||
boolean topConnected= block.equals(world.getBlock(x, y+1, z)) && metadata==world.getBlockMetadata(x, y+1, z);
|
||||
boolean botConnected= block.equals(world.getBlock(x, y-1, z)) && metadata==world.getBlockMetadata(x, y-1, z);
|
||||
|
||||
if( topConnected && botConnected) return variation.seamsCtmVert.icons[2];
|
||||
if( topConnected && !botConnected) return variation.seamsCtmVert.icons[3];
|
||||
if(!topConnected && botConnected) return variation.seamsCtmVert.icons[1];
|
||||
return variation.seamsCtmVert.icons[0]; }
|
||||
case 5:
|
||||
if(side<2)
|
||||
return variation.iconTop;
|
||||
|
||||
Block block = world.getBlock(x, y, z);
|
||||
|
||||
boolean p;
|
||||
boolean n;
|
||||
boolean reverse=side==2||side==4;
|
||||
|
||||
if(side<4){
|
||||
p=isSame(world,x-1,y,z,block,metadata);
|
||||
n=isSame(world,x+1,y,z,block,metadata);
|
||||
} else{
|
||||
p=isSame(world,x,y,z+1,block,metadata);
|
||||
n=isSame(world,x,y,z-1,block,metadata);
|
||||
}
|
||||
|
||||
if(p && n) return variation.seamsCtmVert.icons[1];
|
||||
else if(p) return variation.seamsCtmVert.icons[reverse?2:3];
|
||||
else if(n) return variation.seamsCtmVert.icons[reverse?3:2];
|
||||
return variation.seamsCtmVert.icons[0];
|
||||
case V9:
|
||||
case V4:
|
||||
int index=x+y*606731+z*571163+side*555491;
|
||||
if(index<0) index=-index;
|
||||
|
||||
return variation.variations9.icons[index%((variation.kind==V9)?9:4)];
|
||||
case CTMX:
|
||||
return variation.icon;
|
||||
}
|
||||
|
||||
return GeneralClient.getMissingIcon();
|
||||
}
|
||||
|
||||
void register(Block block, String name) {
|
||||
register(block, name, ItemCarvable.class);
|
||||
}
|
||||
|
||||
void register(Block block, String name, Class cl) {
|
||||
block.setBlockName(name);
|
||||
GameRegistry.registerBlock(block, cl, name);
|
||||
|
||||
if (block instanceof BlockMarbleSlab) {
|
||||
BlockMarbleSlab slab = (BlockMarbleSlab) block;
|
||||
GameRegistry.registerBlock(slab.top, cl, name + ".top");
|
||||
}
|
||||
|
||||
for (CarvableVariation variation : variations) {
|
||||
registerVariation(name, variation, block, variation.metadata);
|
||||
|
||||
if (block instanceof BlockMarbleSlab && ((BlockMarbleSlab) block).isBottom) {
|
||||
BlockMarbleSlab slab = (BlockMarbleSlab) block;
|
||||
slab.top.setHarvestLevel("chisel", 0, variation.metadata);
|
||||
|
||||
slab.top.setHardness(slab.blockHardness).setResistance(slab.blockResistance);
|
||||
|
||||
if(! forbidChiseling){
|
||||
Carving.chisel.addVariation(name + ".top", slab.top, variation.metadata, 0);
|
||||
Carving.chisel.setGroupClass(name + ".top", name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
chiselBlocks.add(block);
|
||||
}
|
||||
|
||||
public void registerVariation(String name, CarvableVariation variation, Block block, int blockMeta) {
|
||||
|
||||
LanguageRegistry.addName(new ItemStack(block, 1, blockMeta),
|
||||
Chisel.blockDescriptions?
|
||||
variation.blockName:
|
||||
variation.description
|
||||
);
|
||||
|
||||
if(forbidChiseling) return;
|
||||
|
||||
if (variation.block == null) {
|
||||
Carving.chisel.addVariation(name, block, blockMeta, variation.metadata);
|
||||
block.setHarvestLevel("chisel", 0, blockMeta);
|
||||
} else {
|
||||
Carving.chisel.addVariation(name, variation.block, variation.blockMeta, variation.metadata);
|
||||
variation.block.setHarvestLevel("chisel", 0, variation.blockMeta);
|
||||
}
|
||||
}
|
||||
|
||||
public void registerBlockIcons(String modName, Block block, IIconRegister register) {
|
||||
for (CarvableVariation variation : variations) {
|
||||
if (variation.block != null) {
|
||||
variation.block.registerBlockIcons(register);
|
||||
|
||||
if (variation.block instanceof BlockPane) {
|
||||
variation.icon = variation.block.getBlockTextureFromSide(2);
|
||||
variation.iconTop = ((BlockPane) variation.block).getBlockTextureFromSide(0);
|
||||
variation.iconBot = ((BlockPane) variation.block).getBlockTextureFromSide(0);
|
||||
} else {
|
||||
switch (variation.kind) {
|
||||
case 0:
|
||||
variation.icon = variation.block.getIcon(2, variation.blockMeta);
|
||||
break;
|
||||
case 1:
|
||||
variation.icon = variation.block.getIcon(2, variation.blockMeta);
|
||||
variation.iconTop = variation.block.getIcon(0, variation.blockMeta);
|
||||
break;
|
||||
case 2:
|
||||
variation.icon = variation.block.getIcon(2, variation.blockMeta);
|
||||
variation.iconTop = variation.block.getIcon(1, variation.blockMeta);
|
||||
variation.iconBot = variation.block.getIcon(0, variation.blockMeta);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
switch (variation.kind) {
|
||||
case 0:
|
||||
variation.icon = register.registerIcon(modName + ":" + variation.texture);
|
||||
break;
|
||||
case 1:
|
||||
variation.icon = register.registerIcon(modName + ":" + variation.texture + "-side");
|
||||
variation.iconTop = register.registerIcon(modName + ":" + variation.texture + "-top");
|
||||
break;
|
||||
case 2:
|
||||
variation.icon = register.registerIcon(modName + ":" + variation.texture + "-side");
|
||||
variation.iconTop = register.registerIcon(modName + ":" + variation.texture + "-top");
|
||||
variation.iconBot = register.registerIcon(modName + ":" + variation.texture + "-bottom");
|
||||
break;
|
||||
case 3:
|
||||
CarvableVariationCTM ctm=new CarvableVariationCTM();
|
||||
ctm.seams[0]=new TextureSubmap(register.registerIcon(modName + ":" + variation.texture+"-ctm1"),4,4);
|
||||
ctm.seams[1]=new TextureSubmap(register.registerIcon(modName + ":" + variation.texture+"-ctm2"),4,4);
|
||||
ctm.seams[2]=new TextureSubmap(register.registerIcon(modName + ":" + variation.texture+"-ctm3"),4,4);
|
||||
variation.ctm=ctm;
|
||||
break;
|
||||
case 4:
|
||||
variation.seamsCtmVert=new TextureSubmap(register.registerIcon(modName + ":" + variation.texture+"-ctmv"),2,2);
|
||||
variation.iconTop = register.registerIcon(modName + ":" + variation.texture + "-top");
|
||||
break;
|
||||
case 5:
|
||||
variation.seamsCtmVert=new TextureSubmap(register.registerIcon(modName + ":" + variation.texture+"-ctmh"),2,2);
|
||||
variation.iconTop = register.registerIcon(modName + ":" + variation.texture + "-top");
|
||||
break;
|
||||
case V9:
|
||||
variation.variations9=new TextureSubmap(register.registerIcon(modName + ":" + variation.texture+"-v9"),3,3);
|
||||
break;
|
||||
case V4:
|
||||
variation.variations9=new TextureSubmap(register.registerIcon(modName + ":" + variation.texture+"-v4"),2,2);
|
||||
break;
|
||||
case CTMX:
|
||||
variation.icon=register.registerIcon(modName + ":" + variation.texture);
|
||||
variation.submap=new TextureSubmap(register.registerIcon(modName + ":" + variation.texture+"-ctm"),4,4);
|
||||
variation.submapSmall=new TextureSubmap(variation.icon,2,2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void registerSubBlocks(Block block, CreativeTabs tabs, List list) {
|
||||
for (CarvableVariation variation : variations) {
|
||||
if ((!Chisel.overrideVanillaBlocks) && variation.block != null)
|
||||
continue;
|
||||
|
||||
list.add(new ItemStack(block, 1, variation.metadata));
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isSame(IBlockAccess world, int x, int y, int z,Block block,int meta) {
|
||||
return world.getBlock(x,y,z).equals(block) && world.getBlockMetadata(x, y, z) == meta;
|
||||
}
|
||||
|
||||
public void setBlockName(String name) {
|
||||
blockName=name;
|
||||
}
|
||||
|
||||
public static Set<Block> getChiselBlockSet() {
|
||||
HashSet<Block> tools = new HashSet<Block>();
|
||||
tools.addAll(CarvableHelper.chiselBlocks);
|
||||
return tools;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package info.jbcs.minecraft.chisel;
|
||||
|
||||
import info.jbcs.minecraft.chisel.render.TextureSubmap;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
public class CarvableVariation {
|
||||
String blockName;
|
||||
public String description;
|
||||
int metadata;
|
||||
public int kind;
|
||||
|
||||
Block block;
|
||||
int blockMeta;
|
||||
|
||||
String texture;
|
||||
|
||||
public IIcon icon;
|
||||
public IIcon iconTop;
|
||||
public IIcon iconBot;
|
||||
|
||||
public CarvableVariationCTM ctm;
|
||||
public TextureSubmap seamsCtmVert;
|
||||
public TextureSubmap variations9;
|
||||
|
||||
public TextureSubmap submap;
|
||||
public TextureSubmap submapSmall;
|
||||
|
||||
static class CarvableVariationCTM {
|
||||
TextureSubmap seams[] = new TextureSubmap[3];
|
||||
}
|
||||
|
||||
}
|
||||
+174
@@ -0,0 +1,174 @@
|
||||
package info.jbcs.minecraft.chisel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public class Carving {
|
||||
class CarvingGroup{
|
||||
public CarvingGroup(String n) {
|
||||
name=n;
|
||||
}
|
||||
|
||||
String name;
|
||||
String className;
|
||||
String sound;
|
||||
String oreName;
|
||||
|
||||
ArrayList<CarvingVariation> variations=new ArrayList<CarvingVariation>();
|
||||
};
|
||||
|
||||
HashMap<String,CarvingGroup> carvingGroupsByName=new HashMap<String,CarvingGroup>();
|
||||
HashMap<String,CarvingGroup> carvingGroupsByOre=new HashMap<String,CarvingGroup>();
|
||||
HashMap<String,CarvingGroup> carvingGroupsByVariation=new HashMap<String,CarvingGroup>();
|
||||
|
||||
public static Carving chisel=new Carving();
|
||||
public static Carving needle=new Carving();
|
||||
|
||||
String key(Item item,int metadata){
|
||||
return Item.getIdFromItem(item)+"|"+metadata;
|
||||
}
|
||||
|
||||
String key(Block block, int metadata){
|
||||
return Block.getIdFromBlock(block)+"|"+metadata;
|
||||
}
|
||||
|
||||
public boolean isVariationOfSameClass(Block target,int metadata1, Block block2, int metadata2){
|
||||
CarvingGroup group1=carvingGroupsByVariation.get(key(target,metadata1));
|
||||
if(group1==null) return false;
|
||||
|
||||
CarvingGroup group2=carvingGroupsByVariation.get(key(block2,metadata2));
|
||||
if(group2==null) return false;
|
||||
|
||||
if(group1==group2)
|
||||
return true;
|
||||
|
||||
return group1.className.equals(group2.className) && ! group1.className.isEmpty();
|
||||
}
|
||||
|
||||
public CarvingVariation[] getVariations(Block block,int metadata){
|
||||
CarvingGroup group=getGroup(block,metadata);
|
||||
if(group==null) return null;
|
||||
|
||||
CarvingVariation[] res=group.variations.toArray(new CarvingVariation[group.variations.size()]);
|
||||
return res;
|
||||
}
|
||||
|
||||
public String getOre(Block block,int metadata){
|
||||
CarvingGroup group=getGroup(block,metadata);
|
||||
if(group==null) return null;
|
||||
|
||||
return group.oreName;
|
||||
}
|
||||
|
||||
public ArrayList<ItemStack> getItems(ItemStack chiseledItem) {
|
||||
ArrayList<ItemStack> items=new ArrayList<ItemStack>();
|
||||
int damage=chiseledItem.getItemDamage();
|
||||
|
||||
CarvingGroup group=getGroup(Block.getBlockFromItem(chiseledItem.getItem()),damage);
|
||||
if(group==null) return items;
|
||||
|
||||
HashMap<String,Integer> mapping=new HashMap<String,Integer>();
|
||||
|
||||
if (group.variations != null) {
|
||||
for (CarvingVariation v: group.variations) {
|
||||
|
||||
String key=Block.getIdFromBlock(v.block)+"|"+v.damage;
|
||||
if(mapping.containsKey(key)) continue;
|
||||
mapping.put(key, 1);
|
||||
|
||||
items.add(new ItemStack(v.block, 1, v.damage));
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList<ItemStack> ores;
|
||||
if(group.oreName!=null && ((ores=OreDictionary.getOres(group.oreName))!=null)){
|
||||
for(ItemStack stack: ores){
|
||||
|
||||
String key=Item.getIdFromItem(stack.getItem())+"|"+stack.getItemDamage();
|
||||
if(mapping.containsKey(key)) continue;
|
||||
mapping.put(key, 2);
|
||||
|
||||
items.add(stack);
|
||||
}
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
public CarvingGroup getGroup(Block block,int metadata) {
|
||||
if(block.equals(Blocks.stone)) block=Blocks.stonebrick;
|
||||
|
||||
CarvingGroup res;
|
||||
|
||||
if((res=carvingGroupsByOre.get(OreDictionary.getOreName(OreDictionary.getOreID(new ItemStack(block,1,metadata)))))!=null)
|
||||
return res;
|
||||
|
||||
if((res=carvingGroupsByVariation.get(key(block,metadata)))!=null)
|
||||
return res;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
CarvingGroup getGroup(String name){
|
||||
CarvingGroup group=carvingGroupsByName.get(name);
|
||||
if(group==null){
|
||||
group=new CarvingGroup(name);
|
||||
group.className=name;
|
||||
carvingGroupsByName.put(name,group);
|
||||
}
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
public CarvingVariation addVariation(String name,Block block,int metadata,int order){
|
||||
CarvingGroup group=getGroup(name);
|
||||
|
||||
CarvingGroup blockGroup=carvingGroupsByVariation.get(key(block,metadata));
|
||||
if(blockGroup!=null || blockGroup==group) return null;
|
||||
|
||||
CarvingVariation variation=new CarvingVariation(block,metadata,order);
|
||||
group.variations.add(variation);
|
||||
Collections.sort(group.variations);
|
||||
carvingGroupsByVariation.put(key(block,metadata), group);
|
||||
|
||||
return variation;
|
||||
}
|
||||
|
||||
|
||||
public void registerOre(String name, String oreName) {
|
||||
CarvingGroup group=getGroup(name);
|
||||
|
||||
carvingGroupsByOre.put(oreName, group);
|
||||
|
||||
group.oreName=oreName;
|
||||
}
|
||||
|
||||
public void setGroupClass(String name,String className){
|
||||
CarvingGroup group=getGroup(name);
|
||||
|
||||
group.className=className;
|
||||
}
|
||||
|
||||
public void setVariationSound(String name, String sound) {
|
||||
CarvingGroup group=getGroup(name);
|
||||
group.sound=sound;
|
||||
}
|
||||
|
||||
public String getVariationSound(Block block,int metadata) {
|
||||
return getVariationSound(Item.getItemFromBlock(block), metadata);
|
||||
}
|
||||
public String getVariationSound(Item item,int metadata) {
|
||||
CarvingGroup blockGroup=carvingGroupsByVariation.get(key(item,metadata));
|
||||
if(blockGroup==null || blockGroup.sound==null) return "chisel:chisel";
|
||||
|
||||
return blockGroup.sound;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package info.jbcs.minecraft.chisel;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
public class CarvingVariation implements Comparable {
|
||||
public CarvingVariation(Block block, int metadata, int ord) {
|
||||
this.order=ord;
|
||||
this.block=block;
|
||||
this.meta=metadata;
|
||||
this.damage=metadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Object a) {
|
||||
return order-((CarvingVariation)a).order;
|
||||
}
|
||||
|
||||
public int order;
|
||||
public Block block;
|
||||
public int meta;
|
||||
public int damage;
|
||||
}
|
||||
+1212
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,118 @@
|
||||
package info.jbcs.minecraft.chisel;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
|
||||
public class ChiselModCompatibility {
|
||||
|
||||
|
||||
abstract class ClassCompat{
|
||||
Class cl;
|
||||
|
||||
public ClassCompat(String name){
|
||||
try {
|
||||
if((cl = Class.forName(name))!=null)
|
||||
action();
|
||||
} catch (ClassNotFoundException e) {
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
} catch (SecurityException e) {
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
abstract void action() throws Exception;
|
||||
|
||||
abstract class BlockCompat{
|
||||
Block block;
|
||||
|
||||
public BlockCompat(String variableName) throws Exception{
|
||||
block=(Block) ClassCompat.this.cl.getField(variableName).get(null);
|
||||
|
||||
if(block!=null)
|
||||
action();
|
||||
}
|
||||
|
||||
abstract void action() throws Exception;
|
||||
};
|
||||
};
|
||||
|
||||
abstract class ClassBlockCompat{
|
||||
Block block;
|
||||
|
||||
ClassBlockCompat(final String className,final String blockName){
|
||||
new ClassCompat(className){
|
||||
@Override void action() throws Exception {
|
||||
new BlockCompat(blockName){
|
||||
@Override void action() throws Exception {
|
||||
ClassBlockCompat.this.doAction(block);
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void doAction(Block b){
|
||||
block=b;
|
||||
|
||||
action();
|
||||
}
|
||||
|
||||
abstract void action();
|
||||
}
|
||||
|
||||
|
||||
public void postInit(FMLPostInitializationEvent event) {
|
||||
new ClassBlockCompat("shukaro.artifice.ArtificeBlocks","blockMarble"){
|
||||
@Override void action(){
|
||||
Carving.chisel.addVariation("marble",block,0,99);
|
||||
block.setHarvestLevel("chisel", 0, 0);
|
||||
}
|
||||
};
|
||||
new ClassBlockCompat("num.numirp.block.ModBlocks","blockDecor"){
|
||||
@Override void action(){
|
||||
Carving.chisel.addVariation("marble",block,0,99);
|
||||
block.setHarvestLevel("chisel", 0, 0);
|
||||
}
|
||||
};
|
||||
new ClassBlockCompat("mrtjp.projectred.ProjectRedExploration","blockStones"){
|
||||
@Override void action(){
|
||||
Carving.chisel.addVariation("marble",block,0,99);
|
||||
block.setHarvestLevel("chisel", 0, 0);
|
||||
}
|
||||
};
|
||||
|
||||
new ClassBlockCompat("mariculture.core.Core","oreBlocks"){
|
||||
@Override void action(){
|
||||
Carving.chisel.addVariation("limestone",block,3,99);
|
||||
block.setHarvestLevel("chisel", 0, 3);
|
||||
}
|
||||
};
|
||||
new ClassBlockCompat("emasher.core.EmasherCore","limestone"){
|
||||
@Override void action(){
|
||||
Carving.chisel.addVariation("limestone",block,0,99);
|
||||
block.setHarvestLevel("chisel", 0, 0);
|
||||
}
|
||||
};
|
||||
|
||||
new ClassCompat("Reika.GeoStrata.GeoStrata"){
|
||||
@Override void action() throws Exception {
|
||||
Block[] blocks=(Block[]) cl.getField("blocks").get(null);
|
||||
|
||||
Carving.chisel.addVariation("marble",blocks[0],2,99);
|
||||
blocks[0].setHarvestLevel("chisel",0,2);
|
||||
|
||||
Carving.chisel.addVariation("limestone",blocks[0],3,99);
|
||||
blocks[0].setHarvestLevel("chisel",0,3);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,206 @@
|
||||
package info.jbcs.minecraft.chisel;
|
||||
|
||||
import info.jbcs.minecraft.chisel.block.BlockHolystone;
|
||||
import info.jbcs.minecraft.chisel.block.BlockLavastone;
|
||||
import info.jbcs.minecraft.chisel.block.BlockSnakestoneObsidian;
|
||||
import info.jbcs.minecraft.chisel.entity.EntityBallOMossFX;
|
||||
import info.jbcs.minecraft.chisel.entity.EntityHolystoneFX;
|
||||
import info.jbcs.minecraft.chisel.entity.EntitySnakestoneObsidianFX;
|
||||
import info.jbcs.minecraft.utilities.GeneralClient;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.particle.EffectRenderer;
|
||||
import net.minecraft.client.particle.EntityDiggingFX;
|
||||
import net.minecraft.client.particle.EntityLavaFX;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
||||
public class GeneralChiselClient {
|
||||
public static Random rand = new Random();
|
||||
public static int tick=0;
|
||||
|
||||
public static void spawnLavastoneFX(World world, BlockLavastone block, int x, int y, int z) {
|
||||
if(Chisel.particlesTickrate!=0 && tick++%Chisel.particlesTickrate!=0) return;
|
||||
|
||||
float f = 0.15F;
|
||||
double x1 = x + rand.nextDouble() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - f * 2.0F) + f + block.getBlockBoundsMinX();
|
||||
double y1 = y + rand.nextDouble() * (block.getBlockBoundsMaxY() - block.getBlockBoundsMinY() - f * 2.0F) + f + block.getBlockBoundsMinY();
|
||||
double z1 = z + rand.nextDouble() * (block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ() - f * 2.0F) + f + block.getBlockBoundsMinZ();
|
||||
|
||||
switch(rand.nextInt(6)){
|
||||
case 0:
|
||||
y1 = y + block.getBlockBoundsMinY() - f;
|
||||
y--;
|
||||
break;
|
||||
case 1:
|
||||
y1 = y + block.getBlockBoundsMaxY() + f;
|
||||
y++;
|
||||
break;
|
||||
case 2:
|
||||
z1 = z + block.getBlockBoundsMinZ() - f;
|
||||
z--;
|
||||
break;
|
||||
case 3:
|
||||
z1 = z + block.getBlockBoundsMaxZ() + f;
|
||||
z++;
|
||||
break;
|
||||
case 4:
|
||||
x1 = x + block.getBlockBoundsMinX() - f;
|
||||
x--;
|
||||
break;
|
||||
case 5:
|
||||
x1 = x + block.getBlockBoundsMaxX() + f;
|
||||
x++;
|
||||
break;
|
||||
}
|
||||
|
||||
if(world.getBlock(x, y, z).isOpaqueCube()) return;
|
||||
|
||||
EntityLavaFX res = new EntityLavaFX(world, x1, y1, z1);
|
||||
// res.motionX=x1-x-0.5;
|
||||
// res.motionY=y1-y-0.5;
|
||||
// res.motionZ=z1-z-0.5;
|
||||
double multiplier=0.45;
|
||||
res.motionX=-multiplier*(x1-x-0.5);
|
||||
res.motionY=multiplier*(y1-y-0.5);
|
||||
res.motionZ=-multiplier*(z1-z-0.5);
|
||||
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect(res);
|
||||
}
|
||||
|
||||
public static void spawnHolystoneFX(World world, BlockHolystone block, int x, int y, int z) {
|
||||
if(Chisel.particlesTickrate!=0 && tick++%Chisel.particlesTickrate!=0) return;
|
||||
|
||||
float f = 0.15F;
|
||||
double x1 = x + rand.nextDouble() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - f * 2.0F) + f + block.getBlockBoundsMinX();
|
||||
double y1 = y + rand.nextDouble() * (block.getBlockBoundsMaxY() - block.getBlockBoundsMinY() - f * 2.0F) + f + block.getBlockBoundsMinY();
|
||||
double z1 = z + rand.nextDouble() * (block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ() - f * 2.0F) + f + block.getBlockBoundsMinZ();
|
||||
|
||||
switch(rand.nextInt(6)){
|
||||
case 0:
|
||||
y1 = y + block.getBlockBoundsMinY() - f;
|
||||
y--;
|
||||
break;
|
||||
case 1:
|
||||
y1 = y + block.getBlockBoundsMaxY() + f;
|
||||
y++;
|
||||
break;
|
||||
case 2:
|
||||
z1 = z + block.getBlockBoundsMinZ() - f;
|
||||
z--;
|
||||
break;
|
||||
case 3:
|
||||
z1 = z + block.getBlockBoundsMaxZ() + f;
|
||||
z++;
|
||||
break;
|
||||
case 4:
|
||||
x1 = x + block.getBlockBoundsMinX() - f;
|
||||
x--;
|
||||
break;
|
||||
case 5:
|
||||
x1 = x + block.getBlockBoundsMaxX() + f;
|
||||
x++;
|
||||
break;
|
||||
}
|
||||
|
||||
if(world.getBlock(x, y, z).isOpaqueCube()) return;
|
||||
|
||||
EntityHolystoneFX res = new EntityHolystoneFX(world, block, x1, y1, z1);
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect(res);
|
||||
}
|
||||
|
||||
public static void spawnSnakestoneObsidianFX(World world, BlockSnakestoneObsidian block, int x, int y, int z) {
|
||||
if(Chisel.particlesTickrate==0 || tick++%Chisel.particlesTickrate==0){
|
||||
EntitySnakestoneObsidianFX res = new EntitySnakestoneObsidianFX(world, block, x, y, z);
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect(res);
|
||||
}
|
||||
}
|
||||
|
||||
public static void spawnBallOMossFX(World world, double x, double y, double z) {
|
||||
if(Chisel.particlesTickrate==0 || tick++%Chisel.particlesTickrate==0){
|
||||
EntityBallOMossFX res = new EntityBallOMossFX(world, x, y, z);
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect(res);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static EntityDiggingFX addBlockHitEffects(World world, int x, int y, int z, int side) {
|
||||
Block block = world.getBlock(x, y, z);
|
||||
if (block.isAir(world, x, y, z))
|
||||
return null;
|
||||
|
||||
EffectRenderer renderer = Minecraft.getMinecraft().effectRenderer;
|
||||
|
||||
float f = 0.1F;
|
||||
double d0 = x + rand.nextDouble() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - f * 2.0F) + f + block.getBlockBoundsMinX();
|
||||
double d1 = y + rand.nextDouble() * (block.getBlockBoundsMaxY() - block.getBlockBoundsMinY() - f * 2.0F) + f + block.getBlockBoundsMinY();
|
||||
double d2 = z + rand.nextDouble() * (block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ() - f * 2.0F) + f + block.getBlockBoundsMinZ();
|
||||
|
||||
switch (side) {
|
||||
case 0:
|
||||
d1 = y + block.getBlockBoundsMinY() - f;
|
||||
break;
|
||||
case 1:
|
||||
d1 = y + block.getBlockBoundsMaxY() + f;
|
||||
break;
|
||||
case 2:
|
||||
d2 = z + block.getBlockBoundsMinZ() - f;
|
||||
break;
|
||||
case 3:
|
||||
d2 = z + block.getBlockBoundsMaxZ() + f;
|
||||
break;
|
||||
case 4:
|
||||
d0 = x + block.getBlockBoundsMinX() - f;
|
||||
break;
|
||||
case 5:
|
||||
d0 = x + block.getBlockBoundsMaxX() + f;
|
||||
break;
|
||||
}
|
||||
|
||||
EntityDiggingFX res = new EntityDiggingFX(world, d0, d1, d2, 0.0D, 0.0D, 0.0D, block, world.getBlockMetadata(x, y, z), side);
|
||||
// res.func_70596_a(x, y, z);
|
||||
res.motionX = d0 - (x + 0.5);
|
||||
res.motionY = d1 - (y + 0.5);
|
||||
res.motionZ = d2 - (z + 0.5);
|
||||
|
||||
renderer.addEffect(res);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public static void spawnChiselEffect(int x, int y, int z, String sound) {
|
||||
World world = Minecraft.getMinecraft().theWorld;
|
||||
for (int side = 0; side < 6; side++) {
|
||||
for (int j = 0; j < 16; j++) {
|
||||
EntityDiggingFX fx = addBlockHitEffects(Minecraft.getMinecraft().theWorld, x, y, z, side);
|
||||
if(fx==null) return;
|
||||
|
||||
fx.multipleParticleScaleBy(0.25f + 0.5f * rand.nextFloat());
|
||||
fx.multiplyVelocity(0.3f * rand.nextFloat());
|
||||
}
|
||||
}
|
||||
|
||||
GeneralClient.playChiselSound(world, x, y, z, sound);
|
||||
}
|
||||
|
||||
public static void speedupPlayer(World world, Entity entity, double concreteVelocity) {
|
||||
double velocity=Math.sqrt(entity.motionX*entity.motionX+entity.motionZ*entity.motionZ);
|
||||
|
||||
if(! (entity instanceof EntityPlayerSP)) return;
|
||||
if(velocity==0) return;
|
||||
if(velocity>=Chisel.concreteVelocity) return;
|
||||
|
||||
EntityPlayerSP player=(EntityPlayerSP) entity;
|
||||
|
||||
if(Math.abs(player.movementInput.moveForward) < 0.75f && Math.abs(player.movementInput.moveStrafe) < 0.75f) return;
|
||||
|
||||
entity.motionX = Chisel.concreteVelocity * entity.motionX / velocity;
|
||||
entity.motionZ = Chisel.concreteVelocity * entity.motionZ / velocity;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package info.jbcs.minecraft.chisel;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import net.minecraft.world.gen.feature.WorldGenMinable;
|
||||
import cpw.mods.fml.common.IWorldGenerator;
|
||||
|
||||
public class MarbleWorldGenerator implements IWorldGenerator {
|
||||
WorldGenMinable gen;
|
||||
int amount;
|
||||
|
||||
public MarbleWorldGenerator(Block id, int count, int am) {
|
||||
gen = new WorldGenMinable(id, count);
|
||||
amount = am;
|
||||
}
|
||||
|
||||
/**
|
||||
* Standard ore generation helper. Generates most ores.
|
||||
*/
|
||||
protected void genStandardOre1(World world, Random random, int x, int z, int bot, int top) {
|
||||
for (int l = 0; l < amount; ++l) {
|
||||
int i1 = x + random.nextInt(16);
|
||||
int j1 = bot + random.nextInt(top - bot);
|
||||
int k1 = z + random.nextInt(16);
|
||||
gen.generate(world, random, i1, j1, k1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
|
||||
genStandardOre1(world, random, chunkX*16, chunkZ*16, 40, 128);
|
||||
}
|
||||
}
|
||||
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
package info.jbcs.minecraft.chisel;
|
||||
|
||||
import info.jbcs.minecraft.utilities.General;
|
||||
import info.jbcs.minecraft.utilities.packets.PacketData;
|
||||
import info.jbcs.minecraft.utilities.packets.PacketHandler;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import pl.asie.lib.network.MessageHandlerBase;
|
||||
import pl.asie.lib.network.Packet;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.network.INetHandler;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.management.ServerConfigurationManager;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
|
||||
public class Packets extends MessageHandlerBase {
|
||||
public static final int CHISELED = 1;
|
||||
|
||||
public void onChiseled(Packet stream, EntityPlayer player) throws IOException {
|
||||
final int x=stream.readInt();
|
||||
final int y=stream.readInt();
|
||||
final int z=stream.readInt();
|
||||
|
||||
switch(FMLCommonHandler.instance().getEffectiveSide()){
|
||||
case SERVER:
|
||||
Packet packet = Chisel.packet.create(CHISELED).writeInt(x).writeInt(y).writeInt(z);
|
||||
Chisel.packet.sendToAllAround(packet, new TargetPoint(player.dimension, x, y, z, 30.0f));
|
||||
break;
|
||||
case CLIENT:
|
||||
Block block =player.worldObj.getBlock(x,y,z);
|
||||
int blockMeta=player.worldObj.getBlockMetadata(x,y,z);
|
||||
GeneralChiselClient.spawnChiselEffect(x, y, z, Carving.chisel.getVariationSound(block, blockMeta));
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessage(Packet packet, INetHandler handler,
|
||||
EntityPlayer player, int command) throws IOException {
|
||||
switch(command) {
|
||||
case CHISELED:
|
||||
onChiseled(packet, player);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package info.jbcs.minecraft.chisel;
|
||||
|
||||
public class Proxy {
|
||||
public void preInit() {
|
||||
}
|
||||
public void init() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package info.jbcs.minecraft.chisel;
|
||||
|
||||
import info.jbcs.minecraft.chisel.entity.EntityBallOMoss;
|
||||
import info.jbcs.minecraft.chisel.entity.EntityCloudInABottle;
|
||||
import info.jbcs.minecraft.chisel.item.ItemChiselRenderer;
|
||||
import info.jbcs.minecraft.chisel.render.BlockAdvancedMarbleRenderer;
|
||||
import info.jbcs.minecraft.chisel.render.BlockCarpetRenderer;
|
||||
import info.jbcs.minecraft.chisel.render.BlockEldritchRenderer;
|
||||
import info.jbcs.minecraft.chisel.render.BlockMarblePaneRenderer;
|
||||
import info.jbcs.minecraft.chisel.render.BlockMarblePillarRenderer;
|
||||
import info.jbcs.minecraft.chisel.render.BlockMarbleStairsRenderer;
|
||||
import info.jbcs.minecraft.chisel.render.BlockNoCTMRenderer;
|
||||
import info.jbcs.minecraft.chisel.render.BlockRoadLineRenderer;
|
||||
import info.jbcs.minecraft.chisel.render.BlockSnakeStoneRenderer;
|
||||
import info.jbcs.minecraft.chisel.render.BlockSpikesRenderer;
|
||||
import info.jbcs.minecraft.utilities.BlockTexturedOreRenderer;
|
||||
import net.minecraft.client.renderer.entity.RenderSnowball;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class ProxyClient extends Proxy {
|
||||
ItemChiselRenderer renderer = new ItemChiselRenderer();
|
||||
|
||||
@Override
|
||||
public void preInit() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
RenderingRegistry.registerBlockHandler(new BlockMarbleStairsRenderer());
|
||||
RenderingRegistry.registerBlockHandler(new BlockMarblePaneRenderer());
|
||||
RenderingRegistry.registerBlockHandler(new BlockRoadLineRenderer());
|
||||
RenderingRegistry.registerBlockHandler(new BlockSnakeStoneRenderer());
|
||||
RenderingRegistry.registerBlockHandler(new BlockNoCTMRenderer());
|
||||
RenderingRegistry.registerBlockHandler(new BlockSpikesRenderer());
|
||||
RenderingRegistry.registerBlockHandler(new BlockMarblePillarRenderer());
|
||||
RenderingRegistry.registerBlockHandler(new BlockEldritchRenderer());
|
||||
RenderingRegistry.registerBlockHandler(new BlockAdvancedMarbleRenderer());
|
||||
RenderingRegistry.registerBlockHandler(new BlockCarpetRenderer());
|
||||
|
||||
|
||||
RenderingRegistry.registerBlockHandler(new BlockTexturedOreRenderer());
|
||||
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityCloudInABottle.class, new RenderSnowball(Chisel.itemCloudInABottle));
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityBallOMoss.class, new RenderSnowball(Chisel.itemBallOMoss));
|
||||
|
||||
|
||||
MinecraftForgeClient.registerItemRenderer(Chisel.chisel, renderer);
|
||||
// MinecraftForgeClient.registerItemRenderer(Chisel.needle.itemID, renderer);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package info.jbcs.minecraft.chisel;
|
||||
|
||||
import net.minecraft.block.Block.SoundType;
|
||||
|
||||
public class StepSoundEx extends SoundType {
|
||||
String stepName;
|
||||
String placeName;
|
||||
|
||||
public StepSoundEx(String name,String stepName,String placeName,float volume) {
|
||||
super(name, volume, 1.0f);
|
||||
|
||||
this.stepName=stepName;
|
||||
this.placeName=placeName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBreakSound() {
|
||||
return this.soundName;
|
||||
}
|
||||
/*
|
||||
@Override
|
||||
public String getStepSound() {
|
||||
return stepName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlaceSound() {
|
||||
return placeName;
|
||||
}
|
||||
*/
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package info.jbcs.minecraft.chisel.block;
|
||||
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockCloud extends BlockMarble {
|
||||
|
||||
public BlockCloud() {
|
||||
super(Material.ice);
|
||||
|
||||
useNeighborBrightness = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock(World world, int i, int j, int k, Entity entity) {
|
||||
entity.fallDistance = 0.0F;
|
||||
|
||||
if (entity.motionY < 0.0D) {
|
||||
entity.motionY *= 0.0050000000000000001D;
|
||||
} else if(entity.motionY>0){
|
||||
entity.motionY+=0.0285;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderBlockPass() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean shouldSideBeRendered(IBlockAccess iblockaccess, int i, int j, int k, int l) {
|
||||
return super.shouldSideBeRendered(iblockaccess, i, j, k, 1 - l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k) {
|
||||
return AxisAlignedBB.getBoundingBox(i+0.2, j, k+0.2, i+0.8, j+0.2, k+0.8);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped(int par1, Random rand, int par3) {
|
||||
return Item.getItemFromBlock(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int quantityDropped(Random rand) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int meta) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package info.jbcs.minecraft.chisel.block;
|
||||
|
||||
import info.jbcs.minecraft.chisel.Chisel;
|
||||
import info.jbcs.minecraft.chisel.GeneralChiselClient;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
public class BlockConcrete extends BlockMarble {
|
||||
|
||||
public BlockConcrete() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4) {
|
||||
float f = 0.125F;
|
||||
return AxisAlignedBB.getAABBPool().getAABB(par2, par3, par4, (par2 + 1), ((par3 + 1) - f), (par4 + 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
|
||||
if (FMLCommonHandler.instance().getEffectiveSide() != Side.CLIENT)
|
||||
return;
|
||||
if(Chisel.concreteVelocity==0)
|
||||
return;
|
||||
|
||||
GeneralChiselClient.speedupPlayer(world,entity,Chisel.concreteVelocity);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package info.jbcs.minecraft.chisel.block;
|
||||
|
||||
import info.jbcs.minecraft.chisel.Chisel;
|
||||
|
||||
|
||||
public class BlockEldritch extends BlockMarble {
|
||||
|
||||
public BlockEldritch() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return Chisel.RenderEldritchId;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package info.jbcs.minecraft.chisel.block;
|
||||
|
||||
import info.jbcs.minecraft.chisel.Carvable;
|
||||
import info.jbcs.minecraft.chisel.CarvableHelper;
|
||||
import info.jbcs.minecraft.chisel.CarvableVariation;
|
||||
import info.jbcs.minecraft.chisel.Chisel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.BlockGlass;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
public class BlockGlassCarvable extends BlockGlass implements Carvable {
|
||||
public CarvableHelper carverHelper;
|
||||
|
||||
public BlockGlassCarvable() {
|
||||
super(Material.glass, false);
|
||||
|
||||
carverHelper = new CarvableHelper();
|
||||
|
||||
setCreativeTab(Chisel.tabChisel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return Chisel.RenderCTMId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
return carverHelper.getIcon(side, metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int i) {
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister register) {
|
||||
carverHelper.registerBlockIcons("Chisel",this,register);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs tabs, List list){
|
||||
carverHelper.registerSubBlocks(this,tabs,list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarvableVariation getVariation(int metadata) {
|
||||
return carverHelper.getVariation(metadata);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package info.jbcs.minecraft.chisel.block;
|
||||
|
||||
import info.jbcs.minecraft.chisel.GeneralChiselClient;
|
||||
import info.jbcs.minecraft.utilities.General;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockHolystone extends BlockMarble{
|
||||
public IIcon iconStar;
|
||||
|
||||
public BlockHolystone(Material m) {
|
||||
super(m);
|
||||
|
||||
this.setLightLevel(0.25F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void randomDisplayTick(World world, int x, int y, int z, Random random) {
|
||||
if(General.rand.nextInt(4)==0)
|
||||
GeneralChiselClient.spawnHolystoneFX(world,this,x,y,z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister register) {
|
||||
super.registerBlockIcons(register);
|
||||
|
||||
iconStar=register.registerIcon("Chisel:holystone/particles/star");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package info.jbcs.minecraft.chisel.block;
|
||||
|
||||
|
||||
import info.jbcs.minecraft.chisel.GeneralChiselClient;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockLavastone extends BlockMarbleTexturedOre {
|
||||
public BlockLavastone(Material mat, String baseIcon) {
|
||||
super(mat, baseIcon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void randomDisplayTick(World world, int x, int y, int z, Random random) {
|
||||
if(random.nextInt(8)==0)
|
||||
GeneralChiselClient.spawnLavastoneFX(world,this,x,y,z);
|
||||
}
|
||||
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package info.jbcs.minecraft.chisel.block;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
public class BlockLightstoneCarvable extends BlockMarble {
|
||||
public BlockLightstoneCarvable() {
|
||||
super(Material.glass);
|
||||
}
|
||||
|
||||
@Override public int quantityDropped(Random random) {
|
||||
return Blocks.glowstone.quantityDropped(random);
|
||||
}
|
||||
|
||||
@Override public Item getItemDropped(int i,Random random,int a) {
|
||||
return Items.glowstone_dust;
|
||||
}
|
||||
|
||||
@Override public int damageDropped(int i) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package info.jbcs.minecraft.chisel.block;
|
||||
|
||||
import info.jbcs.minecraft.chisel.Carvable;
|
||||
import info.jbcs.minecraft.chisel.CarvableHelper;
|
||||
import info.jbcs.minecraft.chisel.CarvableVariation;
|
||||
import info.jbcs.minecraft.chisel.Chisel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
public class BlockMarble extends Block implements Carvable {
|
||||
public CarvableHelper carverHelper;
|
||||
|
||||
public BlockMarble() {
|
||||
this(Material.rock);
|
||||
}
|
||||
|
||||
public BlockMarble(Material m) {
|
||||
super(m);
|
||||
|
||||
carverHelper = new CarvableHelper();
|
||||
|
||||
setCreativeTab(Chisel.tabChisel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
return carverHelper.getIcon(side, metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side){
|
||||
return carverHelper.getIcon(world, x, y, z, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int i) {
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister register) {
|
||||
carverHelper.registerBlockIcons("Chisel",this,register);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs tabs, List list){
|
||||
carverHelper.registerSubBlocks(this,tabs,list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return Chisel.RenderCTMId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarvableVariation getVariation(int metadata) {
|
||||
return carverHelper.getVariation(metadata);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package info.jbcs.minecraft.chisel.block;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockMarbleBookshelf extends BlockMarble {
|
||||
|
||||
public BlockMarbleBookshelf() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
if(side<2)
|
||||
return Blocks.planks.getBlockTextureFromSide(side);
|
||||
return super.getIcon(side, metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side){
|
||||
if(side<2)
|
||||
return Blocks.planks.getBlockTextureFromSide(side);
|
||||
return super.getIcon(world, x, y, z, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int quantityDropped(Random par1Random) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped(int par1, Random par2Random, int par3) {
|
||||
return Items.book;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getEnchantPowerBonus(World world, int x, int y, int z) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package info.jbcs.minecraft.chisel.block;
|
||||
|
||||
import info.jbcs.minecraft.chisel.Carvable;
|
||||
import info.jbcs.minecraft.chisel.CarvableHelper;
|
||||
import info.jbcs.minecraft.chisel.CarvableVariation;
|
||||
import info.jbcs.minecraft.chisel.Chisel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.BlockCarpet;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
public class BlockMarbleCarpet extends BlockCarpet implements Carvable {
|
||||
public CarvableHelper carverHelper;
|
||||
|
||||
public BlockMarbleCarpet(Material m) {
|
||||
carverHelper = new CarvableHelper();
|
||||
|
||||
setCreativeTab(Chisel.tabChisel);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
return carverHelper.getIcon(side, metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side){
|
||||
return carverHelper.getIcon(world, x, y, z, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int i) {
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister register) {
|
||||
carverHelper.registerBlockIcons("Chisel",this,register);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs tabs, List list){
|
||||
carverHelper.registerSubBlocks(this,tabs,list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return Chisel.RenderCarpetId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarvableVariation getVariation(int metadata) {
|
||||
return carverHelper.getVariation(metadata);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package info.jbcs.minecraft.chisel.block;
|
||||
|
||||
import info.jbcs.minecraft.chisel.Carvable;
|
||||
import info.jbcs.minecraft.chisel.CarvableHelper;
|
||||
import info.jbcs.minecraft.chisel.CarvableVariation;
|
||||
import info.jbcs.minecraft.chisel.Chisel;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockIce;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.stats.StatList;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockMarbleIce extends BlockIce implements Carvable {
|
||||
public CarvableHelper carverHelper;
|
||||
|
||||
public BlockMarbleIce() {
|
||||
super();
|
||||
|
||||
carverHelper = new CarvableHelper();
|
||||
|
||||
setCreativeTab(Chisel.tabChisel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
return carverHelper.getIcon(side, metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int i) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister register) {
|
||||
carverHelper.registerBlockIcons("Chisel", this, register);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs tabs, List list) {
|
||||
carverHelper.registerSubBlocks(this, tabs, list);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the player destroys a block with an item that can harvest it.
|
||||
* (i, j, k) are the coordinates of the block and l is the block's
|
||||
* subtype/damage.
|
||||
*/
|
||||
@Override
|
||||
public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6) {
|
||||
if (!Chisel.dropIceShards){
|
||||
super.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6);
|
||||
return;
|
||||
}
|
||||
|
||||
par2EntityPlayer.addStat(StatList.mineBlockStatArray[Block.getIdFromBlock(this)], 1);
|
||||
par2EntityPlayer.addExhaustion(0.025F);
|
||||
|
||||
if(par1World.isRemote)
|
||||
return;
|
||||
|
||||
if (this.canSilkHarvest(par1World, par2EntityPlayer, par3, par4, par5, par6) && EnchantmentHelper.getSilkTouchModifier(par2EntityPlayer)) {
|
||||
ItemStack itemstack = this.createStackedBlock(par6);
|
||||
|
||||
if (itemstack != null) {
|
||||
this.dropBlockAsItem(par1World, par3, par4, par5, itemstack);
|
||||
}
|
||||
} else {
|
||||
int i1 = EnchantmentHelper.getFortuneModifier(par2EntityPlayer);
|
||||
this.dropBlockAsItem(par1World, par3, par4, par5, par6, i1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped(int par1, Random par2Random, int par3) {
|
||||
return Chisel.dropIceShards ? Chisel.itemIceshard : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int quantityDropped(Random par1Random) {
|
||||
return Chisel.dropIceShards ? 1 + par1Random.nextInt(5) : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarvableVariation getVariation(int metadata) {
|
||||
return carverHelper.getVariation(metadata);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package info.jbcs.minecraft.chisel.block;
|
||||
|
||||
import info.jbcs.minecraft.chisel.CarvableHelper;
|
||||
import info.jbcs.minecraft.chisel.Chisel;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockMarbleIceStairs extends BlockMarbleStairs {
|
||||
public BlockMarbleIceStairs(Block block,int meta, CarvableHelper helper) {
|
||||
super(block,meta,helper);
|
||||
|
||||
slipperiness = 0.98F;
|
||||
setTickRandomly(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6) {
|
||||
Chisel.blockIce.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int quantityDropped(Random par1Random) {
|
||||
return Chisel.blockIce.quantityDropped(par1Random);
|
||||
}
|
||||
@Override
|
||||
public int damageDropped(int i) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
|
||||
Chisel.blockIce.updateTick(par1World, par2, par3, par4, par5Random);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMobilityFlag() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package info.jbcs.minecraft.chisel.block;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockMarbleLamp extends BlockMarble {
|
||||
BlockMarbleLamp blockUnpowered;
|
||||
BlockMarbleLamp blockPowered;
|
||||
boolean powered;
|
||||
|
||||
public BlockMarbleLamp() {
|
||||
super(Material.redstoneLight);
|
||||
|
||||
powered=false;
|
||||
blockUnpowered=this;
|
||||
blockPowered=new BlockMarbleLamp(this);
|
||||
|
||||
setHardness(0.3F);
|
||||
}
|
||||
|
||||
public BlockMarbleLamp(BlockMarbleLamp unpoweredVersion) {
|
||||
super(Material.redstoneLight);
|
||||
|
||||
carverHelper=unpoweredVersion.carverHelper;
|
||||
|
||||
powered=true;
|
||||
blockUnpowered=unpoweredVersion;
|
||||
blockPowered=this;
|
||||
|
||||
setLightLevel(1.0F);
|
||||
setHardness(0.3F);
|
||||
}
|
||||
|
||||
|
||||
public void checkPower(World world, int x, int y, int z){
|
||||
if (world.isRemote) return;
|
||||
|
||||
boolean isGettingPower=world.isBlockIndirectlyGettingPowered(x, y, z);
|
||||
int meta=world.getBlockMetadata(x, y, z);
|
||||
|
||||
if (powered && !isGettingPower) {
|
||||
world.setBlock(x, y, z, blockUnpowered, meta, 2);
|
||||
} else if (!powered && isGettingPower) {
|
||||
world.setBlock(x, y, z, blockPowered, meta, 2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World world, int x, int y, int z){
|
||||
checkPower(world,x,y,z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, Block block){
|
||||
checkPower(world,x,y,z);
|
||||
}
|
||||
|
||||
/*
|
||||
@Override
|
||||
public void updateTick(World world, int x, int y, int z, Random rand){
|
||||
if (world.isRemote) return;
|
||||
|
||||
if(powered && !world.isBlockIndirectlyGettingPowered(x, y, z)){
|
||||
int meta=world.getBlockMetadata(x, y, z);
|
||||
world.setBlock(x, y, z, Block.redstoneLampIdle.blockID, meta, 2);
|
||||
}
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public Item getItemDropped(int par1, Random par2Random, int par3){
|
||||
return Item.getItemFromBlock(blockUnpowered);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z){
|
||||
return new ItemStack(blockUnpowered, 1, world.getBlockMetadata(x, y, z));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package info.jbcs.minecraft.chisel.block;
|
||||
|
||||
import info.jbcs.minecraft.chisel.Carvable;
|
||||
import info.jbcs.minecraft.chisel.CarvableHelper;
|
||||
import info.jbcs.minecraft.chisel.CarvableVariation;
|
||||
import info.jbcs.minecraft.chisel.Chisel;
|
||||
import info.jbcs.minecraft.chisel.render.BlockMarblePaneRenderer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockPane;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
public class BlockMarblePane extends BlockPane implements Carvable {
|
||||
public CarvableHelper carverHelper;
|
||||
|
||||
public BlockMarblePane(Material material, boolean drops) {
|
||||
super("", "", material, drops);
|
||||
|
||||
carverHelper = new CarvableHelper();
|
||||
|
||||
setCreativeTab(Chisel.tabChisel);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return BlockMarblePaneRenderer.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
return carverHelper.getIcon(side, metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int i) {
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister register) {
|
||||
carverHelper.registerBlockIcons("Chisel",this,register);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs tabs, List list){
|
||||
carverHelper.registerSubBlocks(this,tabs,list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarvableVariation getVariation(int metadata) {
|
||||
return carverHelper.getVariation(metadata);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package info.jbcs.minecraft.chisel.block;
|
||||
|
||||
import info.jbcs.minecraft.chisel.CarvableVariation;
|
||||
import info.jbcs.minecraft.chisel.render.BlockMarblePillarRenderer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
public class BlockMarblePillar extends BlockMarble{
|
||||
public IIcon sides[]=new IIcon[6];
|
||||
|
||||
public BlockMarblePillar(Material m) {
|
||||
super(m);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return BlockMarblePillarRenderer.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
return sides[side];
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side){
|
||||
return sides[side];
|
||||
}
|
||||
|
||||
public IIcon getCtmIcon(int index, int metadata){
|
||||
CarvableVariation var=carverHelper.variations.get(metadata);
|
||||
|
||||
if(index>=4) return var.iconTop;
|
||||
if(var.seamsCtmVert==null) return var.icon;
|
||||
return var.seamsCtmVert.icons[index];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package info.jbcs.minecraft.chisel.block;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockMarbleSlab extends BlockMarble {
|
||||
public Block master;
|
||||
public BlockMarbleSlab bottom;
|
||||
public BlockMarbleSlab top;
|
||||
public boolean isBottom;
|
||||
|
||||
public BlockMarbleSlab(BlockMarble marble) {
|
||||
opaque = true;
|
||||
|
||||
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F);
|
||||
|
||||
master = marble;
|
||||
bottom = this;
|
||||
top = new BlockMarbleSlab(this);
|
||||
|
||||
isBottom = true;
|
||||
}
|
||||
|
||||
public BlockMarbleSlab(BlockMarbleSlab bottomBlock) {
|
||||
super();
|
||||
|
||||
setBlockBounds(0.0F, 0.5F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
master = bottomBlock.master;
|
||||
bottom = bottomBlock;
|
||||
top = this;
|
||||
|
||||
carverHelper=bottomBlock.carverHelper;
|
||||
isBottom=false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) {
|
||||
if (isBottom) {
|
||||
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F);
|
||||
} else {
|
||||
setBlockBounds(0.0F, 0.5F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockBoundsForItemRender() {
|
||||
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCollisionBoxesToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity) {
|
||||
setBlockBoundsBasedOnState(par1World, par2, par3, par4);
|
||||
super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int meta) {
|
||||
return meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped(int par1, Random par2Random, int par3) {
|
||||
return Item.getItemFromBlock(bottom);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ItemStack getPickBlock(MovingObjectPosition mop, World world, int x, int y, int z) {
|
||||
return new ItemStack(bottom, 1, world.getBlockMetadata(x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
return carverHelper.getIcon(side, metadata);
|
||||
// return master.getIcon(side, metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item block, CreativeTabs tabs, List list){
|
||||
if(isBottom) super.getSubBlocks(block,tabs,list);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package info.jbcs.minecraft.chisel.block;
|
||||
|
||||
import info.jbcs.minecraft.chisel.Carvable;
|
||||
import info.jbcs.minecraft.chisel.CarvableHelper;
|
||||
import info.jbcs.minecraft.chisel.CarvableVariation;
|
||||
import info.jbcs.minecraft.chisel.Chisel;
|
||||
import info.jbcs.minecraft.chisel.render.BlockMarbleStairsRenderer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockStairs;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockMarbleStairs extends BlockStairs implements Carvable {
|
||||
CarvableHelper carverHelper;
|
||||
int blockMeta;
|
||||
|
||||
public BlockMarbleStairs(Block block,int meta, CarvableHelper helper) {
|
||||
super(block, meta);
|
||||
|
||||
this.useNeighborBrightness = true;
|
||||
setCreativeTab(Chisel.tabChisel);
|
||||
carverHelper=helper;
|
||||
blockMeta=meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
return carverHelper.getIcon(side, blockMeta+metadata/8);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int i) {
|
||||
return i&0x8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister register) {
|
||||
if(blockMeta==0)
|
||||
carverHelper.registerBlockIcons("Chisel",this,register);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item block, CreativeTabs tabs, List list){
|
||||
list.add(new ItemStack(block, 1, 0));
|
||||
list.add(new ItemStack(block, 1, 8));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return BlockMarbleStairsRenderer.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLiving, ItemStack par6ItemStack){
|
||||
int l = MathHelper.floor_double((par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
|
||||
int i1 = par1World.getBlockMetadata(par2, par3, par4) & 4;
|
||||
int odd=par6ItemStack.getItemDamage();
|
||||
|
||||
if (l == 0)
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, 2 | i1 + odd, 2);
|
||||
}
|
||||
|
||||
if (l == 1)
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, 1 | i1 + odd, 2);
|
||||
}
|
||||
|
||||
if (l == 2)
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, 3 | i1 + odd, 2);
|
||||
}
|
||||
|
||||
if (l == 3)
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, 0 | i1 + odd, 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int onBlockPlaced(World world, int x, int y, int z, int side, float hx, float hy, float hz, int damage){
|
||||
// int res=super.onBlockPlaced();
|
||||
return side != 0 && (side == 1 || hy <= 0.5D) ? damage : damage | 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarvableVariation getVariation(int metadata) {
|
||||
return carverHelper.getVariation(metadata);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package info.jbcs.minecraft.chisel.block;
|
||||
|
||||
import info.jbcs.minecraft.chisel.CarvableHelper;
|
||||
import info.jbcs.minecraft.chisel.CarvableVariation;
|
||||
import info.jbcs.minecraft.chisel.item.ItemCarvable;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class BlockMarbleStairsMaker {
|
||||
public CarvableHelper carverHelper;
|
||||
BlockMarbleStairs blocks[];
|
||||
|
||||
int idStart;
|
||||
Block blockBase;
|
||||
String blockName;
|
||||
|
||||
public BlockMarbleStairsMaker(Block base){
|
||||
carverHelper=new CarvableHelper();
|
||||
|
||||
blockBase=base;
|
||||
}
|
||||
|
||||
public void create(){
|
||||
create(null);
|
||||
}
|
||||
|
||||
public void create(BlockMarbleStairsMakerCreator creator){
|
||||
blocks=new BlockMarbleStairs[carverHelper.variations.size()/2];
|
||||
|
||||
for(int i=0;i<blocks.length;i++){
|
||||
String n=blockName+"."+i;
|
||||
blocks[i]=creator==null?
|
||||
new BlockMarbleStairs(blockBase, i*2, carverHelper):
|
||||
creator.create(blockBase, i*2, carverHelper);
|
||||
|
||||
blocks[i].setBlockName(n);
|
||||
GameRegistry.registerBlock(blocks[i], ItemCarvable.class, n);
|
||||
|
||||
for(int meta=0;meta<2 && i*2+meta<carverHelper.variations.size();meta++){
|
||||
CarvableVariation variation=carverHelper.variations.get(i*2+meta);
|
||||
|
||||
for(int j=0;j<8;j++)
|
||||
carverHelper.registerVariation(blockName+".orientation."+j,variation,blocks[i],j+meta*8);
|
||||
|
||||
CraftingManager.getInstance().addRecipe(new ItemStack(blocks[i], 4, meta*8), new Object[] { "* ", "** ", "***", '*', new ItemStack(blockBase, 1, i*2+meta)});
|
||||
}
|
||||
|
||||
CarvableHelper.chiselBlocks.add(blocks[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package info.jbcs.minecraft.chisel.block;
|
||||
|
||||
import info.jbcs.minecraft.chisel.CarvableHelper;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
public interface BlockMarbleStairsMakerCreator {
|
||||
public BlockMarbleStairs create(Block block,int meta, CarvableHelper helper);
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package info.jbcs.minecraft.chisel.block;
|
||||
|
||||
import info.jbcs.minecraft.chisel.Carvable;
|
||||
import info.jbcs.minecraft.chisel.CarvableHelper;
|
||||
import info.jbcs.minecraft.chisel.CarvableVariation;
|
||||
import info.jbcs.minecraft.chisel.Chisel;
|
||||
import info.jbcs.minecraft.utilities.BlockTexturedOre;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
public class BlockMarbleTexturedOre extends BlockTexturedOre implements Carvable {
|
||||
public CarvableHelper carverHelper;
|
||||
|
||||
public BlockMarbleTexturedOre(Material mat, String baseIcon) {
|
||||
super(mat, baseIcon);
|
||||
|
||||
carverHelper = new CarvableHelper();
|
||||
|
||||
setCreativeTab(Chisel.tabChisel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
return carverHelper.getIcon(side, metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int i) {
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister register) {
|
||||
super.registerBlockIcons(register);
|
||||
|
||||
carverHelper.registerBlockIcons("Chisel",this,register);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item block, CreativeTabs tabs, List list){
|
||||
carverHelper.registerSubBlocks(this,tabs,list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarvableVariation getVariation(int metadata) {
|
||||
return carverHelper.getVariation(metadata);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package info.jbcs.minecraft.chisel.block;
|
||||
|
||||
import info.jbcs.minecraft.chisel.CarvableHelper;
|
||||
import info.jbcs.minecraft.chisel.Chisel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockWall;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
public class BlockMarbleWall extends BlockWall {
|
||||
CarvableHelper carverHelper;
|
||||
|
||||
public BlockMarbleWall(Block block) {
|
||||
super(block);
|
||||
|
||||
carverHelper = new CarvableHelper();
|
||||
|
||||
setCreativeTab(Chisel.tabChisel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
return carverHelper.getIcon(side, metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int i) {
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister register) {
|
||||
carverHelper.registerBlockIcons("Chisel",this,register);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item block, CreativeTabs tabs, List list){
|
||||
carverHelper.registerSubBlocks(this,tabs,list);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package info.jbcs.minecraft.chisel.block;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
public class BlockPoweredMarble extends BlockMarble {
|
||||
public BlockPoweredMarble(Material m) {
|
||||
super(m);
|
||||
}
|
||||
|
||||
/**
|
||||
* Can this block provide power. Only wire currently seems to have this
|
||||
* change based on its state.
|
||||
*/
|
||||
@Override
|
||||
public boolean canProvidePower() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the block is emitting indirect/weak redstone power on the
|
||||
* specified side. If isBlockNormalCube returns true, standard redstone
|
||||
* propagation rules will apply instead and this will not be called. Args:
|
||||
* World, X, Y, Z, side. Note that the side is reversed - eg it is 1 (up)
|
||||
* when checking the bottom of the block.
|
||||
*/
|
||||
@Override
|
||||
public int isProvidingWeakPower(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) {
|
||||
return 15;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package info.jbcs.minecraft.chisel.block;
|
||||
|
||||
import info.jbcs.minecraft.chisel.Chisel;
|
||||
import info.jbcs.minecraft.chisel.render.BlockRoadLineRenderer;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockRoadLine extends Block {
|
||||
public IIcon aloneIcon;
|
||||
public IIcon halfLineIcon;
|
||||
public IIcon fullLineIcon;
|
||||
|
||||
public BlockRoadLine() {
|
||||
super(Material.circuits);
|
||||
|
||||
this.setBlockBounds(0.0f, 0.0f, 0.0f, 1.0f, 0.00390625f, 1.0f);
|
||||
// this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.0625F, 1.0F);
|
||||
|
||||
setCreativeTab(Chisel.tabChisel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return BlockRoadLineRenderer.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4) {
|
||||
return par1World.doesBlockHaveSolidTopSurface(par1World, par2, par3 - 1, par4) || par1World.getBlock(par2, par3 - 1, par4).equals(Blocks.glowstone);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, Block block) {
|
||||
if (par1World.isRemote) return;
|
||||
|
||||
if (! this.canPlaceBlockAt(par1World, par2, par3, par4)) {
|
||||
this.dropBlockAsItem(par1World, par2, par3, par4, 0, 0);
|
||||
par1World.setBlockToAir(par2, par3, par4);
|
||||
}
|
||||
|
||||
super.onNeighborBlockChange(par1World, par2, par3, par4, block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister reg) {
|
||||
blockIcon = aloneIcon = reg.registerIcon("Chisel:line-marking/white-center");
|
||||
halfLineIcon = reg.registerIcon("Chisel:line-marking/white-side");
|
||||
fullLineIcon = reg.registerIcon("Chisel:line-marking/white-long");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,406 @@
|
||||
package info.jbcs.minecraft.chisel.block;
|
||||
|
||||
import info.jbcs.minecraft.chisel.Chisel;
|
||||
import info.jbcs.minecraft.chisel.render.BlockSnakeStoneRenderer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockSnakestone extends Block {
|
||||
static final int SEC_HEAD = 0;
|
||||
static final int SEC_DOWN = 4;
|
||||
static final int SEC_UP = 8;
|
||||
static final int SEC_HOR = 12;
|
||||
|
||||
static final int SIDE_B = 0;
|
||||
static final int SIDE_T = 1;
|
||||
static final int SIDE_N = 2;
|
||||
static final int SIDE_S = 3;
|
||||
static final int SIDE_W = 4;
|
||||
static final int SIDE_E = 5;
|
||||
|
||||
String iconPrefix;
|
||||
IIcon iconFaceLeft;
|
||||
IIcon iconFaceRight;
|
||||
IIcon iconCross;
|
||||
IIcon iconFace;
|
||||
IIcon iconTopTip;
|
||||
IIcon iconTopSide;
|
||||
IIcon iconBottom;
|
||||
IIcon iconBottomSide;
|
||||
IIcon iconBottomTip;
|
||||
IIcon iconLeftDown;
|
||||
IIcon iconRightDown;
|
||||
IIcon iconLeftUp;
|
||||
IIcon iconRightUp;
|
||||
IIcon iconLeftTip;
|
||||
IIcon iconSide;
|
||||
IIcon iconRightTip;
|
||||
IIcon iconTop;
|
||||
|
||||
public boolean flipTopTextures;
|
||||
|
||||
public BlockSnakestone(String iconPrefix) {
|
||||
super(Material.rock);
|
||||
setHardness(1.5F);
|
||||
setResistance(10.0F);
|
||||
setStepSound(Block.soundTypeStone);
|
||||
setCreativeTab(Chisel.tabChisel);
|
||||
flipTopTextures=false;
|
||||
|
||||
this.iconPrefix = iconPrefix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return BlockSnakeStoneRenderer.id;
|
||||
}
|
||||
|
||||
static final int[] rotRemap={0, 3, 1, 2};
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta > 3) return;
|
||||
|
||||
if(rotateHead(world, x, y, z)!=-1)
|
||||
return;
|
||||
|
||||
int rot = rotRemap[(MathHelper.floor_double(entity.rotationYaw * 4.0 / 360.0 + 0.5) ) & 3];
|
||||
|
||||
world.setBlockMetadataWithNotify(x, y, z, rot, 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onBlockPlaced(World world, int x, int y, int z, int side, float hx, float hy, float hz, int meta) {
|
||||
if (meta <= 3) return meta;
|
||||
|
||||
if(rotateBodyPart(world,x,y,z)){
|
||||
return world.getBlockMetadata(x,y,z);
|
||||
}
|
||||
|
||||
if(side==0 || side==1) meta=14;
|
||||
if(side==2 || side==3) meta=13;
|
||||
if(side==4 || side==5) meta=12;
|
||||
|
||||
world.setBlockMetadataWithNotify(x, y, z, meta, 2);
|
||||
|
||||
return meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
|
||||
int kind = world.getBlockMetadata(x, y, z) & 0xC;
|
||||
|
||||
if (kind == 0) {
|
||||
rotateHead(world, x, y, z);
|
||||
} else {
|
||||
rotateBodyPart(world, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
public int[] getConnections(World world, int ox, int oy, int oz) {
|
||||
int index=0;
|
||||
int[] res={-1,-1,-1,-1,-1,-1,-1};
|
||||
|
||||
for (int direction = 0; direction < 6; direction++) {
|
||||
int x=ox, y=oy, z=oz;
|
||||
switch (direction) {
|
||||
case 0: z--; break;
|
||||
case 1: z++; break;
|
||||
case 2: x--; break;
|
||||
case 3: x++; break;
|
||||
case 4: y--; break;
|
||||
case 5: y++; break;
|
||||
}
|
||||
|
||||
if ( !world.getBlock(x, y, z).equals(this) ) continue;
|
||||
boolean match=false;
|
||||
|
||||
int px1=x,px2=x;
|
||||
int py1=y,py2=y;
|
||||
int pz1=z,pz2=z;
|
||||
|
||||
int meta=world.getBlockMetadata(x,y,z);
|
||||
if((meta&0xc) == 4 || (meta&0xc) == 8){
|
||||
if((meta&4) == 4) py1--; else py1++;
|
||||
|
||||
switch (meta&3) {
|
||||
case 0: pz2--; break;
|
||||
case 1: pz2++; break;
|
||||
case 2: px2--; break;
|
||||
case 3: px2++; break;
|
||||
}
|
||||
} else if(meta==12){
|
||||
px1--; px2++;
|
||||
} else if(meta==13){
|
||||
pz1--; pz2++;
|
||||
} else if(meta==14){
|
||||
py1--; py2++;
|
||||
} else if(meta==15){
|
||||
match=true;
|
||||
} else if(meta<4){
|
||||
match=true;
|
||||
}
|
||||
|
||||
if(! match){
|
||||
Block b1=world.getBlock(px1, py1, pz1);
|
||||
Block b2=world.getBlock(px2, py2, pz2);
|
||||
|
||||
|
||||
if(b1 != this || b2 != this)
|
||||
match=true;
|
||||
|
||||
if(ox==px1 && oy==py1 && oz==pz1)
|
||||
match=true;
|
||||
|
||||
if(ox==px2 && oy==py2 && oz==pz2)
|
||||
match=true;
|
||||
}
|
||||
|
||||
if(match)
|
||||
res[index++]=direction;
|
||||
}
|
||||
|
||||
if(index!=5)
|
||||
res[index]=-1;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
public boolean rotateBodyPart(World world, int x, int y, int z) {
|
||||
int[] con=getConnections(world,x,y,z);
|
||||
int blockMeta=world.getBlockMetadata(x, y, z);
|
||||
int kind=blockMeta&0xc;
|
||||
|
||||
if(con[1]==-1) return false;
|
||||
if(con[2]!=-1) return false;
|
||||
|
||||
int meta=15;
|
||||
|
||||
if(con[0]==2 && con[1]==3){
|
||||
meta=12;
|
||||
} else if(con[0]==0 && con[1]==1){
|
||||
meta=13;
|
||||
} else if(con[0]==4 && con[1]==5){
|
||||
meta=14;
|
||||
} else if(con[1]==4){
|
||||
meta=SEC_DOWN|con[0];
|
||||
} else if(con[1]==5){
|
||||
meta=SEC_UP|con[0];
|
||||
}
|
||||
|
||||
if(blockMeta!=meta)
|
||||
world.setBlockMetadataWithNotify(x, y, z, meta, 3);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public int rotateHead(World world, int x, int y, int z) {
|
||||
int[] con=getConnections(world,x,y,z);
|
||||
|
||||
if (con[1]>=0 && con[1]<4) return -1;
|
||||
|
||||
int meta=-1;
|
||||
switch (con[0]) {
|
||||
case 0: meta=1; break;
|
||||
case 1: meta=0; break;
|
||||
case 2: meta=3; break;
|
||||
case 3: meta=2; break;
|
||||
}
|
||||
|
||||
if(meta==-1) return -1;
|
||||
|
||||
world.setBlock(x, y, z, this, meta, 3);
|
||||
return meta;
|
||||
}
|
||||
|
||||
public boolean connectedTo(World par1World, int x, int y, int z, int direction) {
|
||||
switch (direction) {
|
||||
case 0: return par1World.getBlock(x, y, z - 1).equals(this);
|
||||
case 1: return par1World.getBlock(x, y, z + 1).equals(this);
|
||||
case 2: return par1World.getBlock(x - 1, y, z).equals(this);
|
||||
case 3: return par1World.getBlock(x + 1, y, z).equals(this);
|
||||
case 4: return par1World.getBlock(x, y - 1, z).equals(this);
|
||||
case 5: return par1World.getBlock(x, y + 1, z).equals(this);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
int type = meta & 0xc;
|
||||
int orient = meta & 0x3;
|
||||
|
||||
switch(meta | (side<<4)){
|
||||
|
||||
case(SEC_HOR | 0 | (SIDE_B<<4)): return iconBottomTip;
|
||||
case(SEC_HOR | 0 | (SIDE_T<<4)): return iconTopSide;
|
||||
case(SEC_HOR | 0 | (SIDE_N<<4)): return iconSide;
|
||||
case(SEC_HOR | 0 | (SIDE_S<<4)): return iconSide;
|
||||
case(SEC_HOR | 0 | (SIDE_W<<4)): return iconCross;
|
||||
case(SEC_HOR | 0 | (SIDE_E<<4)): return iconCross;
|
||||
|
||||
case(SEC_HOR | 1 | (SIDE_B<<4)): return iconBottomTip;
|
||||
case(SEC_HOR | 1 | (SIDE_T<<4)): return iconTopSide;
|
||||
case(SEC_HOR | 1 | (SIDE_N<<4)): return iconCross;
|
||||
case(SEC_HOR | 1 | (SIDE_S<<4)): return iconCross;
|
||||
case(SEC_HOR | 1 | (SIDE_W<<4)): return iconSide;
|
||||
case(SEC_HOR | 1 | (SIDE_E<<4)): return iconSide;
|
||||
|
||||
case(SEC_HOR | 2 | (SIDE_B<<4)): return iconCross;
|
||||
case(SEC_HOR | 2 | (SIDE_T<<4)): return iconCross;
|
||||
case(SEC_HOR | 2 | (SIDE_N<<4)): return iconSide;
|
||||
case(SEC_HOR | 2 | (SIDE_S<<4)): return iconSide;
|
||||
case(SEC_HOR | 2 | (SIDE_W<<4)): return iconSide;
|
||||
case(SEC_HOR | 2 | (SIDE_E<<4)): return iconSide;
|
||||
|
||||
case(SEC_HOR | 3 | (SIDE_B<<4)): return iconBottom;
|
||||
case(SEC_HOR | 3 | (SIDE_T<<4)): return iconTop;
|
||||
case(SEC_HOR | 3 | (SIDE_N<<4)): return iconSide;
|
||||
case(SEC_HOR | 3 | (SIDE_S<<4)): return iconSide;
|
||||
case(SEC_HOR | 3 | (SIDE_W<<4)): return iconSide;
|
||||
case(SEC_HOR | 3 | (SIDE_E<<4)): return iconSide;
|
||||
|
||||
case(SEC_DOWN | 0 | (SIDE_B<<4)): return iconCross;
|
||||
case(SEC_DOWN | 0 | (SIDE_T<<4)): return iconTopTip;
|
||||
case(SEC_DOWN | 0 | (SIDE_N<<4)): return iconCross;
|
||||
case(SEC_DOWN | 0 | (SIDE_S<<4)): return iconRightTip;
|
||||
case(SEC_DOWN | 0 | (SIDE_W<<4)): return iconLeftDown;
|
||||
case(SEC_DOWN | 0 | (SIDE_E<<4)): return iconRightDown;
|
||||
|
||||
case(SEC_DOWN | 1 | (SIDE_B<<4)): return iconCross;
|
||||
case(SEC_DOWN | 1 | (SIDE_T<<4)): return iconTopTip;
|
||||
case(SEC_DOWN | 1 | (SIDE_N<<4)): return iconLeftTip;
|
||||
case(SEC_DOWN | 1 | (SIDE_S<<4)): return iconCross;
|
||||
case(SEC_DOWN | 1 | (SIDE_W<<4)): return iconRightDown;
|
||||
case(SEC_DOWN | 1 | (SIDE_E<<4)): return iconLeftDown;
|
||||
|
||||
case(SEC_DOWN | 2 | (SIDE_B<<4)): return iconCross;
|
||||
case(SEC_DOWN | 2 | (SIDE_T<<4)): return iconTopTip;
|
||||
case(SEC_DOWN | 2 | (SIDE_N<<4)): return iconRightDown;
|
||||
case(SEC_DOWN | 2 | (SIDE_S<<4)): return iconLeftDown;
|
||||
case(SEC_DOWN | 2 | (SIDE_W<<4)): return iconCross;
|
||||
case(SEC_DOWN | 2 | (SIDE_E<<4)): return iconLeftTip;
|
||||
|
||||
case(SEC_DOWN | 3 | (SIDE_B<<4)): return iconCross;
|
||||
case(SEC_DOWN | 3 | (SIDE_T<<4)): return iconTopTip;
|
||||
case(SEC_DOWN | 3 | (SIDE_N<<4)): return iconLeftDown;
|
||||
case(SEC_DOWN | 3 | (SIDE_S<<4)): return iconRightDown;
|
||||
case(SEC_DOWN | 3 | (SIDE_W<<4)): return iconRightTip;
|
||||
case(SEC_DOWN | 3 | (SIDE_E<<4)): return iconCross;
|
||||
|
||||
case(SEC_UP | 0 | (SIDE_B<<4)): return iconBottomSide;
|
||||
case(SEC_UP | 0 | (SIDE_T<<4)): return iconCross;
|
||||
case(SEC_UP | 0 | (SIDE_N<<4)): return iconCross;
|
||||
case(SEC_UP | 0 | (SIDE_S<<4)): return iconLeftTip;
|
||||
case(SEC_UP | 0 | (SIDE_W<<4)): return iconLeftUp;
|
||||
case(SEC_UP | 0 | (SIDE_E<<4)): return iconRightUp;
|
||||
|
||||
case(SEC_UP | 1 | (SIDE_B<<4)): return iconBottomSide;
|
||||
case(SEC_UP | 1 | (SIDE_T<<4)): return iconCross;
|
||||
case(SEC_UP | 1 | (SIDE_N<<4)): return iconRightTip;
|
||||
case(SEC_UP | 1 | (SIDE_S<<4)): return iconCross;
|
||||
case(SEC_UP | 1 | (SIDE_W<<4)): return iconRightUp;
|
||||
case(SEC_UP | 1 | (SIDE_E<<4)): return iconLeftUp;
|
||||
|
||||
case(SEC_UP | 2 | (SIDE_B<<4)): return iconBottomSide;
|
||||
case(SEC_UP | 2 | (SIDE_T<<4)): return iconCross;
|
||||
case(SEC_UP | 2 | (SIDE_N<<4)): return iconRightUp;
|
||||
case(SEC_UP | 2 | (SIDE_S<<4)): return iconLeftUp;
|
||||
case(SEC_UP | 2 | (SIDE_W<<4)): return iconCross;
|
||||
case(SEC_UP | 2 | (SIDE_E<<4)): return iconRightTip;
|
||||
|
||||
case(SEC_UP | 3 | (SIDE_B<<4)): return iconBottomSide;
|
||||
case(SEC_UP | 3 | (SIDE_T<<4)): return iconCross;
|
||||
case(SEC_UP | 3 | (SIDE_N<<4)): return iconLeftUp;
|
||||
case(SEC_UP | 3 | (SIDE_S<<4)): return iconRightUp;
|
||||
case(SEC_UP | 3 | (SIDE_W<<4)): return iconLeftTip;
|
||||
case(SEC_UP | 3 | (SIDE_E<<4)): return iconCross;
|
||||
|
||||
case(SEC_HEAD | 0 | (SIDE_B<<4)): return iconBottomSide;
|
||||
case(SEC_HEAD | 0 | (SIDE_T<<4)): return iconTopTip;
|
||||
case(SEC_HEAD | 0 | (SIDE_N<<4)): return iconFace;
|
||||
case(SEC_HEAD | 0 | (SIDE_S<<4)): return iconCross;
|
||||
case(SEC_HEAD | 0 | (SIDE_W<<4)): return iconFaceLeft;
|
||||
case(SEC_HEAD | 0 | (SIDE_E<<4)): return iconFaceRight;
|
||||
|
||||
case(SEC_HEAD | 1 | (SIDE_B<<4)): return iconBottomSide;
|
||||
case(SEC_HEAD | 1 | (SIDE_T<<4)): return iconTopTip;
|
||||
case(SEC_HEAD | 1 | (SIDE_N<<4)): return iconCross;
|
||||
case(SEC_HEAD | 1 | (SIDE_S<<4)): return iconFace;
|
||||
case(SEC_HEAD | 1 | (SIDE_W<<4)): return iconFaceRight;
|
||||
case(SEC_HEAD | 1 | (SIDE_E<<4)): return iconFaceLeft;
|
||||
|
||||
case(SEC_HEAD | 2 | (SIDE_B<<4)): return iconBottomSide;
|
||||
case(SEC_HEAD | 2 | (SIDE_T<<4)): return iconTopTip;
|
||||
case(SEC_HEAD | 2 | (SIDE_N<<4)): return iconFaceRight;
|
||||
case(SEC_HEAD | 2 | (SIDE_S<<4)): return iconFaceLeft;
|
||||
case(SEC_HEAD | 2 | (SIDE_W<<4)): return iconFace;
|
||||
case(SEC_HEAD | 2 | (SIDE_E<<4)): return iconCross;
|
||||
|
||||
case(SEC_HEAD | 3 | (SIDE_B<<4)): return iconBottomSide;
|
||||
case(SEC_HEAD | 3 | (SIDE_T<<4)): return iconTopTip;
|
||||
case(SEC_HEAD | 3 | (SIDE_N<<4)): return iconFaceLeft;
|
||||
case(SEC_HEAD | 3 | (SIDE_S<<4)): return iconFaceRight;
|
||||
case(SEC_HEAD | 3 | (SIDE_W<<4)): return iconCross;
|
||||
case(SEC_HEAD | 3 | (SIDE_E<<4)): return iconFace;
|
||||
|
||||
}
|
||||
|
||||
return iconCross;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs tabs, List list) {
|
||||
list.add(new ItemStack(item, 1, 1));
|
||||
list.add(new ItemStack(item, 1, 13));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int meta) {
|
||||
if (meta < 4) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 13;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister register) {
|
||||
iconFaceLeft = register.registerIcon(iconPrefix + "face-left");
|
||||
iconFaceRight = register.registerIcon(iconPrefix + "face-right");
|
||||
iconFace = register.registerIcon(iconPrefix + "face");
|
||||
|
||||
iconLeftUp = register.registerIcon(iconPrefix + "left-up");
|
||||
iconLeftDown = register.registerIcon(iconPrefix + "left-down");
|
||||
iconLeftTip = register.registerIcon(iconPrefix + "left-tip");
|
||||
|
||||
iconRightUp = register.registerIcon(iconPrefix + "right-up");
|
||||
iconRightDown = register.registerIcon(iconPrefix + "right-down");
|
||||
iconRightTip = register.registerIcon(iconPrefix + "right-tip");
|
||||
|
||||
iconTop = register.registerIcon(iconPrefix + "top");
|
||||
iconTopTip = register.registerIcon(iconPrefix + "top-tip");
|
||||
iconTopSide = register.registerIcon(iconPrefix + "top-side");
|
||||
|
||||
iconBottom = register.registerIcon(iconPrefix + "bot");
|
||||
iconBottomTip = register.registerIcon(iconPrefix + "bot-tip");
|
||||
iconBottomSide = register.registerIcon(iconPrefix + "bot-side");
|
||||
|
||||
iconCross = register.registerIcon(iconPrefix + "crosssection");
|
||||
iconSide = register.registerIcon(iconPrefix + "side");
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package info.jbcs.minecraft.chisel.block;
|
||||
|
||||
|
||||
|
||||
import info.jbcs.minecraft.chisel.GeneralChiselClient;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockSnakestoneObsidian extends BlockSnakestone {
|
||||
public IIcon[] particles=new IIcon[8];
|
||||
|
||||
public BlockSnakestoneObsidian(String iconPrefix) {
|
||||
super(iconPrefix);
|
||||
|
||||
flipTopTextures=true;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void randomDisplayTick(World world, int x, int y, int z, Random random) {
|
||||
GeneralChiselClient.spawnSnakestoneObsidianFX(world,this,x,y,z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister register) {
|
||||
super.registerBlockIcons(register);
|
||||
|
||||
for(int i=0;i<particles.length;i++){
|
||||
particles[i]=register.registerIcon(iconPrefix + "particles/"+i);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package info.jbcs.minecraft.chisel.block;
|
||||
|
||||
import info.jbcs.minecraft.chisel.Chisel;
|
||||
import info.jbcs.minecraft.chisel.GeneralChiselClient;
|
||||
import info.jbcs.minecraft.chisel.render.BlockSpikesRenderer;
|
||||
import info.jbcs.minecraft.utilities.General;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
public class BlockSpikes extends Block {
|
||||
public IIcon iconBase;
|
||||
public IIcon iconSpike;
|
||||
|
||||
public BlockSpikes(Material mat) {
|
||||
super(Material.circuits);
|
||||
|
||||
this.setCreativeTab(CreativeTabs.tabDecorations);
|
||||
this.setBlockBounds(0.0f, 0.0f, 0.0f, 1.0f, 1.0f / 16, 1.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
|
||||
if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT)
|
||||
return;
|
||||
|
||||
// int damage = (int) (entity.motionY*10);
|
||||
// if(damage!=0)
|
||||
// System.out.println(damage);
|
||||
|
||||
double dy=entity.posY-entity.prevPosY;
|
||||
if(dy!=0)
|
||||
System.out.println(dy);
|
||||
|
||||
// System.out.println(entity.speedInAir);
|
||||
|
||||
|
||||
GeneralChiselClient.speedupPlayer(world, entity, Chisel.concreteVelocity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return BlockSpikesRenderer.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int meta) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister register) {
|
||||
blockIcon = iconBase = register.registerIcon(General.getName(this) + "base");
|
||||
iconSpike = register.registerIcon(General.getName(this) + "spike");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
package info.jbcs.minecraft.chisel.entity;
|
||||
|
||||
import info.jbcs.minecraft.chisel.Chisel;
|
||||
import info.jbcs.minecraft.chisel.GeneralChiselClient;
|
||||
import info.jbcs.minecraft.utilities.General;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.projectile.EntityThrowable;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class EntityBallOMoss extends EntityThrowable {
|
||||
|
||||
public EntityBallOMoss(World par1World) {
|
||||
super(par1World);
|
||||
}
|
||||
|
||||
public EntityBallOMoss(World par1World, EntityLivingBase par2EntityLiving) {
|
||||
super(par1World, par2EntityLiving);
|
||||
}
|
||||
|
||||
public EntityBallOMoss(World par1World, double x, double y, double z) {
|
||||
super(par1World, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onImpact(MovingObjectPosition movingobjectposition) {
|
||||
int x = movingobjectposition.blockX;
|
||||
int y = movingobjectposition.blockY;
|
||||
int z = movingobjectposition.blockZ;
|
||||
|
||||
switch (movingobjectposition.sideHit) {
|
||||
case 0:
|
||||
y--;
|
||||
break;
|
||||
case 1:
|
||||
y++;
|
||||
break;
|
||||
case 2:
|
||||
z--;
|
||||
break;
|
||||
case 3:
|
||||
z++;
|
||||
break;
|
||||
case 4:
|
||||
x--;
|
||||
break;
|
||||
case 5:
|
||||
x++;
|
||||
break;
|
||||
}
|
||||
|
||||
setDead();
|
||||
|
||||
if (worldObj.isRemote){
|
||||
worldObj.playSound(x, y, z, "chisel:squash", 1.0f, 1.0f, false);
|
||||
|
||||
for(int i=0;i<32;i++)
|
||||
GeneralChiselClient.spawnBallOMossFX(worldObj,posX,posY,posZ);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int radius=5;
|
||||
int falloff=3;
|
||||
|
||||
for(int xx=-radius;xx<radius;xx++){
|
||||
for(int yy=-radius;yy<radius;yy++){
|
||||
for(int zz=-radius;zz<radius;zz++){
|
||||
double dist=(xx<0?-xx:xx)+(yy<0?-yy:yy)+(zz<0?-zz:zz);
|
||||
|
||||
if(! (dist<falloff || General.rand.nextInt(radius*3-falloff)>=dist*2)) continue;
|
||||
|
||||
if (! worldObj.isRemote)
|
||||
turnToMoss(worldObj, x+xx, y+yy, z+zz);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static void turnToMoss(World world, int x, int y, int z) {
|
||||
Block block=world.getBlock(x, y, z);
|
||||
int meta=world.getBlockMetadata(x, y, z);
|
||||
Block resBlock=block;
|
||||
int resMeta=meta;
|
||||
|
||||
if(block.equals(Blocks.cobblestone)){
|
||||
resBlock = Blocks.mossy_cobblestone;
|
||||
} else if(block.equals(Blocks.cobblestone_wall) && meta==0){
|
||||
resMeta=1;
|
||||
} else if(block.equals(Chisel.blockCobblestone)){
|
||||
resBlock=Chisel.blockCobblestoneMossy;
|
||||
} else if(block.equals(Chisel.blockTemple)){
|
||||
resBlock=Chisel.blockTempleMossy;
|
||||
}
|
||||
|
||||
if(resBlock.equals(block) && resMeta==meta) return;
|
||||
world.setBlock(x, y, z, resBlock, resMeta, 3);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
package info.jbcs.minecraft.chisel.entity;
|
||||
|
||||
import info.jbcs.minecraft.chisel.Chisel;
|
||||
import info.jbcs.minecraft.chisel.block.BlockSnakestoneObsidian;
|
||||
import info.jbcs.minecraft.utilities.General;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class EntityBallOMossFX extends EntityFX{
|
||||
BlockSnakestoneObsidian block;
|
||||
double tx, ty, tz;
|
||||
double speed;
|
||||
|
||||
float u0,u1,v0,v1;
|
||||
IIcon icon;
|
||||
IIcon iconPlus=new IIcon(){
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getIconWidth() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getIconHeight() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float getMinU() {
|
||||
return u0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float getMaxU() {
|
||||
return u1;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float getInterpolatedU(double d0) {
|
||||
return (float) (u0+d0*(u1-u0)/16.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float getMinV() {
|
||||
return v0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float getMaxV() {
|
||||
return v1;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float getInterpolatedV(double d0) {
|
||||
return (float) (v0+d0*(v1-v0)/16.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String getIconName() {
|
||||
return "";
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public EntityBallOMossFX(World world, double x, double y, double z) {
|
||||
super(world, x, y+0.5, z, 0, 0, 0);
|
||||
|
||||
particleScale = 0.5f + 0.5f*General.rand.nextFloat();
|
||||
speed=0.4+0.4*General.rand.nextDouble();
|
||||
|
||||
particleMaxAge = (int) (General.rand.nextDouble() * 10.0) + 5;
|
||||
if(General.rand.nextInt(10)==0)
|
||||
particleMaxAge+=General.rand.nextDouble()*40.0;
|
||||
|
||||
motionX=(General.rand.nextDouble()-0.5)*0.7;
|
||||
motionY=(General.rand.nextDouble()*0.5)*0.7;
|
||||
motionZ=(General.rand.nextDouble()-0.5)*0.7;
|
||||
particleGravity=2.0f;
|
||||
|
||||
// setParticleIcon(block.particles[General.rand.nextInt(block.particles.length)]);
|
||||
|
||||
icon=Chisel.itemBallOMoss.getIconFromDamage(0);
|
||||
float width=4.0f+General.rand.nextFloat()*8.0f;
|
||||
float uu=General.rand.nextFloat()*(16.0f-width);
|
||||
float vv=General.rand.nextFloat()*(16.0f-width);
|
||||
u0=icon.getInterpolatedU(uu);
|
||||
u1=icon.getInterpolatedU(uu+width);
|
||||
v0=icon.getInterpolatedV(vv);
|
||||
v1=icon.getInterpolatedV(vv+width);
|
||||
|
||||
setParticleIcon(iconPlus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderParticle(Tessellator tessellator, float partialTick, float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) {
|
||||
GL11.glDepthMask(false);
|
||||
GL11.glEnable(3042);
|
||||
GL11.glBlendFunc(770, 771);
|
||||
super.renderParticle(tessellator, partialTick, rotX, rotXZ, rotZ, rotYZ, rotXY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
|
||||
double remaining=particleMaxAge-particleAge;
|
||||
|
||||
if(remaining<5){
|
||||
particleAlpha=(float) (remaining/5.0);
|
||||
} else{
|
||||
particleAlpha=1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package info.jbcs.minecraft.chisel.entity;
|
||||
|
||||
import info.jbcs.minecraft.chisel.Chisel;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.projectile.EntityThrowable;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class EntityCloudInABottle extends EntityThrowable {
|
||||
Random rand = new Random();
|
||||
|
||||
public EntityCloudInABottle(World par1World) {
|
||||
super(par1World);
|
||||
}
|
||||
|
||||
public EntityCloudInABottle(World par1World, EntityLivingBase par2EntityLiving) {
|
||||
super(par1World, par2EntityLiving);
|
||||
}
|
||||
|
||||
public EntityCloudInABottle(World par1World, double x, double y, double z) {
|
||||
super(par1World, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onImpact(MovingObjectPosition movingobjectposition) {
|
||||
if (worldObj.isRemote)
|
||||
return;
|
||||
|
||||
int x = movingobjectposition.blockX;
|
||||
int y = movingobjectposition.blockY;
|
||||
int z = movingobjectposition.blockZ;
|
||||
|
||||
switch (movingobjectposition.sideHit) {
|
||||
case 0:
|
||||
y--;
|
||||
break;
|
||||
case 1:
|
||||
y++;
|
||||
break;
|
||||
case 2:
|
||||
z--;
|
||||
break;
|
||||
case 3:
|
||||
z++;
|
||||
break;
|
||||
case 4:
|
||||
x--;
|
||||
break;
|
||||
case 5:
|
||||
x++;
|
||||
break;
|
||||
}
|
||||
|
||||
generate(worldObj, rand, x, y, z, 40);
|
||||
|
||||
// worldObj.playSound(this.posX, this.posY, this.posZ, "random.glass",
|
||||
// 1.0F, worldObj.rand.nextFloat() * 0.1F + 0.9F, false);
|
||||
worldObj.playAuxSFX(2002, (int) Math.round(this.posX), (int) Math.round(this.posY), (int) Math.round(this.posZ), 2);
|
||||
setDead();
|
||||
}
|
||||
|
||||
public boolean generate(World world, Random random, int gx, int gy, int gz, int numberOfBlocks) {
|
||||
int X[] = new int[9];
|
||||
int Y[] = new int[9];
|
||||
int Z[] = new int[9];
|
||||
|
||||
for (int dir = 0; dir < 9; dir++) {
|
||||
X[dir] = gx;
|
||||
Y[dir] = gy;
|
||||
Z[dir] = gz;
|
||||
}
|
||||
int count = 0;
|
||||
while (count < numberOfBlocks) {
|
||||
for (int dir = 0; dir < 9; dir++) {
|
||||
if (count >= numberOfBlocks)
|
||||
break;
|
||||
|
||||
int dx = dir % 3 - 1;
|
||||
int dz = dir / 3 - 1;
|
||||
|
||||
if (dx == 0 && dz == 0)
|
||||
continue;
|
||||
|
||||
X[dir] += random.nextInt(3) - 1 + dx;
|
||||
Z[dir] += random.nextInt(3) - 1 + dz;
|
||||
Y[dir] += random.nextInt(2) * (random.nextInt(3) - 1);
|
||||
|
||||
int x = X[dir];
|
||||
int y = Y[dir];
|
||||
int z = Z[dir];
|
||||
|
||||
for (int j2 = x; j2 < x + random.nextInt(4) + 1; j2++) {
|
||||
for (int k2 = y; k2 < y + random.nextInt(1) + 2; k2++) {
|
||||
for (int l2 = z; l2 < z + random.nextInt(4) + 1; l2++) {
|
||||
if (world.getBlock(j2, k2, l2).isAir(world, j2, k2, l2) && Math.abs(j2 - x) + Math.abs(k2 - y) + Math.abs(l2 - z) < 4 * 1 + random.nextInt(2)) {
|
||||
world.setBlock(j2, k2, l2, Chisel.blockCloud);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("Created " + count + " cloud blocks.");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package info.jbcs.minecraft.chisel.entity;
|
||||
|
||||
import info.jbcs.minecraft.chisel.block.BlockHolystone;
|
||||
import info.jbcs.minecraft.utilities.General;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class EntityHolystoneFX extends EntityFX {
|
||||
float initialScale;
|
||||
float angleOffset;
|
||||
static final float fadetime = 20f;
|
||||
|
||||
public EntityHolystoneFX(World world, BlockHolystone block, double x, double y, double z) {
|
||||
super(world, x, y, z, 0, 0, 0);
|
||||
|
||||
// particleScale = 1.0f + 1.0f * General.rand.nextFloat();
|
||||
// particleScale = 1.0f;
|
||||
initialScale = 1.0f + 1.0f * General.rand.nextFloat();
|
||||
angleOffset = rand.nextFloat() * 360;
|
||||
|
||||
particleMaxAge = (int) (Math.random() * 10.0D) + 80;
|
||||
|
||||
setPosition(x, y, z);
|
||||
prevPosX = posX;
|
||||
prevPosY = posY;
|
||||
prevPosZ = posZ;
|
||||
|
||||
noClip = true;
|
||||
|
||||
setParticleIcon(block.iconStar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderParticle(Tessellator tessellator, float partialTick, float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) {
|
||||
particleScale = 0.25f + initialScale * (float) Math.sin((particleAge+angleOffset) / 180.f);
|
||||
|
||||
if (particleAge < fadetime)
|
||||
particleAlpha = particleAge / fadetime;
|
||||
else if (particleAge + fadetime >= particleMaxAge)
|
||||
particleAlpha = (particleMaxAge - particleAge) / fadetime;
|
||||
else
|
||||
particleAlpha = 1.0f;
|
||||
|
||||
super.renderParticle(tessellator, partialTick, rotX, rotXZ, rotZ, rotYZ, rotXY);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
if (particleAge++ >= particleMaxAge) {
|
||||
setDead();
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+107
@@ -0,0 +1,107 @@
|
||||
package info.jbcs.minecraft.chisel.entity;
|
||||
|
||||
import info.jbcs.minecraft.chisel.block.BlockSnakestoneObsidian;
|
||||
import info.jbcs.minecraft.utilities.General;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class EntitySnakestoneObsidianFX extends EntityFX {
|
||||
BlockSnakestoneObsidian block;
|
||||
double tx, ty, tz;
|
||||
double speed;
|
||||
|
||||
public EntitySnakestoneObsidianFX(World world, BlockSnakestoneObsidian b, int x, int y, int z) {
|
||||
super(world, x + 0.5, y + 0.5, z + 0.5, 0, 0, 0);
|
||||
|
||||
block = b;
|
||||
|
||||
particleScale = 0.5f + 0.5f*General.rand.nextFloat();
|
||||
speed=0.04+0.04*General.rand.nextDouble();
|
||||
//speed = 0;
|
||||
|
||||
// motionX = 0;
|
||||
// motionY = 0;
|
||||
// motionZ = 0;
|
||||
particleMaxAge = (int) (Math.random() * 10.0D) + 40;
|
||||
|
||||
tx = x + General.rand.nextDouble();
|
||||
ty = y + General.rand.nextDouble();
|
||||
tz = z + General.rand.nextDouble();
|
||||
switch(General.rand.nextInt(6)){
|
||||
case 0: tx=x; break;
|
||||
case 1: tx=x+1; break;
|
||||
case 2: ty=y; break;
|
||||
case 3: ty=y+1; break;
|
||||
case 4: tz=z; break;
|
||||
case 5: tz=z+1; break;
|
||||
}
|
||||
|
||||
double dx=(tx-posX)*3;
|
||||
double dy=(ty-posY)*3;
|
||||
double dz=(tz-posZ)*3;
|
||||
|
||||
setPosition(posX + dx, posY + dy, posZ + dz);
|
||||
prevPosX=posX;
|
||||
prevPosY=posY;
|
||||
prevPosZ=posZ;
|
||||
|
||||
noClip = true;
|
||||
|
||||
setParticleIcon(block.particles[General.rand.nextInt(block.particles.length)]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderParticle(Tessellator tessellator, float partialTick, float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) {
|
||||
GL11.glDepthMask(false);
|
||||
GL11.glEnable(3042);
|
||||
GL11.glBlendFunc(770, 771);
|
||||
super.renderParticle(tessellator, partialTick, rotX, rotXZ, rotZ, rotYZ, rotXY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
if (particleAge++ >= particleMaxAge) {
|
||||
setDead();
|
||||
return;
|
||||
}
|
||||
|
||||
double dx = tx - posX;
|
||||
double dy = ty - posY;
|
||||
double dz = tz - posZ;
|
||||
|
||||
double distance = Math.sqrt(dx * dx + dy * dy + dz * dz);
|
||||
if (distance == 0) {
|
||||
setDead();
|
||||
return;
|
||||
}
|
||||
if(distance<0.4){
|
||||
particleAlpha=(float) (distance/0.4);
|
||||
} else if(particleAge<20){
|
||||
particleAlpha=1.0f*particleAge/20;
|
||||
} else{
|
||||
particleAlpha=1.0f;
|
||||
}
|
||||
|
||||
if(distance<speed){
|
||||
speed=distance;
|
||||
}
|
||||
|
||||
prevPosX=posX;
|
||||
prevPosY=posY;
|
||||
prevPosZ=posZ;
|
||||
|
||||
double px=posX + dx / distance * speed;
|
||||
double py=posY + dy / distance * speed;
|
||||
double pz=posZ + dz / distance * speed;
|
||||
|
||||
setPosition(px, py, pz);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package info.jbcs.minecraft.chisel.inventory;
|
||||
|
||||
import info.jbcs.minecraft.chisel.Carving;
|
||||
import info.jbcs.minecraft.chisel.item.ItemChisel;
|
||||
import info.jbcs.minecraft.utilities.General;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class ContainerChisel extends Container {
|
||||
final InventoryChiselSelection inventory;
|
||||
InventoryPlayer playerInventory;
|
||||
int currentIndex;
|
||||
ItemStack chisel;
|
||||
public boolean finished;
|
||||
Carving carving;
|
||||
|
||||
public ContainerChisel(InventoryPlayer inventoryplayer, InventoryChiselSelection inv) {
|
||||
inventory = inv;
|
||||
playerInventory=inventoryplayer;
|
||||
currentIndex=playerInventory.currentItem;
|
||||
inv.container=this;
|
||||
|
||||
int[] leftOffsets = { 8, 26, 134, 152, 44, 116 };
|
||||
int[] topOffsets = { 8, 26, 44, 62 };
|
||||
|
||||
int index = 0;
|
||||
for (int i = 0; i < 2; i++) {
|
||||
for (int y = 0; y < 4; y++) {
|
||||
for (int x = 0; x < 2; x++) {
|
||||
addSlotToContainer(new SlotChiselSelection(this,inventory, inventory, x + i * 8 + y * 2, leftOffsets[x+i*2], topOffsets[y]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int y = 0; y < 4; y++) {
|
||||
for (int x = 0; x < 2; x++) {
|
||||
addSlotToContainer(new SlotChiselSelection(this,inventory, inventory, 16 + x + y * 2, leftOffsets[4 + x], topOffsets[3-y]));
|
||||
}
|
||||
}
|
||||
|
||||
addSlotToContainer(new SlotChiselInput(this,inventory, InventoryChiselSelection.normalSlots, 80, 35));
|
||||
|
||||
for (int k = 0; k < 3; k++) {
|
||||
for (int j1 = 0; j1 < 9; j1++) {
|
||||
addSlotToContainer(new Slot(inventoryplayer, j1 + k * 9 + 9, 8 + j1 * 18, 102 + k * 18 - 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (int l = 0; l < 9; l++) {
|
||||
addSlotToContainer(l==currentIndex?
|
||||
new SlotChiselPlayer(this,inventoryplayer, l, 8 + l * 18, 160 - 18):
|
||||
new Slot(inventoryplayer, l, 8 + l * 18, 160 - 18)
|
||||
);
|
||||
}
|
||||
|
||||
chisel=inventoryplayer.getCurrentItem();
|
||||
if(chisel.stackTagCompound!=null){
|
||||
ItemStack stack=ItemStack.loadItemStackFromNBT(chisel.stackTagCompound.getCompoundTag("chiselTarget"));
|
||||
inventory.setInventorySlotContents(InventoryChiselSelection.normalSlots, stack);
|
||||
}
|
||||
|
||||
Item item=General.getItem(chisel);
|
||||
carving=item instanceof ItemChisel?((ItemChisel)item).carving:Carving.chisel;
|
||||
|
||||
inventory.updateItems();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack slotClick(int par1, int par2, int par3, EntityPlayer par4EntityPlayer){
|
||||
if(par3==2 && par2==currentIndex)
|
||||
return null;
|
||||
|
||||
return super.slotClick(par1, par2, par3, par4EntityPlayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer entityplayer) {
|
||||
inventory.clearItems();
|
||||
super.onContainerClosed(entityplayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer entityplayer) {
|
||||
return inventory.isUseableByPlayer(entityplayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer entity, int i) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void onChiselSlotChanged() {
|
||||
ItemStack stack=playerInventory.mainInventory[currentIndex];
|
||||
if(!stack.isItemEqual(chisel)) finished=true;
|
||||
|
||||
if(finished) return;
|
||||
|
||||
if(chisel.stackTagCompound==null)
|
||||
chisel.stackTagCompound=new NBTTagCompound();
|
||||
|
||||
NBTTagCompound tag=new NBTTagCompound();
|
||||
if(inventory.getStackInSpecialSlot()!=null)
|
||||
inventory.getStackInSpecialSlot().writeToNBT(tag);
|
||||
|
||||
chisel.stackTagCompound.setTag("chiselTarget", tag);
|
||||
playerInventory.mainInventory[currentIndex]=chisel;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package info.jbcs.minecraft.chisel.inventory;
|
||||
|
||||
import info.jbcs.minecraft.utilities.GeneralClient;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class GuiChisel extends GuiContainer {
|
||||
EntityPlayer player;
|
||||
ContainerChisel container;
|
||||
|
||||
public GuiChisel(InventoryPlayer iinventory, InventoryChiselSelection menu) {
|
||||
super(new ContainerChisel(iinventory, menu));
|
||||
player = iinventory.player;
|
||||
height = 177;
|
||||
|
||||
container=(ContainerChisel) inventorySlots;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
super.onGuiClosed();
|
||||
inventorySlots.onContainerClosed(player);
|
||||
}
|
||||
|
||||
boolean isExtended(){
|
||||
return container.inventory.activeVariations>16;
|
||||
}
|
||||
|
||||
//@Override
|
||||
protected boolean isPointInRegion(int x, int y, int w, int h, int px, int py) {
|
||||
px -= this.guiLeft;
|
||||
py -= this.guiTop;
|
||||
|
||||
if(! isExtended() && y>=7 && y<=62){
|
||||
if(px >= 43 && px <= 60) return false;
|
||||
if(px >= 115 && px <= 132) return false;
|
||||
}
|
||||
|
||||
return px >= x - 1 && px < x + w + 1 && py >= y - 1 && py < y + h + 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int j, int i) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
String line=isExtended()?"Carve":"Carve blocks";
|
||||
// this.drawCenteredString(fontRenderer, isExtended()?"Carve":"Carve blocks", 88, 13, 0x888888);
|
||||
fontRendererObj.drawString(line, 88-fontRendererObj.getStringWidth(line) / 2, 13, 0x404040);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float f, int mx, int my) {
|
||||
drawDefaultBackground();
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
int i = width - xSize >> 1;
|
||||
int j = height - ySize >> 1;
|
||||
|
||||
String texture=isExtended()?
|
||||
"chisel:textures/chisel-gui-24.png":
|
||||
"chisel:textures/chisel-gui.png";
|
||||
|
||||
GeneralClient.bind(texture);
|
||||
drawTexturedModalRect(i, j, 0, 0, xSize, ySize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton guibutton) {
|
||||
super.actionPerformed(guibutton);
|
||||
}
|
||||
}
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
package info.jbcs.minecraft.chisel.inventory;
|
||||
|
||||
import info.jbcs.minecraft.chisel.item.ItemChisel;
|
||||
import info.jbcs.minecraft.utilities.General;
|
||||
import info.jbcs.minecraft.utilities.InventoryStatic;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class InventoryChiselSelection extends InventoryStatic {
|
||||
ItemStack chisel = null;
|
||||
final static int normalSlots=32;
|
||||
int activeVariations=0;
|
||||
ContainerChisel container;
|
||||
|
||||
public InventoryChiselSelection(ItemStack c) {
|
||||
super(normalSlots+1);
|
||||
|
||||
chisel = c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "Carve blocks";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer entityplayer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInventoryChanged() {
|
||||
}
|
||||
|
||||
public void clearItems() {
|
||||
activeVariations=0;
|
||||
for (int i = 0; i < normalSlots; i++) {
|
||||
items[i] = null;
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack getStackInSpecialSlot() {
|
||||
return items[normalSlots];
|
||||
}
|
||||
|
||||
public void updateItems() {
|
||||
ItemStack chiseledItem = items[normalSlots];
|
||||
|
||||
clearItems();
|
||||
|
||||
if (chiseledItem == null){
|
||||
container.onChiselSlotChanged();
|
||||
return;
|
||||
}
|
||||
|
||||
Item item = chiseledItem.getItem();
|
||||
if(item == null) return;
|
||||
|
||||
if(Block.getBlockFromItem(item) == null)
|
||||
return;
|
||||
|
||||
ArrayList<ItemStack> list=container.carving.getItems(chiseledItem);
|
||||
|
||||
activeVariations=0;
|
||||
while(activeVariations<normalSlots && activeVariations<list.size()){
|
||||
items[activeVariations]=list.get(activeVariations);
|
||||
activeVariations++;
|
||||
}
|
||||
|
||||
container.onChiselSlotChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int i) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack stack) {
|
||||
if(stack!=null && (stack.getItem() instanceof ItemChisel)){
|
||||
return false;
|
||||
}
|
||||
|
||||
return i==normalSlots;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package info.jbcs.minecraft.chisel.inventory;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class SlotChiselInput extends Slot {
|
||||
public SlotChiselInput(ContainerChisel container, InventoryChiselSelection inv,int i,int j,int k) {
|
||||
super(inv, i, j, k);
|
||||
selInventory = inv;
|
||||
this.container=container;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack itemstack) {
|
||||
if(container.finished) return false;
|
||||
|
||||
return super.isItemValid(itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack(EntityPlayer par1EntityPlayer){
|
||||
if(container.finished) return false;
|
||||
|
||||
return super.canTakeStack(par1EntityPlayer);
|
||||
}
|
||||
|
||||
@Override public void onSlotChanged() {
|
||||
if(container.finished) return;
|
||||
|
||||
super.onSlotChanged();
|
||||
selInventory.updateItems();
|
||||
}
|
||||
|
||||
ContainerChisel container;
|
||||
InventoryChiselSelection selInventory;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package info.jbcs.minecraft.chisel.inventory;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
|
||||
public class SlotChiselPlayer extends Slot {
|
||||
|
||||
public SlotChiselPlayer(ContainerChisel container,InventoryPlayer inv,int i,int j,int k) {
|
||||
super(inv, i, j, k);
|
||||
|
||||
this.container=container;
|
||||
selInventory = inv;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack par1ItemStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickupFromSlot(EntityPlayer player,ItemStack itemstack) {
|
||||
container.finished=true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getHasStack() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int i) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ContainerChisel container;
|
||||
InventoryPlayer selInventory;
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
package info.jbcs.minecraft.chisel.inventory;
|
||||
|
||||
import info.jbcs.minecraft.utilities.General;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class SlotChiselSelection extends Slot {
|
||||
public SlotChiselSelection(ContainerChisel container, InventoryChiselSelection inv,IInventory iinventory,int i,int j,int k) {
|
||||
super(iinventory, i, j, k);
|
||||
|
||||
this.container=container;
|
||||
selInventory = inv;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack itemstack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack(EntityPlayer par1EntityPlayer){
|
||||
if(container.finished) return false;
|
||||
|
||||
return par1EntityPlayer.inventory.getItemStack()==null;
|
||||
}
|
||||
|
||||
@Override public void onPickupFromSlot(EntityPlayer player,ItemStack itemstack) {
|
||||
ItemStack stack=player.inventory.getItemStack();
|
||||
ItemStack crafted=selInventory.items[InventoryChiselSelection.normalSlots];
|
||||
|
||||
if(stack==null){
|
||||
if(crafted!=null && crafted.stackSize>0) crafted.stackSize--;
|
||||
if(crafted.stackSize==0) crafted=null;
|
||||
|
||||
selInventory.setInventorySlotContents(InventoryChiselSelection.normalSlots,crafted);
|
||||
} else{
|
||||
putStack(new ItemStack(itemstack.getItem(), itemstack.stackSize, itemstack.getItemDamage()));
|
||||
|
||||
player.inventory.setItemStack(null);
|
||||
|
||||
if(selInventory.items[InventoryChiselSelection.normalSlots]==null) return;
|
||||
|
||||
player.inventory.setItemStack(new ItemStack(itemstack.getItem(), selInventory.items[InventoryChiselSelection.normalSlots].stackSize, itemstack.getItemDamage()));
|
||||
selInventory.setInventorySlotContents(InventoryChiselSelection.normalSlots,null);
|
||||
}
|
||||
|
||||
|
||||
selInventory.updateItems();
|
||||
|
||||
String sound=container.carving.getVariationSound(itemstack.getItem(), itemstack.getItemDamage());
|
||||
player.worldObj.playSoundAtEntity(player, sound, 0.3f + 0.7f * General.rand.nextFloat(), 0.6f + 0.4f * General.rand.nextFloat());
|
||||
|
||||
|
||||
/* ItemStack stack=player.inventory.getItemStack();
|
||||
|
||||
putStack(new ItemStack(itemstack.itemID, itemstack.stackSize, itemstack.getItemDamage()));
|
||||
|
||||
super.onPickupFromSlot(player,itemstack);
|
||||
|
||||
player.inventory.setItemStack(null);
|
||||
|
||||
if(selInventory.items[InventoryChiselSelection.normalSlots]==null) return;
|
||||
|
||||
player.inventory.setItemStack(new ItemStack(itemstack.itemID, selInventory.items[InventoryChiselSelection.normalSlots].stackSize, itemstack.getItemDamage()));
|
||||
selInventory.setInventorySlotContents(InventoryChiselSelection.normalSlots,null);
|
||||
|
||||
selInventory.updateItems();
|
||||
|
||||
String sound=Carving.chisel.getVariationSound(itemstack.itemID, itemstack.getItemDamage());
|
||||
player.worldObj.playSoundAtEntity(player, sound, 0.3f + 0.7f * General.rand.nextFloat(), 0.6f + 0.4f * General.rand.nextFloat());
|
||||
*/ }
|
||||
|
||||
ContainerChisel container;
|
||||
InventoryChiselSelection selInventory;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package info.jbcs.minecraft.chisel.item;
|
||||
|
||||
import info.jbcs.minecraft.chisel.entity.EntityBallOMoss;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemBallOMoss extends Item{
|
||||
|
||||
public ItemBallOMoss() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
|
||||
if (!par3EntityPlayer.capabilities.isCreativeMode) {
|
||||
--par1ItemStack.stackSize;
|
||||
}
|
||||
|
||||
par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
|
||||
|
||||
if (!par2World.isRemote) {
|
||||
par2World.spawnEntityInWorld(new EntityBallOMoss(par2World,par3EntityPlayer));
|
||||
}
|
||||
|
||||
return par1ItemStack;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package info.jbcs.minecraft.chisel.item;
|
||||
|
||||
import info.jbcs.minecraft.chisel.Carvable;
|
||||
import info.jbcs.minecraft.chisel.CarvableVariation;
|
||||
import info.jbcs.minecraft.chisel.Chisel;
|
||||
import info.jbcs.minecraft.utilities.General;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
public class ItemCarvable extends ItemBlock {
|
||||
|
||||
public ItemCarvable(Block block) {
|
||||
super(block);
|
||||
setMaxDamage(0);
|
||||
setHasSubtypes(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(int i) {
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack itemstack) {
|
||||
return "item." + Block.getBlockFromItem(this).getUnlocalizedName() + "." + itemstack.getItemDamage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIconFromDamage(int damage) {
|
||||
return Block.getBlockFromItem(this).getIcon(2,damage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List lines, boolean advancedTooltips) {
|
||||
if(! Chisel.blockDescriptions) return;
|
||||
|
||||
Item item=General.getItem(stack);
|
||||
if(item==null) return;
|
||||
|
||||
Block block = Block.getBlockFromItem(this);
|
||||
if(! (block instanceof Carvable)) return;
|
||||
|
||||
Carvable carvable=(Carvable) block;
|
||||
CarvableVariation var=carvable.getVariation(stack.getItemDamage());
|
||||
if(var==null) return;
|
||||
|
||||
lines.add(var.description);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
package info.jbcs.minecraft.chisel.item;
|
||||
|
||||
import info.jbcs.minecraft.chisel.CarvableHelper;
|
||||
import info.jbcs.minecraft.chisel.Carving;
|
||||
import info.jbcs.minecraft.chisel.CarvingVariation;
|
||||
import info.jbcs.minecraft.chisel.Chisel;
|
||||
import info.jbcs.minecraft.chisel.GeneralChiselClient;
|
||||
import info.jbcs.minecraft.chisel.Packets;
|
||||
import info.jbcs.minecraft.utilities.General;
|
||||
import info.jbcs.minecraft.utilities.packets.PacketData;
|
||||
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import pl.asie.lib.network.Packet;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemTool;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.management.ServerConfigurationManager;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
|
||||
public class ItemChisel extends ItemTool {
|
||||
Random random=new Random();
|
||||
public Carving carving;
|
||||
|
||||
private static final HashSet<String> toolSet = new HashSet<String>();
|
||||
|
||||
public ItemChisel(Carving c) {
|
||||
super(1,ToolMaterial.IRON,CarvableHelper.getChiselBlockSet());
|
||||
|
||||
maxStackSize = 1;
|
||||
setMaxDamage(500);
|
||||
efficiencyOnProperMaterial=100f;
|
||||
|
||||
toolSet.add("chisel");
|
||||
carving=c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getToolClasses(ItemStack stack) {
|
||||
return toolSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) {
|
||||
entityplayer.openGui(Chisel.instance, 0, world, 0, 0, 0);
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
/*
|
||||
@Override
|
||||
public void registerIcons(IconRegister register)
|
||||
{
|
||||
}*/
|
||||
|
||||
HashMap<String,Long> chiselUseTime=new HashMap<String,Long>();
|
||||
HashMap<String,String> chiselUseLocation=new HashMap<String,String>();
|
||||
|
||||
@Override
|
||||
public boolean onBlockStartBreak(ItemStack stack, final int x, final int y, final int z, EntityPlayer player){
|
||||
World world=player.worldObj;
|
||||
Block block = world.getBlock(x, y, z);
|
||||
int blockMeta=world.getBlockMetadata(x,y,z);
|
||||
|
||||
if(! ForgeHooks.isToolEffective(stack, block, blockMeta))
|
||||
return false;
|
||||
|
||||
ItemStack chiselTarget=null;
|
||||
|
||||
if(stack.stackTagCompound!=null){
|
||||
chiselTarget=ItemStack.loadItemStackFromNBT(stack.stackTagCompound.getCompoundTag("chiselTarget"));
|
||||
}
|
||||
|
||||
boolean chiselHasBlockInside=true;
|
||||
|
||||
if(chiselTarget==null){
|
||||
Long useTime=chiselUseTime.get(player.getCommandSenderName());
|
||||
String loc=chiselUseLocation.get(player.getCommandSenderName());
|
||||
|
||||
if(useTime!=null && chiselUseLocation!=null && loc.equals(x+"|"+y+"|"+z)){
|
||||
long cooldown=20;
|
||||
long time=world.getWorldInfo().getWorldTotalTime();
|
||||
|
||||
if(time>useTime-cooldown && time<useTime+cooldown)
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
CarvingVariation[] variations=carving.getVariations(block, blockMeta);
|
||||
if(variations==null || variations.length<2) return true;
|
||||
|
||||
int index=random.nextInt(variations.length-1);
|
||||
if(variations[index].equals(block) && variations[index].meta==blockMeta){
|
||||
index++;
|
||||
if(index>=variations.length) index=0;
|
||||
}
|
||||
CarvingVariation var=variations[index];
|
||||
chiselTarget=new ItemStack(var.block,1,var.damage);
|
||||
|
||||
chiselHasBlockInside=false;
|
||||
}
|
||||
|
||||
Item target = chiselTarget.getItem();
|
||||
|
||||
int targetMeta=chiselTarget.getItemDamage();
|
||||
|
||||
boolean match=carving.isVariationOfSameClass(Block.getBlockFromItem(target),targetMeta,block,blockMeta);
|
||||
Item result = target;
|
||||
|
||||
|
||||
/* special case: stone can be carved to cobble and bricks */
|
||||
if(!match && block.equals(Blocks.stone) && Block.getBlockFromItem(target).equals(Chisel.blockCobblestone))
|
||||
match=true;
|
||||
if(!match && block.equals(Blocks.stone) && Block.getBlockFromItem(target).equals(Chisel.stoneBrick))
|
||||
match=true;
|
||||
|
||||
if(!match) return true;
|
||||
if(result.equals(block) && targetMeta == blockMeta) return true;
|
||||
|
||||
if(! world.isRemote || chiselHasBlockInside)
|
||||
world.setBlock(x, y, z, Block.getBlockFromItem(result), chiselTarget.getItemDamage(), 2);
|
||||
|
||||
switch(FMLCommonHandler.instance().getEffectiveSide()){
|
||||
case SERVER:
|
||||
chiselUseTime.put(player.getCommandSenderName(), world.getWorldInfo().getWorldTotalTime());
|
||||
chiselUseLocation.put(player.getCommandSenderName(),x+"|"+y+"|"+z);
|
||||
|
||||
try {
|
||||
Packet packet = Chisel.packet.create(Packets.CHISELED).writeInt(x).writeInt(y).writeInt(z);
|
||||
Chisel.packet.sendToAllAround(packet, new TargetPoint(player.dimension, x, y, z, 30.0f));
|
||||
} catch(Exception e) { e.printStackTrace(); }
|
||||
break;
|
||||
|
||||
case CLIENT:
|
||||
if(chiselHasBlockInside){
|
||||
String sound=carving.getVariationSound(result, chiselTarget.getItemDamage());
|
||||
GeneralChiselClient.spawnChiselEffect(x, y, z, sound);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
stack.damageItem(1, player);
|
||||
if(stack.stackSize==0){
|
||||
player.inventory.mainInventory[player.inventory.currentItem]=
|
||||
chiselHasBlockInside?
|
||||
chiselTarget:
|
||||
null;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package info.jbcs.minecraft.chisel.item;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class ItemChiselRenderer implements IItemRenderer {
|
||||
RenderBlocks renderBlock=new RenderBlocks();
|
||||
RenderItem renderItem=new RenderItem();
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
||||
return type == IItemRenderer.ItemRenderType.INVENTORY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem(ItemRenderType type, ItemStack stack, Object... data) {
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
|
||||
renderItem.renderItemIntoGUI(Minecraft.getMinecraft().fontRenderer, Minecraft.getMinecraft().renderEngine, stack, 0, 0);
|
||||
|
||||
if(stack.stackTagCompound==null) return;
|
||||
|
||||
ItemStack chiselTarget=ItemStack.loadItemStackFromNBT(stack.stackTagCompound.getCompoundTag("chiselTarget"));
|
||||
if(chiselTarget==null) return;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScalef(0.65f,0.65f,0.65f);
|
||||
GL11.glTranslatef(-8f, -8f, 0.0f);
|
||||
|
||||
renderItem.renderItemIntoGUI(Minecraft.getMinecraft().fontRenderer, Minecraft.getMinecraft().renderEngine, chiselTarget, 8, 8);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package info.jbcs.minecraft.chisel.item;
|
||||
|
||||
import info.jbcs.minecraft.chisel.entity.EntityCloudInABottle;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemCloudInABottle extends Item {
|
||||
|
||||
public ItemCloudInABottle() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called whenever this item is equipped and the right mouse button is
|
||||
* pressed. Args: itemStack, world, entityPlayer
|
||||
*/
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
|
||||
if (!par3EntityPlayer.capabilities.isCreativeMode) {
|
||||
--par1ItemStack.stackSize;
|
||||
}
|
||||
|
||||
par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
|
||||
|
||||
if (!par2World.isRemote) {
|
||||
par2World.spawnEntityInWorld(new EntityCloudInABottle(par2World,par3EntityPlayer));
|
||||
}
|
||||
|
||||
return par1ItemStack;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package info.jbcs.minecraft.chisel.item;
|
||||
|
||||
import info.jbcs.minecraft.chisel.block.BlockMarbleSlab;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemMarbleSlab extends ItemCarvable {
|
||||
|
||||
public ItemMarbleSlab(Block block) {
|
||||
super(block);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given ItemBlock can be placed on the given side of the given block position.
|
||||
*/
|
||||
@Override
|
||||
public boolean func_150936_a(World world, int x, int y, int z, int side, EntityPlayer player, ItemStack stack){
|
||||
BlockMarbleSlab block = (BlockMarbleSlab)Block.getBlockFromItem(this);
|
||||
|
||||
switch(side){
|
||||
case 0: --y; break;
|
||||
case 1: ++y; break;
|
||||
case 2: --z; break;
|
||||
case 3: ++z; break;
|
||||
case 4: --x; break;
|
||||
case 5: ++x; break;
|
||||
}
|
||||
|
||||
Block targetBlock = world.getBlock(x, y, z);
|
||||
int meta=world.getBlockMetadata(x, y, z);
|
||||
|
||||
if((targetBlock.equals(block) || targetBlock.equals(block.top)) && meta==stack.getItemDamage())
|
||||
return true;
|
||||
|
||||
return world.canPlaceEntityOnSide(block, x, y, z, false, side, (Entity)null, stack);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hx, float hy, float hz){
|
||||
BlockMarbleSlab block = (BlockMarbleSlab)Block.getBlockFromItem(this);
|
||||
|
||||
Block targetBlock = world.getBlock(x, y, z);
|
||||
int meta=world.getBlockMetadata(x, y, z);
|
||||
boolean metaMatches=meta==stack.getItemDamage();
|
||||
|
||||
if(metaMatches && side==0 && targetBlock.equals(block.top)){
|
||||
world.setBlock(x, y, z, block.master, meta, 2);
|
||||
return true;
|
||||
} else if(metaMatches && side==1 && targetBlock.equals(block.bottom)){
|
||||
world.setBlock(x, y, z, block.master, meta, 2);
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean result=super.onItemUse(stack,player,world,x,y,z,side,hz,hy,hz);
|
||||
|
||||
|
||||
switch(side){
|
||||
case 0: --y; break;
|
||||
case 1: ++y; break;
|
||||
case 2: --z; break;
|
||||
case 3: ++z; break;
|
||||
case 4: --x; break;
|
||||
case 5: ++x; break;
|
||||
}
|
||||
|
||||
targetBlock = world.getBlock(x, y, z);
|
||||
meta=world.getBlockMetadata(x, y, z);
|
||||
|
||||
if(!result && (targetBlock.equals(block.top) || targetBlock.equals(block.bottom)) && meta==stack.getItemDamage()){
|
||||
world.setBlock(x, y, z, block.master, meta, 2);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!result)
|
||||
return false;
|
||||
|
||||
if(side != 0 && (side == 1 || hy <= 0.5D))
|
||||
return true;
|
||||
|
||||
world.setBlock(x, y, z, block.top, meta, 2);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
package info.jbcs.minecraft.chisel.render;
|
||||
|
||||
import info.jbcs.minecraft.chisel.Carvable;
|
||||
import info.jbcs.minecraft.chisel.CarvableHelper;
|
||||
import info.jbcs.minecraft.chisel.CarvableVariation;
|
||||
import info.jbcs.minecraft.chisel.Chisel;
|
||||
import info.jbcs.minecraft.utilities.Drawing;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class BlockAdvancedMarbleRenderer implements ISimpleBlockRenderingHandler {
|
||||
RenderBlocksCTM rendererCTM=new RenderBlocksCTM();
|
||||
RenderBlocksColumn rendererColumn=new RenderBlocksColumn();
|
||||
|
||||
public BlockAdvancedMarbleRenderer() {
|
||||
if(Chisel.RenderCTMId==0){
|
||||
Chisel.RenderCTMId = RenderingRegistry.getNextAvailableRenderId();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
Drawing.drawBlock(block, metadata, renderer);
|
||||
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks rendererOld) {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
|
||||
CarvableVariation var=((Carvable) block).getVariation(meta);
|
||||
|
||||
switch(var==null?0:var.kind){
|
||||
case CarvableHelper.CTMX:
|
||||
rendererCTM.blockAccess=world;
|
||||
rendererCTM.renderMaxX=1.0;
|
||||
rendererCTM.renderMaxY=1.0;
|
||||
rendererCTM.renderMaxZ=1.0;
|
||||
|
||||
rendererCTM.submap=var.submap;
|
||||
rendererCTM.submapSmall=var.submapSmall;
|
||||
|
||||
rendererCTM.rendererOld=rendererOld;
|
||||
|
||||
return rendererCTM.renderStandardBlock(block,x,y,z);
|
||||
case CarvableHelper.CTMV:
|
||||
rendererColumn.blockAccess=world;
|
||||
rendererColumn.renderMaxX=1.0;
|
||||
rendererColumn.renderMaxY=1.0;
|
||||
rendererColumn.renderMaxZ=1.0;
|
||||
|
||||
rendererColumn.submap=var.seamsCtmVert;
|
||||
rendererColumn.iconTop=var.iconTop;
|
||||
|
||||
return rendererColumn.renderStandardBlock(block,x,y,z);
|
||||
default:
|
||||
return rendererOld.renderStandardBlock(block,x,y,z);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int renderId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return Chisel.RenderCTMId;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package info.jbcs.minecraft.chisel.render;
|
||||
|
||||
import info.jbcs.minecraft.chisel.Chisel;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
|
||||
public class BlockCarpetRenderer extends BlockAdvancedMarbleRenderer {
|
||||
|
||||
public BlockCarpetRenderer(){
|
||||
super();
|
||||
|
||||
Chisel.RenderCarpetId = RenderingRegistry.getNextAvailableRenderId();
|
||||
|
||||
rendererCTM=new RenderBlocksCTMCarpet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return Chisel.RenderCarpetId;
|
||||
}
|
||||
}
|
||||
+109
@@ -0,0 +1,109 @@
|
||||
package info.jbcs.minecraft.chisel.render;
|
||||
|
||||
import info.jbcs.minecraft.chisel.Chisel;
|
||||
import info.jbcs.minecraft.utilities.Drawing;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class BlockEldritchRenderer implements ISimpleBlockRenderingHandler {
|
||||
public BlockEldritchRenderer() {
|
||||
Chisel.RenderEldritchId = RenderingRegistry.getNextAvailableRenderId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
Drawing.drawBlock(block, metadata, renderer);
|
||||
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
|
||||
}
|
||||
|
||||
|
||||
RenderBlocksEldritch renderer=new RenderBlocksEldritch();
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks rendererOld) {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
|
||||
// tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
|
||||
/*
|
||||
double d0 = 0.4000000059604645D;
|
||||
double d1 = 0.5D - d0;
|
||||
double d2 = 0.20000000298023224D;
|
||||
|
||||
*/
|
||||
// renderer.renderTorchAtAngle(Block.torchWood, x - d1, y + d2, z, -d0, 0.0D, 0);
|
||||
/*
|
||||
Icon icon = block.getIcon(2, meta);
|
||||
double u0 = icon.getMinU();
|
||||
double v0 = icon.getMaxV();
|
||||
double u1 = icon.getMaxU();
|
||||
double v1 = icon.getMinV();
|
||||
double uu = icon.getInterpolatedU(8.0D);
|
||||
double vv = icon.getInterpolatedV(8.0D);
|
||||
|
||||
|
||||
int lyp=block.getMixedBrightnessForBlock(world, x, y+1, z);
|
||||
int lym=block.getMixedBrightnessForBlock(world, x, y-1, z);
|
||||
int lxp=block.getMixedBrightnessForBlock(world, x+1, y, z);
|
||||
int lxm=block.getMixedBrightnessForBlock(world, x-1, y, z);
|
||||
int lzp=block.getMixedBrightnessForBlock(world, x, y, z+1);
|
||||
int lzm=block.getMixedBrightnessForBlock(world, x, y, z-1);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
icon = block.getIcon(0, meta);
|
||||
u0 = icon.getMinU();
|
||||
v0 = icon.getMinV();
|
||||
u1 = icon.getMaxU();
|
||||
v1 = icon.getMaxV();
|
||||
vertex(1,u0,v0); vertex(5,u1,v0); vertex(6,u1,v1); vertex(2,u0,v1);
|
||||
|
||||
icon = block.getIcon(1, meta);
|
||||
u0 = icon.getMinU();
|
||||
v0 = icon.getMinV();
|
||||
u1 = icon.getMaxU();
|
||||
v1 = icon.getMaxV();
|
||||
vertex(0,u0,v0); vertex(3,u0,v1); vertex(7,u1,v1); vertex(4,u1,v0);
|
||||
|
||||
*/
|
||||
|
||||
renderer.blockAccess=world;
|
||||
renderer.renderMaxX=1.0;
|
||||
renderer.renderMaxY=1.0;
|
||||
renderer.renderMaxZ=1.0;
|
||||
renderer.renderStandardBlock(block,x,y,z);
|
||||
|
||||
return true;
|
||||
/*
|
||||
|
||||
boolean flag = renderer.renderStandardBlock(block, x, y, z);
|
||||
|
||||
return flag;*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int renderId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return Chisel.RenderEldritchId;
|
||||
}
|
||||
|
||||
}
|
||||
+307
@@ -0,0 +1,307 @@
|
||||
package info.jbcs.minecraft.chisel.render;
|
||||
|
||||
import info.jbcs.minecraft.utilities.Drawing;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockPane;
|
||||
import net.minecraft.client.renderer.EntityRenderer;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class BlockMarblePaneRenderer implements ISimpleBlockRenderingHandler {
|
||||
public static int id;
|
||||
|
||||
public BlockMarblePaneRenderer() {
|
||||
id = RenderingRegistry.getNextAvailableRenderId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int meta, int modelID, RenderBlocks renderer) {
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
GL11.glScalef(1.25f, 1.25f, 1.25f);
|
||||
renderer.setRenderBounds(0.0f, 0.0f, 0.5f - 0.0625f, 1.0f, 1.0f, 0.5f + 0.0625f);
|
||||
Drawing.drawBlock(block, meta, renderer);
|
||||
}
|
||||
|
||||
class PaneRenderer {
|
||||
Tessellator tessellator;
|
||||
|
||||
double i0u0;
|
||||
double i0uh;
|
||||
double i0u1;
|
||||
double i0v0;
|
||||
double i0v1;
|
||||
|
||||
double i1u0;
|
||||
double i1u1;
|
||||
double i1v0;
|
||||
double i1vh;
|
||||
double i1v1;
|
||||
double i1v;
|
||||
|
||||
double i2u0;
|
||||
double i2u1;
|
||||
double i2v0;
|
||||
double i2v1;
|
||||
double i2v;
|
||||
|
||||
double x0;
|
||||
double xh;
|
||||
double x1;
|
||||
double xp0;
|
||||
double xp1;
|
||||
|
||||
double z0;
|
||||
double zh;
|
||||
double z1;
|
||||
double zp0;
|
||||
double zp1;
|
||||
|
||||
double y0;
|
||||
double y1;
|
||||
|
||||
void set(double x, double y, double z, IIcon icon, IIcon icon1, IIcon icon2) {
|
||||
tessellator = Tessellator.instance;
|
||||
|
||||
i0u0 = icon.getMinU();
|
||||
i0uh = icon.getInterpolatedU(8.0D);
|
||||
i0u1 = icon.getMaxU();
|
||||
i0v0 = icon.getMinV();
|
||||
i0v1 = icon.getMaxV();
|
||||
|
||||
i1u0 = icon1.getInterpolatedU(7.0D);
|
||||
i1u1 = icon1.getInterpolatedU(9.0D);
|
||||
i1v0 = icon1.getMinV();
|
||||
i1vh = icon1.getInterpolatedV(8.0D);
|
||||
i1v1 = icon1.getMaxV();
|
||||
i1v = i1v1 - i1v0;
|
||||
|
||||
i2u0 = icon2.getInterpolatedU(7.0D);
|
||||
i2u1 = icon2.getInterpolatedU(9.0D);
|
||||
i2v0 = icon2.getMinV();
|
||||
i2v1 = icon2.getMaxV();
|
||||
i2v = i2v1 - i2v0;
|
||||
|
||||
x0 = x;
|
||||
xh = x0 + 0.5D;
|
||||
x1 = x + 1;
|
||||
xp0 = x0 + 0.5D - 0.0625D;
|
||||
xp1 = x0 + 0.5D + 0.0625D;
|
||||
|
||||
z0 = z;
|
||||
zh = z0 + 0.5D;
|
||||
z1 = z + 1;
|
||||
zp0 = z0 + 0.5D - 0.0625D;
|
||||
zp1 = z0 + 0.5D + 0.0625D;
|
||||
|
||||
y0 = y;
|
||||
y1 = y + 1;
|
||||
}
|
||||
|
||||
public void renderNorthPane() {
|
||||
tessellator.addVertexWithUV(xh, y1, z0, i0uh, i0v0);
|
||||
tessellator.addVertexWithUV(xh, y0, z0, i0uh, i0v1);
|
||||
tessellator.addVertexWithUV(xh, y0, zh, i0u0, i0v1);
|
||||
tessellator.addVertexWithUV(xh, y1, zh, i0u0, i0v0);
|
||||
tessellator.addVertexWithUV(xh, y1, zh, i0u0, i0v0);
|
||||
tessellator.addVertexWithUV(xh, y0, zh, i0u0, i0v1);
|
||||
tessellator.addVertexWithUV(xh, y0, z0, i0uh, i0v1);
|
||||
tessellator.addVertexWithUV(xh, y1, z0, i0uh, i0v0);
|
||||
}
|
||||
|
||||
public void renderSouthPane() {
|
||||
tessellator.addVertexWithUV(xh, y1, zh, i0u1, i0v0);
|
||||
tessellator.addVertexWithUV(xh, y0, zh, i0u1, i0v1);
|
||||
tessellator.addVertexWithUV(xh, y0, z1, i0uh, i0v1);
|
||||
tessellator.addVertexWithUV(xh, y1, z1, i0uh, i0v0);
|
||||
tessellator.addVertexWithUV(xh, y1, z1, i0uh, i0v0);
|
||||
tessellator.addVertexWithUV(xh, y0, z1, i0uh, i0v1);
|
||||
tessellator.addVertexWithUV(xh, y0, zh, i0u1, i0v1);
|
||||
tessellator.addVertexWithUV(xh, y1, zh, i0u1, i0v0);
|
||||
}
|
||||
|
||||
public void renderWestPane() {
|
||||
tessellator.addVertexWithUV(x0, y1, zh, i0uh, i0v0);
|
||||
tessellator.addVertexWithUV(x0, y0, zh, i0uh, i0v1);
|
||||
tessellator.addVertexWithUV(xh, y0, zh, i0u0, i0v1);
|
||||
tessellator.addVertexWithUV(xh, y1, zh, i0u0, i0v0);
|
||||
tessellator.addVertexWithUV(xh, y1, zh, i0u0, i0v0);
|
||||
tessellator.addVertexWithUV(xh, y0, zh, i0u0, i0v1);
|
||||
tessellator.addVertexWithUV(x0, y0, zh, i0uh, i0v1);
|
||||
tessellator.addVertexWithUV(x0, y1, zh, i0uh, i0v0);
|
||||
}
|
||||
|
||||
public void renderEastPane() {
|
||||
tessellator.addVertexWithUV(xh, y1, zh, i0u1, i0v0);
|
||||
tessellator.addVertexWithUV(xh, y0, zh, i0u1, i0v1);
|
||||
tessellator.addVertexWithUV(x1, y0, zh, i0uh, i0v1);
|
||||
tessellator.addVertexWithUV(x1, y1, zh, i0uh, i0v0);
|
||||
tessellator.addVertexWithUV(x1, y1, zh, i0uh, i0v0);
|
||||
tessellator.addVertexWithUV(x1, y0, zh, i0uh, i0v1);
|
||||
tessellator.addVertexWithUV(xh, y0, zh, i0u1, i0v1);
|
||||
tessellator.addVertexWithUV(xh, y1, zh, i0u1, i0v0);
|
||||
}
|
||||
|
||||
public void renderVerticalNS(double y, double zoff0, double zoff1, double v0, double v1) {
|
||||
tessellator.addVertexWithUV(xp0, y0 + y, z0 + zoff0, i1u0, i1v0 + i1v * v0);
|
||||
tessellator.addVertexWithUV(xp0, y0 + y, z0 + zoff1, i1u0, i1v0 + i1v * v1);
|
||||
tessellator.addVertexWithUV(xp1, y0 + y, z0 + zoff1, i1u1, i1v0 + i1v * v1);
|
||||
tessellator.addVertexWithUV(xp1, y0 + y, z0 + zoff0, i1u1, i1v0 + i1v * v0);
|
||||
tessellator.addVertexWithUV(xp0, y0 + y, z0 + zoff1, i1u0, i1v0 + i1v * v1);
|
||||
tessellator.addVertexWithUV(xp0, y0 + y, z0 + zoff0, i1u0, i1v0 + i1v * v0);
|
||||
tessellator.addVertexWithUV(xp1, y0 + y, z0 + zoff0, i1u1, i1v0 + i1v * v0);
|
||||
tessellator.addVertexWithUV(xp1, y0 + y, z0 + zoff1, i1u1, i1v0 + i1v * v1);
|
||||
}
|
||||
|
||||
public void renderVerticalWE(double y, double xoff0, double xoff1, double v0, double v1) {
|
||||
tessellator.addVertexWithUV(x0 + xoff0, y0 + y, zp1, i1u1, i1v0 + i1v * v0);
|
||||
tessellator.addVertexWithUV(x0 + xoff1, y0 + y, zp1, i1u1, i1v0 + i1v * v1);
|
||||
tessellator.addVertexWithUV(x0 + xoff1, y0 + y, zp0, i1u0, i1v0 + i1v * v1);
|
||||
tessellator.addVertexWithUV(x0 + xoff0, y0 + y, zp0, i1u0, i1v0 + i1v * v0);
|
||||
tessellator.addVertexWithUV(x0 + xoff1, y0 + y, zp1, i1u1, i1v0 + i1v * v1);
|
||||
tessellator.addVertexWithUV(x0 + xoff0, y0 + y, zp1, i1u1, i1v0 + i1v * v0);
|
||||
tessellator.addVertexWithUV(x0 + xoff0, y0 + y, zp0, i1u0, i1v0 + i1v * v0);
|
||||
tessellator.addVertexWithUV(x0 + xoff1, y0 + y, zp0, i1u0, i1v0 + i1v * v1);
|
||||
}
|
||||
|
||||
|
||||
public void renderHorizontalNS(double zoff, double v0, double v1) {
|
||||
tessellator.addVertexWithUV(xp0, y1, z0+zoff, i2u0, i2v0 + i2v * v1);
|
||||
tessellator.addVertexWithUV(xp0, y0, z0+zoff, i2u0, i2v0 + i2v * v0);
|
||||
tessellator.addVertexWithUV(xp1, y0, z0+zoff, i2u1, i2v0 + i2v * v0);
|
||||
tessellator.addVertexWithUV(xp1, y1, z0+zoff, i2u1, i2v0 + i2v * v1);
|
||||
tessellator.addVertexWithUV(xp1, y1, z0+zoff, i2u1, i2v0 + i2v * v1);
|
||||
tessellator.addVertexWithUV(xp1, y0, z0+zoff, i2u1, i2v0 + i2v * v0);
|
||||
tessellator.addVertexWithUV(xp0, y0, z0+zoff, i2u0, i2v0 + i2v * v0);
|
||||
tessellator.addVertexWithUV(xp0, y1, z0+zoff, i2u0, i2v0 + i2v * v1);
|
||||
|
||||
}
|
||||
|
||||
public void renderHorizontalWE(double xoff,double v0,double v1){
|
||||
tessellator.addVertexWithUV(x0 + xoff, y1, zp0, i2u0, i2v0 + i2v * v1);
|
||||
tessellator.addVertexWithUV(x0 + xoff, y0, zp0, i2u0, i2v0 + i2v * v0);
|
||||
tessellator.addVertexWithUV(x0 + xoff, y0, zp1, i2u1, i2v0 + i2v * v0);
|
||||
tessellator.addVertexWithUV(x0 + xoff, y1, zp1, i2u1, i2v0 + i2v * v1);
|
||||
tessellator.addVertexWithUV(x0 + xoff, y1, zp1, i2u1, i2v0 + i2v * v1);
|
||||
tessellator.addVertexWithUV(x0 + xoff, y0, zp1, i2u1, i2v0 + i2v * v0);
|
||||
tessellator.addVertexWithUV(x0 + xoff, y0, zp0, i2u0, i2v0 + i2v * v0);
|
||||
tessellator.addVertexWithUV(x0 + xoff, y1, zp0, i2u0, i2v0 + i2v * v1);
|
||||
}
|
||||
}
|
||||
|
||||
PaneRenderer paneRenderer = new PaneRenderer();
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block b, int modelId, RenderBlocks renderer) {
|
||||
BlockPane block = (BlockPane) b;
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
int worldHeight = world.getHeight();
|
||||
tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
|
||||
|
||||
float f = 1.0F;
|
||||
int i1 = block.colorMultiplier(world, x, y, z);
|
||||
float f1 = (i1 >> 16 & 255) / 255.0F;
|
||||
float f2 = (i1 >> 8 & 255) / 255.0F;
|
||||
float f3 = (i1 & 255) / 255.0F;
|
||||
|
||||
if (EntityRenderer.anaglyphEnable) {
|
||||
float f4 = (f1 * 30.0F + f2 * 59.0F + f3 * 11.0F) / 100.0F;
|
||||
float f5 = (f1 * 30.0F + f2 * 70.0F) / 100.0F;
|
||||
float f6 = (f1 * 30.0F + f3 * 70.0F) / 100.0F;
|
||||
f1 = f4;
|
||||
f2 = f5;
|
||||
f3 = f6;
|
||||
}
|
||||
tessellator.setColorOpaque_F(f * f1, f * f2, f * f3);
|
||||
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
IIcon iconPane = block.getIcon(2, meta);
|
||||
IIcon iconTop = block.getIcon(1, meta);
|
||||
IIcon iconSide = block.getIcon(0, meta);
|
||||
if(iconPane==null || iconTop==null || iconSide==null) return false;
|
||||
|
||||
paneRenderer.set(x, y, z, iconPane, iconTop, iconSide);
|
||||
|
||||
boolean connectsNorth = block.canPaneConnectToBlock(world.getBlock(x, y, z - 1));
|
||||
boolean connectsSouth = block.canPaneConnectToBlock(world.getBlock(x, y, z + 1));
|
||||
boolean connectsWest = block.canPaneConnectToBlock(world.getBlock(x - 1, y, z));
|
||||
boolean connectsEast = block.canPaneConnectToBlock(world.getBlock(x + 1, y, z));
|
||||
boolean connectsTop = block.canPaneConnectToBlock(world.getBlock(x, y + 1, z));
|
||||
boolean connectsBottom = block.canPaneConnectToBlock(world.getBlock(x, y - 1, z));
|
||||
|
||||
boolean connectsTopNorth=block.canPaneConnectToBlock(world.getBlock(x, y + 1, z - 1));
|
||||
boolean connectsTopSouth=block.canPaneConnectToBlock(world.getBlock(x, y + 1, z + 1));
|
||||
boolean connectsTopWest=block.canPaneConnectToBlock(world.getBlock(x-1, y + 1, z));
|
||||
boolean connectsTopEast=block.canPaneConnectToBlock(world.getBlock(x+1, y + 1, z));
|
||||
|
||||
boolean connectsBottomNorth=block.canPaneConnectToBlock(world.getBlock(x, y - 1, z - 1));
|
||||
boolean connectsBottomSouth=block.canPaneConnectToBlock(world.getBlock(x, y - 1, z + 1));
|
||||
boolean connectsBottomWest=block.canPaneConnectToBlock(world.getBlock(x-1, y - 1, z));
|
||||
boolean connectsBottomEast=block.canPaneConnectToBlock(world.getBlock(x+1, y - 1, z));
|
||||
|
||||
boolean isolatedTop=!connectsTopNorth && !connectsTopSouth && !connectsTopWest && !connectsTopEast;
|
||||
boolean isolatedBottom=!connectsBottomNorth && !connectsBottomSouth && !connectsBottomWest && !connectsBottomEast;
|
||||
|
||||
if (!connectsNorth && !connectsSouth && !connectsWest && !connectsEast) {
|
||||
connectsNorth = connectsSouth = connectsWest = connectsEast = true;
|
||||
}
|
||||
|
||||
int connections=0;
|
||||
if (connectsNorth) {
|
||||
paneRenderer.renderNorthPane();
|
||||
if(!connectsBottom || !connectsBottomNorth && !isolatedBottom) paneRenderer.renderVerticalNS(-0.0003, 0.0, 0.5, 0.5, 0.0);
|
||||
if(!connectsTop || !connectsTopNorth && !isolatedTop) paneRenderer.renderVerticalNS(+1.0003, 0.0, 0.5, 0.5, 0.0);
|
||||
connections++;
|
||||
}
|
||||
if (connectsSouth) {
|
||||
paneRenderer.renderSouthPane();
|
||||
if(!connectsBottom || !connectsBottomSouth && !isolatedBottom) paneRenderer.renderVerticalNS(-0.0004, 0.5, 1.0, 1.0, 0.5);
|
||||
if(!connectsTop || !connectsTopSouth && !isolatedTop) paneRenderer.renderVerticalNS(+1.0004, 0.5, 1.0, 1.0, 0.5);
|
||||
connections++;
|
||||
}
|
||||
if (connectsWest) {
|
||||
paneRenderer.renderWestPane();
|
||||
if(!connectsBottom || !connectsBottomWest && !isolatedBottom) paneRenderer.renderVerticalWE(-0.0001, 0.0, 0.5, 0.5, 0.0);
|
||||
if(!connectsTop || !connectsTopWest && !isolatedTop) paneRenderer.renderVerticalWE(+1.0001, 0.0, 0.5, 0.5, 0.0);
|
||||
connections++;
|
||||
}
|
||||
if (connectsEast) {
|
||||
paneRenderer.renderEastPane();
|
||||
if(!connectsBottom || !connectsBottomEast && !isolatedBottom) paneRenderer.renderVerticalWE(-0.0002, 0.5, 1.0, 1.0, 0.5);
|
||||
if(!connectsTop || !connectsTopEast && !isolatedTop) paneRenderer.renderVerticalWE(+1.0002, 0.5, 1.0, 1.0, 0.5);
|
||||
connections++;
|
||||
}
|
||||
|
||||
|
||||
if(connections==1){
|
||||
if(connectsNorth) paneRenderer.renderHorizontalNS(0.5,1.0,0.0);
|
||||
if(connectsSouth) paneRenderer.renderHorizontalNS(0.5,0.0,1.0);
|
||||
if(connectsEast) paneRenderer.renderHorizontalWE(0.5,0.0,1.0);
|
||||
if(connectsWest) paneRenderer.renderHorizontalWE(0.5,1.0,0.0);
|
||||
} else if(connections==4){
|
||||
paneRenderer.renderHorizontalNS(0.0,1.0,0.0);
|
||||
paneRenderer.renderHorizontalNS(1.0,0.0,1.0);
|
||||
paneRenderer.renderHorizontalWE(0.0,0.0,1.0);
|
||||
paneRenderer.renderHorizontalWE(1.0,1.0,0.0);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int renderId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
+160
@@ -0,0 +1,160 @@
|
||||
package info.jbcs.minecraft.chisel.render;
|
||||
|
||||
import info.jbcs.minecraft.chisel.CarvableHelper;
|
||||
import info.jbcs.minecraft.chisel.block.BlockMarblePillar;
|
||||
import info.jbcs.minecraft.utilities.Drawing;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class BlockMarblePillarRenderer implements ISimpleBlockRenderingHandler {
|
||||
public static int id;
|
||||
|
||||
public BlockMarblePillarRenderer() {
|
||||
id = RenderingRegistry.getNextAvailableRenderId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block blck, int metadata, int modelID, RenderBlocks renderer) {
|
||||
if(! (blck instanceof BlockMarblePillar))
|
||||
return;
|
||||
|
||||
BlockMarblePillar block=(BlockMarblePillar) blck;
|
||||
|
||||
block.sides[0]=block.sides[1]=block.getCtmIcon(4,metadata);
|
||||
block.sides[2]=block.sides[3]=block.sides[4]=block.sides[5]=block.getCtmIcon(0,metadata);
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
Drawing.drawBlock(block, metadata, renderer);
|
||||
}
|
||||
|
||||
boolean connected(IBlockAccess world, int x,int y,int z, Block block, int meta){
|
||||
return world.getBlock(x,y,z).equals(block) && world.getBlockMetadata(x,y,z)==meta;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block blck, int modelId, RenderBlocks renderer) {
|
||||
if(! (blck instanceof BlockMarblePillar))
|
||||
return false;
|
||||
|
||||
BlockMarblePillar block=(BlockMarblePillar) blck;
|
||||
|
||||
int metadata=world.getBlockMetadata(x, y, z);
|
||||
|
||||
if(block.carverHelper.variations.get(metadata).kind!=CarvableHelper.CTMV){
|
||||
block.sides[0]=block.carverHelper.getIcon(0,metadata);
|
||||
block.sides[1]=block.carverHelper.getIcon(1,metadata);
|
||||
block.sides[2]=block.carverHelper.getIcon(2,metadata);
|
||||
block.sides[3]=block.carverHelper.getIcon(3,metadata);
|
||||
block.sides[4]=block.carverHelper.getIcon(4,metadata);
|
||||
block.sides[5]=block.carverHelper.getIcon(5,metadata);
|
||||
|
||||
return renderer.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
boolean yp=connected(world,x,y+1,z,block,metadata);
|
||||
boolean yn=connected(world,x,y-1,z,block,metadata);
|
||||
|
||||
if(yp || yn){
|
||||
block.sides[0]=block.getCtmIcon(4,metadata);
|
||||
block.sides[1]=block.getCtmIcon(4,metadata);
|
||||
|
||||
if(yp && yn)
|
||||
block.sides[2]=block.getCtmIcon(2,metadata);
|
||||
else if(yp)
|
||||
block.sides[2]=block.getCtmIcon(3,metadata);
|
||||
else
|
||||
block.sides[2]=block.getCtmIcon(1,metadata);
|
||||
|
||||
block.sides[3]=block.sides[4]=block.sides[5]=block.sides[2];
|
||||
} else{
|
||||
boolean xp=connected(world,x+1,y,z,block,metadata);
|
||||
boolean xn=connected(world,x-1,y,z,block,metadata);
|
||||
|
||||
if(xp && (connected(world,x+1,y+1,z,block,metadata) || connected(world,x+1,y-1,z,block,metadata)))
|
||||
xp=false;
|
||||
if(xn && (connected(world,x-1,y+1,z,block,metadata) || connected(world,x-1,y-1,z,block,metadata)))
|
||||
xn=false;
|
||||
|
||||
if(xp || xn){
|
||||
renderer.uvRotateEast = 2;
|
||||
renderer.uvRotateWest = 1;
|
||||
renderer.uvRotateTop = 1;
|
||||
renderer.uvRotateBottom = 1;
|
||||
|
||||
block.sides[4]=block.getCtmIcon(4,metadata);
|
||||
block.sides[5]=block.getCtmIcon(4,metadata);
|
||||
|
||||
if(xp && xn)
|
||||
block.sides[0]=block.getCtmIcon(2,metadata);
|
||||
else if(xp)
|
||||
block.sides[0]=block.getCtmIcon(3,metadata);
|
||||
else
|
||||
block.sides[0]=block.getCtmIcon(1,metadata);
|
||||
|
||||
block.sides[1]=block.sides[2]=block.sides[3]=block.sides[0];
|
||||
} else{
|
||||
boolean zp=connected(world,x,y,z+1,block,metadata);
|
||||
boolean zn=connected(world,x,y,z-1,block,metadata);
|
||||
|
||||
if(zp && (connected(world,x,y+1,z+1,block,metadata) || connected(world,x,y-1,z+1,block,metadata)))
|
||||
zp=false;
|
||||
if(zp && (connected(world,x+1,y,z+1,block,metadata) || connected(world,x-1,y,z+1,block,metadata)))
|
||||
zp=false;
|
||||
if(zn && (connected(world,x,y+1,z-1,block,metadata) || connected(world,x,y-1,z-1,block,metadata)))
|
||||
zn=false;
|
||||
if(zn && (connected(world,x+1,y,z-1,block,metadata) || connected(world,x-1,y,z-1,block,metadata)))
|
||||
zn=false;
|
||||
|
||||
if(zp || zn){
|
||||
renderer.uvRotateSouth = 1;
|
||||
renderer.uvRotateNorth = 2;
|
||||
|
||||
block.sides[2]=block.getCtmIcon(4,metadata);
|
||||
block.sides[3]=block.getCtmIcon(4,metadata);
|
||||
|
||||
if(zp && zn)
|
||||
block.sides[0]=block.getCtmIcon(2,metadata);
|
||||
else if(zp)
|
||||
block.sides[0]=block.getCtmIcon(1,metadata);
|
||||
else
|
||||
block.sides[0]=block.getCtmIcon(3,metadata);
|
||||
|
||||
block.sides[1]=block.sides[4]=block.sides[5]=block.sides[0];
|
||||
} else{
|
||||
block.sides[0]=block.sides[1]=block.getCtmIcon(4,metadata);
|
||||
block.sides[2]=block.sides[3]=block.sides[4]=block.sides[5]=block.getCtmIcon(0,metadata);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
boolean flag = renderer.renderStandardBlock(block, x, y, z);
|
||||
|
||||
renderer.uvRotateSouth = 0;
|
||||
renderer.uvRotateEast = 0;
|
||||
renderer.uvRotateWest = 0;
|
||||
renderer.uvRotateNorth = 0;
|
||||
renderer.uvRotateTop = 0;
|
||||
renderer.uvRotateBottom = 0;
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int renderId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
package info.jbcs.minecraft.chisel.render;
|
||||
|
||||
import info.jbcs.minecraft.chisel.block.BlockMarbleStairs;
|
||||
import info.jbcs.minecraft.utilities.Drawing;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class BlockMarbleStairsRenderer implements ISimpleBlockRenderingHandler {
|
||||
public static int id;
|
||||
|
||||
public BlockMarbleStairsRenderer() {
|
||||
id = RenderingRegistry.getNextAvailableRenderId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int meta, int modelID, RenderBlocks renderer) {
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.5F);
|
||||
Drawing.drawBlock(block, meta, renderer);
|
||||
renderer.setRenderBounds(0.0F, 0.0F, 0.5F, 1.0F, 0.5F, 1.0F);
|
||||
Drawing.drawBlock(block, meta, renderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block blck, int modelId, RenderBlocks renderer) {
|
||||
if (blck == null || !(blck instanceof BlockMarbleStairs))
|
||||
return false;
|
||||
BlockMarbleStairs block = (BlockMarbleStairs) blck;
|
||||
|
||||
renderer.renderBlockStairs(block, x, y, z);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int renderId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getRenderBlockPass() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package info.jbcs.minecraft.chisel.render;
|
||||
|
||||
import info.jbcs.minecraft.utilities.Drawing;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class BlockNoCTMRenderer implements ISimpleBlockRenderingHandler {
|
||||
static int id;
|
||||
|
||||
public BlockNoCTMRenderer() {
|
||||
id = RenderingRegistry.getNextAvailableRenderId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int meta, int modelID, RenderBlocks renderer) {
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
Drawing.drawBlock(block, meta, renderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
|
||||
int meta=world.getBlockMetadata(x, y, z);
|
||||
|
||||
if(meta!=0) renderer.overrideBlockTexture=block.getIcon(0,meta);
|
||||
renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.overrideBlockTexture=null;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int renderId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
}
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
package info.jbcs.minecraft.chisel.render;
|
||||
|
||||
import info.jbcs.minecraft.chisel.block.BlockRoadLine;
|
||||
import info.jbcs.minecraft.utilities.Drawing;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.EntityRenderer;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class BlockRoadLineRenderer implements ISimpleBlockRenderingHandler {
|
||||
public static int id;
|
||||
|
||||
public BlockRoadLineRenderer() {
|
||||
id = RenderingRegistry.getNextAvailableRenderId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int meta, int modelID, RenderBlocks renderer) {
|
||||
renderer.setRenderBoundsFromBlock(block);
|
||||
Drawing.drawBlock(block, meta, renderer);
|
||||
}
|
||||
|
||||
public void renderTopFace(double y,IIcon icon) {
|
||||
Tessellator tessellator=Tessellator.instance;
|
||||
|
||||
tessellator.addVertexWithUV(1, y, 0, icon.getMaxU(), icon.getMinV());
|
||||
tessellator.addVertexWithUV(0, y, 0, icon.getMinU(), icon.getMinV());
|
||||
tessellator.addVertexWithUV(0, y, 1, icon.getMinU(), icon.getMaxV());
|
||||
tessellator.addVertexWithUV(1, y, 1, icon.getMaxU(), icon.getMaxV());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block b, int modelId, RenderBlocks renderer) {
|
||||
int meta=world.getBlockMetadata(x, y, z);
|
||||
BlockRoadLine block=(BlockRoadLine) b;
|
||||
Tessellator tessellator=Tessellator.instance;
|
||||
|
||||
tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
|
||||
|
||||
float f = 1.0F;
|
||||
int i1 = block.colorMultiplier(world, x, y, z);
|
||||
float f1 = (i1 >> 16 & 255) / 255.0F;
|
||||
float f2 = (i1 >> 8 & 255) / 255.0F;
|
||||
float f3 = (i1 & 255) / 255.0F;
|
||||
|
||||
if (EntityRenderer.anaglyphEnable) {
|
||||
float f4 = (f1 * 30.0F + f2 * 59.0F + f3 * 11.0F) / 100.0F;
|
||||
float f5 = (f1 * 30.0F + f2 * 70.0F) / 100.0F;
|
||||
float f6 = (f1 * 30.0F + f3 * 70.0F) / 100.0F;
|
||||
f1 = f4;
|
||||
f2 = f5;
|
||||
f3 = f6;
|
||||
}
|
||||
tessellator.setColorOpaque_F(f * f1, f * f2, f * f3);
|
||||
|
||||
boolean N=world.getBlock(x, y, z-1).equals(block);
|
||||
boolean S=world.getBlock(x, y, z+1).equals(block);
|
||||
boolean W=world.getBlock(x-1, y, z).equals(block);
|
||||
boolean E=world.getBlock(x+1, y, z).equals(block);
|
||||
|
||||
if(!N && !S && !W && !E){
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(N && S){
|
||||
renderer.uvRotateTop=0;
|
||||
renderer.overrideBlockTexture=block.fullLineIcon;
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
|
||||
} else{
|
||||
if(N){
|
||||
renderer.uvRotateTop=0;
|
||||
renderer.overrideBlockTexture=block.halfLineIcon;
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
if(S){
|
||||
renderer.uvRotateTop=3;
|
||||
renderer.overrideBlockTexture=block.halfLineIcon;
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(E && W){
|
||||
renderer.uvRotateTop=1;
|
||||
renderer.overrideBlockTexture=block.fullLineIcon;
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
} else{
|
||||
if(E){
|
||||
renderer.uvRotateTop=1;
|
||||
renderer.overrideBlockTexture=block.halfLineIcon;
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
if(W){
|
||||
renderer.uvRotateTop=2;
|
||||
renderer.overrideBlockTexture=block.halfLineIcon;
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
renderer.uvRotateTop=0;
|
||||
renderer.overrideBlockTexture=null;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int renderId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
+126
@@ -0,0 +1,126 @@
|
||||
package info.jbcs.minecraft.chisel.render;
|
||||
|
||||
import info.jbcs.minecraft.chisel.block.BlockSnakestone;
|
||||
import info.jbcs.minecraft.utilities.Drawing;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class BlockSnakeStoneRenderer implements ISimpleBlockRenderingHandler {
|
||||
public static int id;
|
||||
|
||||
public BlockSnakeStoneRenderer() {
|
||||
id = RenderingRegistry.getNextAvailableRenderId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int meta, int modelID, RenderBlocks renderer) {
|
||||
setRenderRotate(renderer, (BlockSnakestone) block, meta);
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
Drawing.drawBlock(block, meta, renderer);
|
||||
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
|
||||
restoreRendererRotate(renderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
|
||||
setRenderRotate(renderer, (BlockSnakestone) block, meta);
|
||||
boolean didRender = renderer.renderStandardBlock(block, x, y, z);
|
||||
restoreRendererRotate(renderer);
|
||||
|
||||
return didRender;
|
||||
}
|
||||
|
||||
private void restoreRendererRotate(RenderBlocks renderer) {
|
||||
renderer.uvRotateSouth = 0;
|
||||
renderer.uvRotateEast = 0;
|
||||
renderer.uvRotateWest = 0;
|
||||
renderer.uvRotateNorth = 0;
|
||||
renderer.uvRotateTop = 0;
|
||||
renderer.uvRotateBottom = 0;
|
||||
}
|
||||
|
||||
private void setRenderRotate(RenderBlocks renderer, BlockSnakestone block, int meta) {
|
||||
int type = meta & 0xC;
|
||||
int orient = meta & 0x3;
|
||||
|
||||
|
||||
|
||||
if (type == 0) {
|
||||
switch (orient) {
|
||||
case 0:
|
||||
renderer.uvRotateTop = 1;
|
||||
renderer.uvRotateBottom = 2;
|
||||
break;
|
||||
case 1:
|
||||
renderer.uvRotateTop = 1;
|
||||
renderer.uvRotateBottom = 1;
|
||||
break;
|
||||
case 2:
|
||||
renderer.uvRotateTop = 0;
|
||||
renderer.uvRotateBottom = 3;
|
||||
break;
|
||||
case 3:
|
||||
renderer.uvRotateTop = 0;
|
||||
renderer.uvRotateBottom = 0;
|
||||
}
|
||||
|
||||
} else if ((type == 4) || (type == 8)) {
|
||||
switch (orient) {
|
||||
case 0:
|
||||
renderer.uvRotateTop = block.flipTopTextures?1:2;
|
||||
renderer.uvRotateBottom = 1;
|
||||
renderer.uvRotateWest = 2;
|
||||
break;
|
||||
case 1:
|
||||
renderer.uvRotateTop = 1;
|
||||
renderer.uvRotateBottom = 1;
|
||||
renderer.uvRotateEast = 2;
|
||||
break;
|
||||
case 2:
|
||||
renderer.uvRotateTop = block.flipTopTextures?0:3;
|
||||
renderer.uvRotateBottom = 0;
|
||||
renderer.uvRotateSouth = 2;
|
||||
break;
|
||||
case 3:
|
||||
renderer.uvRotateTop = 0;
|
||||
renderer.uvRotateBottom = 0;
|
||||
renderer.uvRotateNorth = 2;
|
||||
}
|
||||
|
||||
} else if (type == 12) {
|
||||
switch (orient) {
|
||||
case 0:
|
||||
renderer.uvRotateTop = 0;
|
||||
renderer.uvRotateBottom = 0;
|
||||
break;
|
||||
case 1:
|
||||
renderer.uvRotateTop = 1;
|
||||
renderer.uvRotateBottom = 1;
|
||||
break;
|
||||
case 2:
|
||||
renderer.uvRotateNorth = 2;
|
||||
renderer.uvRotateSouth = 2;
|
||||
renderer.uvRotateEast = 2;
|
||||
renderer.uvRotateWest = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int renderId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package info.jbcs.minecraft.chisel.render;
|
||||
|
||||
import info.jbcs.minecraft.chisel.Chisel;
|
||||
import info.jbcs.minecraft.utilities.Drawing;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class BlockSpikesRenderer implements ISimpleBlockRenderingHandler {
|
||||
public static int id;
|
||||
|
||||
public BlockSpikesRenderer() {
|
||||
id = RenderingRegistry.getNextAvailableRenderId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int meta, int modelID, RenderBlocks renderer) {
|
||||
Drawing.drawBlock(block, meta, renderer);
|
||||
}
|
||||
|
||||
void drawSpike(IIcon icon,double r,double h,double x,double y,double z,double dx,double dz){
|
||||
Tessellator tessellator=Tessellator.instance;
|
||||
|
||||
double u0=icon.getMinU();
|
||||
double u1=icon.getMaxU();
|
||||
double v0=icon.getMaxV();
|
||||
double v1=icon.getMinV();
|
||||
|
||||
double tx=x+dx;
|
||||
double ty=y+h;
|
||||
double tz=z+dz;
|
||||
|
||||
tessellator.addVertexWithUV(x+r, y+0, z+r, u0, v0);
|
||||
tessellator.addVertexWithUV(x+r, y+0, z-r, u1, v0);
|
||||
tessellator.addVertexWithUV(tx, ty, tz, u1, v1);
|
||||
tessellator.addVertexWithUV(tx, ty, tz, u0, v1);
|
||||
|
||||
tessellator.addVertexWithUV(x-r, y+0, z+r, u1, v0);
|
||||
tessellator.addVertexWithUV(x+r, y+0, z+r, u0, v0);
|
||||
tessellator.addVertexWithUV(tx, ty, tz, u1, v1);
|
||||
tessellator.addVertexWithUV(tx, ty, tz, u0, v1);
|
||||
|
||||
|
||||
tessellator.addVertexWithUV(x+r, y+0, z-r, u1, v0);
|
||||
tessellator.addVertexWithUV(x-r, y+0, z-r, u0, v0);
|
||||
tessellator.addVertexWithUV(tx, ty, tz, u1, v1);
|
||||
tessellator.addVertexWithUV(tx, ty, tz, u0, v1);
|
||||
|
||||
tessellator.addVertexWithUV(x-r, y+0, z-r, u1, v0);
|
||||
tessellator.addVertexWithUV(x-r, y+0, z+r, u0, v0);
|
||||
tessellator.addVertexWithUV(tx, ty, tz, u1, v1);
|
||||
tessellator.addVertexWithUV(tx, ty, tz, u0, v1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
|
||||
Tessellator tessellator=Tessellator.instance;
|
||||
IIcon icon=Chisel.blockSpiketrap.iconSpike;
|
||||
// Icon icon=Chisel.blockSpiketrap.iconBase;
|
||||
|
||||
double h=0.85;
|
||||
double d=1.5/16;
|
||||
double r=d/2;
|
||||
|
||||
|
||||
double tx=x+0.25;
|
||||
double ty=y+h;
|
||||
double tz=z+0.25;
|
||||
double skew=0.5;
|
||||
|
||||
// tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
|
||||
tessellator.addTranslation(0, 1.0f/16, 0);
|
||||
|
||||
Random rand=new Random();
|
||||
for(int xx=0;xx<4;xx++){
|
||||
for(int yy=0;yy<4;yy++){
|
||||
// float sx=1.0f/16+rand.nextFloat()*13.0f/16;
|
||||
// float sz=1.0f/16+rand.nextFloat()*13.0f/16;
|
||||
float sx=(2.0f+(12.0f-(float)d)*xx/3)/16;
|
||||
float sz=(2.0f+(12.0f-(float)d)*yy/3)/16;
|
||||
|
||||
|
||||
tessellator.addTranslation(sx, 0, sz);
|
||||
drawSpike(icon,r,0.5+rand.nextDouble()*0.35,x,y,z,rand.nextDouble()*skew-skew/2,rand.nextDouble()*skew-skew/2);
|
||||
tessellator.addTranslation(-sx, 0, -sz);
|
||||
}
|
||||
}
|
||||
|
||||
tessellator.addTranslation(0, -1.0f/16, 0);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int renderId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
+267
@@ -0,0 +1,267 @@
|
||||
package info.jbcs.minecraft.chisel.render;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
public class CTM {
|
||||
static int submaps[][]={
|
||||
{16,17,18,19},
|
||||
{16, 9,18,13},
|
||||
{ 8, 9,12,13},
|
||||
{ 8,17,12,19},
|
||||
{16, 9, 6,15},
|
||||
{ 8,17,14, 7},
|
||||
{ 2,11, 6,15},
|
||||
{ 8, 9,14,15},
|
||||
{10, 1,14,15},
|
||||
{10,11,14, 5},
|
||||
{ 0,11, 4,15},
|
||||
{ 0, 1,14,15},
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{16,17, 6, 7},
|
||||
{16, 9, 6, 5},
|
||||
{ 8, 9, 4, 5},
|
||||
{ 8,17, 4, 7},
|
||||
{ 2,11,18,13},
|
||||
{10, 3,12,19},
|
||||
{10,11,12,13},
|
||||
{10, 3,14, 7},
|
||||
{ 0,11,14,15},
|
||||
{10,11, 4,15},
|
||||
{10,11, 4, 5},
|
||||
{10, 1,14, 5},
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{ 2, 3, 6, 7},
|
||||
{ 2, 1, 6, 5},
|
||||
{ 0, 1, 4, 5},
|
||||
{ 0, 3, 4, 7},
|
||||
{ 2,11, 6, 5},
|
||||
{ 8, 9, 4,15},
|
||||
{ 2, 1, 6,15},
|
||||
{ 8, 9,14, 5},
|
||||
{ 0, 1, 4,15},
|
||||
{ 0, 1,14, 5},
|
||||
{10, 1, 4,15},
|
||||
{ 0,11,14, 5},
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{ 2, 3,18,19},
|
||||
{ 2, 1,18,13},
|
||||
{ 0, 1,12,13},
|
||||
{ 0, 3,12,19},
|
||||
{10, 1,12,13},
|
||||
{ 0, 3,14, 7},
|
||||
{ 0,11,12,13},
|
||||
{10, 3, 4, 7},
|
||||
{ 0,11, 4, 5},
|
||||
{10, 1, 4, 5},
|
||||
{10,11,14,15},
|
||||
{ 0, 1, 4, 5},
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
};
|
||||
|
||||
public static int[] getSubmapIndices(IBlockAccess world, int x, int y, int z, int side){
|
||||
int index=getTexture(world,x,y,z,side);
|
||||
|
||||
return submaps[index];
|
||||
}
|
||||
|
||||
public static int getTexture(IBlockAccess world, int x, int y, int z, int side) {
|
||||
if(world==null) return 0;
|
||||
|
||||
int texture = 0;
|
||||
Block block = world.getBlock(x, y, z);
|
||||
int blockMetadata=world.getBlockMetadata(x, y, z);
|
||||
|
||||
boolean b[] = new boolean[6];
|
||||
if (side <= 1) {
|
||||
b[0] = isConnected(world, x - 1, y, z, side, block, blockMetadata);
|
||||
b[1] = isConnected(world, x + 1, y, z, side, block, blockMetadata);
|
||||
b[2] = isConnected(world, x, y, z + 1, side, block, blockMetadata);
|
||||
b[3] = isConnected(world, x, y, z - 1, side, block, blockMetadata);
|
||||
} else if (side == 2) {
|
||||
b[0] = isConnected(world, x + 1, y, z, side, block, blockMetadata);
|
||||
b[1] = isConnected(world, x - 1, y, z, side, block, blockMetadata);
|
||||
b[2] = isConnected(world, x, y - 1, z, side, block, blockMetadata);
|
||||
b[3] = isConnected(world, x, y + 1, z, side, block, blockMetadata);
|
||||
} else if (side == 3) {
|
||||
b[0] = isConnected(world, x - 1, y, z, side, block, blockMetadata);
|
||||
b[1] = isConnected(world, x + 1, y, z, side, block, blockMetadata);
|
||||
b[2] = isConnected(world, x, y - 1, z, side, block, blockMetadata);
|
||||
b[3] = isConnected(world, x, y + 1, z, side, block, blockMetadata);
|
||||
} else if (side == 4) {
|
||||
b[0] = isConnected(world, x, y, z - 1, side, block, blockMetadata);
|
||||
b[1] = isConnected(world, x, y, z + 1, side, block, blockMetadata);
|
||||
b[2] = isConnected(world, x, y - 1, z, side, block, blockMetadata);
|
||||
b[3] = isConnected(world, x, y + 1, z, side, block, blockMetadata);
|
||||
} else if (side == 5) {
|
||||
b[0] = isConnected(world, x, y, z + 1, side, block, blockMetadata);
|
||||
b[1] = isConnected(world, x, y, z - 1, side, block, blockMetadata);
|
||||
b[2] = isConnected(world, x, y - 1, z, side, block, blockMetadata);
|
||||
b[3] = isConnected(world, x, y + 1, z, side, block, blockMetadata);
|
||||
}
|
||||
if (b[0] & !b[1] & !b[2] & !b[3])
|
||||
texture = 3;
|
||||
else if (!b[0] & b[1] & !b[2] & !b[3])
|
||||
texture = 1;
|
||||
else if (!b[0] & !b[1] & b[2] & !b[3])
|
||||
texture = 16;
|
||||
else if (!b[0] & !b[1] & !b[2] & b[3])
|
||||
texture = 48;
|
||||
else if (b[0] & b[1] & !b[2] & !b[3])
|
||||
texture = 2;
|
||||
else if (!b[0] & !b[1] & b[2] & b[3])
|
||||
texture = 32;
|
||||
else if (b[0] & !b[1] & b[2] & !b[3])
|
||||
texture = 19;
|
||||
else if (b[0] & !b[1] & !b[2] & b[3])
|
||||
texture = 51;
|
||||
else if (!b[0] & b[1] & b[2] & !b[3])
|
||||
texture = 17;
|
||||
else if (!b[0] & b[1] & !b[2] & b[3])
|
||||
texture = 49;
|
||||
else if (!b[0] & b[1] & b[2] & b[3])
|
||||
texture = 33;
|
||||
else if (b[0] & !b[1] & b[2] & b[3])
|
||||
texture = 35;
|
||||
else if (b[0] & b[1] & !b[2] & b[3])
|
||||
texture = 50;
|
||||
else if (b[0] & b[1] & b[2] & !b[3])
|
||||
texture = 18;
|
||||
else if (b[0] & b[1] & b[2] & b[3])
|
||||
texture = 34;
|
||||
|
||||
boolean b2[] = new boolean[6];
|
||||
if (side <= 1) {
|
||||
b2[0] = !isConnected(world, x + 1, y, z + 1, side, block, blockMetadata);
|
||||
b2[1] = !isConnected(world, x - 1, y, z + 1, side, block, blockMetadata);
|
||||
b2[2] = !isConnected(world, x + 1, y, z - 1, side, block, blockMetadata);
|
||||
b2[3] = !isConnected(world, x - 1, y, z - 1, side, block, blockMetadata);
|
||||
} else if (side == 2) {
|
||||
b2[0] = !isConnected(world, x - 1, y - 1, z, side, block, blockMetadata);
|
||||
b2[1] = !isConnected(world, x + 1, y - 1, z, side, block, blockMetadata);
|
||||
b2[2] = !isConnected(world, x - 1, y + 1, z, side, block, blockMetadata);
|
||||
b2[3] = !isConnected(world, x + 1, y + 1, z, side, block, blockMetadata);
|
||||
} else if (side == 3) {
|
||||
b2[0] = !isConnected(world, x + 1, y - 1, z, side, block, blockMetadata);
|
||||
b2[1] = !isConnected(world, x - 1, y - 1, z, side, block, blockMetadata);
|
||||
b2[2] = !isConnected(world, x + 1, y + 1, z, side, block, blockMetadata);
|
||||
b2[3] = !isConnected(world, x - 1, y + 1, z, side, block, blockMetadata);
|
||||
} else if (side == 4) {
|
||||
b2[0] = !isConnected(world, x, y - 1, z + 1, side, block, blockMetadata);
|
||||
b2[1] = !isConnected(world, x, y - 1, z - 1, side, block, blockMetadata);
|
||||
b2[2] = !isConnected(world, x, y + 1, z + 1, side, block, blockMetadata);
|
||||
b2[3] = !isConnected(world, x, y + 1, z - 1, side, block, blockMetadata);
|
||||
} else if (side == 5) {
|
||||
b2[0] = !isConnected(world, x, y - 1, z - 1, side, block, blockMetadata);
|
||||
b2[1] = !isConnected(world, x, y - 1, z + 1, side, block, blockMetadata);
|
||||
b2[2] = !isConnected(world, x, y + 1, z - 1, side, block, blockMetadata);
|
||||
b2[3] = !isConnected(world, x, y + 1, z + 1, side, block, blockMetadata);
|
||||
}
|
||||
|
||||
if (texture == 17 && b2[0])
|
||||
texture = 4;
|
||||
if (texture == 19 && b2[1])
|
||||
texture = 5;
|
||||
if (texture == 49 && b2[2])
|
||||
texture = 20;
|
||||
if (texture == 51 && b2[3])
|
||||
texture = 21;
|
||||
|
||||
if (texture == 18 && b2[0] && b2[1])
|
||||
texture = 7;
|
||||
if (texture == 33 && b2[0] && b2[2])
|
||||
texture = 6;
|
||||
if (texture == 35 && b2[3] && b2[1])
|
||||
texture = 23;
|
||||
if (texture == 50 && b2[3] && b2[2])
|
||||
texture = 22;
|
||||
|
||||
if (texture == 18 && !b2[0] && b2[1])
|
||||
texture = 39;
|
||||
if (texture == 33 && b2[0] && !b2[2])
|
||||
texture = 38;
|
||||
if (texture == 35 && !b2[3] && b2[1])
|
||||
texture = 53;
|
||||
if (texture == 50 && b2[3] && !b2[2])
|
||||
texture = 52;
|
||||
|
||||
if (texture == 18 && b2[0] && !b2[1])
|
||||
texture = 37;
|
||||
if (texture == 33 && !b2[0] && b2[2])
|
||||
texture = 36;
|
||||
if (texture == 35 && b2[3] && !b2[1])
|
||||
texture = 55;
|
||||
if (texture == 50 && !b2[3] && b2[2])
|
||||
texture = 54;
|
||||
|
||||
|
||||
if (texture == 34 && b2[0] && b2[1] && b2[2] && b2[3])
|
||||
texture = 58;
|
||||
|
||||
if (texture == 34 && !b2[0] && b2[1] && b2[2] && b2[3])
|
||||
texture = 9;
|
||||
if (texture == 34 && b2[0] && !b2[1] && b2[2] && b2[3])
|
||||
texture = 25;
|
||||
if (texture == 34 && b2[0] && b2[1] && !b2[2] && b2[3])
|
||||
texture = 8;
|
||||
if (texture == 34 && b2[0] && b2[1] && b2[2] && !b2[3])
|
||||
texture = 24;
|
||||
|
||||
if (texture == 34 && b2[0] && b2[1] && !b2[2] && !b2[3])
|
||||
texture = 11;
|
||||
if (texture == 34 && !b2[0] && !b2[1] && b2[2] && b2[3])
|
||||
texture = 26;
|
||||
if (texture == 34 && !b2[0] && b2[1] && !b2[2] && b2[3])
|
||||
texture = 27;
|
||||
if (texture == 34 && b2[0] && !b2[1] && b2[2] && !b2[3])
|
||||
texture = 10;
|
||||
|
||||
if (texture == 34 && b2[0] && !b2[1] && !b2[2] && b2[3])
|
||||
texture = 42;
|
||||
if (texture == 34 && !b2[0] && b2[1] && b2[2] && !b2[3])
|
||||
texture = 43;
|
||||
|
||||
if (texture == 34 && b2[0] && !b2[1] && !b2[2] && !b2[3])
|
||||
texture = 40;
|
||||
if (texture == 34 && !b2[0] && b2[1] && !b2[2] && !b2[3])
|
||||
texture = 41;
|
||||
if (texture == 34 && !b2[0] && !b2[1] && b2[2] && !b2[3])
|
||||
texture = 56;
|
||||
if (texture == 34 && !b2[0] && !b2[1] && !b2[2] && b2[3])
|
||||
texture = 57;
|
||||
return texture;
|
||||
}
|
||||
|
||||
private static boolean isConnected(IBlockAccess world, int x, int y, int z, int side, Block block, int meta) {
|
||||
int x2=x,y2=y,z2=z;
|
||||
|
||||
switch(side){
|
||||
case 0: y2--; break;
|
||||
case 1: y2++; break;
|
||||
case 2: z2--; break;
|
||||
case 3: z2++; break;
|
||||
case 4: x2--; break;
|
||||
case 5: x2++; break;
|
||||
}
|
||||
|
||||
return
|
||||
world.getBlock(x, y, z).equals(block) &&
|
||||
world.getBlockMetadata(x, y, z) == meta &&
|
||||
(!world.getBlock(x2, y2, z2).equals(block) || world.getBlockMetadata(x2, y2, z2) != meta)
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,296 @@
|
||||
package info.jbcs.minecraft.chisel.render;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
public class RenderBlocksCTM extends RenderBlocks {
|
||||
|
||||
RenderBlocksCTM(){
|
||||
super();
|
||||
|
||||
resetVertices();
|
||||
}
|
||||
|
||||
Tessellator tessellator;
|
||||
double[] X=new double[26];
|
||||
double[] Y=new double[26];
|
||||
double[] Z=new double[26];
|
||||
double[] U=new double[26];
|
||||
double[] V=new double[26];
|
||||
int[] L=new int[26];
|
||||
float[] R=new float[26];
|
||||
float[] G=new float[26];
|
||||
float[] B=new float[26];
|
||||
TextureSubmap submap;
|
||||
TextureSubmap submapSmall;
|
||||
RenderBlocks rendererOld;
|
||||
|
||||
int bx,by,bz;
|
||||
|
||||
@Override
|
||||
public boolean renderStandardBlock(Block block, int x, int y, int z){
|
||||
bx=x; by=y; bz=z;
|
||||
|
||||
tessellator = Tessellator.instance;
|
||||
tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F);
|
||||
|
||||
tessellator.xOffset+=x;
|
||||
tessellator.yOffset+=y;
|
||||
tessellator.zOffset+=z;
|
||||
|
||||
boolean res=super.renderStandardBlock(block, x, y, z);
|
||||
|
||||
tessellator.xOffset-=x;
|
||||
tessellator.yOffset-=y;
|
||||
tessellator.zOffset-=z;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void setupSides(int a,int b,int c,int d,int xa,int xb,int xc,int xd,int e){
|
||||
L[a]=brightnessBottomLeft;
|
||||
L[b]=brightnessBottomRight;
|
||||
L[c]=brightnessTopRight;
|
||||
L[d]=brightnessTopLeft;
|
||||
L[e]=(brightnessBottomLeft+brightnessTopLeft+brightnessTopRight+brightnessBottomRight)/4;
|
||||
L[xa]=(L[a]+L[b])/2;
|
||||
L[xb]=(L[b]+L[c])/2;
|
||||
L[xc]=(L[c]+L[d])/2;
|
||||
L[xd]=(L[d]+L[a])/2;
|
||||
|
||||
R[a]=colorRedBottomLeft;
|
||||
R[b]=colorRedBottomRight;
|
||||
R[c]=colorRedTopRight;
|
||||
R[d]=colorRedTopLeft;
|
||||
R[e]=(colorRedBottomLeft+colorRedTopLeft+colorRedTopRight+colorRedBottomRight)/4;
|
||||
R[xa]=(R[a]+R[b])/2;
|
||||
R[xb]=(R[b]+R[c])/2;
|
||||
R[xc]=(R[c]+R[d])/2;
|
||||
R[xd]=(R[d]+R[a])/2;
|
||||
|
||||
G[a]=colorGreenBottomLeft;
|
||||
G[b]=colorGreenBottomRight;
|
||||
G[c]=colorGreenTopRight;
|
||||
G[d]=colorGreenTopLeft;
|
||||
G[e]=(colorGreenBottomLeft+colorGreenTopLeft+colorGreenTopRight+colorGreenBottomRight)/4;
|
||||
G[xa]=(G[a]+G[b])/2;
|
||||
G[xb]=(G[b]+G[c])/2;
|
||||
G[xc]=(G[c]+G[d])/2;
|
||||
G[xd]=(G[d]+G[a])/2;
|
||||
|
||||
B[a]=colorBlueBottomLeft;
|
||||
B[b]=colorBlueBottomRight;
|
||||
B[c]=colorBlueTopRight;
|
||||
B[d]=colorBlueTopLeft;
|
||||
B[e]=(colorBlueBottomLeft+colorBlueTopLeft+colorBlueTopRight+colorBlueBottomRight)/4;
|
||||
B[xa]=(B[a]+B[b])/2;
|
||||
B[xb]=(B[b]+B[c])/2;
|
||||
B[xc]=(B[c]+B[d])/2;
|
||||
B[xd]=(B[d]+B[a])/2;
|
||||
}
|
||||
|
||||
void side(int a,int b,int c,int d,int iconIndex,boolean flip){
|
||||
IIcon icon=iconIndex>=16?submapSmall.icons[iconIndex-16]:submap.icons[iconIndex];
|
||||
|
||||
double u0=icon.getMaxU();
|
||||
double u1=icon.getMinU();
|
||||
double v0=icon.getMaxV();
|
||||
double v1=icon.getMinV();
|
||||
|
||||
U[a]=flip?u1:u1;
|
||||
U[b]=flip?u0:u1;
|
||||
U[c]=flip?u0:u0;
|
||||
U[d]=flip?u1:u0;
|
||||
|
||||
V[a]=flip?v1:v1;
|
||||
V[b]=flip?v1:v0;
|
||||
V[c]=flip?v0:v0;
|
||||
V[d]=flip?v0:v1;
|
||||
|
||||
vert(a); vert(b); vert(c); vert(d);
|
||||
}
|
||||
|
||||
void vert(int index){
|
||||
if(enableAO){
|
||||
tessellator.setColorOpaque_F(R[index], G[index], B[index]);
|
||||
tessellator.setBrightness(L[index]);
|
||||
}
|
||||
|
||||
tessellator.addVertexWithUV(X[index], Y[index], Z[index], U[index], V[index]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceXNeg(Block block, double x, double y, double z, IIcon icon){
|
||||
int tex[]=CTM.getSubmapIndices(blockAccess,bx,by,bz,4);
|
||||
|
||||
setupSides(1, 0, 4, 5, 14, 19, 17, 23, 9);
|
||||
side(1,14,9,23,tex[0],false);
|
||||
side(23,9,17,5,tex[1],false);
|
||||
side(9,19,4,17,tex[3],false);
|
||||
side(14,0,19,9,tex[2],false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceXPos(Block block, double x, double y, double z, IIcon icon){
|
||||
int tex[]=CTM.getSubmapIndices(blockAccess,bx,by,bz,5);
|
||||
|
||||
setupSides(3, 2, 6, 7, 15, 25, 16, 21, 11);
|
||||
side(11,21,3,15,tex[3],false);
|
||||
side(16,7,21,11,tex[2],false);
|
||||
side(25,11,15,2,tex[1],false);
|
||||
side(6,16,11,25,tex[0],false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceZNeg(Block block, double x, double y, double z, IIcon icon){
|
||||
int tex[]=CTM.getSubmapIndices(blockAccess,bx,by,bz,2);
|
||||
|
||||
setupSides(2, 3, 0, 1, 15, 18, 14, 22, 8);
|
||||
side(2,15,8,22,tex[0],false);
|
||||
side(15,3,18,8,tex[2],false);
|
||||
side(8,18,0,14,tex[3],false);
|
||||
side(22,8,14,1,tex[1],false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void renderFaceZPos(Block block, double x, double y, double z, IIcon icon){
|
||||
int tex[]=CTM.getSubmapIndices(blockAccess,bx,by,bz,3);
|
||||
|
||||
setupSides(4, 7, 6, 5, 20, 16, 24, 17, 10);
|
||||
side(17,4,20,10,tex[2],false);
|
||||
side(5,17,10,24,tex[0],false);
|
||||
side(24,10,16,6,tex[1],false);
|
||||
side(10,20,7,16,tex[3],false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceYNeg(Block block, double x, double y, double z, IIcon icon){
|
||||
int tex[]=CTM.getSubmapIndices(blockAccess,bx,by,bz,0);
|
||||
|
||||
setupSides(0,3,7,4,18,21,20,19,13);
|
||||
side(13,21,7,20,tex[3],true);
|
||||
side(19,13,20,4,tex[2],true);
|
||||
side(0,18,13,19,tex[0],true);
|
||||
side(18,3,21,13,tex[1],true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceYPos(Block block, double x, double y, double z, IIcon icon){
|
||||
int tex[]=CTM.getSubmapIndices(blockAccess,bx,by,bz,1);
|
||||
|
||||
setupSides(2,1,5,6,22,23,24,25,12);
|
||||
side(12,24,6,25,tex[3],false);
|
||||
side(22,12,25,2,tex[1],false);
|
||||
side(1,23,12,22,tex[0],false);
|
||||
side(23,5,24,12,tex[2],false);
|
||||
}
|
||||
|
||||
void resetVertices(){
|
||||
X[ 0]=0;
|
||||
Z[ 0]=0;
|
||||
Y[ 0]=0;
|
||||
|
||||
X[ 1]=0;
|
||||
Z[ 1]=0;
|
||||
Y[ 1]=1;
|
||||
|
||||
X[ 2]=1;
|
||||
Z[ 2]=0;
|
||||
Y[ 2]=1;
|
||||
|
||||
X[ 3]=1;
|
||||
Z[ 3]=0;
|
||||
Y[ 3]=0;
|
||||
|
||||
X[ 4]=0;
|
||||
Z[ 4]=1;
|
||||
Y[ 4]=0;
|
||||
|
||||
X[ 5]=0;
|
||||
Z[ 5]=1;
|
||||
Y[ 5]=1;
|
||||
|
||||
X[ 6]=1;
|
||||
Z[ 6]=1;
|
||||
Y[ 6]=1;
|
||||
|
||||
X[ 7]=1;
|
||||
Z[ 7]=1;
|
||||
Y[ 7]=0;
|
||||
|
||||
X[ 8]=0.5;
|
||||
Z[ 8]=0;
|
||||
Y[ 8]=0.5;
|
||||
|
||||
X[ 9]=0;
|
||||
Z[ 9]=0.5;
|
||||
Y[ 9]=0.5;
|
||||
|
||||
X[10]=0.5;
|
||||
Z[10]=1;
|
||||
Y[10]=0.5;
|
||||
|
||||
X[11]=1;
|
||||
Z[11]=0.5;
|
||||
Y[11]=0.5;
|
||||
|
||||
X[12]=0.5;
|
||||
Z[12]=0.5;
|
||||
Y[12]=1;
|
||||
|
||||
X[13]=0.5;
|
||||
Z[13]=0.5;
|
||||
Y[13]=0;
|
||||
|
||||
X[14]=0;
|
||||
Z[14]=0;
|
||||
Y[14]=0.5;
|
||||
|
||||
X[15]=1;
|
||||
Z[15]=0;
|
||||
Y[15]=0.5;
|
||||
|
||||
X[16]=1;
|
||||
Z[16]=1;
|
||||
Y[16]=0.5;
|
||||
|
||||
X[17]=0;
|
||||
Z[17]=1;
|
||||
Y[17]=0.5;
|
||||
|
||||
X[18]=0.5;
|
||||
Z[18]=0;
|
||||
Y[18]=0;
|
||||
|
||||
X[19]=0;
|
||||
Z[19]=0.5;
|
||||
Y[19]=0;
|
||||
|
||||
X[20]=0.5;
|
||||
Z[20]=1;
|
||||
Y[20]=0;
|
||||
|
||||
X[21]=1;
|
||||
Z[21]=0.5;
|
||||
Y[21]=0;
|
||||
|
||||
X[22]=0.5;
|
||||
Z[22]=0;
|
||||
Y[22]=1;
|
||||
|
||||
X[23]=0;
|
||||
Z[23]=0.5;
|
||||
Y[23]=1;
|
||||
|
||||
X[24]=0.5;
|
||||
Z[24]=1;
|
||||
Y[24]=1;
|
||||
|
||||
X[25]=1;
|
||||
Z[25]=0.5;
|
||||
Y[25]=1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package info.jbcs.minecraft.chisel.render;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
public class RenderBlocksCTMCarpet extends RenderBlocksCTM {
|
||||
RenderBlocksCTMCarpet(){
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
void resetVertices(){
|
||||
super.resetVertices();
|
||||
|
||||
for(int i=0;i<Y.length;i++){
|
||||
Y[i]/=16;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void renderFaceXNeg(Block block, double x, double y, double z, IIcon icon){
|
||||
rendererOld.renderFaceXNeg(block,0,0,0,submapSmall.icon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceXPos(Block block, double x, double y, double z, IIcon icon){
|
||||
rendererOld.renderFaceXPos(block,0,0,0,submapSmall.icon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceZNeg(Block block, double x, double y, double z, IIcon icon){
|
||||
rendererOld.renderFaceZNeg(block,0,0,0,submapSmall.icon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceZPos(Block block, double x, double y, double z, IIcon icon){
|
||||
rendererOld.renderFaceZPos(block,0,0,0,submapSmall.icon);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
package info.jbcs.minecraft.chisel.render;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
public class RenderBlocksColumn extends RenderBlocks {
|
||||
TextureSubmap submap;
|
||||
IIcon iconTop;
|
||||
IIcon sides[]=new IIcon[6];
|
||||
|
||||
RenderBlocksColumn(){
|
||||
super();
|
||||
}
|
||||
|
||||
boolean connected(IBlockAccess world, int x,int y,int z,Block block,int meta){
|
||||
return world.getBlock(x,y,z).equals(block) && world.getBlockMetadata(x,y,z)==meta;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderStandardBlock(Block block, int x, int y, int z){
|
||||
int metadata=blockAccess.getBlockMetadata(x, y, z);
|
||||
|
||||
boolean yp=connected(blockAccess,x,y+1,z,block,metadata);
|
||||
boolean yn=connected(blockAccess,x,y-1,z,block,metadata);
|
||||
|
||||
if(yp || yn){
|
||||
sides[0]=iconTop;
|
||||
sides[1]=iconTop;
|
||||
|
||||
if(yp && yn)
|
||||
sides[2]=submap.icons[2];
|
||||
else if(yp)
|
||||
sides[2]=submap.icons[3];
|
||||
else
|
||||
sides[2]=submap.icons[1];
|
||||
|
||||
sides[3]=sides[4]=sides[5]=sides[2];
|
||||
} else{
|
||||
boolean xp=connected(blockAccess,x+1,y,z,block,metadata);
|
||||
boolean xn=connected(blockAccess,x-1,y,z,block,metadata);
|
||||
|
||||
if(xp && (connected(blockAccess,x+1,y+1,z,block,metadata) || connected(blockAccess,x+1,y-1,z,block,metadata)))
|
||||
xp=false;
|
||||
if(xn && (connected(blockAccess,x-1,y+1,z,block,metadata) || connected(blockAccess,x-1,y-1,z,block,metadata)))
|
||||
xn=false;
|
||||
|
||||
if(xp || xn){
|
||||
uvRotateEast = 2;
|
||||
uvRotateWest = 1;
|
||||
uvRotateTop = 1;
|
||||
uvRotateBottom = 1;
|
||||
|
||||
sides[4]=iconTop;
|
||||
sides[5]=iconTop;
|
||||
|
||||
if(xp && xn)
|
||||
sides[0]=submap.icons[2];
|
||||
else if(xp)
|
||||
sides[0]=submap.icons[3];
|
||||
else
|
||||
sides[0]=submap.icons[1];
|
||||
|
||||
sides[1]=sides[2]=sides[3]=sides[0];
|
||||
} else{
|
||||
boolean zp=connected(blockAccess,x,y,z+1,block,metadata);
|
||||
boolean zn=connected(blockAccess,x,y,z-1,block,metadata);
|
||||
|
||||
if(zp && (connected(blockAccess,x,y+1,z+1,block,metadata) || connected(blockAccess,x,y-1,z+1,block,metadata)))
|
||||
zp=false;
|
||||
if(zp && (connected(blockAccess,x+1,y,z+1,block,metadata) || connected(blockAccess,x-1,y,z+1,block,metadata)))
|
||||
zp=false;
|
||||
if(zn && (connected(blockAccess,x,y+1,z-1,block,metadata) || connected(blockAccess,x,y-1,z-1,block,metadata)))
|
||||
zn=false;
|
||||
if(zn && (connected(blockAccess,x+1,y,z-1,block,metadata) || connected(blockAccess,x-1,y,z-1,block,metadata)))
|
||||
zn=false;
|
||||
|
||||
if(zp || zn){
|
||||
uvRotateSouth = 1;
|
||||
uvRotateNorth = 2;
|
||||
|
||||
sides[2]=iconTop;
|
||||
sides[3]=iconTop;
|
||||
|
||||
if(zp && zn)
|
||||
sides[0]=submap.icons[2];
|
||||
else if(zp)
|
||||
sides[0]=submap.icons[1];
|
||||
else
|
||||
sides[0]=submap.icons[3];
|
||||
|
||||
sides[1]=sides[4]=sides[5]=sides[0];
|
||||
} else{
|
||||
sides[0]=sides[1]=iconTop;
|
||||
sides[2]=sides[3]=sides[4]=sides[5]=submap.icons[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
boolean flag = super.renderStandardBlock(block, x, y, z);
|
||||
|
||||
uvRotateSouth = 0;
|
||||
uvRotateEast = 0;
|
||||
uvRotateWest = 0;
|
||||
uvRotateNorth = 0;
|
||||
uvRotateTop = 0;
|
||||
uvRotateBottom = 0;
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void renderFaceXNeg(Block block, double x, double y, double z, IIcon icon){
|
||||
super.renderFaceXNeg(block,x,y,z,sides[4]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceXPos(Block block, double x, double y, double z, IIcon icon){
|
||||
super.renderFaceXPos(block,x,y,z,sides[5]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceZNeg(Block block, double x, double y, double z, IIcon icon){
|
||||
super.renderFaceZNeg(block,x,y,z,sides[2]);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void renderFaceZPos(Block block, double x, double y, double z, IIcon icon){
|
||||
super.renderFaceZPos(block,x,y,z,sides[3]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceYNeg(Block block, double x, double y, double z, IIcon icon){
|
||||
super.renderFaceYNeg(block,x,y,z,sides[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceYPos(Block block, double x, double y, double z, IIcon icon){
|
||||
super.renderFaceYPos(block,x,y,z,sides[1]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,245 @@
|
||||
package info.jbcs.minecraft.chisel.render;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
public class RenderBlocksEldritch extends RenderBlocks {
|
||||
|
||||
RenderBlocksEldritch(){
|
||||
super();
|
||||
}
|
||||
|
||||
static double displacementMap[]={
|
||||
+0.1165, -0.0352, -0.1208, +0.0906, -0.0295, +0.0302, -0.0973, +0.0548,
|
||||
-0.1077, +0.0662, -0.0932, -0.0925, -0.1161, +0.0073, -0.1084, +0.1136,
|
||||
+0.0307, +0.0316, -0.1066, -0.0237, +0.0614, -0.0864, +0.0837, +0.1218,
|
||||
+0.0502, -0.0529, -0.0942, +0.1209, -0.0418, +0.1035, +0.0066, -0.0255,
|
||||
+0.0830, -0.0361, +0.0965, +0.0646, +0.1124, +0.0890, -0.0037, +0.0467,
|
||||
+0.1025, +0.1161, +0.0014, +0.0365, +0.0755, -0.0025, +0.0739, +0.0656,
|
||||
+0.0571, -0.0813, -0.0062, -0.0904, -0.0005, +0.0612, -0.0227, +0.0138,
|
||||
-0.0899, -0.0019, -0.1047, +0.1191, -0.1197, -0.1123, +0.0999, +0.0638,
|
||||
+0.0865, +0.0029, -0.0084, +0.1132, -0.0433, +0.0115, +0.0850, +0.0439,
|
||||
+0.0748, +0.0460, -0.0441, +0.0839, +0.0162, -0.0229, +0.0774, -0.0647,
|
||||
-0.0636, -0.0709, -0.0719, -0.0194, +0.1070, -0.0466, -0.1200, -0.0996,
|
||||
-0.0298, -0.1035, -0.0006, +0.0530, -0.0939, -0.1210, +0.0176, +0.0924,
|
||||
+0.0343, -0.0777, +0.1050, -0.0729, -0.0062, -0.1107, -0.0434, -0.0042,
|
||||
+0.0232, +0.0269, +0.0709, -0.0388, +0.0342, +0.0240, -0.0192, +0.0491,
|
||||
+0.0017, -0.1240, +0.0687, -0.1160, +0.1123, -0.0332, -0.0260, +0.0476,
|
||||
-0.0049, -0.0893, -0.0243, -0.0371, -0.0230, +0.0656, +0.1080, +0.0781,
|
||||
-0.0648, +0.0082, -0.1086, -0.0451, -0.0594, -0.1155, -0.0623, -0.0152,
|
||||
+0.0131, -0.0754, +0.0607, +0.0876, -0.0657, +0.0366, -0.0981, +0.1164,
|
||||
-0.0623, +0.0181, -0.0475, +0.0722, -0.0293, +0.0486, -0.0195, +0.1041,
|
||||
+0.1011, +0.0042, -0.0045, -0.1031, +0.0110, +0.0058, +0.0083, -0.0782,
|
||||
-0.1003, -0.0082, -0.0304, -0.0971, -0.0097, -0.0208, -0.1059, -0.0239,
|
||||
-0.0385, +0.0505, +0.0537, -0.1098, -0.0022, -0.0165, -0.0027, -0.0208,
|
||||
+0.0305, +0.0592, +0.0301, +0.0055, +0.1138, -0.0338, -0.0901, +0.1015,
|
||||
+0.0061, +0.0861, -0.1057, -0.0889, -0.0972, +0.0783, -0.1052, -0.0932,
|
||||
-0.1103, +0.0497, +0.1222, -0.0146, +0.0632, -0.0240, -0.0193, +0.0676,
|
||||
-0.1128, -0.0886, +0.0926, +0.0538, -0.0175, -0.0966, -0.0369, +0.1124,
|
||||
-0.0820, -0.1013, -0.0836, -0.0981, -0.0502, +0.0573, +0.0616, -0.0458,
|
||||
+0.0294, +0.0108, -0.0782, +0.0692, +0.0234, -0.0178, -0.0171, -0.0505,
|
||||
-0.0313, +0.0538, +0.0462, -0.0758, +0.0556, -0.0023, -0.1086, -0.0100,
|
||||
-0.0897, -0.0409, -0.1161, +0.0212, +0.1229, -0.0945, +0.0341, +0.1238,
|
||||
+0.0893, -0.1189, -0.1098, -0.0125, +0.1137, -0.0202, +0.0239, -0.0408,
|
||||
+0.0920, +0.0777, -0.0085, -0.0572, -0.0293, -0.0131, +0.0272, +0.0991,
|
||||
};
|
||||
|
||||
static int dmap1=displacementMap.length*1/6;
|
||||
static int dmap2=displacementMap.length*2/6;
|
||||
static int dmap3=displacementMap.length*3/6;
|
||||
static int dmap4=displacementMap.length*4/6;
|
||||
static int dmap5=displacementMap.length*5/6;
|
||||
static int dmap=displacementMap.length;
|
||||
|
||||
Tessellator tessellator;
|
||||
double[] X=new double[14];
|
||||
double[] Y=new double[14];
|
||||
double[] Z=new double[14];
|
||||
double[] U=new double[14];
|
||||
double[] V=new double[14];
|
||||
int[] L=new int[14];
|
||||
float[] R=new float[14];
|
||||
float[] G=new float[14];
|
||||
float[] B=new float[14];
|
||||
|
||||
@Override
|
||||
public boolean renderStandardBlock(Block block, int x, int y, int z){
|
||||
int index=x+y*34573+z*32465781;
|
||||
if(index<0) index=-index;
|
||||
|
||||
X[ 0]=x;
|
||||
Z[ 0]=z;
|
||||
Y[ 0]=y;
|
||||
|
||||
X[ 1]=x;
|
||||
Z[ 1]=z;
|
||||
Y[ 1]=y+1;
|
||||
|
||||
X[ 2]=x+1;
|
||||
Z[ 2]=z;
|
||||
Y[ 2]=y+1;
|
||||
|
||||
X[ 3]=x+1;
|
||||
Z[ 3]=z;
|
||||
Y[ 3]=y;
|
||||
|
||||
X[ 4]=x;
|
||||
Z[ 4]=z+1;
|
||||
Y[ 4]=y;
|
||||
|
||||
X[ 5]=x;
|
||||
Z[ 5]=z+1;
|
||||
Y[ 5]=y+1;
|
||||
|
||||
X[ 6]=x+1;
|
||||
Z[ 6]=z+1;
|
||||
Y[ 6]=y+1;
|
||||
|
||||
X[ 7]=x+1;
|
||||
Z[ 7]=z+1;
|
||||
Y[ 7]=y;
|
||||
|
||||
X[ 8]=x+0.5+displacementMap[(index+ 0)%dmap];
|
||||
Z[ 8]=z-displacementMap[(index+10)%dmap];
|
||||
Y[ 8]=y+0.5+displacementMap[(index+20)%dmap];
|
||||
|
||||
X[ 9]=x-displacementMap[(index+0+dmap1)%dmap];
|
||||
Z[ 9]=z+0.5+displacementMap[(index+10+dmap1)%dmap];
|
||||
Y[ 9]=y+0.5+displacementMap[(index+20+dmap1)%dmap];
|
||||
|
||||
X[10]=x+0.5+displacementMap[(index+0+dmap2)%dmap];
|
||||
Z[10]=z+1+displacementMap[(index+10+dmap2)%dmap];
|
||||
Y[10]=y+0.5+displacementMap[(index+20+dmap2)%dmap];
|
||||
|
||||
X[11]=x+1+displacementMap[(index+0+dmap3)%dmap];
|
||||
Z[11]=z+0.5+displacementMap[(index+10+dmap3)%dmap];
|
||||
Y[11]=y+0.5+displacementMap[(index+20+dmap3)%dmap];
|
||||
|
||||
X[12]=x+0.5+displacementMap[(index+0+dmap4)%dmap];
|
||||
Z[12]=z+0.5+displacementMap[(index+10+dmap4)%dmap];
|
||||
Y[12]=y+1;//+displacementMap[(index+20+dmap4)%dmap];
|
||||
|
||||
X[13]=x+0.5+displacementMap[(index+0+dmap5)%dmap];
|
||||
Z[13]=z+0.5+displacementMap[(index+10+dmap5)%dmap];
|
||||
Y[13]=y+0;//+displacementMap[(index+20+dmap5)%dmap];
|
||||
|
||||
tessellator = Tessellator.instance;
|
||||
tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F);
|
||||
|
||||
return super.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
void setupSides(IIcon icon,int a,int b,int c,int d,int e, int ta,int tb,int tc,int td){
|
||||
L[a]=brightnessBottomLeft;
|
||||
L[b]=brightnessBottomRight;
|
||||
L[c]=brightnessTopRight;
|
||||
L[d]=brightnessTopLeft;
|
||||
L[e]=(brightnessBottomLeft+brightnessTopLeft+brightnessTopRight+brightnessBottomRight)/4;
|
||||
|
||||
R[a]=colorRedBottomLeft;
|
||||
R[b]=colorRedBottomRight;
|
||||
R[c]=colorRedTopRight;
|
||||
R[d]=colorRedTopLeft;
|
||||
R[e]=(colorRedBottomLeft+colorRedTopLeft+colorRedTopRight+colorRedBottomRight)/4;
|
||||
|
||||
G[a]=colorGreenBottomLeft;
|
||||
G[b]=colorGreenBottomRight;
|
||||
G[c]=colorGreenTopRight;
|
||||
G[d]=colorGreenTopLeft;
|
||||
G[e]=(colorGreenBottomLeft+colorGreenTopLeft+colorGreenTopRight+colorGreenBottomRight)/4;
|
||||
|
||||
B[a]=colorBlueBottomLeft;
|
||||
B[b]=colorBlueBottomRight;
|
||||
B[c]=colorBlueTopRight;
|
||||
B[d]=colorBlueTopLeft;
|
||||
B[e]=(colorBlueBottomLeft+colorBlueTopLeft+colorBlueTopRight+colorBlueBottomRight)/4;
|
||||
|
||||
double u0=icon.getMaxU();
|
||||
double u1=icon.getMinU();
|
||||
double v0=icon.getMaxV();
|
||||
double v1=icon.getMinV();
|
||||
|
||||
U[ta]=u0;
|
||||
U[tb]=u0;
|
||||
U[tc]=u1;
|
||||
U[td]=u1;
|
||||
U[e]=icon.getInterpolatedU(8.0D);
|
||||
|
||||
V[ta]=v0;
|
||||
V[tb]=v1;
|
||||
V[tc]=v1;
|
||||
V[td]=v0;
|
||||
V[e]=icon.getInterpolatedV(8.0D);
|
||||
}
|
||||
|
||||
void vert(int index){
|
||||
if(enableAO){
|
||||
tessellator.setColorOpaque_F(R[index], G[index], B[index]);
|
||||
tessellator.setBrightness(L[index]);
|
||||
}
|
||||
|
||||
tessellator.addVertexWithUV(X[index], Y[index], Z[index], U[index], V[index]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceXNeg(Block block, double x, double y, double z, IIcon icon){
|
||||
setupSides(icon, 1, 0, 4, 5, 9, 4, 5, 1, 0);
|
||||
vert(1); vert(0); vert(9); vert(9);
|
||||
vert(0); vert(4); vert(9); vert(9);
|
||||
vert(4); vert(5); vert(9); vert(9);
|
||||
vert(5); vert(1); vert(9); vert(9);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceXPos(Block block, double x, double y, double z, IIcon icon){
|
||||
setupSides(icon, 3, 2, 6, 7, 11, 3, 2, 6, 7);
|
||||
vert(6); vert(7); vert(11); vert(11);
|
||||
vert(7); vert(3); vert(11); vert(11);
|
||||
vert(3); vert(2); vert(11); vert(11);
|
||||
vert(2); vert(6); vert(11); vert(11);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceZNeg(Block block, double x, double y, double z, IIcon icon){
|
||||
setupSides(icon, 2, 3, 0, 1, 8, 0, 1, 2, 3);
|
||||
vert(0); vert(1); vert(8); vert(8);
|
||||
vert(1); vert(2); vert(8); vert(8);
|
||||
vert(2); vert(3); vert(8); vert(8);
|
||||
vert(3); vert(0); vert(8); vert(8);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void renderFaceZPos(Block block, double x, double y, double z, IIcon icon){
|
||||
setupSides(icon, 4, 7, 6, 5, 10, 7, 6, 5, 4);
|
||||
vert(5); vert(4); vert(10); vert(10);
|
||||
vert(6); vert(5); vert(10); vert(10);
|
||||
vert(7); vert(6); vert(10); vert(10);
|
||||
vert(4); vert(7); vert(10); vert(10);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void renderFaceYNeg(Block block, double x, double y, double z, IIcon icon){
|
||||
setupSides(icon,0,3,7,4,13,0,3,7,4);
|
||||
vert(0); vert(3); vert(13); vert(13);
|
||||
vert(3); vert(7); vert(13); vert(13);
|
||||
vert(7); vert(4); vert(13); vert(13);
|
||||
vert(4); vert(0); vert(13); vert(13);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceYPos(Block block, double x, double y, double z, IIcon icon){
|
||||
setupSides(icon,2,1,5,6,12,2,1,5,6);
|
||||
|
||||
vert(2); vert(1); vert(12); vert(12);
|
||||
vert(1); vert(5); vert(12); vert(12);
|
||||
vert(5); vert(6); vert(12); vert(12);
|
||||
vert(6); vert(2); vert(12); vert(12);
|
||||
}
|
||||
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package info.jbcs.minecraft.chisel.render;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
|
||||
public class TextureStitchFinishedEvent extends Event {
|
||||
public TextureMap map;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package info.jbcs.minecraft.chisel.render;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
public class TextureSubmap {
|
||||
public int width,height;
|
||||
public IIcon icon;
|
||||
public IIcon icons[];
|
||||
|
||||
public TextureSubmap(IIcon i,int w,int h) {
|
||||
icon=i;
|
||||
width=w;
|
||||
height=h;
|
||||
icons=new IIcon[width*height];
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void TexturesStitched(TextureStitchEvent.Post event){
|
||||
|
||||
for(int x=0;x<width;x++){
|
||||
for(int y=0;y<height;y++){
|
||||
icons[y*width+x]=new TextureVirtual(icon,width,height,x,y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package info.jbcs.minecraft.chisel.render;
|
||||
|
||||
import net.minecraft.util.IIcon;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class TextureVirtual implements IIcon {
|
||||
int ox,oy;
|
||||
float u0,u1,v0,v1;
|
||||
String name;
|
||||
IIcon icon;
|
||||
|
||||
TextureVirtual(IIcon parent, int w, int h, int x, int y){
|
||||
icon=parent;
|
||||
|
||||
u0=icon.getInterpolatedU(16.0*(x+0)/w);
|
||||
u1=icon.getInterpolatedU(16.0*(x+1)/w);
|
||||
v0=icon.getInterpolatedV(16.0*(y+0)/h);
|
||||
v1=icon.getInterpolatedV(16.0*(y+1)/h);
|
||||
|
||||
name=icon.getIconName()+"|"+x+"."+y;
|
||||
|
||||
ox=icon.getIconWidth();
|
||||
oy=icon.getIconHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float getMinU() {
|
||||
return u0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float getMaxU() {
|
||||
return u1;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float getInterpolatedU(double d0) {
|
||||
return (float) (u0+(u1-u0)*d0/16.0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float getMinV() {
|
||||
return v0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float getMaxV() {
|
||||
return v1;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float getInterpolatedV(double d0) {
|
||||
return (float) (v0+(v1-v0)*d0/16.0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String getIconName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getIconWidth() {
|
||||
return ox;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getIconHeight() {
|
||||
return oy;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package info.jbcs.minecraft.gui;
|
||||
|
||||
import info.jbcs.minecraft.utilities.InventoryStatic;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ContainerPickBlock extends Container
|
||||
{
|
||||
ArrayList<ItemStack> items = new ArrayList<ItemStack>();
|
||||
GuiPickBlock gui;
|
||||
EntityPlayer player;
|
||||
int width = 9;
|
||||
int height = 7;
|
||||
|
||||
SlotPickBlock resultSlot;
|
||||
|
||||
public ContainerPickBlock(EntityPlayer p)
|
||||
{
|
||||
for (Object o : Item.itemRegistry.getKeys())
|
||||
{
|
||||
Item item = (Item)Item.itemRegistry.getObject((String)o);
|
||||
|
||||
if (item != null && item.getCreativeTab() != null)
|
||||
{
|
||||
item.getSubItems(item, null, items);
|
||||
}
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
|
||||
for (int y = 0; y < height; y++)
|
||||
{
|
||||
for (int x = 0; x < width; x++)
|
||||
{
|
||||
addSlotToContainer(new SlotPickBlock(this, index++, 9 + x * 18, 18 + y * 18));
|
||||
}
|
||||
}
|
||||
|
||||
addSlotToContainer(resultSlot = new SlotPickBlock(this, index++, 18, 153));
|
||||
player = p;
|
||||
scrollTo(0);
|
||||
}
|
||||
|
||||
public InventoryStatic inventory = new InventoryStatic(width * height + 1)
|
||||
{
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemstack)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
public void scrollTo(float offset)
|
||||
{
|
||||
int columnsNotFitting = items.size() / width - height + 1;
|
||||
|
||||
if (columnsNotFitting < 0)
|
||||
{
|
||||
columnsNotFitting = 0;
|
||||
}
|
||||
|
||||
int columnOffset = (int)(offset * columnsNotFitting + 0.5D);
|
||||
|
||||
for (int y = 0; y < height; ++y)
|
||||
{
|
||||
for (int x = 0; x < width; ++x)
|
||||
{
|
||||
int index = x + (y + columnOffset) * width;
|
||||
|
||||
if (index >= 0 && index < items.size())
|
||||
{
|
||||
inventory.setInventorySlotContents(x + y * width, items.get(index));
|
||||
}
|
||||
else
|
||||
{
|
||||
inventory.setInventorySlotContents(x + y * width, (ItemStack) null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int index)
|
||||
{
|
||||
SlotPickBlock slot = (SlotPickBlock) this.inventorySlots.get(index);
|
||||
return slot.transferStackInSlot(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer entityplayer)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package info.jbcs.minecraft.gui;
|
||||
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
|
||||
public class GuiEdit extends GuiElement {
|
||||
GuiTextField field;
|
||||
String tempString="";
|
||||
|
||||
public GuiEdit(int x, int y, int w, int h) {
|
||||
super(x, y, w, h);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdded() {
|
||||
field = new GuiTextField(gui.fontRendererObj(), x, y, w, h);
|
||||
setText(tempString);
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
if (field == null) {
|
||||
return tempString;
|
||||
} else {
|
||||
return field.getText();
|
||||
}
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
if (field == null) {
|
||||
tempString = text;
|
||||
} else {
|
||||
field.setText(text);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render() {
|
||||
field.drawTextBox();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseDown(InputMouseEvent ev) {
|
||||
field.mouseClicked(ev.x, ev.y, ev.button);
|
||||
|
||||
if (isMouseOver(ev)) {
|
||||
ev.handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyPressed(InputKeyboardEvent ev) {
|
||||
field.textboxKeyTyped(ev.character, ev.key);
|
||||
|
||||
if (field.isFocused()) {
|
||||
ev.handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
package info.jbcs.minecraft.gui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class GuiElement {
|
||||
public int x;
|
||||
public int y;
|
||||
public int w;
|
||||
public int h;
|
||||
|
||||
public GuiScreenPlus gui;
|
||||
public GuiElement parent, addedParent;
|
||||
private ArrayList<GuiElement> children = null;
|
||||
|
||||
public GuiElement(int x, int y, int w, int h) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.w = w;
|
||||
this.h = h;
|
||||
}
|
||||
|
||||
public GuiElement addChild(GuiElement e) {
|
||||
if (children == null) {
|
||||
children = new ArrayList<GuiElement>();
|
||||
}
|
||||
|
||||
if (e.parent != null) {
|
||||
e.parent.removeChild(e);
|
||||
}
|
||||
|
||||
children.add(e);
|
||||
e.x += x;
|
||||
e.y += y;
|
||||
e.parent = this;
|
||||
e.gui = gui;
|
||||
return e;
|
||||
}
|
||||
|
||||
public GuiElement removeChild(GuiElement e) {
|
||||
if (children == null) {
|
||||
return e;
|
||||
}
|
||||
|
||||
children.remove(e);
|
||||
e.x -= x;
|
||||
e.y -= y;
|
||||
e.parent = null;
|
||||
e.gui = null;
|
||||
return e;
|
||||
}
|
||||
|
||||
public void onAdded() {
|
||||
if (children == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (GuiElement e : children) {
|
||||
if (e.parent != e.addedParent) {
|
||||
e.onAdded();
|
||||
}
|
||||
|
||||
e.addedParent = e.parent;
|
||||
}
|
||||
}
|
||||
|
||||
boolean isMouseOver(InputMouseEvent ev) {
|
||||
return ev.x >= x && ev.x < x + w && ev.y >= y && ev.y < y + h;
|
||||
}
|
||||
|
||||
public void mouseDown(InputMouseEvent ev) {
|
||||
if (children == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (GuiElement e : children) {
|
||||
e.mouseDown(ev);
|
||||
|
||||
if (ev.handled) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void mouseUp(InputMouseEvent ev) {
|
||||
if (children == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (GuiElement e : children) {
|
||||
e.mouseUp(ev);
|
||||
|
||||
if (ev.handled) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void mouseMove(InputMouseEvent ev) {
|
||||
if (children == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (GuiElement e : children) {
|
||||
e.mouseMove(ev);
|
||||
|
||||
if (ev.handled) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void mouseWheel(InputMouseEvent ev) {
|
||||
if (children == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (GuiElement e : children) {
|
||||
e.mouseWheel(ev);
|
||||
|
||||
if (ev.handled) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void render() {
|
||||
if (children == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (GuiElement e : children) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
e.render();
|
||||
}
|
||||
}
|
||||
|
||||
public void keyPressed(InputKeyboardEvent ev) {
|
||||
if (children == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (GuiElement e : children) {
|
||||
e.keyPressed(ev);
|
||||
|
||||
if (ev.handled) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package info.jbcs.minecraft.gui;
|
||||
|
||||
public class GuiExButton extends GuiElement {
|
||||
protected String caption;
|
||||
|
||||
int u, v, texw, texh;
|
||||
int borderTop, borderRight, borderBottom, borderLeft;
|
||||
|
||||
boolean over;
|
||||
public boolean disabled;
|
||||
|
||||
public TexturedBox boxDisabled;
|
||||
public TexturedBox boxNormal;
|
||||
public TexturedBox boxOver;
|
||||
|
||||
public GuiExButton(int x, int y, int w, int h, String caption) {
|
||||
this(x, y, w, h, caption, "textures/gui/widgets.png");
|
||||
}
|
||||
|
||||
public GuiExButton(int x, int y, int w, int h, String caption,String texture) {
|
||||
super(x, y, w, h);
|
||||
this.caption = caption;
|
||||
disabled = false;
|
||||
u = 0;
|
||||
v = 46;
|
||||
texw = 200;
|
||||
texh = 20;
|
||||
borderTop = 2;
|
||||
borderRight = 2;
|
||||
borderBottom = 3;
|
||||
borderLeft = 2;
|
||||
|
||||
boxDisabled = new TexturedBox(texture, 0, 46, 200, 20, 2, 2, 3, 2);
|
||||
boxNormal = new TexturedBox(texture, 0, 66, 200, 20, 2, 2, 3, 2);
|
||||
boxOver = new TexturedBox(texture, 0, 86, 200, 20, 2, 2, 3, 2);
|
||||
|
||||
}
|
||||
|
||||
public void onClick() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render() {
|
||||
int color = 0xffe0e0e0;
|
||||
TexturedBox box = boxDisabled;
|
||||
|
||||
if (!disabled && !over) {
|
||||
box = boxNormal;
|
||||
color = 0xffffffff;
|
||||
} else if (!disabled && over) {
|
||||
box = boxOver;
|
||||
color = 0xffffff70;
|
||||
}
|
||||
|
||||
box.render(gui, x, y, w, h);
|
||||
gui.drawCenteredStringWithShadow(caption, x + w / 2, y + h / 2, color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseMove(InputMouseEvent ev) {
|
||||
over = isMouseOver(ev);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseDown(InputMouseEvent ev) {
|
||||
if (!isMouseOver(ev)) {
|
||||
return;
|
||||
}
|
||||
|
||||
gui.playSound("random.click", 1.0f, 1.0f);
|
||||
onClick();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package info.jbcs.minecraft.gui;
|
||||
|
||||
public class GuiLabel extends GuiElement {
|
||||
String caption;
|
||||
|
||||
public GuiLabel(int x, int y, int w, int h, String caption) {
|
||||
super(x, y, w, h);
|
||||
this.caption = caption;
|
||||
}
|
||||
|
||||
public GuiLabel(int x, int y, String string) {
|
||||
this(x, y, 0, 0, string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render() {
|
||||
gui.drawString(caption, x, y, 0x404040);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package info.jbcs.minecraft.gui;
|
||||
|
||||
|
||||
import info.jbcs.minecraft.utilities.GeneralClient;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class GuiPickBlock extends GuiContainer
|
||||
{
|
||||
Scrollbar scrollbar;
|
||||
ContainerPickBlock container;
|
||||
GuiScreen parent;
|
||||
|
||||
public GuiPickBlock(EntityPlayer player, ItemStack stack, GuiScreen screen)
|
||||
{
|
||||
super(new ContainerPickBlock(player));
|
||||
ySize = 185;
|
||||
xSize = 195;
|
||||
container = (ContainerPickBlock) inventorySlots;
|
||||
container.gui = this;
|
||||
parent = screen;
|
||||
container.resultSlot.putStack(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float f, int x, int y)
|
||||
{
|
||||
GeneralClient.bind("vending:textures/list_items.png");
|
||||
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
|
||||
scrollbar.drawButton(mc, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMouseInput()
|
||||
{
|
||||
super.handleMouseInput();
|
||||
scrollbar.handleMouseInput();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the buttons (and other controls) to the screen in question.
|
||||
*/
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
buttonList.add(scrollbar = new Scrollbar(200, guiLeft + 175, guiTop + 18, 12, 124, "")
|
||||
{
|
||||
@Override
|
||||
public void onScrolled(float off)
|
||||
{
|
||||
int columnsNotFitting = container.items.size() / container.width - container.height + 1;
|
||||
|
||||
if (columnsNotFitting < 0)
|
||||
{
|
||||
columnsNotFitting = 0;
|
||||
}
|
||||
|
||||
if (columnsNotFitting == 0)
|
||||
{
|
||||
scrollbar.active = false;
|
||||
scrollbar.offset = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
scrollbar.active = true;
|
||||
scrollbar.step = 1.0f / columnsNotFitting;
|
||||
}
|
||||
|
||||
container.scrollTo(off);
|
||||
}
|
||||
});
|
||||
buttonList.add(new GuiButton(100, guiLeft + 44, guiTop + 151, 70, 20, "Select"));
|
||||
}
|
||||
|
||||
public void picked(ItemStack stack)
|
||||
{
|
||||
if (parent == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (parent instanceof IPickBlockHandler)
|
||||
{
|
||||
((IPickBlockHandler) parent).blockPicked(stack);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired when a control is clicked. This is the equivalent of
|
||||
* ActionListener.actionPerformed(ActionEvent e).
|
||||
*/
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton button)
|
||||
{
|
||||
switch (button.id)
|
||||
{
|
||||
case 100:
|
||||
ItemStack stack = container.resultSlot.getStack();
|
||||
|
||||
if (parent instanceof IPickBlockHandler)
|
||||
{
|
||||
((IPickBlockHandler) parent).blockPicked(stack);
|
||||
}
|
||||
|
||||
Minecraft.getMinecraft().displayGuiScreen(parent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,233 @@
|
||||
package info.jbcs.minecraft.gui;
|
||||
|
||||
import info.jbcs.minecraft.utilities.DummyContainer;
|
||||
import info.jbcs.minecraft.utilities.GeneralClient;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class GuiScreenPlus extends GuiContainer {
|
||||
public int screenW;
|
||||
public int screenH;
|
||||
public int screenX;
|
||||
public int screenY;
|
||||
|
||||
public GuiElement root;
|
||||
|
||||
String backgroundTexture;
|
||||
|
||||
public GuiScreenPlus(Container container, int w, int h, String backgroundTexture) {
|
||||
super(container);
|
||||
root = new GuiElement(0, 0, w, h);
|
||||
root.gui = this;
|
||||
this.screenW = w;
|
||||
this.screenH = h;
|
||||
this.backgroundTexture = backgroundTexture;
|
||||
}
|
||||
|
||||
public GuiScreenPlus(int w, int h, String backgroundTexture) {
|
||||
this(new DummyContainer(), w, h, backgroundTexture);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
xSize = screenW;
|
||||
ySize = screenH;
|
||||
super.initGui();
|
||||
screenX = guiLeft;
|
||||
screenY = guiTop;
|
||||
root.onAdded();
|
||||
|
||||
Keyboard.enableRepeatEvents(true);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void handleInput() {
|
||||
while (Mouse.next()) {
|
||||
this.handleMouseInput();
|
||||
}
|
||||
|
||||
while (Keyboard.next()) {
|
||||
this.handleKeyboardInput();
|
||||
}
|
||||
}
|
||||
|
||||
InputMouseEvent mouseEvent = new InputMouseEvent();
|
||||
int oldX = -1;
|
||||
int oldY = -1;
|
||||
|
||||
boolean[] downButtons = new boolean[12];
|
||||
|
||||
@Override
|
||||
public void handleMouseInput() {
|
||||
mouseEvent.handled = false;
|
||||
mouseEvent.x = Mouse.getEventX() * width / mc.displayWidth - this.screenX;
|
||||
mouseEvent.y = height - Mouse.getEventY() * height / mc.displayHeight - 1 - this.screenY;
|
||||
|
||||
if (oldX == -1) {
|
||||
oldX = mouseEvent.x;
|
||||
oldY = mouseEvent.y;
|
||||
}
|
||||
|
||||
mouseEvent.dx = mouseEvent.x - oldX;
|
||||
mouseEvent.dy = mouseEvent.y - oldY;
|
||||
oldX = mouseEvent.x;
|
||||
oldY = mouseEvent.y;
|
||||
mouseEvent.down = Mouse.getEventButtonState();
|
||||
mouseEvent.button = Mouse.getEventButton();
|
||||
mouseEvent.wheel = Mouse.getEventDWheel();
|
||||
|
||||
if (mouseEvent.wheel != 0) {
|
||||
if (mouseEvent.wheel < 0) {
|
||||
mouseEvent.wheel = -1;
|
||||
} else {
|
||||
mouseEvent.wheel = 1;
|
||||
}
|
||||
|
||||
root.mouseWheel(mouseEvent);
|
||||
} else if (mouseEvent.button >= 0 && mouseEvent.button < downButtons.length) {
|
||||
if (downButtons[mouseEvent.button] != mouseEvent.down) {
|
||||
downButtons[mouseEvent.button] = mouseEvent.down;
|
||||
|
||||
if (mouseEvent.down) {
|
||||
root.mouseDown(mouseEvent);
|
||||
} else {
|
||||
root.mouseUp(mouseEvent);
|
||||
}
|
||||
} else if (mouseEvent.dx != 0 || mouseEvent.dy != 0) {
|
||||
root.mouseMove(mouseEvent);
|
||||
}
|
||||
} else if (mouseEvent.dx != 0 || mouseEvent.dy != 0) {
|
||||
root.mouseMove(mouseEvent);
|
||||
}
|
||||
|
||||
if (!mouseEvent.handled) {
|
||||
super.handleMouseInput();
|
||||
}
|
||||
}
|
||||
|
||||
InputKeyboardEvent keyboardEvent = new InputKeyboardEvent();
|
||||
|
||||
@Override
|
||||
public void handleKeyboardInput() {
|
||||
keyboardEvent.handled = false;
|
||||
|
||||
if (Keyboard.getEventKeyState()) {
|
||||
keyboardEvent.key = Keyboard.getEventKey();
|
||||
keyboardEvent.character = Keyboard.getEventCharacter();
|
||||
|
||||
switch (keyboardEvent.key) {
|
||||
case 1:
|
||||
break;
|
||||
|
||||
default:
|
||||
root.keyPressed(keyboardEvent);
|
||||
}
|
||||
}
|
||||
|
||||
if (!keyboardEvent.handled) {
|
||||
super.handleKeyboardInput();
|
||||
}
|
||||
}
|
||||
|
||||
public void close() {
|
||||
mc.displayGuiScreen((GuiScreen) null);
|
||||
mc.setIngameFocus();
|
||||
}
|
||||
|
||||
protected void addChild(GuiElement e) {
|
||||
root.addChild(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float f, int bx, int by) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GeneralClient.bind(backgroundTexture);
|
||||
drawTexturedModalRect(screenX, screenY, 0, 0, screenW, screenH);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int fx, int fy) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
root.render();
|
||||
}
|
||||
|
||||
public void drawString(String text, int sx, int sy, int color) {
|
||||
fontRendererObj.drawString(text, sx, sy, color);
|
||||
}
|
||||
|
||||
public void drawCenteredString(String text, int sx, int sy, int color) {
|
||||
fontRendererObj.drawString(text, sx - fontRendererObj.getStringWidth(text) / 2, sy - fontRendererObj.FONT_HEIGHT / 2, color);
|
||||
}
|
||||
|
||||
public void drawStringWithShadow(String text, int sx, int sy, int color) {
|
||||
fontRendererObj.drawStringWithShadow(text, sx, sy, color);
|
||||
}
|
||||
|
||||
public void drawCenteredStringWithShadow(String text, int sx, int sy, int color) {
|
||||
fontRendererObj.drawStringWithShadow(text, sx - fontRendererObj.getStringWidth(text) / 2, sy - fontRendererObj.FONT_HEIGHT / 2, color);
|
||||
}
|
||||
|
||||
public FontRenderer fontRendererObj() {
|
||||
return this.fontRendererObj;
|
||||
}
|
||||
|
||||
protected void drawRect(int gx, int gy, int gw, int gh, int c1, int c2) {
|
||||
drawGradientRect(gx, gy, gx + gw, gy + gh, c1, c2);
|
||||
}
|
||||
|
||||
public void drawTiledRect(int rx, int ry, int rw, int rh, int u, int v, int tw, int th) {
|
||||
if(rw==0 || rh==0 || tw==0 || th==0) return;
|
||||
|
||||
float pixel = 0.00390625f;
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
|
||||
for (int y = 0; y < rh; y += th) {
|
||||
for (int x = 0; x < rw; x += tw) {
|
||||
int qw = tw;
|
||||
|
||||
if (x + qw > rw) {
|
||||
qw = rw - x;
|
||||
}
|
||||
|
||||
int qh = th;
|
||||
|
||||
if (y + qh > rh) {
|
||||
qh = rh - y;
|
||||
}
|
||||
|
||||
double x1 = rx + x;
|
||||
double x2 = rx + x + qw;
|
||||
double y1 = ry + y;
|
||||
double y2 = ry + y + qh;
|
||||
double u1 = pixel * (u);
|
||||
double u2 = pixel * (u + tw);
|
||||
double v1 = pixel * (v);
|
||||
double v2 = pixel * (v + th);
|
||||
tessellator.addVertexWithUV(x1, y2, this.zLevel, u1, v2);
|
||||
tessellator.addVertexWithUV(x2, y2, this.zLevel, u2, v2);
|
||||
tessellator.addVertexWithUV(x2, y1, this.zLevel, u2, v1);
|
||||
tessellator.addVertexWithUV(x1, y1, this.zLevel, u1, v1);
|
||||
}
|
||||
}
|
||||
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
public void bindTexture(String tex) {
|
||||
GeneralClient.bind(tex);
|
||||
}
|
||||
|
||||
public void playSound(String sound, float volume, float pitch) {
|
||||
// TODO
|
||||
//mc.getSoundHandler().playSoundFX(null, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package info.jbcs.minecraft.gui;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class GuilScrolledBox extends GuiElement {
|
||||
public int offset=0;
|
||||
int contentHeight=0;
|
||||
int scrollingStart=-1;
|
||||
|
||||
public GuilScrolledBox(int x, int y, int w, int h) {
|
||||
super(x, y, w, h);
|
||||
}
|
||||
|
||||
int x0,x1;
|
||||
|
||||
protected void overlayBackground(int start, int end, int color, int a1, int a2){
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
float f = 32.0F;
|
||||
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setColorRGBA_I(color, a2);
|
||||
tessellator.addVertexWithUV(x0, end, 0.0D, 0.0D, end / f);
|
||||
tessellator.addVertexWithUV(x1, end, 0.0D, gui.width / f, end / f);
|
||||
tessellator.setColorRGBA_I(color, a1);
|
||||
tessellator.addVertexWithUV(x1, start, 0.0D, gui.width / f, start / f);
|
||||
tessellator.addVertexWithUV(x0, start, 0.0D, 0.0D, start / f);
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public GuiElement addChild(GuiElement e) {
|
||||
int childBottom=e.y+e.h-18;
|
||||
if(childBottom>contentHeight)
|
||||
contentHeight=childBottom;
|
||||
|
||||
return super.addChild(e);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void render() {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(Gui.optionsBackground);
|
||||
x0=-gui.screenX; x1=-gui.screenX+gui.width;
|
||||
|
||||
overlayBackground(y, h, 0x202020, 0xff, 0xff);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(0.0f,offset,0.0f);
|
||||
super.render();
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glShadeModel(GL11.GL_SMOOTH);
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
overlayBackground(y, y+8, 0x000000, 0xff, 0x00);
|
||||
overlayBackground(h-8, h, 0x000000, 0x00, 0xff);
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glShadeModel(GL11.GL_FLAT);
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(Gui.optionsBackground);
|
||||
overlayBackground(-gui.screenY, y, 0x404040, 0xff, 0xff);
|
||||
overlayBackground(h, -gui.screenY+gui.height, 0x404040, 0xff, 0xff);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseMove(InputMouseEvent ev) {
|
||||
if(scrollingStart!=-1){
|
||||
offset=ev.y-scrollingStart;
|
||||
if(offset>contentHeight) offset=contentHeight;
|
||||
if(offset<-contentHeight) offset=-contentHeight;
|
||||
}
|
||||
|
||||
ev.y-=offset;
|
||||
super.mouseMove(ev);
|
||||
ev.y+=offset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseDown(InputMouseEvent ev) {
|
||||
scrollingStart=ev.y-offset;
|
||||
|
||||
if(ev.y>=y && ev.y<y+h){
|
||||
ev.y-=offset;
|
||||
super.mouseDown(ev);
|
||||
ev.y+=offset;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseUp(InputMouseEvent ev) {
|
||||
scrollingStart=-1;
|
||||
|
||||
if(ev.y>=y && ev.y<y+h){
|
||||
ev.y-=offset;
|
||||
super.mouseUp(ev);
|
||||
ev.y+=offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package info.jbcs.minecraft.gui;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IPickBlockHandler {
|
||||
void blockPicked(ItemStack stack);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package info.jbcs.minecraft.gui;
|
||||
|
||||
public class InputEvent {
|
||||
public boolean handled;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package info.jbcs.minecraft.gui;
|
||||
|
||||
public class InputKeyboardEvent extends InputEvent {
|
||||
public int key;
|
||||
public char character;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package info.jbcs.minecraft.gui;
|
||||
|
||||
public class InputMouseEvent extends InputEvent {
|
||||
public int x;
|
||||
public int y;
|
||||
public int dx;
|
||||
public int dy;
|
||||
public int wheel;
|
||||
public int button;
|
||||
public boolean down;
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package info.jbcs.minecraft.gui;
|
||||
|
||||
import info.jbcs.minecraft.utilities.GeneralClient;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
public abstract class Scrollbar extends GuiButton {
|
||||
public boolean active;
|
||||
|
||||
public float offset;
|
||||
public float step;
|
||||
|
||||
boolean dragged;
|
||||
|
||||
int elementHeight = 15;
|
||||
|
||||
public Scrollbar(int id, int x, int y, int w, int h, String string) {
|
||||
super(id, x, y, w, h, string);
|
||||
offset = 0;
|
||||
step = 0.025f;
|
||||
height = h;
|
||||
active = true;
|
||||
dragged = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the mouse has been pressed on this control. Equivalent of
|
||||
* MouseListener.mousePressed(MouseEvent e).
|
||||
*/
|
||||
@Override
|
||||
public boolean mousePressed(Minecraft mc, int x, int y) {
|
||||
if (x < xPosition || x >= xPosition + width) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (y < yPosition || y >= yPosition + height) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (active) {
|
||||
dragged = true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws this button to the screen.
|
||||
*/
|
||||
@Override
|
||||
public void drawButton(Minecraft mc, int x, int y) {
|
||||
if (dragged) {
|
||||
float initialOffset = offset;
|
||||
int off = y - yPosition - elementHeight / 2;
|
||||
offset = 1.0f * off / (height - elementHeight);
|
||||
|
||||
if (offset < 0) {
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
if (offset > 1) {
|
||||
offset = 1;
|
||||
}
|
||||
|
||||
if (initialOffset != offset) {
|
||||
onScrolled(offset);
|
||||
}
|
||||
}
|
||||
|
||||
int bottom = yPosition + height;
|
||||
GeneralClient.bind("/gui/allitems.png");
|
||||
drawTexturedModalRect(xPosition, yPosition + (int) ((height - elementHeight) * offset), active ? 232 : 244, 0, 12, elementHeight);
|
||||
}
|
||||
|
||||
public void handleMouseInput() {
|
||||
if (Mouse.getEventButton() == 0 && !Mouse.getEventButtonState()) {
|
||||
dragged = false;
|
||||
}
|
||||
|
||||
if (!active) {
|
||||
return;
|
||||
}
|
||||
|
||||
float initialOffset = offset;
|
||||
int direction = Mouse.getEventDWheel();
|
||||
|
||||
if (direction != 0) {
|
||||
offset += direction > 0 ? -step : step;
|
||||
}
|
||||
|
||||
if (offset < 0) {
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
if (offset > 1) {
|
||||
offset = 1;
|
||||
}
|
||||
|
||||
if (initialOffset != offset) {
|
||||
onScrolled(offset);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void onScrolled(float off);
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package info.jbcs.minecraft.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class SlotPickBlock extends Slot
|
||||
{
|
||||
ContainerPickBlock container;
|
||||
|
||||
public SlotPickBlock(ContainerPickBlock c, int index, int x, int y)
|
||||
{
|
||||
super(c.inventory, index, x, y);
|
||||
container = c;
|
||||
}
|
||||
|
||||
void click(EntityPlayer player, ItemStack itemstack, int count)
|
||||
{
|
||||
player.inventory.setItemStack(null);
|
||||
|
||||
if (itemstack == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (container.gui == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
putStack(new ItemStack(itemstack.getItem(), itemstack.stackSize, itemstack.getItemDamage()));
|
||||
int newSize;
|
||||
|
||||
if (container.resultSlot == this)
|
||||
{
|
||||
newSize = itemstack.stackSize - count;
|
||||
}
|
||||
else
|
||||
{
|
||||
newSize = itemstack.stackSize;
|
||||
ItemStack otherstack = container.resultSlot.getStack();
|
||||
|
||||
if (otherstack != null && otherstack.getItem().equals(itemstack.getItem()) && otherstack.getItemDamage() == itemstack.getItemDamage())
|
||||
{
|
||||
newSize = otherstack.stackSize + count;
|
||||
}
|
||||
else
|
||||
{
|
||||
newSize = count;
|
||||
}
|
||||
}
|
||||
|
||||
if (newSize > 64)
|
||||
{
|
||||
newSize = 64;
|
||||
}
|
||||
|
||||
container.resultSlot.putStack(newSize <= 0 ? null : new ItemStack(itemstack.getItem(), newSize, itemstack.getItemDamage()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickupFromSlot(EntityPlayer player, ItemStack itemstack)
|
||||
{
|
||||
super.onPickupFromSlot(player, itemstack);
|
||||
click(player, itemstack, 1);
|
||||
}
|
||||
|
||||
public ItemStack transferStackInSlot(EntityPlayer player)
|
||||
{
|
||||
click(player, getStack(), 64);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package info.jbcs.minecraft.gui;
|
||||
|
||||
public class TexturedBox {
|
||||
String texture;
|
||||
int u, v, texw, texh;
|
||||
int borderTop, borderRight, borderBottom, borderLeft;
|
||||
|
||||
public TexturedBox(String texture, int u, int v, int texw, int texh, int borderTop, int borderRight, int borderBottom, int borderLeft) {
|
||||
this.texture = texture;
|
||||
this.u = u;
|
||||
this.v = v;
|
||||
this.texw = texw;
|
||||
this.texh = texh;
|
||||
this.borderTop = borderTop;
|
||||
this.borderRight = borderRight;
|
||||
this.borderBottom = borderBottom;
|
||||
this.borderLeft = borderLeft;
|
||||
}
|
||||
|
||||
public void render(GuiScreenPlus gui, int x, int y, int w, int h) {
|
||||
int x1 = x;
|
||||
int x2 = x + borderLeft;
|
||||
int x3 = x + w - borderRight;
|
||||
int y1 = y;
|
||||
int y2 = y + borderTop;
|
||||
int y3 = y + h - borderBottom;
|
||||
int w1 = borderLeft;
|
||||
int w2 = w - borderLeft - borderRight;
|
||||
int w3 = borderRight;
|
||||
int h1 = borderTop;
|
||||
int h2 = h - borderTop - borderBottom;
|
||||
int h3 = borderBottom;
|
||||
int u1 = u;
|
||||
int v1 = v;
|
||||
int tw = texw;
|
||||
|
||||
if (tw > w) {
|
||||
tw = w;
|
||||
}
|
||||
|
||||
int th = texh;
|
||||
|
||||
if (th > h) {
|
||||
th = h;
|
||||
}
|
||||
|
||||
int u2 = u1 + borderLeft;
|
||||
int u3 = u1 + texw - borderRight;
|
||||
int v2 = v1 + borderTop;
|
||||
int v3 = v1 + texh - borderBottom;
|
||||
int texw1 = borderLeft;
|
||||
int texw2 = tw - borderLeft - borderRight;
|
||||
int texw3 = borderRight;
|
||||
int texh1 = borderTop;
|
||||
int texh2 = th - borderTop - borderBottom;
|
||||
int texh3 = borderBottom;
|
||||
gui.bindTexture(texture);
|
||||
gui.drawTexturedModalRect(x1, y1, u1, v1, w1, h1);
|
||||
gui.drawTiledRect(x2, y1, w2, h1, u2, v1, texw2, texh1);
|
||||
gui.drawTexturedModalRect(x3, y1, u3, v1, w3, h1);
|
||||
gui.drawTiledRect(x1, y2, w1, h2, u1, v2, w1, texh2);
|
||||
gui.drawTiledRect(x2, y2, w2, h2, u2, v2, texw2, texh2);
|
||||
gui.drawTiledRect(x3, y2, w3, h2, u3, v2, w3, texh2);
|
||||
gui.drawTexturedModalRect(x1, y3, u1, v3, w1, h3);
|
||||
gui.drawTiledRect(x2, y3, w2, h3, u2, v3, texw2, texh3);
|
||||
gui.drawTexturedModalRect(x3, y3, u3, v3, w3, h3);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package info.jbcs.minecraft.utilities;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
public class BlockTexturedOre extends Block {
|
||||
int currentPass;
|
||||
Block base;
|
||||
IIcon icon;
|
||||
String iconFile;
|
||||
|
||||
public BlockTexturedOre(Material mat, Block base) {
|
||||
super(mat);
|
||||
|
||||
this.base = base;
|
||||
}
|
||||
|
||||
public BlockTexturedOre(Material mat, String iconFile) {
|
||||
super(mat);
|
||||
|
||||
this.iconFile=iconFile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return BlockTexturedOreRenderer.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderBlockPass() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRenderInPass(int pass) {
|
||||
currentPass = pass;
|
||||
|
||||
return pass == 1 || pass == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister register) {
|
||||
if(iconFile!=null)
|
||||
icon=register.registerIcon(iconFile);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package info.jbcs.minecraft.utilities;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class BlockTexturedOreRenderer implements ISimpleBlockRenderingHandler {
|
||||
float bot=-0.001f,top=1.0f-bot;
|
||||
static int id;
|
||||
|
||||
public BlockTexturedOreRenderer() {
|
||||
id = RenderingRegistry.getNextAvailableRenderId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block blck, int meta, int modelID, RenderBlocks renderer) {
|
||||
if (blck == null || !(blck instanceof BlockTexturedOre))
|
||||
return;
|
||||
|
||||
BlockTexturedOre block=(BlockTexturedOre) blck;
|
||||
|
||||
if(block.icon!=null){
|
||||
renderer.overrideBlockTexture=block.icon;
|
||||
renderer.renderBlockAsItem(Blocks.stone,meta,1.0f);
|
||||
renderer.overrideBlockTexture=null;
|
||||
} else if(block.base!=null){
|
||||
renderer.renderBlockAsItem(block.base,meta,1.0f);
|
||||
}
|
||||
|
||||
GL11.glEnable(3042);
|
||||
GL11.glBlendFunc(770, 771);
|
||||
renderer.setRenderBounds(bot, bot, bot, top, top, top);
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
Drawing.drawBlock(block, meta, renderer);
|
||||
GL11.glDisable(3042);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block blck, int modelId, RenderBlocks renderer) {
|
||||
if (blck == null || !(blck instanceof BlockTexturedOre))
|
||||
return false;
|
||||
BlockTexturedOre block=(BlockTexturedOre) blck;
|
||||
|
||||
if(block.currentPass==0){
|
||||
if(block.icon!=null){
|
||||
renderer.overrideBlockTexture=block.icon;
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.overrideBlockTexture=null;
|
||||
} else if(block.base!=null){
|
||||
renderer.renderBlockByRenderType(block.base, x, y, z);
|
||||
}
|
||||
} else{
|
||||
renderer.setRenderBounds(bot, bot, bot, top, top, top);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int modelId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package info.jbcs.minecraft.utilities;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class ContainerTileEntity<T extends TileEntity & IInventory> extends Container {
|
||||
public final IInventory playerInventory;
|
||||
public final T entity;
|
||||
public int playerSlotsCount;
|
||||
|
||||
public ContainerTileEntity(IInventory playerInv, T tileEntity,int startX,int startY) {
|
||||
playerInventory = playerInv;
|
||||
entity = tileEntity;
|
||||
|
||||
for (int k = 0; k < 3; k++) {
|
||||
for (int j1 = 0; j1 < 9; j1++) {
|
||||
addSlotToContainer(new Slot(playerInv, j1 + k * 9 + 9, startX + j1 * 18, startY + k * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (int l = 0; l < 9; l++) {
|
||||
addSlotToContainer(new Slot(playerInv, l, startX + l * 18, startY + 142-84));
|
||||
}
|
||||
|
||||
playerSlotsCount=inventorySlots.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer entityplayer) {
|
||||
return entity.isUseableByPlayer(entityplayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer entityplayer, int i) {
|
||||
ItemStack itemstack = null;
|
||||
Slot slot = (Slot) this.inventorySlots.get(i);
|
||||
|
||||
if (slot != null && slot.getHasStack()) {
|
||||
ItemStack itemstack1 = slot.getStack();
|
||||
itemstack = itemstack1.copy();
|
||||
|
||||
if (i < playerSlotsCount) {
|
||||
if (!mergeItemStack(itemstack1, playerSlotsCount, inventorySlots.size(), true)) {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
if (!mergeItemStack(itemstack1, 0, playerSlotsCount, false)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (itemstack1.stackSize == 0) {
|
||||
slot.putStack(null);
|
||||
} else {
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package info.jbcs.minecraft.utilities;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
public class Drawing {
|
||||
public static void drawBlock(Block block,IIcon icon, RenderBlocks renderer){
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, -1.0F, 0.0F);
|
||||
renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, icon);
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 1.0F, 0.0F);
|
||||
renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, icon);
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, -1.0F);
|
||||
renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, icon);
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, 1.0F);
|
||||
renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, icon);
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(-1.0F, 0.0F, 0.0F);
|
||||
renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, icon);
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(1.0F, 0.0F, 0.0F);
|
||||
renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, icon);
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
public static void drawBlock(Block block,int meta, RenderBlocks renderer){
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, -1.0F, 0.0F);
|
||||
renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 1.0F, 0.0F);
|
||||
renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(1, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, -1.0F);
|
||||
renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(2, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, 1.0F);
|
||||
renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(3, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(-1.0F, 0.0F, 0.0F);
|
||||
renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(4, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(1.0F, 0.0F, 0.0F);
|
||||
renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(5, meta));
|
||||
tessellator.draw();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package info.jbcs.minecraft.utilities;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
public class DummyContainer extends Container {
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer entityplayer) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package info.jbcs.minecraft.utilities;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class General {
|
||||
public static Random rand = new Random();
|
||||
|
||||
public static void propelTowards(Entity what, Entity whereTo, double force) {
|
||||
double dx = whereTo.posX - what.posX;
|
||||
double dy = whereTo.posY - what.posY;
|
||||
double dz = whereTo.posZ - what.posZ;
|
||||
double total = Math.sqrt(dx * dx + dy * dy + dz * dz);
|
||||
|
||||
if (total == 0) {
|
||||
what.motionX = 0;
|
||||
what.motionY = 0;
|
||||
what.motionZ = 0;
|
||||
} else {
|
||||
what.motionX = dx / total * force;
|
||||
what.motionY = dy / total * force;
|
||||
what.motionZ = dz / total * force;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isInRange(double distance, double x1, double y1, double z1, double x2, double y2, double z2) {
|
||||
double x = x1 - x2;
|
||||
double y = y1 - y2;
|
||||
double z = z1 - z2;
|
||||
|
||||
return x * x + y * y + z * z < distance * distance;
|
||||
}
|
||||
|
||||
public static Item getItem(ItemStack stack) {
|
||||
if (stack == null)
|
||||
return null;
|
||||
if (stack.getItem() == null)
|
||||
return null;
|
||||
|
||||
return stack.getItem();
|
||||
}
|
||||
|
||||
public static String getUnlocalizedName(Block block) {
|
||||
String name=block.getUnlocalizedName();
|
||||
if(name.startsWith("tile.")) name=name.substring(5);
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
public static String getName(Block block){
|
||||
String res=block.getUnlocalizedName();
|
||||
return res.substring(5);
|
||||
}
|
||||
|
||||
|
||||
public static MovingObjectPosition getMovingObjectPositionFromPlayer(World par1World, EntityPlayer par2EntityPlayer, boolean par3) {
|
||||
float var4 = 1.0F;
|
||||
float var5 = par2EntityPlayer.prevRotationPitch + (par2EntityPlayer.rotationPitch - par2EntityPlayer.prevRotationPitch) * var4;
|
||||
float var6 = par2EntityPlayer.prevRotationYaw + (par2EntityPlayer.rotationYaw - par2EntityPlayer.prevRotationYaw) * var4;
|
||||
double var7 = par2EntityPlayer.prevPosX + (par2EntityPlayer.posX - par2EntityPlayer.prevPosX) * var4;
|
||||
double var9 = par2EntityPlayer.prevPosY + (par2EntityPlayer.posY - par2EntityPlayer.prevPosY) * var4 + 1.62D - par2EntityPlayer.yOffset;
|
||||
double var11 = par2EntityPlayer.prevPosZ + (par2EntityPlayer.posZ - par2EntityPlayer.prevPosZ) * var4;
|
||||
Vec3 var13 = par1World.getWorldVec3Pool().getVecFromPool(var7, var9, var11);
|
||||
float var14 = MathHelper.cos(-var6 * 0.017453292F - (float) Math.PI);
|
||||
float var15 = MathHelper.sin(-var6 * 0.017453292F - (float) Math.PI);
|
||||
float var16 = -MathHelper.cos(-var5 * 0.017453292F);
|
||||
float var17 = MathHelper.sin(-var5 * 0.017453292F);
|
||||
float var18 = var15 * var16;
|
||||
float var20 = var14 * var16;
|
||||
double var21 = 5.0D;
|
||||
|
||||
if (par2EntityPlayer instanceof EntityPlayerMP) {
|
||||
var21 = ((EntityPlayerMP) par2EntityPlayer).theItemInWorldManager.getBlockReachDistance();
|
||||
}
|
||||
|
||||
Vec3 var23 = var13.addVector(var18 * var21, var17 * var21, var20 * var21);
|
||||
return par1World.rayTraceBlocks(var13, var23, par3);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package info.jbcs.minecraft.utilities;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class GeneralClient {
|
||||
public static Random rand = new Random();
|
||||
|
||||
public static void playChiselSound(World world, int x, int y, int z, String sound) {
|
||||
Minecraft.getMinecraft().theWorld.playSound(x + 0.5, y + 0.5, z + 0.5, sound, 0.3f + 0.7f * rand.nextFloat(), 0.6f + 0.4f * rand.nextFloat(), true);
|
||||
}
|
||||
|
||||
|
||||
public static IIcon getMissingIcon() {
|
||||
return ((TextureMap)Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture)).getAtlasSprite("missingno");
|
||||
}
|
||||
|
||||
static HashMap<String,ResourceLocation> resources=new HashMap<String,ResourceLocation>();
|
||||
public static void bind(String textureName) {
|
||||
ResourceLocation res=resources.get(textureName);
|
||||
|
||||
if(res==null){
|
||||
res=new ResourceLocation(textureName);
|
||||
resources.put(textureName,res);
|
||||
}
|
||||
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(res);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package info.jbcs.minecraft.utilities;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
|
||||
public abstract class GuiHandler implements Comparable {
|
||||
static ArrayList<GuiHandler> items = new ArrayList<GuiHandler>();
|
||||
|
||||
int index;
|
||||
Object mod;
|
||||
String name;
|
||||
|
||||
public GuiHandler(String n) {
|
||||
items.add(this);
|
||||
name = n;
|
||||
}
|
||||
|
||||
public void open(EntityPlayer player, World world, int x, int y, int z) {
|
||||
player.openGui(mod, index, world, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Object a) {
|
||||
return name.compareTo(((GuiHandler) a).name);
|
||||
}
|
||||
|
||||
public static void register(Object mod) {
|
||||
Collections.sort(items);
|
||||
int index = 0;
|
||||
|
||||
for (GuiHandler h : items) {
|
||||
h.mod = mod;
|
||||
h.index = index++;
|
||||
}
|
||||
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(mod, new IGuiHandler() {
|
||||
@Override
|
||||
public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
|
||||
if (id < 0 || id >= items.size()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return items.get(id).getServerGuiElement(id, player, world, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
|
||||
if (id < 0 || id >= items.size()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return items.get(id).getClientGuiElement(id, player, world, x, y, z);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public abstract Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z);
|
||||
|
||||
public abstract Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z);
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package info.jbcs.minecraft.utilities;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Hashtable;
|
||||
|
||||
public class Infodata {
|
||||
public String name;
|
||||
|
||||
public Hashtable<String, String> fields = new Hashtable<String, String>();
|
||||
public String[] lines;
|
||||
|
||||
public Infodata(String n) {
|
||||
name = n;
|
||||
}
|
||||
|
||||
public Infodata(String n,int lineCount) {
|
||||
name = n;
|
||||
lines = new String[lineCount];
|
||||
}
|
||||
|
||||
public String field(String key,String dflt) {
|
||||
String n = key.toLowerCase();
|
||||
|
||||
if (fields.containsKey(n)) return fields.get(n);
|
||||
|
||||
return dflt;
|
||||
}
|
||||
|
||||
public String field(String key) {
|
||||
return field(key, null);
|
||||
}
|
||||
|
||||
public int value(String key) {
|
||||
return Integer.parseInt(field(key, null));
|
||||
}
|
||||
|
||||
public void set(String key,String value) {
|
||||
fields.put(key.length() == 1 ? key : key.toLowerCase(), value);
|
||||
}
|
||||
|
||||
public void set(String key,int value) {
|
||||
fields.put(key.length() == 1 ? key : key.toLowerCase(), "" + value);
|
||||
}
|
||||
|
||||
public void write(Writer writer,int linebreakEvery) throws IOException {
|
||||
writer.write(name + " {\n");
|
||||
|
||||
Enumeration<String> keys = fields.keys();
|
||||
while (keys.hasMoreElements()) {
|
||||
String key = keys.nextElement();
|
||||
if (key.length() == 1) continue;
|
||||
|
||||
writer.write("\t" + key + " = " + fields.get(key) + "\n");
|
||||
}
|
||||
|
||||
writer.write("\n");
|
||||
int linesWritten = 0;
|
||||
for (int i = 0; i < lines.length; i++) {
|
||||
writer.write("\t" + lines[i] + "\n");
|
||||
linesWritten++;
|
||||
if (linebreakEvery != 0 && linesWritten % linebreakEvery == 0) writer.write("\n");
|
||||
}
|
||||
writer.write("\n");
|
||||
|
||||
keys = fields.keys();
|
||||
while (keys.hasMoreElements()) {
|
||||
String key = keys.nextElement();
|
||||
if (key.length() != 1) continue;
|
||||
|
||||
writer.write("\t" + key + " = " + fields.get(key) + "\n");
|
||||
}
|
||||
writer.write("}");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package info.jbcs.minecraft.utilities;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Infofile {
|
||||
static String[] stringArray=new String[0];
|
||||
public ArrayList<Infodata> data=new ArrayList<Infodata>();
|
||||
|
||||
public Infofile(File file) throws IOException {
|
||||
LineReader reader = new LineReader(file);
|
||||
String line;
|
||||
|
||||
Infodata d=null;
|
||||
ArrayList<String> lines=new ArrayList<String>();
|
||||
|
||||
int state = 0;
|
||||
|
||||
try{
|
||||
while ((line = reader.readLine()) != null) {
|
||||
if((line=line.trim()).isEmpty()) continue;
|
||||
|
||||
switch (state) {
|
||||
case 0:
|
||||
if (line.charAt(line.length() - 1) != '{') {
|
||||
reader.die("unexpected: \""+line+"\" (expecting name and opening bracket)");
|
||||
}
|
||||
|
||||
|
||||
line=line.substring(0,line.length()-1).trim();
|
||||
state=1;
|
||||
|
||||
d=new Infodata(line);
|
||||
|
||||
lines.clear();
|
||||
break;
|
||||
|
||||
case 1:
|
||||
if (line.equals("}")) {
|
||||
state=0;
|
||||
|
||||
d.lines=lines.toArray(stringArray);
|
||||
data.add(d);
|
||||
continue;
|
||||
}
|
||||
|
||||
int index=line.indexOf('=');
|
||||
if(index!=-1){
|
||||
String key=line.substring(0, index).trim().toLowerCase();
|
||||
String val=line.substring(index+1,line.length()).trim();
|
||||
|
||||
d.fields.put(key,val);
|
||||
} else{
|
||||
lines.add(line);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} finally{
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,319 @@
|
||||
package info.jbcs.minecraft.utilities;
|
||||
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public abstract class InventoryStatic implements IInventory {
|
||||
public final ItemStack items[];
|
||||
|
||||
public InventoryStatic(int size) {
|
||||
items = new ItemStack[size];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer entityplayer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void onInventoryChanged(int slot) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return items.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int i) {
|
||||
return items[i];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int i, int j) {
|
||||
if (items[i] != null) {
|
||||
if (items[i].stackSize <= j) {
|
||||
ItemStack itemstack = items[i];
|
||||
items[i] = null;
|
||||
onInventoryChanged();
|
||||
onInventoryChanged(i);
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
ItemStack itemstack1 = items[i].splitStack(j);
|
||||
|
||||
if (items[i].stackSize == 0) {
|
||||
items[i] = null;
|
||||
}
|
||||
|
||||
onInventoryChanged();
|
||||
onInventoryChanged(i);
|
||||
return itemstack1;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int i, ItemStack itemstack) {
|
||||
items[i] = itemstack;
|
||||
|
||||
if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) {
|
||||
itemstack.stackSize = getInventoryStackLimit();
|
||||
}
|
||||
|
||||
onInventoryChanged();
|
||||
onInventoryChanged(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 64;
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
NBTTagList nbttaglist = nbttagcompound.getTagList("Items", 10);
|
||||
|
||||
for (int i = 0; i < nbttaglist.tagCount(); i++) {
|
||||
NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.getCompoundTagAt(i);
|
||||
int j = nbttagcompound1.getByte("slot") & 0xff;
|
||||
|
||||
if (j >= 0 && j < items.length) {
|
||||
items[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
|
||||
}
|
||||
}
|
||||
|
||||
onInventoryChanged();
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
if (items[i] == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
||||
nbttagcompound1.setByte("slot", (byte) i);
|
||||
items[i].writeToNBT(nbttagcompound1);
|
||||
nbttaglist.appendTag(nbttagcompound1);
|
||||
}
|
||||
|
||||
nbttagcompound.setTag("items", nbttaglist);
|
||||
}
|
||||
|
||||
private int getFirstEmptyStack(int start, int end) {
|
||||
for (int i = start; i <= end; i++) {
|
||||
if (items[i] == null) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
private int storeItemStack(ItemStack itemstack, int start, int end) {
|
||||
for (int i = start; i <= end; i++) {
|
||||
if (items[i] != null && items[i].getItem().equals(itemstack.getItem() )&& items[i].isStackable() && items[i].stackSize < items[i].getMaxStackSize() && items[i].stackSize < getInventoryStackLimit() && (!items[i].getHasSubtypes() || items[i].getItemDamage() == itemstack.getItemDamage())) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
private int storePartialItemStack(ItemStack itemstack, int start, int end) {
|
||||
Item i = itemstack.getItem();
|
||||
int j = itemstack.stackSize;
|
||||
int k = storeItemStack(itemstack, start, end);
|
||||
|
||||
if (k < 0) {
|
||||
k = getFirstEmptyStack(start, end);
|
||||
}
|
||||
|
||||
if (k < 0) {
|
||||
return j;
|
||||
}
|
||||
|
||||
if (items[k] == null) {
|
||||
items[k] = new ItemStack(i, 0, itemstack.getItemDamage());
|
||||
}
|
||||
|
||||
int l = j;
|
||||
|
||||
if (l > items[k].getMaxStackSize() - items[k].stackSize) {
|
||||
l = items[k].getMaxStackSize() - items[k].stackSize;
|
||||
}
|
||||
|
||||
if (l > getInventoryStackLimit() - items[k].stackSize) {
|
||||
l = getInventoryStackLimit() - items[k].stackSize;
|
||||
}
|
||||
|
||||
if (l == 0) {
|
||||
return j;
|
||||
} else {
|
||||
j -= l;
|
||||
items[k].stackSize += l;
|
||||
items[k].animationsToGo = 5;
|
||||
onInventoryChanged();
|
||||
onInventoryChanged(k);
|
||||
return j;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean addItemStackToInventory(ItemStack itemstack, int start, int end) {
|
||||
if (itemstack == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!itemstack.isItemDamaged()) {
|
||||
int i;
|
||||
|
||||
do {
|
||||
i = itemstack.stackSize;
|
||||
itemstack.stackSize = storePartialItemStack(itemstack, start, end);
|
||||
} while (itemstack.stackSize > 0 && itemstack.stackSize < i);
|
||||
|
||||
return itemstack.stackSize < i;
|
||||
}
|
||||
|
||||
int j = getFirstEmptyStack(start, end);
|
||||
|
||||
if (j >= 0) {
|
||||
items[j] = ItemStack.copyItemStack(itemstack);
|
||||
items[j].animationsToGo = 5;
|
||||
itemstack.stackSize = 0;
|
||||
onInventoryChanged();
|
||||
onInventoryChanged(j);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean addItemStackToInventory(ItemStack itemstack) {
|
||||
return addItemStackToInventory(itemstack, 0, items.length - 1);
|
||||
}
|
||||
|
||||
public ItemStack takeItems(Item item, int damage, int count) {
|
||||
ItemStack res = null;
|
||||
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
if (items[i] == null || !items[i].getItem().equals(item) || items[i].getItemDamage() != damage) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (res == null) {
|
||||
res = new ItemStack(item, 0, damage);
|
||||
}
|
||||
|
||||
while (items[i] != null && res.stackSize < count && items[i].stackSize > 0) {
|
||||
res.stackSize++;
|
||||
items[i].stackSize--;
|
||||
|
||||
if (items[i].stackSize == 0) {
|
||||
items[i] = null;
|
||||
}
|
||||
|
||||
onInventoryChanged(i);
|
||||
}
|
||||
|
||||
if (res.stackSize >= count) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
onInventoryChanged();
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int i) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void onInventoryChanged() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemstack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
if (items[i] != null && items[i].getItem() != null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
items[i] = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void throwItems(World world, int x, int y, int z){
|
||||
if(world.isRemote) return;
|
||||
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
ItemStack itemstack = items[i];
|
||||
if (itemstack == null) continue;
|
||||
|
||||
items[i]=null;
|
||||
|
||||
float xx = world.rand.nextFloat() * 0.8F + 0.1F;
|
||||
float yy = world.rand.nextFloat() * 0.8F + 0.1F;
|
||||
float zz = world.rand.nextFloat() * 0.8F + 0.1F;
|
||||
while (itemstack.stackSize > 0) {
|
||||
int c = world.rand.nextInt(21) + 10;
|
||||
if (c > itemstack.stackSize) {
|
||||
c = itemstack.stackSize;
|
||||
}
|
||||
|
||||
itemstack.stackSize -= c;
|
||||
EntityItem entityitem = new EntityItem(world, x + xx, y + yy, z + zz, new ItemStack(itemstack.getItem(), c, itemstack.getItemDamage()));
|
||||
float f3 = 0.05F;
|
||||
entityitem.motionX = (float) world.rand.nextGaussian() * f3;
|
||||
entityitem.motionY = (float) world.rand.nextGaussian() * f3 + 0.2F;
|
||||
entityitem.motionZ = (float) world.rand.nextGaussian() * f3;
|
||||
world.spawnEntityInWorld(entityitem);
|
||||
}
|
||||
}
|
||||
|
||||
onInventoryChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
Loaded 100 of 1389 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user