fix another crash

This commit is contained in:
Meredith Espinosa 2019-07-11 16:13:00 -07:00
parent 3fef940041
commit 4ec0a07e7d
3 changed files with 9 additions and 4 deletions

View File

@ -30,7 +30,7 @@ if(rootProject.file('private.gradle').exists()) { //Publishing details
archivesBaseName = "templates" archivesBaseName = "templates"
group = "io.github.cottonmc" group = "io.github.cottonmc"
version = "1.0.4+1.14.3" version = "1.0.5+1.14.3"
minecraft { minecraft {
refmapName = 'mixins.templates.refmap.json' refmapName = 'mixins.templates.refmap.json'

View File

@ -42,7 +42,7 @@ public abstract class TemplateBlock extends Block implements BlockEntityProvider
} }
ItemPlacementContext ctx = new ItemPlacementContext(new ItemUsageContext(player, hand, hit)); ItemPlacementContext ctx = new ItemPlacementContext(new ItemUsageContext(player, hand, hit));
BlockState placementState = block.getPlacementState(ctx); BlockState placementState = block.getPlacementState(ctx);
if (state.isSimpleFullBlock(world, pos) && !(block instanceof BlockEntityProvider)) { if (Block.isShapeFullCube(state.getCollisionShape(world, pos)) && !(block instanceof BlockEntityProvider)) {
if (be.getRenderedState().getBlock() == Blocks.AIR) { if (be.getRenderedState().getBlock() == Blocks.AIR) {
be.setRenderedState(placementState); be.setRenderedState(placementState);
if (!player.abilities.creativeMode) stack.decrement(1); if (!player.abilities.creativeMode) stack.decrement(1);

View File

@ -3,6 +3,7 @@ package io.github.cottonmc.templates.util;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import net.minecraft.client.texture.MissingSprite;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
@ -17,7 +18,8 @@ import net.minecraft.util.math.Direction;
public class SpriteSet { public class SpriteSet {
private Object2ObjectOpenHashMap<Direction, BakedQuad> quads = new Object2ObjectOpenHashMap<>(); private Object2ObjectOpenHashMap<Direction, BakedQuad> quads = new Object2ObjectOpenHashMap<>();
private boolean isDefault = true; private boolean isDefault = true;
public static final Sprite FALLBACK = MinecraftClient.getInstance().getSpriteAtlas().getSprite(new Identifier("minecraft:block/scaffolding_top")); public static final Sprite DEFAULT = MinecraftClient.getInstance().getSpriteAtlas().getSprite(new Identifier("minecraft:block/scaffolding_top"));
public static final Sprite FALLBACK = MissingSprite.getMissingSprite();
public SpriteSet() { public SpriteSet() {
clear(); clear();
@ -43,7 +45,10 @@ public class SpriteSet {
} }
public Sprite getSprite(Direction dir) { public Sprite getSprite(Direction dir) {
return isDefault ? FALLBACK : ObjectUtils.defaultIfNull(quads.get(dir).getSprite(), FALLBACK); if (isDefault) return DEFAULT;
BakedQuad quad = quads.get(dir);
if (quad == null) return FALLBACK;
return quad.getSprite();
} }
public boolean hasColor(Direction dir) { public boolean hasColor(Direction dir) {