Permalink
Browse files

Don't make me name this shit... pls

  • Loading branch information...
ArekkuusuJerii committed Jan 13, 2018
1 parent 501843c commit 23265eca73208f070b3e39d60f73465ff249175d
Showing with 147 additions and 228 deletions.
  1. +3 −2 src/main/java/arekkuusu/solar/api/entanglement/IEntangledStack.java
  2. +2 −1 src/main/java/arekkuusu/solar/api/entanglement/quantum/IQuantumStack.java
  3. +51 −11 src/main/java/arekkuusu/solar/api/helper/NBTHelper.java
  4. +0 −3 src/main/java/arekkuusu/solar/client/render/ModRenders.java
  5. +0 −88 src/main/java/arekkuusu/solar/client/render/entity/CustomItemRenderer.java
  6. +0 −28 src/main/java/arekkuusu/solar/client/render/entity/EyeOfSchrodingerRenderer.java
  7. +1 −1 src/main/java/arekkuusu/solar/common/block/BlockVacuumConveyor.java
  8. +9 −8 src/main/java/arekkuusu/solar/common/block/tile/TileQSquared.java
  9. +39 −37 src/main/java/arekkuusu/solar/common/block/tile/TileVacuumConveyor.java
  10. +1 −1 src/main/java/arekkuusu/solar/common/entity/EntityCrystalQuartzItem.java
  11. +12 −11 src/main/java/arekkuusu/solar/common/entity/EntityEyeOfSchrodinger.java
  12. +4 −7 src/main/java/arekkuusu/solar/common/entity/{EntityFastItem.java → EntityStaticItem.java}
  13. +17 −21 src/main/java/arekkuusu/solar/common/entity/{EntitySingularityItem.java → EntityTemporalItem.java}
  14. +2 −2 src/main/java/arekkuusu/solar/common/entity/ModEntities.java
  15. +1 −1 src/main/java/arekkuusu/solar/common/handler/data/QuantumStackProvider.java
  16. +2 −1 src/main/java/arekkuusu/solar/common/item/ItemQimranut.java
  17. +2 −2 src/main/java/arekkuusu/solar/common/item/ItemVacuumConveyor.java
  18. +1 −3 src/main/resources/assets/solar/lang/en_us.lang
@@ -9,6 +9,7 @@
import arekkuusu.solar.api.entanglement.quantum.QuantumHandler;
import arekkuusu.solar.api.helper.NBTHelper;
import arekkuusu.solar.api.helper.NBTHelper.NBTType;
import arekkuusu.solar.client.util.helper.TooltipBuilder;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -36,12 +37,12 @@ default TooltipBuilder getInfo(TooltipBuilder builder, UUID uuid) {
default void setKey(ItemStack stack, UUID uuid) {
Optional<UUID> optional = getKey(stack);
if(!optional.isPresent()) {
NBTHelper.getOrCreate(stack, QuantumHandler.NBT_TAG, NBTTagCompound::new).setUniqueId("key", uuid);
NBTHelper.<NBTTagCompound>getOrCreate(stack, QuantumHandler.NBT_TAG, NBTType.COMPOUND).setUniqueId("key", uuid);
}
}
default Optional<UUID> getKey(ItemStack stack) {
Optional<NBTTagCompound> optional = NBTHelper.getNBT(stack, QuantumHandler.NBT_TAG);
Optional<NBTTagCompound> optional = NBTHelper.getNBTTag(stack, QuantumHandler.NBT_TAG);
return Optional.ofNullable(optional.map(nbtTagCompound -> nbtTagCompound.getUniqueId("key")).orElse(null));
}
}
@@ -17,6 +17,7 @@
import java.util.List;
import java.util.UUID;
import static arekkuusu.solar.client.util.helper.TooltipBuilder.KeyCondition.CONTROL_KEY_DOWN;
import static arekkuusu.solar.client.util.helper.TooltipBuilder.KeyCondition.SHIFT_KEY_DOWN;
/**
@@ -44,6 +45,6 @@ default TooltipBuilder getDetailedInfo(TooltipBuilder builder, List<ItemStack> s
.add(" x " + item.getCount()).end()
);
builder.skip();
return getInfo(builder, uuid);
return builder.condition(CONTROL_KEY_DOWN).ifPresent(b -> getInfo(builder, uuid)).apply();
}
}
@@ -9,14 +9,12 @@
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.*;
import net.minecraft.world.World;
import javax.annotation.Nullable;
import java.util.Optional;
import java.util.UUID;
import java.util.function.Supplier;
/**
* This class was created by Arekkuusu on 02/03/2017.
@@ -91,26 +89,34 @@ public static UUID getUniqueID(ItemStack stack, String tag) {
return base;
}
@SuppressWarnings({"ConstantConditions", "unchecked"})
public static <T extends NBTBase> Optional<T> getNBT(ItemStack stack, String tag) {
return Optional.ofNullable((T) fixNBT(stack).getTag(tag));
public static <T extends NBTBase> Optional<T> getNBT(ItemStack stack, String tag, NBTType type) {
//noinspection unchecked
return hasTag(stack, tag, type) ? Optional.of((T) fixNBT(stack).getTag(tag)) : Optional.empty();
}
public static <T extends NBTBase> T getOrCreate(ItemStack stack, String tag, Supplier<T> supplier) {
return NBTHelper.<T>getNBT(stack, tag).orElseGet(() -> setNBT(stack, tag, supplier.get()));
public static Optional<NBTTagCompound> getNBTTag(ItemStack stack, String tag) {
return hasTag(stack, tag, NBTType.COMPOUND) ? Optional.of(fixNBT(stack).getCompoundTag(tag)) : Optional.empty();
}
public static Optional<NBTTagList> getNBTList(ItemStack stack, String tag) {
return hasTag(stack, tag, NBTType.COMPOUND) ? Optional.of(fixNBT(stack).getTagList(tag, NBTType.LIST.ordinal())) : Optional.empty();
}
public static <T extends NBTBase> T getOrCreate(ItemStack stack, String tag, NBTType type) {
//noinspection unchecked
return NBTHelper.<T>getNBT(stack, tag, type).orElseGet(() -> NBTHelper.setNBT(stack, tag, (T) NBTType.create(type)));
}
public static <T extends Entity> Optional<T> getEntityByUUID(Class<T> clazz, UUID uuid, World world) {
for (Entity entity : world.loadedEntityList) {
if (clazz.isInstance(entity) && entity.getUniqueID().equals(uuid)) return Optional.of(clazz.cast(entity));
}
return Optional.empty();
}
public static boolean hasTag(ItemStack stack, String tag, int type) {
public static boolean hasTag(ItemStack stack, String tag, NBTType type) {
NBTTagCompound tagCompound = stack.getTagCompound();
return tagCompound != null && tagCompound.hasKey(tag, type);
return tagCompound != null && tagCompound.hasKey(tag, type.ordinal());
}
public static boolean hasTag(ItemStack stack, String tag) {
@@ -124,4 +130,38 @@ public static void removeTag(ItemStack stack, String tag) {
tagCompound.removeTag(tag);
}
}
public enum NBTType {
END,
BYTE,
SHORT,
INT,
LONG,
FLOAT,
DOUBLE,
BYTE_ARRAY,
STRING,
LIST,
COMPOUND,
INT_ARRAY,
LONG_ARRAY;
@Nullable
public static NBTBase create(NBTType type) {
switch(type.ordinal()) {
case 0:
return new NBTTagEnd();
case 2:
return new NBTTagShort();
case 8:
return new NBTTagString();
case 9:
return new NBTTagList();
case 10:
return new NBTTagCompound();
default:
return null;
}
}
}
}
@@ -7,12 +7,10 @@
******************************************************************************/
package arekkuusu.solar.client.render;
import arekkuusu.solar.client.render.entity.CustomItemRenderer;
import arekkuusu.solar.client.render.entity.EyeOfSchrodingerRenderer;
import arekkuusu.solar.common.block.ModBlocks;
import arekkuusu.solar.common.block.tile.*;
import arekkuusu.solar.common.entity.EntityEyeOfSchrodinger;
import arekkuusu.solar.common.entity.EntityFastItem;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.entity.Entity;
@@ -33,7 +31,6 @@
public final class ModRenders {
public static void preInit() {
registerEntity(EntityFastItem.class, CustomItemRenderer::new);
registerEntity(EntityEyeOfSchrodinger.class, EyeOfSchrodingerRenderer::new);
}

This file was deleted.

Oops, something went wrong.
@@ -115,34 +115,6 @@ public void doRenderLayer(EntityEyeOfSchrodinger schrodinger, float limbSwing, f
GlStateManager.enableLighting();
GlStateManager.disableBlend();
GlStateManager.enableAlpha();
Entity entity = schrodinger.getTargetedEntity();
if(entity != null) { //FIXME: GLLine cannot be seen?
/*Vector3 from = Vector3.create(schrodinger.posX, schrodinger.posY + 0.25D, schrodinger.posZ);
Vector3 to = Vector3.create(entity.posX, entity.posY + entity.getEyeHeight(), entity.posZ);
//Render laser
GlStateManager.pushMatrix();
GlStateManager.enableAlpha();
GlStateManager.enableBlend();
GlStateManager.alphaFunc(516, 0.003921569F);
GlStateManager.disableCull();
GlStateManager.depthMask(false);
GLHelper.BLEND_SRC_ALPHA$ONE.blend();
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder buff = tessellator.getBuffer();
buff.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR);
buff.pos(from.x, from.y, from.z).color(r, g, b, 1F)
.endVertex();
buff.pos(to.x, to.y, to.z).color(r, g, b, 1F)
.endVertex();
tessellator.draw();
GlStateManager.enableCull();
GlStateManager.depthMask(true);
GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
GlStateManager.disableBlend();
GlStateManager.alphaFunc(516, 0.1F);
GlStateManager.popMatrix();*/
}
}
@Override
@@ -63,7 +63,7 @@ public BlockVacuumConveyor() {
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
if(!world.isRemote) {
getTile(TileVacuumConveyor.class, world, pos).ifPresent(vacuum -> {
NBTHelper.<NBTTagCompound>getNBT(stack, "lookup").ifPresent(tag -> {
NBTHelper.getNBTTag(stack, "lookup").ifPresent(tag -> {
vacuum.setLookup(new ItemStack(tag));
});
});
@@ -7,7 +7,7 @@
******************************************************************************/
package arekkuusu.solar.common.block.tile;
import arekkuusu.solar.common.entity.EntityFastItem;
import arekkuusu.solar.common.entity.EntityTemporalItem;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.nbt.NBTTagCompound;
@@ -36,16 +36,17 @@ public void update() {
private void suspendNearbyItems() {
world.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(getPos()).grow(5), Entity::isEntityAlive)
.stream().filter(entity -> !(entity instanceof EntityFastItem)).forEach(this::replace);
.forEach(this::map);
}
private void replace(EntityItem entity) {
EntityFastItem item = new EntityFastItem(entity);
item.setNoDespawn();
item.setNoGravity(true);
item.setMotionRest(0.85F);
private void map(EntityItem entity) {
if(entity instanceof EntityTemporalItem) {
((EntityTemporalItem) entity).lifeTime = 10;
return;
}
EntityTemporalItem item = new EntityTemporalItem(entity);
item.setMotion(entity.motionX, entity.motionY, entity.motionZ);
item.setMotionRest(0.85F);
world.spawnEntity(item);
entity.setDead();
}
Oops, something went wrong.

0 comments on commit 23265ec

Please sign in to comment.