Potentially fix scrolls not being placeable on server
This commit is contained in:
parent
0371a56ab3
commit
9d15239635
3 changed files with 31 additions and 29 deletions
|
@ -20,7 +20,7 @@ apply plugin: 'net.minecraftforge.gradle'
|
|||
apply plugin: 'org.parchmentmc.librarian.forgegradle'
|
||||
apply plugin: 'org.spongepowered.mixin'
|
||||
|
||||
version = '0.7.0'
|
||||
version = '0.7.1'
|
||||
group = 'at.petra-k.hexcasting' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
archivesBaseName = 'hexcasting'
|
||||
|
||||
|
|
|
@ -40,8 +40,9 @@ public class EntityWallScroll extends HangingEntity implements IEntityAdditional
|
|||
|
||||
public ItemStack scroll;
|
||||
public HexPattern pattern;
|
||||
public List<Vec2> zappyPoints;
|
||||
public boolean isAncient;
|
||||
// Client-side only!
|
||||
public List<Vec2> zappyPoints;
|
||||
|
||||
public EntityWallScroll(EntityType<? extends EntityWallScroll> type, Level world) {
|
||||
super(type, world);
|
||||
|
@ -58,10 +59,12 @@ public class EntityWallScroll extends HangingEntity implements IEntityAdditional
|
|||
|
||||
var tag = scroll.getTag();
|
||||
if (tag != null && tag.contains(ItemScroll.TAG_PATTERN)) {
|
||||
var pattern = HexPattern.DeserializeFromNBT(tag.getCompound(ItemScroll.TAG_PATTERN));
|
||||
var pair = RenderLib.getCenteredPattern(pattern, 128, 128, 16f);
|
||||
var dots = pair.getSecond();
|
||||
this.zappyPoints = RenderLib.makeZappy(dots, 10f, 0.8f, 0f);
|
||||
this.pattern = HexPattern.DeserializeFromNBT(tag.getCompound(ItemScroll.TAG_PATTERN));
|
||||
if (this.level.isClientSide) {
|
||||
var pair = RenderLib.getCenteredPattern(pattern, 128, 128, 16f);
|
||||
var dots = pair.getSecond();
|
||||
this.zappyPoints = RenderLib.makeZappy(dots, 10f, 0.8f, 0f);
|
||||
}
|
||||
|
||||
this.isAncient = tag.contains(ItemScroll.TAG_OP_ID);
|
||||
} else {
|
||||
|
|
|
@ -42,30 +42,29 @@ public class ItemScroll extends Item {
|
|||
ItemStack itemstack = ctx.getItemInHand();
|
||||
if (player != null && !this.mayPlace(player, direction, itemstack, posInFront)) {
|
||||
return InteractionResult.FAIL;
|
||||
}
|
||||
var level = ctx.getLevel();
|
||||
var scrollStack = itemstack.copy();
|
||||
scrollStack.setCount(1);
|
||||
var scrollEntity = new EntityWallScroll(level, posInFront, direction, scrollStack);
|
||||
|
||||
// i guess
|
||||
var compoundtag = itemstack.getTag();
|
||||
if (compoundtag != null) {
|
||||
EntityType.updateCustomEntityTag(level, player, scrollEntity, compoundtag);
|
||||
}
|
||||
|
||||
if (scrollEntity.survives()) {
|
||||
if (!level.isClientSide) {
|
||||
scrollEntity.playPlacementSound();
|
||||
level.gameEvent(player, GameEvent.ENTITY_PLACE, posClicked);
|
||||
level.addFreshEntity(scrollEntity);
|
||||
}
|
||||
|
||||
itemstack.shrink(1);
|
||||
return InteractionResult.sidedSuccess(level.isClientSide);
|
||||
} else {
|
||||
var level = ctx.getLevel();
|
||||
var scrollStack = itemstack.copy();
|
||||
scrollStack.setCount(1);
|
||||
var scrollEntity = new EntityWallScroll(level, posInFront, direction, scrollStack);
|
||||
|
||||
// i guess
|
||||
var compoundtag = itemstack.getTag();
|
||||
if (compoundtag != null) {
|
||||
EntityType.updateCustomEntityTag(level, player, scrollEntity, compoundtag);
|
||||
}
|
||||
|
||||
if (scrollEntity.survives()) {
|
||||
if (!level.isClientSide) {
|
||||
scrollEntity.playPlacementSound();
|
||||
level.gameEvent(player, GameEvent.ENTITY_PLACE, posClicked);
|
||||
level.addFreshEntity(scrollEntity);
|
||||
}
|
||||
|
||||
itemstack.shrink(1);
|
||||
return InteractionResult.sidedSuccess(level.isClientSide);
|
||||
} else {
|
||||
return InteractionResult.CONSUME;
|
||||
}
|
||||
return InteractionResult.CONSUME;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue