1.0.0
Twine/pipeline/head This commit looks good Details

This commit is contained in:
TheBrokenRail 2020-06-18 18:25:33 -04:00
parent fec445e22a
commit 002005e813
8 changed files with 49 additions and 29 deletions

View File

@ -23,20 +23,22 @@ import java.util.List;
public class GlowingObsidianBlock extends Block {
public GlowingObsidianBlock() {
super(Settings.of(Material.STONE, MaterialColor.BLACK).requiresTool().strength(50.0F, 1200.0F).lightLevel(state -> 4));
super(Settings.of(Material.STONE, MaterialColor.BLACK).requiresTool().strength(50.0F, 1200.0F).lightLevel(state -> 6).allowsSpawning((state, world, pos, type) -> false).emissiveLighting((state, world, pos) -> true));
}
@Override
public void onSteppedOn(World world, BlockPos pos, Entity entity) {
super.onSteppedOn(world, pos, entity);
if (!world.isClient() && entity instanceof LivingEntity && entity.age % 10 == 0) {
final float amount = 2f;
if (entity instanceof Monster) {
((LivingEntity) entity).heal(amount);
} else {
entity.damage(DamageSource.MAGIC, amount);
if (!world.isClient() && entity instanceof LivingEntity) {
((ServerWorld) world).spawnParticles(ParticleTypes.SMOKE, pos.getX() + 0.5d, pos.getY() + 1d, pos.getZ() + 0.5d, 3 + world.getRandom().nextInt(3), 0.2d, 0.5d, 0.2d,0.01d);
if (entity.age % 10 == 0) {
final float amount = 2f;
if (entity instanceof Monster) {
((LivingEntity) entity).heal(amount);
} else {
entity.damage(DamageSource.MAGIC, amount);
}
}
((ServerWorld) world).spawnParticles(ParticleTypes.SMOKE, pos.getX() + 0.5d, pos.getY() + 1d, pos.getZ() + 0.5d, 12 + world.getRandom().nextInt(12), 0.1d, 0.5d, 0.1d,0.01d);
}
}

View File

@ -29,7 +29,7 @@ public class StageDataComponent extends PersistentState {
return data.computeIfAbsent(uuid, k -> new StageData[Twine.STAGE_COUNT]);
}
public static int findStageOfChunk(BlockPos pos, StageDataComponent.StageData[] data) {
public static int findPersonalStageOfChunk(BlockPos pos, StageDataComponent.StageData[] data) {
for (int i = Twine.STAGE_COUNT - 1; i >= 0; i--) {
StageDataComponent.StageData stage = data[i];
if (stage != null && Math.abs(stage.x - pos.getX()) <= CHUNK_RADIUS && Math.abs(stage.z - pos.getZ()) <= CHUNK_RADIUS) {
@ -46,7 +46,7 @@ public class StageDataComponent extends PersistentState {
int stage = 0;
for (Map.Entry<UUID, StageData[]> entry : data.entrySet()) {
if (world.getPlayerByUuid(entry.getKey()) != null) {
stage = Math.max(stage, findStageOfChunk(pos, entry.getValue()));
stage = Math.max(stage, findPersonalStageOfChunk(pos, entry.getValue()));
}
}
return stage;
@ -57,7 +57,7 @@ public class StageDataComponent extends PersistentState {
int stage = findEffectiveStageOfChunk(world, pos);
for (Map.Entry<UUID, StageData[]> entry : data.entrySet()) {
if (world.getPlayerByUuid(entry.getKey()) != null) {
int personalStage = findStageOfChunk(pos, entry.getValue());
int personalStage = findPersonalStageOfChunk(pos, entry.getValue());
if (personalStage == stage) {
time = Math.max(time, entry.getValue()[stage].time);
}
@ -71,7 +71,7 @@ public class StageDataComponent extends PersistentState {
for (Map.Entry<UUID, StageData[]> entry : data.entrySet()) {
PlayerEntity player = world.getPlayerByUuid(entry.getKey());
if (player != null) {
int personalStage = findStageOfChunk(pos, entry.getValue());
int personalStage = findPersonalStageOfChunk(pos, entry.getValue());
if (personalStage == stage) {
return player.getDisplayName();
}

View File

@ -56,9 +56,11 @@ public class StandOnGlowingObsidianGoal extends Goal {
return !mob.getNavigation().isIdle();
}
private static final float SPEED = 1.25f;
@Override
public void start() {
mob.getNavigation().startMovingAlong(path, 1f);
mob.getNavigation().startMovingAlong(path, SPEED);
}
@Override

View File

@ -6,6 +6,7 @@ import com.thebrokenrail.twine.util.ItemUtil;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.item.TooltipContext;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@ -13,7 +14,6 @@ import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
import net.minecraft.text.LiteralText;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.ActionResult;
@ -26,8 +26,10 @@ import net.minecraft.world.World;
import java.util.List;
public class DivinerItem extends Item {
private static final Text STAGE_COUNT_TEXT = new LiteralText(String.valueOf(Twine.STAGE_COUNT)).formatted(Formatting.WHITE);
public DivinerItem() {
super(new Settings().group(Twine.ITEM_GROUP).maxDamage(6));
super(new Settings().group(Twine.ITEM_GROUP).maxCount(1));
}
@Override
@ -37,25 +39,36 @@ public class DivinerItem extends Item {
StageDataComponent component = StageDataComponent.getFromWorld((ServerWorld) world);
BlockPos pos = user.getBlockPos();
int stage = component.findEffectiveStageOfChunk((ServerWorld) world, pos);
int effectiveStage = component.findEffectiveStageOfChunk((ServerWorld) world, pos);
StageDataComponent.StageData[] personalData = component.getData(user.getUuid());
int effectiveStage = StageDataComponent.findStageOfChunk(pos, personalData);
int personalStage = StageDataComponent.findPersonalStageOfChunk(pos, personalData);
user.sendMessage(new TranslatableText("chat.twine.diviner_info_1", new LiteralText(String.valueOf(stage + 1)).formatted(Formatting.WHITE)).formatted(Formatting.YELLOW), false);
user.sendMessage(new TranslatableText("chat.twine.diviner_info_2", (stage + 1 >= Twine.STAGE_COUNT ? new TranslatableText("chat.twine.diviner_info_never") : new LiteralText(String.valueOf(Twine.STAGE_TIME - component.findEffectiveTimeOfChunk((ServerWorld) world, pos)))).formatted(Formatting.WHITE)).formatted(Formatting.YELLOW), false);
user.sendMessage(new TranslatableText("chat.twine.diviner_info_1", new LiteralText(String.valueOf(effectiveStage + 1)).formatted(Formatting.WHITE), STAGE_COUNT_TEXT).formatted(Formatting.YELLOW), false);
user.sendMessage(new TranslatableText("chat.twine.diviner_info_2", (effectiveStage + 1 >= Twine.STAGE_COUNT ? new TranslatableText("chat.twine.diviner_info_never") : new LiteralText(String.valueOf(Twine.STAGE_TIME - component.findEffectiveTimeOfChunk((ServerWorld) world, pos)))).formatted(Formatting.WHITE)).formatted(Formatting.YELLOW), false);
user.sendMessage(new TranslatableText("chat.twine.diviner_info_3", component.findEffectiveCauseOfChunk((ServerWorld) world, pos).shallowCopy().formatted(Formatting.WHITE)).formatted(Formatting.YELLOW), false);
user.sendMessage(new TranslatableText("chat.twine.diviner_info_4", new LiteralText(String.valueOf(effectiveStage + 1)).formatted(Formatting.WHITE)).formatted(Formatting.YELLOW), false);
user.sendMessage(new TranslatableText("chat.twine.diviner_info_5", new LiteralText(String.valueOf(personalData[effectiveStage].x)).formatted(Formatting.WHITE), new LiteralText(String.valueOf(personalData[effectiveStage].z)).formatted(Formatting.WHITE)).formatted(Formatting.YELLOW), false);
user.sendMessage(new TranslatableText("chat.twine.diviner_info_6", (effectiveStage + 1 >= Twine.STAGE_COUNT ? new TranslatableText("chat.twine.diviner_info_never") : new LiteralText(String.valueOf(Twine.STAGE_TIME - personalData[effectiveStage].time))).formatted(Formatting.WHITE)).formatted(Formatting.YELLOW), false);
user.sendMessage(new TranslatableText("chat.twine.diviner_info_4", new LiteralText(String.valueOf(personalStage + 1)).formatted(Formatting.WHITE), STAGE_COUNT_TEXT).formatted(Formatting.YELLOW), false);
user.sendMessage(new TranslatableText("chat.twine.diviner_info_5", new LiteralText(String.valueOf(personalData[personalStage].x)).formatted(Formatting.WHITE), new LiteralText(String.valueOf(personalData[personalStage].z)).formatted(Formatting.WHITE)).formatted(Formatting.YELLOW), false);
user.sendMessage(new TranslatableText("chat.twine.diviner_info_6", (personalStage + 1 >= Twine.STAGE_COUNT ? new TranslatableText("chat.twine.diviner_info_never") : new LiteralText(String.valueOf(Twine.STAGE_TIME - personalData[personalStage].time))).formatted(Formatting.WHITE)).formatted(Formatting.YELLOW), false);
world.playSound(null, user.getBlockPos(), SoundEvents.BLOCK_ENCHANTMENT_TABLE_USE, SoundCategory.PLAYERS, 1f, 1f);
stack.damage(1, user, e -> e.sendToolBreakStatus(hand));
}
return new TypedActionResult<>(ActionResult.SUCCESS, stack);
}
@Override
public void inventoryTick(ItemStack stack, World world, Entity entity, int slot, boolean selected) {
super.inventoryTick(stack, world, entity, slot, selected);
if (!world.isClient() && entity instanceof PlayerEntity) {
StageDataComponent component = StageDataComponent.getFromWorld((ServerWorld) world);
BlockPos pos = entity.getBlockPos();
int effectiveStage = component.findEffectiveStageOfChunk((ServerWorld) world, pos);
((PlayerEntity) entity).sendMessage(new TranslatableText("chat.twine.diviner_info_1", new LiteralText(String.valueOf(effectiveStage + 1)).formatted(Formatting.WHITE), STAGE_COUNT_TEXT).formatted(Formatting.YELLOW), true);
}
}
@Override
@Environment(EnvType.CLIENT)
public void appendTooltip(ItemStack stack, World world, List<Text> tooltip, TooltipContext context) {

View File

@ -175,12 +175,12 @@ public class MixinBoatEntity implements BoatUtil {
@Inject(at = @At("RETURN"), method = "writeCustomDataToTag")
public void writeCustomDataToTag(CompoundTag tag, CallbackInfo info) {
tag.put("ChestItem", stack.toTag(new CompoundTag()));
tag.put("TwineChestItem", stack.toTag(new CompoundTag()));
}
@Inject(at = @At("RETURN"), method = "readCustomDataFromTag")
public void readCustomDataFromTag(CompoundTag tag, CallbackInfo info) {
CompoundTag itemTag = tag.getCompound("ChestItem");
CompoundTag itemTag = tag.getCompound("TwineChestItem");
ItemStack newStack = ItemStack.fromTag(itemTag);
setChestItem(newStack);

View File

@ -24,7 +24,7 @@ public abstract class MixinServerPlayerEntity {
public void tick(CallbackInfo info) {
StageDataComponent component = StageDataComponent.getFromWorld(getServerWorld());
StageDataComponent.StageData[] data = component.getData(((ServerPlayerEntity) (Object) this).getUuid());
int stage = StageDataComponent.findStageOfChunk(((ServerPlayerEntity) (Object) this).getBlockPos(), data);
int stage = StageDataComponent.findPersonalStageOfChunk(((ServerPlayerEntity) (Object) this).getBlockPos(), data);
StageDataComponent.StageData stageObj = data[stage];
if (stage + 1 < Twine.STAGE_COUNT) {
if (lastTime != -1L) {

View File

@ -39,10 +39,10 @@
"item.twine.diviner.tooltip_1": "This item shows you the bigger",
"item.twine.diviner.tooltip_2": "picture of your area in the world",
"chat.twine.diviner_info_1": "Effective Stage Of Area: %s",
"chat.twine.diviner_info_1": "Effective Stage Of Area: %s / %s",
"chat.twine.diviner_info_2": "Effective Stage Of Area Increases In: %s Ticks",
"chat.twine.diviner_info_3": "Effective Stage Of Area Caused By: %s",
"chat.twine.diviner_info_4": "Personal Stage Of Area: %s",
"chat.twine.diviner_info_4": "Personal Stage Of Area: %s / %s",
"chat.twine.diviner_info_5": "Personal Center Of Area: X: %s Z: %s",
"chat.twine.diviner_info_6": "Personal Stage Of Area Increases In: %s Ticks",
"chat.twine.diviner_info_never": "Never",

View File

@ -16,6 +16,9 @@
"#minecraft:beds",
"#minecraft:shulker_boxes",
"#minecraft:stone_bricks",
"#minecraft:crops",
"#minecraft:rails",
"#minecraft:saplings",
"minecraft:nether_portal",
"minecraft:cobblestone"
]