Skip to content

Render campfire items #1704

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 43 additions & 36 deletions chunky/src/java/se/llbit/chunky/block/minecraft/Campfire.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,51 +25,58 @@
import se.llbit.math.Ray;
import se.llbit.math.Vector3;
import se.llbit.nbt.CompoundTag;
import se.llbit.nbt.ListTag;

import java.util.Random;

public class Campfire extends MinecraftBlockTranslucent {
private final se.llbit.chunky.entity.Campfire.Kind kind;
private final String facing;
public final boolean isLit;
private final se.llbit.chunky.entity.Campfire.Kind kind;
private final String facing;
public final boolean isLit;

public Campfire(String name, se.llbit.chunky.entity.Campfire.Kind kind, String facing, boolean lit) {
super(name, Texture.campfireLog);
invisible = true;
opaque = false;
localIntersect = true;
this.kind = kind;
this.facing = facing;
this.isLit = lit;
}
public Campfire(String name, se.llbit.chunky.entity.Campfire.Kind kind, String facing, boolean lit) {
super(name, Texture.campfireLog);
invisible = true;
opaque = false;
localIntersect = true;
this.kind = kind;
this.facing = facing;
this.isLit = lit;
}

@Override
public boolean intersect(Ray ray, Scene scene) {
return false;
}
@Override
public boolean intersect(Ray ray, Scene scene) {
return false;
}

@Override
public boolean isBlockEntity() {
return true;
}
@Override
public boolean isBlockEntity() {
return true;
}

@Override
public Entity toBlockEntity(Vector3 position, CompoundTag entityTag) {
return new se.llbit.chunky.entity.Campfire(this.kind, position, this.facing, this.isLit, this);
}
@Override
public Entity toBlockEntity(Vector3 position, CompoundTag entityTag) {
ListTag items = entityTag.get("Items").asList();
return new se.llbit.chunky.entity.Campfire(this.kind, position, this.facing, this.isLit, this,
!items.isEmpty() ? items.get(0).get("id").stringValue(null) : null,
items.size() >= 2 ? items.get(1).get("id").stringValue(null) : null,
items.size() >= 3 ? items.get(2).get("id").stringValue(null) : null,
items.size() >= 4 ? items.get(3).get("id").stringValue(null) : null
);
}

@Override
public int faceCount() {
return se.llbit.chunky.entity.Campfire.faceCount();
}
@Override
public int faceCount() {
return se.llbit.chunky.entity.Campfire.faceCount();
}

@Override
public void sample(int face, Vector3 loc, Random rand) {
se.llbit.chunky.entity.Campfire.sample(face, loc, rand);
}
@Override
public void sample(int face, Vector3 loc, Random rand) {
se.llbit.chunky.entity.Campfire.sample(face, loc, rand);
}

@Override
public double surfaceArea(int face) {
return se.llbit.chunky.entity.Campfire.surfaceArea(face);
}
@Override
public double surfaceArea(int face) {
return se.llbit.chunky.entity.Campfire.surfaceArea(face);
}
}
Loading