-
-
Save ThexXTURBOXx/55a548d32c1e0994c2285abda4958dbd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package de.Femtopedia.XYCraftRL; | |
import java.util.ArrayList; | |
import java.util.List; | |
import net.minecraft.nbt.*; | |
import net.minecraft.tileentity.TileEntity; | |
import net.minecraft.util.ResourceLocation; | |
public class TileEntityGlow extends TileEntity { | |
public String name_xy; | |
public List<ResourceLocation> layers; | |
public List<Boolean> light; | |
public List<Float> coordX; | |
public List<Float> coordY; | |
public List<Float> maxX; | |
public List<Float> maxY; | |
public TileEntityGlow() { | |
} | |
public TileEntityGlow(String name, List<ResourceLocation> layers, List<Boolean> light, List<Float> coordX, List<Float> coordY, List<Float> maxX, List<Float> maxY) { | |
this.name_xy = name; | |
this.layers = layers; | |
this.light = light; | |
this.coordX = coordX; | |
this.coordY = coordY; | |
this.maxX = maxX; | |
this.maxY = maxY; | |
} | |
@Override | |
public boolean hasFastRenderer() { | |
return false; | |
} | |
@Override | |
public void readFromNBT(NBTTagCompound compound) { | |
super.readFromNBT(compound); | |
if(compound.hasKey("name_xy")) { | |
name_xy = compound.getString("name_xy"); | |
} | |
if(compound.hasKey("layers_id") && compound.hasKey("layers_path")) { | |
List<ResourceLocation> l = new ArrayList<>(); | |
NBTTagList ls = compound.getTagList("layers_id", 8); | |
NBTTagList ls1 = compound.getTagList("layers_path", 8); | |
for(int i = 0; i < ls.tagCount(); i++) { | |
l.add(new ResourceLocation(ls.getStringTagAt(i), ls1.getStringTagAt(i))); | |
} | |
layers = l; | |
} | |
if(compound.hasKey("light_xy")) { | |
List<Boolean> l = new ArrayList<>(); | |
NBTTagList ls = compound.getTagList("light_xy", 8); | |
for(int i = 0; i < ls.tagCount(); i++) { | |
l.add(ls.getIntAt(i) == 1); | |
} | |
light = l; | |
} | |
if(compound.hasKey("coord_x_xy")) { | |
List<Float> l = new ArrayList<>(); | |
NBTTagList ls = compound.getTagList("coord_x_xy", 8); | |
for(int i = 0; i < ls.tagCount(); i++) { | |
l.add(ls.getFloatAt(i)); | |
} | |
coordX = l; | |
} | |
if(compound.hasKey("coord_y_xy")) { | |
List<Float> l = new ArrayList<>(); | |
NBTTagList ls = compound.getTagList("coord_y_xy", 8); | |
for(int i = 0; i < ls.tagCount(); i++) { | |
l.add(ls.getFloatAt(i)); | |
} | |
coordY = l; | |
} | |
if(compound.hasKey("max_x_xy")) { | |
List<Float> l = new ArrayList<>(); | |
NBTTagList ls = compound.getTagList("max_x_xy", 8); | |
for(int i = 0; i < ls.tagCount(); i++) { | |
l.add(ls.getFloatAt(i)); | |
} | |
maxX = l; | |
} | |
if(compound.hasKey("max_y_xy")) { | |
List<Float> l = new ArrayList<>(); | |
NBTTagList ls = compound.getTagList("max_y_xy", 8); | |
for(int i = 0; i < ls.tagCount(); i++) { | |
l.add(ls.getFloatAt(i)); | |
} | |
maxY = l; | |
} | |
} | |
@Override | |
public NBTTagCompound writeToNBT(NBTTagCompound compound) { | |
super.writeToNBT(compound); | |
compound.setString("name_xy", name_xy); | |
NBTTagList l1 = new NBTTagList(); | |
NBTTagList l2 = new NBTTagList(); | |
for(ResourceLocation rs : layers) { | |
l1.appendTag(new NBTTagString(rs.getResourceDomain())); | |
l2.appendTag(new NBTTagString(rs.getResourcePath())); | |
} | |
compound.setTag("layers_id", l1); | |
compound.setTag("layers_path", l2); | |
NBTTagList l3 = new NBTTagList(); | |
for(boolean b : light) { | |
l3.appendTag(new NBTTagInt(b ? 1 : 0)); | |
} | |
compound.setTag("light_xy", l3); | |
NBTTagList l4 = new NBTTagList(); | |
for(float x : coordX) { | |
l4.appendTag(new NBTTagFloat(x)); | |
} | |
compound.setTag("coord_x_xy", l4); | |
NBTTagList l5 = new NBTTagList(); | |
for(float y : coordY) { | |
l5.appendTag(new NBTTagFloat(y)); | |
} | |
compound.setTag("coord_y_xy", l5); | |
NBTTagList l6 = new NBTTagList(); | |
for(float y : maxY) { | |
l6.appendTag(new NBTTagFloat(y)); | |
} | |
compound.setTag("max_y_xy", l6); | |
NBTTagList l7 = new NBTTagList(); | |
for(float x : maxX) { | |
l7.appendTag(new NBTTagFloat(x)); | |
} | |
compound.setTag("max_x_xy", l7); | |
return compound; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment